设置nginx在uWSGIclosures时显示维护页面

我有nginx设置为一个Flask应用程序uWSGI服务。 有时会出现错误,或者我将重新启动uWSGI服务,但是我希望nginx提供更好的维护页面,而不是在uWSGI没有响应时发生的默认502错误网关。 我已经尝试了多个configuration,应该这样做,但没有一个似乎有任何效果。 这是我目前的configuration:

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; } } 

error_page指令应位于@flask位置。 可能你也需要uwsgi_intercept_errors on; 那里。