title: uwsgi upstart on amazon linux
body: <p>I created a uwsgi file following this tutorial <a href="https://uwsgi.readthedocs.org/en/latest/Upstart.html">https://uwsgi.readthedocs.org/en/latest/Upstart.html</a> on amazon linux. Though It doesn't seem to run as Nginx just says bad gateway. If I run the </p>
  
  <p>/etc/init/uwsgi.conf</p>
  
  <pre><code>description "uwsgi tiny instance"
  start on runlevel [2345]
  stop on runlevel [06]
  
  exec /home/ec2-user/venv/bin/uwsgi --ini /home/ec2-user/uwsgi-prod_demo.ini
  </code></pre>
  
  <p>if I do run the following in shell, then python application runs. </p>
  
  <pre><code>/home/ec2-user/venv/bin/uwsgi --ini /home/ec2-user/uwsgi-prod_demo.ini
  </code></pre>
  
  <p>uwsgi-prod_demo.ini</p>
  
  <pre><code>[uwsgi]
  socket = :8080
  chdir = /home/ec2-user/prod_demo
  master = True
  venv = /home/ec2-user/venv
  callable = app
  wsgi-file = /home/ec2-user/prod_demo/manage.py
  enable-threads = True
  https = =0,/home/ec2-user/xxx.com.au.pem,/home/ec2-user/newkey.pem,HIGH
  </code></pre>
  
  <p>nginx.conf</p>
  
  <pre><code>user  ec2-user;
  worker_processes  1;
  
  error_log  /var/log/nginx/error.log;
  #error_log  /var/log/nginx/error.log  notice;
  #error_log  /var/log/nginx/error.log  info;
  
  pid        /var/run/nginx.pid;
  
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile        on;
      #tcp_nopush     on;
  
      #keepalive_timeout  0;
      keepalive_timeout  65;
  
      #gzip  on;
  
      # Load modular configuration files from the /etc/nginx/conf.d directory.
      # See http://nginx.org/en/docs/ngx_core_module.html#include
      # for more information.
      include /etc/nginx/conf.d/*.conf;
  
    server {
      listen 80;
      listen 443 ssl;
      ssl_certificate /home/ec2-user/xxx.com.au.pem;
      ssl_certificate_key /home/ec2-user/newkey.pem;
      server_name import.xxx.com.au  *.import.xxx.com.au;
      access_log /var/log/prod_demo/access_log;
  
      root /home/ec2-user/prod_demo;
  
      location / {
        uwsgi_pass 127.0.0.1:8080;
        include uwsgi_params;
      }
  
      location /static {
           alias /home/ec2-user/prod_demo/app/static;
      }
  
      location = /favicon.ico {
              alias    /home/ec2-user/prod_demo/app/static/images/favicon.ico;
      }
    }
  }
  </code></pre>