Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Apache2 as a reverse proxy for tomcat, my configuration being something like:

ProxyRequests Off

ProxyPass        / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

My question is: can I configure Apache to show up a courtesy page (an "under construction" HTML static page) whenever Tomcat is down?

share|improve this question
up vote 4 down vote accepted

You can use the Apache ErrorDocument directive to do this. You should use a URL to point to your ErrorDocument otherwise if you use a filesystem reference you will get an additional 503 whilst trying to find it.

ErrorDocument 503 http://somehost.tld/errors/503.html
share|improve this answer
1  
That is correct, since I am proxying all the pages starting from "/", so there won't be any web server actually servicing an error page of the type "/var/www/html/error/gonefishing.html" – Overflow May 13 '11 at 11:29

Apache will throw a 503 "Service unavailable" error when it can't connect to Tomcat. You could just create a "nice" 503 error page.

ErrorDocument 503 /var/www/html/error/gonefishing.html
share|improve this answer

If your local server has apache listening on default ports you could point a ERROR uri to local host and have custom error pages available there. Will negate need for separate domain / server

ProxyPass /ERROR http:// localhost:80/

ProxyPass        / http:// localhost:8080/
ProxyPassReverse / http:// localhost:8080/

ErrorDocument 503 /ERROR/custom_50x.html
share|improve this answer

The order of ProxyPass statements as listed in @snyman's info is very important.. proxypass error should be the first proxypass statement for the virtualhost before any other proxypass statements are written..

this is my experience on centos 7 with apache 2.4 and tomcat7

share|improve this answer

Pardon my ignorance.But can't you put ProxyPass /var/www/html/error ! to ignore just that folder and so serve up the page from that folder ?

share|improve this answer
    
that does not seem correct, check the ProxyPass Directive httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass – krisdigitx Mar 14 '15 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.