Caddy reverse proxy sends upstream hostname instead of original Host header #451
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-platform#451
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Bug
Lineage
Discovered during custom domain validation (wave 2/3 of godaddy-tofu DNS deployment). No parent plan.
Repo
ldraney/pal-e-platform
What Broke
landscaping-assistant.appredirects tohttps://landscaping-assistant.tail5b443a.ts.net/logininstead ofhttps://landscaping-assistant.app/login. The Rails app generates redirect URLs using theHostheader it receives, but Caddy is sending the upstream Tailscale hostname instead of the original client hostname.Confirmed by testing from the edge proxy:
curl -H 'Host: landscaping-assistant.app' https://landscaping-assistant.tail5b443a.ts.net/→location: https://landscaping-assistant.app/login(correct)curl -H 'Host: landscaping-assistant.tail5b443a.ts.net' https://landscaping-assistant.tail5b443a.ts.net/→location: https://landscaping-assistant.tail5b443a.ts.net/login(wrong)curl https://landscaping-assistant.app/through Caddy →location: https://landscaping-assistant.tail5b443a.ts.net/login(wrong — proves Caddy sends upstream host)Repro Steps
https://landscaping-assistant.appin a browser (unauthenticated)https://landscaping-assistant.tail5b443a.ts.net/logininstead ofhttps://landscaping-assistant.app/loginExpected Behavior
Caddy should pass the original client
Hostheader (landscaping-assistant.app) to the backend, so the Rails app generates redirect URLs using the custom domain.Environment
salt/states/caddy/Caddyfile.j2Fix
One-line change in
salt/states/caddy/Caddyfile.j2line 18:The
header_up Host {http.request.host}directive tells Caddy to preserve the original client Host header when proxying to the backend.tls_server_namestill handles the TLS SNI correctly.After merging, run
salt state.apply caddyon the edge proxy to deploy.Acceptance Criteria
curl -sI https://landscaping-assistant.app/returnslocation: https://landscaping-assistant.app/login(not Tailscale URL)curl -sI https://palinks.app/still returns 200 OKRelated
landscaping-assistant.app(verified via admin API) — not the cause