Skip to content

feat(reverse_proxy): lb_retry_on conditions#7569

Open
seroperson wants to merge 1 commit intocaddyserver:masterfrom
seroperson:i6267-reverse-proxy-retry
Open

feat(reverse_proxy): lb_retry_on conditions#7569
seroperson wants to merge 1 commit intocaddyserver:masterfrom
seroperson:i6267-reverse-proxy-retry

Conversation

@seroperson
Copy link

Closes #6267

Added a new field, lb_retry_on which is responsible for retrying based on response.

Available conditions:

  • Status codes: 502, 503, 5xx-like
  • empty_response - socket closed before receiving a response
  • tls_handshake_error - TLS negotiation failed
  • response_timeout - upstream was too slow to respond
  • other - any other unclassified error

In Caddyfile it looks like:

reverse_proxy backend1:8080 backend2:8080 {
    lb_retries 3
    lb_retry_on 503 502 response_timeout
}

If lb_retry_on is unset, the old default behavior is preserved if retry-related options are set:

  1. Dial errors (connection refused, DNS failure, etc) - always retried
  2. All other errors (EOF, timeout, TLS errors, etc):
    2.1 GET requests - always retried
    2.2 Non-GET requests - retried only if lb_retry_match is configured and the request matches it
  3. Status codes - never trigger retries

Now lb_retry_on allows you to mostly override the default behavior (except of dial errors, they're always retried).

Assistance Disclosure

Co-Authored with Claude Opus 4.6, mostly for tests and consulting about the codebase.

@CLAassistant
Copy link

CLAassistant commented Mar 14, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom conditions for retrying proxy requests

2 participants