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

Barry Brimer lists at brimer.org
Fri Aug 24 04:21:33 UTC 2007



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



More information about the CentOS mailing list