Show a 503 error page if server unavailable

domain-name-systemredirect

I've searched through google, stackoverflow and serverfault but I'm not quite sure how to phrase what I'm looking for, sorry if this is a duplicate (it probably is)!

What I would like to know is if its possible to do the following:

I currently have access to two different servers (droplets) with Digital Ocean under two accounts, one account is for development work and the other is actually hosting a site.
Both run a LAMP stack.

So the setup is like this


Development Server

Account1

Server1

IP (example) 1.1.1.1



Website Server

Account2

Server2

IP (example) 2.2.2.2


The website server has its DNS records all setup correctly (A Record, and CNAME record and nameserver details).

What I would like to achieve, is to host a 503 page on my development server, so when I power down apache and/or the whole VM for maintenence/installing/updating, that anyone who tries to access our domain is automatically redirected to a 503 page.

EG. Someone tries to access www.domain.com, which would resolve to 2.2.2.2, however, if 2.2.2.2 is unreachable, redirect to 1.1.1.1/503.html, or too 503.1.1.1.1 if it has to use sub-domain.

Because the server may be off, htaccess or php header-redirects aren't an option.

I think this might be possible using a 3rd server to monitor the status of 2.2.2.2 and redirecting when not available, but I don't want the extra overhead if possible.

Is this possible?

I don't want to use replication (just yet anyway) as the site is still in its early days.

Best Answer

You can't do it without an additional device. You need to have something upstream which is fielding the requests and passing them on to the relevant servers. When it detects that something has gone away then it returns the 503.

Related Topic