When things break Recommended
Say when you'll be back
During planned maintenance, answer 503 with Retry-After and a clear page. Keep the health check working.
How to do it
Add a maintenance switch. When it is on, pages answer 503 with Retry-After and Cache-Control: no-store, while the health check stays up. Never answer 200 or redirect to a maintenance page, or search engines index it in place of your pages. Keep it under a day, because search engines start dropping pages after a few days of 503.
Example
# Turn on with: touch /var/www/maintenance.on
location = /healthz { proxy_pass http://127.0.0.1:8080; }
location / {
if (-f /var/www/maintenance.on) { return 503; }
proxy_pass http://127.0.0.1:8080;
}
error_page 503 /maintenance.html;
location = /maintenance.html {
root /var/www;
add_header Retry-After 1800 always;
add_header Cache-Control no-store always;
internal;
}
How to check
With the switch on, curl -sI on a page answers 503 with Retry-After, and the health check answers 200.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/when-things-break/maintenance-pages.