title: Unable to deploy Tornado with nginx reverse proxy, no errors are displayed
body: <p>I am trying to deploy my Tornado app with Nginx as proxy. I am trying to run this on Ramnode VPS (512 CVZ) whose configuration is: </p>
  
  <ul>
  <li>512MB RAM </li>
  <li>512MB VSwap </li>
  <li>2 CPU Core Access </li>
  <li>120GB SSD-Cached HDD Space</li>
  <li>1Gbps Port</li>
  </ul>
  
  <p>I am not using supervisor as of now and I manually started four instances of my tornado process:</p>
  
  <pre><code>sudo python /home/magneto/pricechase/main.py --port=8000 &amp;
  sudo python /home/magneto/pricechase/main.py --port=8001 &amp;
  sudo python /home/magneto/pricechase/main.py --port=8002 &amp;
  sudo python /home/magneto/pricechase/main.py --port=8003 &amp;
  </code></pre>
  
  <p>and I can access the site now at pricechase.in:8000 to pricechase.in:8003</p>
  
  <p>I created a new user <code>nginx</code> and gave permissions to my project directory:</p>
  
  <pre><code>sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx
  sudo chown -R nginx:nginx /home/magneto/pricechase/
  </code></pre>
  
  <p>Following is the conf file for my project, located at <code>/etc/nginx/sites-enabled/pricechase.in</code></p>
  
  <pre><code>user nginx;
  worker_processes 5;
  
  error_log /var/log/nginx/error.log;
  
  pid /var/run/nginx.pid;
  
  events {
      worker_connections 1024;
      use epoll; 
  }
  
  http{
  
      proxy_next_upstream error;
  
      upstream tornadoes { 
          server 127.0.0.1:8000;
          server 127.0.0.1:8001;
          server 127.0.0.1:8002;
          server 127.0.0.1:8003;
      }
  
      include /etc/nginx/mime.types;
      default_type application/octet-stream;  
  
      access_log /var/log/nginx/access.log;
  
      keepalive_timeout 65;
      proxy_read_timeout 200;
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      gzip on;
      gzip_min_length 1000;
      gzip_proxied any;
      gzip_types text/plain text/html text/css text/xml
                 application/x-javascript application/xml
                 application/atom+xml text/javascript;
  
  
      server { 
          listen 80;
          server_name pricechase.in www.pricechase.in;
  
          location /static/ {
              root /home/magneto/pricechase/static; 
              if ($query_string) {
                  expires max; 
              }
          }
          location / {
              proxy_pass_header Server; 
              proxy_set_header Host $http_host; 
              proxy_redirect off;
              proxy_set_header X-Real-IP $remote_addr; 
              proxy_set_header X-Scheme $scheme; 
              proxy_pass http://tornadoes;
          } 
      }
  }
  </code></pre>
  
  <p>When I tried to restart nginx service I was getting following error: </p>
  
  <pre><code>Restarting nginx: nginx: [emerg] unknown directive "user" in /etc/nginx/sites-enabled/pricechase.in:1
  nginx: configuration file /etc/nginx/nginx.conf test failed
  </code></pre>
  
  <p>As the answers indicated <a href="https://stackoverflow.com/questions/5751455/configuration-fail-nginx-setting-for-tornadoweb-unknown-directive-user">here</a>, I commented the following line in <code>/etc/nginx/nginx.conf</code>:</p>
  
  <pre><code># include /etc/nginx/sites-enabled/*;
  </code></pre>
  
  <p>Now I can start/restart it however when I type in pricechase.in, its not opening the site. Its not able to access static files also, ex: <a href="http://pricechase.in/static/css/tooltipster.css" rel="nofollow noreferrer">http://pricechase.in/static/css/tooltipster.css</a> which is located at <code>/home/magneto/pricechase/static/css/tooltipster.css</code></p>
  
  <p>Following is the contents of <code>/etc/nginx/nginx.conf</code>:</p>
  
  <pre><code>user www-data;
  worker_processes 4;
  pid /var/run/nginx.pid;
  
  events {
      worker_connections 768;
      # multi_accept on;
  }
  
  http {
  
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 65;
      types_hash_max_size 2048;
      # server_tokens off;
  
      # server_names_hash_bucket_size 64;
      # server_name_in_redirect off;
  
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
  
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;
  
      gzip on;
      gzip_disable "msie6";
  
      # gzip_vary on;
      # gzip_proxied any;
      # gzip_comp_level 6;
      # gzip_buffers 16 8k;
      # gzip_http_version 1.1;
      # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  
      ##
      # Virtual Host Configs
      ##
  
      include /etc/nginx/conf.d/*.conf;
      # include /etc/nginx/sites-enabled/*;
      # include /etc/nginx/sites-enabled/pricechase.in;
  }
  </code></pre>
  
  <ul>
  <li>How do I debug this? </li>
  <li>Why its not logging any errors? I checked access and error logs (located in <code>/var/log/nginx/</code>)</li>
  <li>Any tips/improvements on nginx config files? </li>
  <li>If I understand correctly <code>/etc/nginx/nginx.conf</code> is like a base template and all the common config I require for any other hosts should be included in this, right?</li>
  <li>If I want to add another domain and serve different tornado instances, I guess I have to add new conf in <code>sites-enabled</code>, however will there be any conflict? for example, I want <a href="http://abc.xyz.com" rel="nofollow noreferrer">http://abc.xyz.com</a> to serve static content located in <code>/home/magneto/blog</code> and <a href="http://pqrs.com" rel="nofollow noreferrer">http://pqrs.com</a> to serve tornado process of ports 8005 to 8008.</li>
  </ul>