title: "http" directive is not allowed here Nginx
body: <p>I start and I want to connect to my database with Nginx. Here is my <code>sites-enables / default</code> file:</p>
  
  <pre><code>http {
    upstream database {
     postgres_server 192.168.0.166 dbname=stardb 
                                  user=username password=yourpass;
    }
  
    server {
      listen 80 default_server;
      listen [::]:80 default_server;
  
      location /ip {
        postgres_pass     database;
  
        postgres_query    HEAD GET  "SELECT http_host as ip FROM establishment_view where aet = 'NXS_DEV_FLO2'";
      }
    }
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>nginx[7597]: nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:17</p>
  </blockquote>
  
  <p>I saw that this error was common but even looking at the other posts I can not solve my problem.
  And I have this line in my <code>nginx.conf</code> file : </p>
  
  <pre><code>include /etc/nginx/sites-enabled/*;
  </code></pre>
  
  <p>Did I need to remove the line http in my <code>sites_enables/default</code> file ?</p>