LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-06-2010, 03:59 AM   #1
nikhil010586
Member
 
Registered: Oct 2007
Posts: 44

Rep: Reputation: 15
Suppress Tomcat error pages using Nginx


Hi,

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 http://mydomain.com/anybaduristring 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 http://mydomain.com are proxied transparently to http://localhost:8080 (Tomcat) .

--
Nikhil
 
Old 01-08-2010, 01:52 AM   #2
nikhil010586
Member
 
Registered: Oct 2007
Posts: 44

Original Poster
Rep: Reputation: 15
Bump! Anyone?
 
Old 12-27-2010, 01:50 PM   #3
licorna
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
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.

Thanks
 
Old 12-27-2010, 02:19 PM   #4
licorna
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
Yep, found it:

Quote:
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.
 
  


Reply

Tags
nginx, tomcat


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nginx redirect error page cbtshare Linux - Server 0 10-10-2009 01:30 PM
How do I get Tomcat to accept my application and start displaying the pages driven13 Linux - Server 2 05-12-2007 03:57 PM
Tomcat : unable to access the jsp pages minil Programming 11 01-28-2006 09:19 AM
tomcat error on fc 4 melinda_sayang Fedora 0 06-27-2005 09:00 AM
bash scripting - suppress error messages? brian0918 Programming 2 06-19-2003 11:16 AM


All times are GMT -5. The time now is 10:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration