Reputation: 41
I'm trying to deploy a Flask app on a Linode VPS running Ubuntu 10.10. I've been following this tutorial (https://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-10.10-maverick#sph_configure-nginx) but I keep getting a 502 Bad Gateway error.
Here this is /etc/default/uwsgi:
PYTHONPATH=/var/www/reframeit-im
MODULE=wsgi
Here is /var/www/reframeit-im/wsgi.py:
# add the application directory to the python path
import sys
sys.path.append("/var/www/reframeit-im")
# run flask app
from reframeit import app as application
Here is the app's nginx config file, which is symlinked to the /sites-enabled directory (/opt/nginx/conf/sites-enabled/reframeit-im):
server {
listen 80;
server_name www.reframeit-im.coshx.com reframeit-im.coshx.com;
access_log /var/www/reframeit-im/logs/access.log;
error_log /var/www/reframeit-im/logs/error.log;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
}
}
I checked the nginx error logs for the app and I found this:
2013/07/17 19:30:19 [error] 20037#0: *1 upstream prematurely closed connection while reading response header from upstream, client: 70.88.168.82, server: www.reframeit-im.coshx.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://127.0.0.1:9001", host: "reframeit-im.coshx.com"
Is there something wrong with my configuration?
Upvotes: 2
Views: 4837
Reputation: 1
Please add "protocol = uwsgi" apart from what Flavio has suggested. As below
PYTHONPATH=/var/www/reframeit-im
MODULE=wsgi
socket=127.0.0.1:9001
protocol = uwsgi
Upvotes: 0
Reputation: 7815
With uwsgi_pass 127.0.0.1:9001;
you declared to Nginx your intent to talk to uWSGI through TCP socket, but have not warned uWSGI about it.
Try adding a corresponding socket line to your /etc/default/uwsgi
file:
PYTHONPATH=/var/www/reframeit-im
MODULE=wsgi
socket=127.0.0.1:9001
Upvotes: 1