librelist archives

« back to archive

Flask + uWSGI + Nginx 502 error pages

Flask + uWSGI + Nginx 502 error pages

From:
Franklyn Tackitt
Date:
2013-08-26 @ 22:47
I have been fighting with this configuration for a while, and cannot seem
to figure this out.
At the moment, my configs look something like this:

nginx.conf
> http {
> #standard config here, no error-page configuration
>  server {
>    location @app {
>        include uwsgi_params;
>        uwsgi_pass unix:/var/run/uwsgi/app/socket;
>   }
>    location / {
>        try_files @uri @comanage; #try_files for static files,
>    }
>  }

uwsgi.ini
[uwsgi]
chdir = /srv/flask-app
module = app
callable = app
chmod-socket = 666
master = True
vacuum = True
max-requests = 5000
processes = 2
workers = 10
harakiri = 20
harakiri-verbose = true
touch-reload = /tmp/uwsgi.reload
lazy = true
plugins = python
virtualenv = /srv/flask-app/venv

i have also included @app.error_handler(502) with a view

However, when I throw an exception in a page, or fail for other reasons, I
get a standard nginx 502 page. What is the best way to handle these errors?

Re: [flask] Flask + uWSGI + Nginx 502 error pages

From:
David J
Date:
2013-08-26 @ 23:00
Check the nginx docs for uwsgi. There is a flag to catch errors and pass it
to nginx handler
On Aug 26, 2013 6:48 PM, "Franklyn Tackitt" <franklyn@tackitt.net> wrote:

> I have been fighting with this configuration for a while, and cannot seem
> to figure this out.
> At the moment, my configs look something like this:
>
> nginx.conf
> > http {
> > #standard config here, no error-page configuration
> >  server {
> >    location @app {
> >        include uwsgi_params;
> >        uwsgi_pass unix:/var/run/uwsgi/app/socket;
> >   }
> >    location / {
> >        try_files @uri @comanage; #try_files for static files,
> >    }
> >  }
>
> uwsgi.ini
> [uwsgi]
> chdir = /srv/flask-app
> module = app
> callable = app
> chmod-socket = 666
> master = True
> vacuum = True
> max-requests = 5000
> processes = 2
> workers = 10
> harakiri = 20
> harakiri-verbose = true
> touch-reload = /tmp/uwsgi.reload
> lazy = true
> plugins = python
> virtualenv = /srv/flask-app/venv
>
> i have also included @app.error_handler(502) with a view
>
> However, when I throw an exception in a page, or fail for other reasons, I
> get a standard nginx 502 page. What is the best way to handle these errors?
>
>