1

Is there a way to have a holding page saying something along the lines of "The site is down don't panic" - just a static html page, nothing fancy, when apache is restarted or goes down?

If it is possible how would I go about doing it? Would it require a separate web server running which kicks in once apache goes down.

Any ideas or links to help out would be greatly appreciated!

m4rc
  • 133
  • 4

4 Answers4

5

The "correct" answer is that you should have a cluster with automated failover for unplanned outages, and shift your DNS to a new server for planned outages... But as you probably have noticed that is not always an option.

When I need a truly minimal web server to show offline messages and the like I usually use netcat:

while true; do nc -l -p 80 -q 1 < offline.html; done

It gets the job done with a minimum of fuzz and saves me from having to install additional software on the server. Just ctrl-c the script when you are done.

You could probably set it up start when apache goes down, but I done see the need. Random outages of apache are pretty much unknown in my environment.

pehrs
  • 8,789
  • 1
  • 30
  • 46
  • Random outages of apache were previously unknown to us too, it's only in the past 2weeks that we've been seeing the load spike apparently randomly. This is more of a safeguard until we find the root cause. – m4rc Jan 11 '11 at 11:20
  • 2
    +1 for netcat. Doesn't that offline.html file have to contain the HTTP response headers, too, though? – SmallClanger Jan 11 '11 at 12:08
  • I think that I will use this approach as a temporary solution and long term probably go with nginx as a reverse proxy like vartec suggests – m4rc Jan 11 '11 at 14:07
  • @SmallClanger Yes, you have to start the file with something like "HTTP/1.0 200 OK" to make browsers happy. – pehrs Jan 11 '11 at 18:03
  • I tried that, but it didnt work. I created `offline.html`, stopped apache, then I started `while true; do nc -l -p 80 -q 1 < offline.html; done` as root and then called `http://localhost` but there was no page shown – rubo77 Nov 02 '12 at 10:11
  • but this worked: http://serverfault.com/a/444831/128892 – rubo77 Nov 02 '12 at 21:58
1

The first thing I would like to ask is what kind of websites are you hosting? If its a small personal or corporate website that doesn't have many visitors, then don't worry about a little bot of downtime, or get a reliable hosting provider.

If you would really like to have a page then you could use a reverse proxy server to redirect the user while the web server is down.

Hope that helps, RayQuang

RayQuang
  • 674
  • 1
  • 9
  • 16
  • There is a corporate site on there and a couple of other smaller sites. The main site gets around 90K visitors a month. – m4rc Jan 11 '11 at 11:10
  • Ok, In that case you would probably like to get a second server running with a reverse squid, and possibly a backup web server that you could redirect to in case the main one fails. – RayQuang Jan 11 '11 at 11:45
1

I'd suggest using reverse proxy, for example NgniX. Then on Apache being down, you'd get 502 or 504 error, which you can handle with you custom error page.

vartec
  • 6,217
  • 2
  • 33
  • 49
0

it might be possible if you have an upstream cache (squid or similar) that can return a page while the server is restarting.

it would be a custom 10060 error page (or however squid references them)

Liquidkristal
  • 41
  • 1
  • 6