Flask app running with gunicorn and nginx is crashing at redirecting point

不羁岁月 提交于 2019-12-11 04:28:03

问题


Can you please help? I am stuck.

My server is crashing at @return redirect(url_for(‘login’)) ,when I run it using gunicorn i.e. $gunicorn — bind 127.0.0.1:5000 -w 4 wsgi:app. Same issue arises when I run it using supervisor. The code is working fine when I run it normally i.e. python app.py

Appreciate any suggestions.


回答1:


Try using this config, might help you. Create a new file in /etc/nginx/sites-enabled/

server {
        listen 80 ;
        server_name abc.com;
        large_client_header_buffers 8 32k;
  if ($http_user_agent ~* Googlebot) {  
    return 403; 
  }
        access_log /var/log/nginx/access.log;
        location / {
                add_header 'Access-Control-Allow-Origin' "$http_origin";
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT';
                add_header 'Access-Control-Allow-Credentials' 'true';
                add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type';
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass https://127.0.0.1:5000;
                proxy_read_timeout 90;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_buffers 8 32k;
                proxy_buffer_size 64k;
        }
}

use

nginx -t reload

check the config



来源:https://stackoverflow.com/questions/52605769/flask-app-running-with-gunicorn-and-nginx-is-crashing-at-redirecting-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!