-   Linux - Server (
-   -   Suppress Tomcat error pages using Nginx (

nikhil010586 01-06-2010 03:59 AM

Suppress Tomcat error pages using Nginx

As known to most of us, Tomcat's error pages can be altered using the <error-page>...</error-page> tag in web.xml. However, in my case, everything works fine except the most frequently observed 404 Not Found page. Also, these error-page configurations won't work if the webapp is unavailable or undeployed.

As a solution, I have thought about having these error codes relayed back to Nginx while proxying (or reverse proxying). Further, setting error handlers with error_page directive would only be a piece of cake.

However, even after adding the error_page directives, the Tomcat errors are visible. Something like should go to Nginx's 404 handler but in my case, it shows Tomcat's default "404 Resource unavailable" page.

I'm on Nginx 0.7.64 and 0.6.32 along with Apache Tomcat 6.0.18 . All requests for are proxied transparently to http://localhost:8080 (Tomcat) .


nikhil010586 01-08-2010 01:52 AM

Bump! Anyone?

licorna 12-27-2010 01:50 PM

Having the same problem here
I'm trying to do the same thing. Tomcat is a web application server so it's not is job to serve static error pages. I'm trying to make nginx serve the messages returned by tomcat with no success.

Any clue of how to do it? Any http server configuration is a starting point I think.


licorna 12-27-2010 02:19 PM

Yep, found it:


error_page 404 /404.html;
location = /404.html {
root /var/www/nginx;

location / {
proxy_pass http://localhost:8080/api/;
proxy_intercept_errors on;
You need to add proxy_intercept_errors on to nginx configuration.

All times are GMT -5. The time now is 06:47 AM.