tourdownunder
tourdownunder

Reputation: 1829

i can access flask app directly the port 8080 though then through nginx reverse proxy I get an error

Error: 2014/11/28 01:02:16 [error] 2501#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 75.64.105.189, server: xxx.yyy.com.au, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8080", host: "xxx.yyy.com.au"

Calling uwsgi in a virtual env using the following

cd /home/ec2-user/prod_demo && /home/ec2-user/venv/bin/uwsgi --socket :8080 --wsgi-file /home/ec2-user/prod_demo/manage.py --callable app --processes 4 --threads 2 --stats :18080 --protocol=http &

Nginx Config

/etc/nginx/nginx.conf

user  ec2-user;
worker_processes  1;

error_log  /var/log/nginx/error.log;

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;
    server_name xxx.yyy.com.au  *.xxx.yyy.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;
    }
  }
}

Upvotes: 0

Views: 485

Answers (1)

tourdownunder
tourdownunder

Reputation: 1829

seems to be working now after changing to the uwsgi ini config format instead of the cmd line

uwsgi.ini

[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

calling uwsgi.ini in shell / upstart (hopefully)

/home/ec2-user/venv/bin/uwsgi --ini uwsgi.ini

Upvotes: 0

Related Questions