Skip to content

reverseproxy: Honor health check redirect destinations - #8223

Merged
steadytao merged 1 commit into
caddyserver:masterfrom
Indra55:fix-health-check-redirect-dial
Oct 16, 2026
Merged

steadytao merged 1 commit into
caddyserver:masterfrom
Indra55:fix-health-check-redirect-dial

Conversation

@Indra55

@Indra55 Indra55 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8222

Active health checks with follow_redirects enabled followed the redirect path and updated the Host header, but continued connecting to the original upstream address.

For example, if backend A redirected its health check to backend B, Caddy requested B’s path from A instead. Depending on A’s response, this could remove a healthy backend from service or leave an unhealthy backend available.

This change clears the original dialing override when a redirect changes the scheme or host/port, allowing the transport to connect to the redirect destination. Same-origin redirects and redirects returning to the original origin retain the original override.

Six regression cases cover healthy and unhealthy redirect targets, HTTPS, relative redirects, redirects back to the original origin, and disabled redirect following.

Validation:

  • go test -race -short ./...
  • go build ./...
  • go vet ./...
  • Original reproduction passes with the rebuilt binary.

AI disclosure: I wrote the fix. The regression tests were generated with GPT-6.1 and I reviewed them.

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@steadytao
steadytao merged commit 1f099b3 into caddyserver:master Oct 16, 2026
25 checks passed
@steadytao steadytao added the bug 🐞 Something isn't working label Oct 16, 2026
@steadytao steadytao added this to the v2.12.0 milestone Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reverseproxy: health-check redirects still dial the original upstream

2 participants