当前位置: 首页 > 知识库问答 >
问题:

502错误的网关上游过早关闭连接,同时从上游读取响应报头与flask,uWSGI,nginx

水瀚漠
2023-03-14

你好吗?我在DigitalOcean上有一个使用Ubuntu16.04的服务器,我正在用uWSGI和Nginx制作一个Flask应用程序。

我的文件如下所示:wsgi.py:

from flaskapp import app
if __name__ == "__main__":
    app.run()
[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
[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
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;


   }
}

非常感谢!!!

我该如何解决?

共有1个答案

姚烨
2023-03-14

也许足够为烧瓶应用程序设置规则了。例如:

sudo chmod 710 /var/www/flask_app 
sudo chown -R nginx: /var/www/flask_app
 类似资料: