我正在尝试在ubuntu 20.04服务器上部署flask项目(uwsgi + Nginx)。所以,我选择了Digital Ocean。
我得到**502 bad gateway nginx/1.18.0(Ubuntu)**错误。
在检查nginx错误日志后,我发现
upstream prematurely closed connection while reading response header from upstream, client: 93.37.157.148, server: 3.75.132.146, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/ubuntu/flask-app/webapp/flask-app.sock:", host: "3.75.132.146", referrer: "http://3.75.132.146/"
我的.ini文件包括:
[uwsgi]
module = wsgi:app
wsgi-file = /home/ubuntu/flask-app/webapp/wsgi.py
chdir = /home/ubuntu/flask-app/webapp/
protocol = http
#home = /usr/local/lib/python3.8/dist-packages/
master = true
processes = 5
limit-as = 512
uid = ubuntu
gid = www-data
socket = flask-app.sock
chown-socket = ubuntu
chmod-socket = 777
vacuum = true
die-on-term = true
我的nginx配置文件包括:
server {
listen 80;
server_name 3.75.132.146;
location /static {
alias /home/ubuntu/flask-app/webapp/static/;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/flask-app/webapp/flask-app.sock;
}
}
我一直在网上搜索,似乎没有人对此有一个坚实的解决方案。请帮助我,如果有人已经面临这一点和解决这个问题。
谢谢
1条答案
按热度按时间zbdgwd5y1#
尝试从My.ini中删除'protocol = http'并添加'socket-timeout=36000'