A Maintenance-Mode Switch

Google advises a 503 for an outage of a day or two. touch maintenance.on shows one to all but your own addresses; rm ends it:

Maintenance mode while maintenance.on existsApache config
# Needs: mod_rewrite, mod_headers; AllowOverride FileInfo; Options FollowSymLinks
ErrorDocument 503 /maintenance.html
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.on -f
RewriteCond expr "! -R '127.0.0.1' && ! -R '203.0.113.0/24'"
RewriteCond %{REQUEST_URI} !^/(maintenance\.html|css/|img/)
RewriteRule ^ - [R=503,L]
Header always set Retry-After "1800" "expr=%{REQUEST_STATUS} == 503"
Header always set Cache-Control "no-store" "expr=%{REQUEST_STATUS} == 503"

Line 5's -R matches the client against CIDR blocks; line 6 lets the page and its styles through. Line 7's 503 makes Apache 129 serve line 2's page, and lines 8 and 9 tell crawlers when to return. A visitor at 127.0.0.2 and the administrator saw:

Output of 81
$ touch maintenance.on; curl -si http://example.com/checkout    # visitor
HTTP/1.1 503 Service Unavailable
Retry-After: 1800
Cache-Control: no-store
...
<!doctype html><title>Back soon</title><h1>Back in 30 minutes</h1>
admin at 127.0.0.1, /          shop home 200
rm maintenance.on; visitor /   shop home 200