Redirect to another site page if site one is down

2019-07-28 15:48发布

问题:

I'm developing one web application, where requirement is something like, If for any reason site is gets down or stopped, it should redirect to some another page saying site is under maintenance

Any idea how can I achieve this?

回答1:

In part, this depends on how the site "gets down or stopped." If the www publishing service is stopped, then you'd need a load balancer (https://f5.com/glossary/load-balancer) that can detect if your service is down and redirect traffic to another host. Keep in mind for Windows services you are able to set Recovery options so you can restart the service upon failure.

In the case of the web site itself being stopped in IIS, there is a way to direct traffic to another site. In your live site, you can add a host header for your domain and bind it to the IP address. Then, you create a 2nd site using the same IP address, but with no host header. Put your maintenance message there on the 2nd site. Requests coming in will go to the site that matches the host header first (your live site), and if that site is stopped, it will match on the IP address and thereby hit your 2nd site (your maintenance site).