gpt4 book ai didi

python - Flask with Gunicorn on nginx 502 bad gateway 错误

转载 作者:行者123 更新时间:2023-12-01 02:53:35 24 4
gpt4 key购买 nike

经过一些 ubuntu 16.04 升级和应用程序代码修改后,我之前在gunicorn 和 nginx 网站上运行的 Flask 现在出现 502 bad gateway 错误。

myapp.conf:

upstream app_server_wsgiapp {
server localhost:8000 fail_timeout=0;
}

server {
listen 80;
server_name www.myserver.com;

access_log /var/log/nginx/www.myapp.access.log;
error_log /var/log/nginx/www.myapp.error.log info;
keepalive_timeout 5;

location /static {
autoindex on;
alias /myapp/static;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server_wsgiapp;
break;
}
client_max_body_size 2097152;
#to get around upstream sent too big header while reading response header from upstream error
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}

# this section allows Nginx to reverse proxy for websockets
location /socket.io {
proxy_pass http://app_server_wsgiapp/socket.io;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}

/var/log/nginx/myapp.error.log

2017/06/11 06:42:52 [error] 31054#31054: *1 connect() failed (111: Connection refused) while connecting to upstream, client: clientip, server: www.myserver.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "www.myapp.com"

从我的应用程序日志文件中,我注意到 Flask 已经启动了一部分,然后在连续的失败/重新启动循环中重新启动。

我有什么想法可以调试可能导致此问题的原因吗?

最佳答案

看起来问题是由 Flask 应用程序运行错误引起的。您能尝试以交互方式运行该应用程序吗?以守护进程方式使用相同的参数和环境设置,检查服务是否可以正确启动?

关于python - Flask with Gunicorn on nginx 502 bad gateway 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44481895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com