[CentOS] "Site down for maintenance" - How is this accomplished?

Fri Aug 24 13:38:57 UTC 2007
Barry Brimer <lists at brimer.org>


On Fri, 24 Aug 2007, Matt Shields wrote:

> Depending on the traffic level and the amount of hardware, I would
> recommend against what you just said.  Especially if your current
> environment is multiple servers that are load balanced.  You don't
> want to have to replicate the environment just to have a construction
> page.
>
> Instead of setting up Apache with PHP, just setup a really basic
> server with lighttpd and a single static page with really minimum
> graphics.  It will serve pages and the one or two graphics a lot
> faster and a single server can usually handle the load.
>
> -matt
>
> On 8/24/07, Barry Brimer <lists at brimer.org> wrote:
>>
>>
>> On Fri, 24 Aug 2007, Matt Arnilo S. Baluyos (Mailing Lists) wrote:
>>
>>> Hello everyone,
>>>
>>> Although we use CentOS primarily on our servers, this query is
>>> actually more of a general networking question than something specific
>>> to CentOS.
>>>
>>> In the next week or so, we shall be migrating our in-house servers to
>>> a data center. While we're doing that, we'd like to show a "Site down
>>> for maintenance" message while the servers that hosts our websites (we
>>> have around 15 sites hosted btw), are down.
>>>
>>> So, how is this accomplished? While I can probably hack something on
>>> our name servers, I'm sure there are people on this list that have
>>> been doing this and could give some recommendations as to the best
>>> practices for this type of task.
>>
>> I would have DNS for all domains point to a web server that has the
>> following php page:
>> =========================================================================
>> <html>
>> <head>
>> <title>Maintenance</title>
>> </head>
>> <body bgcolor=white>
>> <font size=5><center>Maintenance</center>
>> <br>
>> <center>The server that hosts <? $_SERVER['HTTP_HOST'] ?> is currently
>> undergoing maintenance.  <? $_SERVER['HTTP_HOST'] ?> will return to full
>> service as soon as possible.
>> </center>
>> </body>
>> </html>
>> =========================================================================
>> I would also add to your httpd.conf file:
>> =========================================================================
>> RewriteEngine on
>> RewriteRule !^/index\.php$ /index.php [NC,L]
>> RewriteRule !^/index\.php$ - [F]
>> =========================================================================
>> This makes it so that anyone who connects to any URL on any of your
>> websites will be told that the server they are connecting to is under
>> maintenance.
>>
>> When you have the new server up and running, change DNS.  Alternately you
>> could place this on a server in the new location, but change the
>> routing/NATing to temporarily deliver the addresses to the server hosting
>> this page.  If you are using SSL certificates, you will need to have them
>> as well and create different virtualhosts, although they can all have the
>> same DocumentRoot and web page.
>>
>> Hope this helps.
>>
>> Barry

My page does not use any graphics.  The reason I used PHP and not a static 
page was that I wanted the user to know that the site and url they had 
connected to was valid, and that they had not reached the page by mistake, 
or mis-typed the address.  If you are that worried about loading a page 
faster, and you think lighttpd is the way to go, I am all for it, but I 
don't think it is necessary.  For added performance, you could put the 
page on a ram disk, but I really think the return will be minimal.

Barry