0
經過一些Ubuntu 16.04升級和應用程序代碼修改後,我以前工作的gunicorn和nginx網站上的Flask現在給出了502壞門錯誤。nginx 502上的gunicorn燒瓶壞網關錯誤
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"
從我的應用程序日誌文件我注意到,瓶通過首發獲得一部分的方式然後在連續失敗/重新啓動循環中重新啓動。
任何想法,我可以去調試什麼可能會導致此問題?
你是如何開始燒瓶服務的?您是否嘗試在交互模式下運行燒瓶服務並檢查控制檯輸出? – hzm
@hzm我通過一個安全的部署腳本部署和啓動燒瓶,該腳本設置gunicorn然後使用監督器重新啓動nginx。在服務器上手動啓動這個燒瓶設置並不難, – proximacentauri
@hzm你是一個傳奇人物,你可以把你的評論置於一個答案中 - 通過在服務器上手動啓動應用程序我拿起一個依賴性問題,應用程序每次都在崩潰,然後主管剛剛重新啓動它。現在全部修好了 – proximacentauri