homepage Welcome to WebmasterWorld Guest from 54.198.140.182
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Return 503 page until backend application is up running
chitech




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

Hi

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

 

phranque




msg:4606664
 2:32 am on Sep 2, 2013 (gmt 0)

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]

chitech




msg:4607802
 9:07 am on Sep 6, 2013 (gmt 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?

chitech




msg:4637933
 3:14 pm on Jan 16, 2014 (gmt 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?

lucy24




msg:4638009
 11:12 pm on Jan 16, 2014 (gmt 0)

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.

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved