1

I have nginx set up to serve uWSGI for a Flask app. Sometimes there will be errors or I will be restarting the uWSGI service, but I want nginx to serve a nicer maintenance page instead of the default 502 Bad Gateway that happens when uWSGI doesn't respond. I have tried multiple configs that are supposed to do this but none of them seem to have any effect. Here is my current config:

server {
    listen  80;
    server_name     mydomain.com;
    charset utf-8;
    client_max_body_size 75M;

    location / {
            try_files $uri @flask;
            error_page 502 =200 @maintenance;
    }
    location @flask {
            include uwsgi_params;
            uwsgi_pass unix:/path/to/socket/uwsgi.sock;
    }
    location @maintenance {
            root /path/to/web;
            rewrite ^(.*)$ /maintenance.html break;
    }

}
1
  • 1
    error_page directive should be in @flask location. Probably you'll also need uwsgi_intercept_errors on; there.
    – Alexey Ten
    May 3, 2014 at 5:12

1 Answer 1

2

error_page directive should be in @flask location. Probably you'll also need uwsgi_intercept_errors on; there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .