Thursday, June 25, 2015

Create custom error_page with nginx to resolve 400 Bad Request custom error page problem. Let's say www.host/% -> will return some Bad Request 400 but not custom error message from nginx.

To note:
error_page handles errors that are generated by nginx. By default, nginx will return whatever the proxy server returns regardless of http status code.

http://stackoverflow.com/questions/8715064/nginx-not-serving-my-error-page

Remember to check if your errors are actually from nginx and not from Tomcat or what so ever.
http://wiki.nginx.org/HttpProxyModule#proxy_intercept_errors
then add to server or location:
...
proxy_intercept_errors on;
...
Then write some custom error page:
Something like this:
https://vpsineu.com/blog/how-to-setup-nginx-to-show-custom-error-pages-on-a-centos-7-vps/
restart: service nginx restart
And test.
Some host/% error can be fixed with this one. So when getting some 400 from this request, you can create some custom error_page with nginx if just place this directive.

No comments:

Post a Comment