Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is "Is offline for maintenance" page implemented?

Occasionally when I try to open a site I will see a page saying smth like "This site is offline for maintenance" and then some comments follow on how long it would presumably take. Stack Overflow does that too.

How does it work? I mean if the site is shut down who replies to my HTTP request and serves this page?

like image 351
sharptooth Avatar asked Aug 19 '09 07:08

sharptooth


4 Answers

There is a trick in asp.net where you place a file called

App_Offline.htm

All requests will go to this, until the page is deleted.

For other environments you can often just change where the server points, or another such plan.

-- Edit

A server-agnostic approach is achieved through something like load-balancing.

Under the hood you can send the requests to a given internal server. You may then decide to point all requests to your server 'a', which you configure to show the 'downtime' page. Then, you make changes to server 'b', confirm it as successful, and point all requests to 'b'. Then you update 'a', and let requests go to both.

like image 150
Noon Silk Avatar answered Sep 20 '22 15:09

Noon Silk


In ASP.NET (and ASP.NET MVC as Stackoverflow uses) this is provided by the app_offline.htm feature. This works simply by forwarding all ASP.NET requests to the app_offline.htm file.

Incidentally the copy Web Site tool in ASP.NET performs the process of placing this file in the root of the web app, copyies the Web site files and then deletes this file.

Strategies for other technologies are discussed here.

like image 30
RichardOD Avatar answered Sep 22 '22 15:09

RichardOD


In apache you may use a .htacces file with this content.

order deny,allow
allow from 192.168.1.151
deny from all

ErrorDocument 403 404.html
ErrorDocument 404 404.html
ErrorDocument 500 404.html

This will deny access to everyone except one IP and serve a static 404.html file.

This works in the case you only have one server without load-balancing and other stuff. Should work for load-balancing too though.

like image 44
Quamis Avatar answered Sep 20 '22 15:09

Quamis


The apache reverse proxy server can be configured to send that response - if it is being used as part of that architecture.

like image 28
techzen Avatar answered Sep 23 '22 15:09

techzen