Fix Ghost healthcheck to tolerate http→https redirect#7
Merged
Conversation
Ghost redirects any request whose Host header doesn't match its configured url — so `wget http://localhost:2368/ghost/api/admin/site/` from inside the container gets a 301 to the public URL, and wget follows it back out through Traefik. That only works if the host supports hairpin NAT (routing to its own public IP from inside a container), which is commonly blocked on VPS and firewall setups. On such hosts the healthcheck fails silently, Docker marks the container unhealthy, and Traefik stops routing to it — Ghost is running fine but the site shows as down. New healthcheck uses `--max-redirect=0` so wget stops at the 301 instead of trying to follow, plus `-S --spider` to emit the server response headers, then greps for any `HTTP/1` status line. Ghost responding at all (any 2xx/3xx/4xx/5xx) counts as healthy — a dead container won't emit headers, so the check still fails correctly. Spotted on a live Coolify deploy where Ghost booted successfully but Traefik returned 503. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
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.
Summary
Change Ghost's healthcheck from:
to:
Why
Ghost redirects any request whose
Host:header doesn't match its configuredurl. From inside the containerhttp://localhost:2368/…returns a 301 tohttps://tower.unredacted.org/…— wget by default follows the redirect, which requires hairpin NAT (routing to your own public IP from inside a container). Many VPS setups and firewall configs block hairpin, so the follow fails, wget exits non-zero, Docker marks the container unhealthy, and Traefik stops routing to it. Ghost itself is fine — the site just looks down.The new check uses
--max-redirect=0so wget stops at the 301 instead of following, then greps for anyHTTP/1response line. Any Ghost response (2xx/3xx/4xx/5xx) counts as healthy; a dead port emits no header → still fails correctly.Spotted on a live Coolify deploy — Ghost booted clean but repeated
GET /ghost/api/admin/site/ 301lines every 30s in the logs, site returning 503 through Traefik.Test plan
bash .github/scripts/test-patch.shpasses (existing assertions still match)docker compose config --quietparses the newCMD-SHELLhealthcheckdocker compose psshows ghost(healthy), site responds through Traefik🤖 Generated with Claude Code