Serve a static maintenance page when the frontend is unreachable - #219
Closed
ssavutu wants to merge 1 commit into
Closed
Serve a static maintenance page when the frontend is unreachable#219ssavutu wants to merge 1 commit into
ssavutu wants to merge 1 commit into
Conversation
When Nginx cannot complete the proxy to the active frontend slot -- connection refused because no container is listening, or a read timeout -- it fell through to the stock Nginx error page. That page says nothing useful, carries no cache directives, and looks like a broken server rather than a site that is coming back. `location /` now falls back to an internal rewrite to a self-contained maintenance page. Three choices are load-bearing: It is a rewrite, not a redirect. Uptime checks follow redirects, so a 302 to a down page would land every monitor on a 200 and report the site healthy for the whole outage. The client sees 503 on the URL it actually asked for. The page sends Cache-Control: no-store. Cloudflare pinning it at the edge would keep the site dark after the backend recovered -- the same trap as the /wp-content/ 404 caching this file already documents, except it takes out every page at once instead of one image. proxy_intercept_errors stays off, so this only catches an unreachable upstream. Turning it on would also replace error responses the frontend returns on purpose, hiding real application behaviour. 502 and 504 are normalised to 503 to pair with Retry-After; the original code is still in error.log, which is where it gets diagnosed anyway. /v1/ and /healthz are untouched, so API clients keep getting real transport errors and monitoring keeps reporting the truth. Nothing in deploy.sh installs the HTML -- it is copied during bootstrap next to the site config, as documented. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Nginx cannot complete the proxy to the active frontend slot — connection refused because no container is listening, or a read timeout — it fell through to the stock Nginx error page. That page says nothing useful, carries no cache directives, and looks like a broken server rather than a site that is coming back.
location /now falls back to an internal rewrite to a self-contained maintenance page.Three choices that are load-bearing
It is a rewrite, not a redirect. Uptime checks follow redirects, so a 302 to a down page would land every monitor on a 200 and report the site healthy for the whole outage. The client sees 503 on the URL it actually asked for.
The page sends
Cache-Control: no-store. Cloudflare pinning it at the edge would keep the site dark after the backend recovered — the same trap as the/wp-content/404 caching this file already documents, except it takes out every page at once instead of one image.proxy_intercept_errorsstays off, so this only catches an unreachable upstream. Turning it on would also replace error responses the frontend returns on purpose, hiding real application behaviour.502 and 504 are normalised to 503 to pair with
Retry-After; the original code is still inerror.log, which is where it gets diagnosed anyway.Verified behaviour
Tested against a dead upstream in a container, not just
nginx -t:GET /(upstream dead)503+ maintenance page,Cache-Control: no-store,Retry-After: 60,X-Robots-Tag: noindexGET /_down.html404—internal;, so it cannot be cached or indexed as a 200GET /healthz200— Nginx liveness unaffectedGET /v1/health/db502, stock error — API never receives an HTML bodyDeployment note
Nothing in
deploy.shinstalls the HTML. It is copied during bootstrap next to the site config, as documented indeploy/README.md. Worth folding into the deploy script later so it cannot drift.🤖 Generated with Claude Code