8000 I would like to ask whether Caddy server's reverseproxy dynamic upstream supports passive health checks. · Issue #7037 · caddyserver/caddy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

I would like to ask whether Caddy server's reverseproxy dynamic upstream supports passive health checks. #7037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
faf-xff opened this issue May 26, 2025 · 1 comment
Labels
question ❔ Help is being requested

Comments

@faf-xff
Copy link
faf-xff commented May 26, 2025

Based on my own testing, reverseproxy dynamic upstream does not support passive health checks. This conclusion is drawn from the following code:

github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy/reverseproxy.go:461

func (h *Handler) proxyLoopIteration(r *http.Request, origReq *http.Request, w http.ResponseWriter, proxyErr error, start time.Time, retries int,
	repl *caddy.Replacer, reqHeader http.Header, reqHost string, next caddyhttp.Handler,
) (bool, error) {
	// get the updated list of upstreams
	upstreams := h.Upstreams
	if h.DynamicUpstreams != nil {
		dUpstreams, err := h.DynamicUpstreams.GetUpstreams(r)
		if err != nil {
			h.logger.Error("failed getting dynamic upstreams; falling back to static upstreams", zap.Error(err))
		} else {
			upstreams = dUpstreams
			for _, dUp := range dUpstreams {
				h.provisionUpstream(dUp)
			}
			h.logger.Debug("provisioned dynamic upstreams", zap.Int("count", len(dUpstreams)))
			defer func() {
				// these upstreams are dynamic, so they are only used for this iteration
				// of the proxy loop; be sure to let them go away when we're done with them
				for _, upstream := range dUpstreams {
					_, _ = hosts.Delete(upstream.String())
				}
			}()
		}
	}


The main issue lies in the defer method, which deletes the hosts. If the deletion didn't happen, it would work. However, I am not sure what the impact would be if the deletion were omitted.

@mholt
Copy link
Member
mholt commented May 26, 2025

Right; when you have dynamic upstream, only healthy ones should be given to caddy in the first place.

For example if you use SRV upstreams, whatever is setting and deleting SRV records should already be doing so for unhealthy hosts too.

@mholt mholt closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2025
@mholt mholt added the question ❔ Help is being requested label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❔ Help is being requested
Projects
None yet
Development

No branches or pull requests

2 participants
0