502错误的网关上游在从带有flask、uWSGI、nginx的上游阅读响应报头时过早关闭连接

0yg35tkg  于 2022-12-26  发布在  Nginx
关注(0)|答案(1)|浏览(191)

你好吗?我有一个服务器上的数字海洋与Ubuntu 16.04我正在做一个 flask 应用程序与uWSGI和Nginx.
我的文件看起来像:wsgi.py:

from flaskapp import app
if __name__ == "__main__":
    app.run()

flaskapp.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/系统文件/系统文件/flakapp.service

[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/可访问站点/flakapp.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年1月19日15:58:18 [错误] 19181#19181:*36在从上游阅读响应报头时,上游过早关闭连接,客户端:{myip},服务器:{我的服务器},请求:“POST /yajugue HTTP/1.1”,上游:“uwsgi://unix:///home/blitwak/flankapp/flankapp.sock:“,主机:“{我的服务器}",引用地址:“http://{我的服务器}/jugarPrimeraVez”
非常感谢!!!
我该怎么解决呢?

4uqofj5v

4uqofj5v1#

可能已为Flask应用程序设置了足够的规则。例如:

sudo chmod 710 /var/www/flask_app 
sudo chown -R nginx: /var/www/flask_app

相关问题