Reputation: 4426
I am using the following errorhandler in my flask app
@app.errorhandler(413)
def error413(e):
return render_template('error413.html'), 413
which shows an error page if error 413 happens (filesize too large). This works fine on my localhost, but on the server I get the nginx 413 error page instead.
413 Request Entity Too Large
nginx/1.4.6 (Ubuntu)
Is there anything which is different between nginx server and localhost regarding error handling? I use gunicorn together with nginx... thanks carl
Upvotes: 4
Views: 820
Reputation: 4987
By default, nginx catch HTTP error codes. It is a good thing, for security purposes.
It is possible to disable this behaviour, you can set uwsgi_intercept_errors off
.
http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_intercept_errors
You can use custom static error pages, served by nginx. Example:
error_page 413 /custom_413.html;
location = /custom_413.html {
root /usr/share/nginx/html;
internal;
}
Just set it to all error codes you want to handle.
Upvotes: 2