我正在尝试在运行 Ubuntu 10.10 的 Linode VPS 上部署 Flask 应用程序。我一直在关注本教程(https://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-10.10-maverick#sph_configure-nginx),但我不断收到 502 Bad Gateway 错误。
这是/etc/default/uwsgi:
PYTHONPATH=/var/www/reframeit-im
MODULE=wsgi
这是/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
这是应用程序的 nginx 配置文件,它符号链接到 /sites-enabled 目录 (/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;
}
}
我检查了应用程序的 nginx 错误日志,发现:
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"
我的配置有问题吗?