Weblog entry #23 for lee

Putting an apache website into maintenance mode
Posted by lee on Thu 26 Oct 2006 at 12:44
Tags:

I was recently asked to temporarily take down a database-driven apache website while maintenance was performed on the database. Looking at RFC2616 the correct approach is to return a 503 Service Unavailable status, and hopefully all the robots and client programs will do the right thing.

Firstly create a directory in the root of the website called something like "/err/". Originally I called it "/error/" but then I ran into issues because the default apache configuration sets that as a system-wide alias for handling errors, which is fine on a server with one website, but can complicate things for multiple virtual hosts.

Create an html page in "err/503.html" that communicates the nature of the downtime to clients. It might also include information such as contact addresses. You can design it to fit in with the style of the rest of the website, however keep in mind that all included files such as css and image files must be referred to by absolute, rather than relative, paths. If referring to files on the same website you'll want to make sure they're available from within "/err" directory.

Then add the following to the appropriate VirtualHost section, then uncomment the redirect and reload the apache server when needed.

ErrorDocument 503 /err/503.html
## uncomment below to enter maintenance mode
#RedirectMatch 503 ^/(?!err/)

 

Comments on this Entry

Posted by spiney (85.127.xx.xx) on Fri 27 Oct 2006 at 12:00
[ Send Message ]
In case you're also using mod_rewrite, be sure to turn off the RewriteEngine temporarily, because mod_rewrite seems to take precedence over RedirectMatch.

Kind regards
--
Debian GNU/Linux on an IBM Thinkpad T43p

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search