user1731285
user1731285

Reputation: 41

Configuring apache/tomcat 503 page

I'm running Apache "Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/1.0.0d mod_jk/1.2.32" for Web server and Apache Tomcat/6.0.32 as the application server.

I need to configure apache to render the 503 page whenever tomcat is down or unavailable.I have read a couple of articles which suggest that the configuration need to be done on the mod_jk.conf virtual host. One of the links suggested that I need to the following in my virtual host:

<Directory /udd001/app/docroot>
    Order allow,deny
    Allow from all
</Directory>

But this doesn't seem to work for me. My 404 aqnd 503 html files are sitting in /udd001/app/docroot. And my virtual host currently has the following which doesn't seem to work properly.

ErrorDocument 404 /error404.html
ErrorDocument 503 /maintenance503.html

Whenever tomcat is down, I'm still getting the 404 page.

Upvotes: 4

Views: 4422

Answers (1)

Koen Peters
Koen Peters

Reputation: 12916

I do this like this:

First create a nice 503 page and configure that as the default 503 page. Remember that the path that you use is relative to the Documentroot you defined in your apache config. In my case the Documentroot is defined as follows:

DocumentRoot "c:/apache/htdocs"

In that folder I have a subfolder /tomcat-offline in which I put normal webpage that will serve as the 503 page. Now I config the 503 page like this:

ErrorDocument 503 /tomcat-offline/index.html

Because you probably forward all your traffic to tomcat we need to exclude the 503 page from being forwarded, or else it won't work. In my case I use mod_jk to do all the forwarding like this:

JkMount /* tomcat

To exclude my 503 page and let apache serve it from its Documentroot I unmount that page like this:

JkUnMount /tomcat-offline/* tomcat

Restart apache and bring tomcat down. You should be able to see the 503 page.

Upvotes: 4

Related Questions