你好吗?
我在DigitalOcean上有一台装有Ubuntu16.04的服务器
我正在和uWSGI和Nginx申请烧瓶。
我的文件看起来像:
wsgi.py版本:
from flaskapp import app
if __name__ == "__main__":
app.run()
烧瓶app.ini
[uwsgi]
limit-as = 512
module = wsgi:app
plugin = python
master = true
processes = 5
socket = flaskapp.sock
chmod-socket = 660
vacuum = true
die-on-term = true
/etc/systemd/system/flaskapp.服务
[Unit]
Description=uWSGI instance to serve flaskapp
After=network.target
[Service]
User=blitwak
Group=www-data
WorkingDirectory=/home/blitwak/flaskapp
Environment="PATH=/home/blitwak/flaskapp/myprojectenv/bin"
ExecStart=/home/blitwak/flaskapp/myprojectenv/bin/uwsgi --ini flaskapp.ini
[Install]
WantedBy=multi-user.target
/etc/nginx/sites available/flaskapp.conf
server {
listen 80;
server_name 162.243.76.55;
charset utf-8;
proxy_buffering on;
proxy_buffer_size 1k;
proxy_buffers 24 4k;
proxy_busy_buffers_size 8k;
proxy_max_temp_file_size 2048m;
proxy_temp_file_write_size 32k;
proxy_connect_timeout 75s;
proxy_read_timeout 300s;
location / {
include uwsgi_params;
uwsgi_pass unix:///home/blitwak/flaskapp/flaskapp.sock;
uwsgi_param UWSGI_SCRIPT app.wsgi;
uwsgi_buffer_size 32k;
uwsgi_buffers 8 32k;
uwsgi_busy_buffers_size 32k;
}
}
在/var/log/nginx/error.log中,它会多次显示:
2017/01/19 15:58:18[错误]19181#19181:*36上游过早
从上游读取响应头时关闭连接,客户端:
{myip},服务器:{myserver},请求:“POST/yajugue HTTP/1.1”,
上游:“uwsgi://unix:///home/blitwak/flaskapp/flaskapp.sock:”,
主机:{myserver},引用者:“http://{myserver}/jugarPrimeraVez”
非常感谢你!!!
我该怎么解决?
最佳答案
可能已经为烧瓶应用程序设置了足够的规则。
例如:
sudo chmod 710 /var/www/flask_app
sudo chown -R nginx: /var/www/flask_app
关于python - 502 Bad Gateway上游过早关闭连接,同时使用flask,uWSGI,nginx从上游读取响应头,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41749889/