uwsgi upstream在读取上游flask+uwsgi+nginx的响应头时过早关闭连接 &g



我正在尝试在ubuntu 20.04服务器上部署一个flask项目(uwsgi + Nginx)。为此,我关注Digital Ocean。

我得到502坏网关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;
}
}

我一直在网上搜索,似乎没有人对此有一个坚实的解决方案。如果有人遇到过这个问题并且解决了,请帮助我。这个问题。

感谢

尝试从My.ini中删除'protocol = http'并添加'socket-timeout=36000'

最新更新