0

I've looked at Apache ErrorDocument directive on how to do this. I found an answer here and it mentioned :

You should use a URL to point to your ErrorDocument otherwise if you use a filesystem reference you will get an additional 503 whilst trying to find it.

So here's how my virtualhost looks like. For test purpose i'm pointing it at Google

<VirtualHost *:80>  
    ServerName shabbasheep.mydomain.com
    ServerAlias www.mydomain.com

    ErrorDocument 503 https://www.google.com
    ...
    ...
</VirtualHost>

I'm trying to show a maintenance page when my apache server goes down. I'm currently testing this on my local machine before applying it on the live server.

To Test this I stop my apache server and try to access my page hoping the page gets re-directed to the Google Page.

It goes not work :| and I get Firefox can't establish a connection to the server at shabbasheep.mydomain.com.

After doing some further re-search I found a solution that uses RewriteEngine so i went along and added the following to my virtual host.

RewriteEngine On
RewriteCond %{REQUEST_URI} $ 
RewriteRule $ /https://www.google.com [R=503,L]

Still no luck of redirecting to Google when my server is down. Excuse my understanding on this subject.

Any help on how to solve this is much appreciated.

Thanks in advance

shabeer90
  • 113
  • 1
  • 1
  • 6
  • 6
    I think you misunderstand the concept a bit. Apache shows a (custom) error page when it encounters an error, but to be able to do that it still needs to be running. If Apache isn't running it can't do anything and the connection the visitor is making to your server will time-out and fail. – HBruijn Aug 06 '14 at 10:56
  • @HBruijn is correct. Basically Apache listen on port 80. But if you stop Apache, no one is listening on port 80. So when a request arrives on this port, your Operating System is simply rejecting it as no service is listening. – Huygens Aug 06 '14 at 10:58
  • Thanks a lot for enlightening me on this. I did wonder how it was going to work when apache was down, but was not very clear on it. I was assuming apache had something hidden that performs this. So there is no possible way of doing this? – shabeer90 Aug 06 '14 at 11:01
  • 1
    Larger sites typically have a loadbalancer, which during normal operations simply forwards all requests and lets the actual web server(s) handle them. During an outage or scheduled maintenance when none of the actual web servers are available, the loadbalancer, as an outside source, can often display a simple static page with a notification instead. – HBruijn Aug 06 '14 at 11:05
  • There are 3rd party services that you can use as reverse proxy for your application and will show a custom error page if your server is down, or even a cached version of your website. – Florin Asăvoaie Aug 06 '14 at 11:39
  • Could you point me to some direction for it, so I could use it in future. – shabeer90 Aug 06 '14 at 11:48
  • 1
    Take a look at what for instance cloudflare offers [in this regard](https://support.cloudflare.com/hc/en-us/articles/200168006-What-does-Always-Online-do-) – HBruijn Aug 06 '14 at 12:39

0 Answers0