Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Return 503 page until backend application is up running

11:55 am on Aug 20, 2013 (gmt 0)

New User

joined:June 25, 2013
votes: 0


We are using Apache as proxy server for a tomcat(jboss) application.
The application is about 5 minutes to start up. While it's starting up we want Apache to return a 503 page to the clients. It's working fine when tomcat (jboss) is down.

The application has an i_am_alive page. Can Apache somehow poll this with some timeout value?

Thx in advance
2:32 am on Sept 2, 2013 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 10

i would write an independent script that runs every minute or 30 seconds on a cron job.
this script would poll the i_am_alive page and create or delete an "i_am_alive" file on the apache server according to the status of the i_am_alive page.
then you could use mod_rewrite to test for this file and send a 503 response when appropriate:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteCond /path/to/document/root/i_am_alive -f
RewriteRule ^(.*)$ /$1 [R=503,L]
9:07 am on Sept 6, 2013 (gmt 0)

New User

joined:June 25, 2013
votes: 0

The cronjob can be use but not the most be beautiful solution :-)

We found out that the backend application can return an 503 page until it's started up and if we are using

ProxyErrorOverride On

We can use the 503 page defined in Apache. With ProxyErrorOverride enabled other http codes like 404 is also not proxy. The problem is that we only want http code 503 not to be proxy.

Can we somehow tell apache only 503 should not be proxy?
3:14 pm on Jan 16, 2014 (gmt 0)

New User

joined:June 25, 2013
votes: 0

My maintenance page is defined like this:

ProxyPass /maintenance !
ProxyPass /maintenance-gfx !
ProxyPass /maintenance-css !

Alias /maintenance /var/www/html/maintenance
Alias /maintenance-css /var/www/html/maintenance/maintenance-css
Alias /maintenance-gfx /var/www/html/maintenance/maintenance-gfx

ErrorDocument 503 /maintenance/maintenance.php

And it working fine.

Now I added this:

RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteCond /path/i_am_down -f
RewriteRule ^(.*)$ /$1 [R=503,L]

If the file exists (/path/i_am_down) then it show the maintenance page but all image/styling is missing. Does the RewriteRule overwrite my aliases?
11:12 pm on Jan 16, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
votes: 308

but all image/styling is missing

99 times out of 100 this points to a problem with relative links. Error documents (of any kind) are the 100th time.

If all requests lead to the 503 page, then you've made it impossible to serve any documents other than the 503 page. One solution is to use strictly internal styles; this also makes for fewer requests at a time when your server isn't set up to handle requests. (Won't help with images, unless they're tiny little things that can be served in dataimage form instead.) Another is to poke a hole for stylesheets, either via a <FilesMatch> envelope or by constraining the rule to requests for pages. A third-- or is it fourth?-- way is to add a RewriteCond checking for referer; if the referer is your own 503 page, admit any requests.

RewriteRule ^(.*)$ /$1 [R=503,L]

R values other than 30x don't return an address, so the argument will be ignored anyway. Just - will do. I'm also pretty sure all non-30x values carry an automatic [L], but the flag does no harm.

Do as I say. Not as I do. I've just realized that I made the same css mistake myself a few weeks ago when I moved. Luckily nobody was affected but robots.