title: When do we need to use http block in nginx config file?
body: <p>I am reading nginx beginner's tutorial, on the section <a href="http://nginx.org/en/docs/beginners_guide.html#static">Serving Static Content</a> they have</p>
  
  <pre><code>http {
    server {
    }
  }
  </code></pre>
  
  <p>but when I add an http block I get the error</p>
  
  <blockquote>
    <p>[emerg] "http" directive is not allowed here …</p>
  </blockquote>
  
  <p>When I remove the http block and change the conf file to this, it works fine: </p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server ipv6only=on;
  
      root /var/example.com/html;
      index index.html index.htm;
  
      # make site accessible from http://localhost/
      server_name localhost
  
      location / {
        try_files $uri $uri/ /index.html;
    }
  </code></pre>
  
  <p>I suspect that I am missing something simple, but why do they use http to serve static files?</p>