@marcel91200 / caddy Mirror · read-only / commits / 1c596e3c
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 22:15 UTC

reverse_proxy: use the new KeepAliveConfig to set probe interval (#7157)

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>

WeidiDeng committed Aug 22, 2025 at 04:36 UTC 1c596e3c5a1cd0b52febb1506ffe471918bd1128
1 file changed +12
modules/caddyhttp/reverseproxy/httptransport.go
+12
@@ -428,7 +428,19 @@ func (h *HTTPTransport) NewTransport(caddyCtx caddy.Context) (*http.Transport, e
428 }
429
430 if h.KeepAlive != nil {
431 + // according to https://pkg.go.dev/net#Dialer.KeepAliveConfig,
432 + // KeepAlive is ignored if KeepAliveConfig.Enable is true.
433 + // If configured to 0, a system-dependent default is used.
434 + // To disable tcp keepalive, choose a negative value,
435 + // so KeepAliveConfig.Enable is false and KeepAlive is negative.
436 +
437 + // This is different from http keepalive where a tcp connection
438 + // can transfer multiple http requests/responses.
439 dialer.KeepAlive = time.Duration(h.KeepAlive.ProbeInterval)
440 + dialer.KeepAliveConfig = net.KeepAliveConfig{
441 + Enable: h.KeepAlive.ProbeInterval > 0,
442 + Interval: time.Duration(h.KeepAlive.ProbeInterval),
443 + }
444 if h.KeepAlive.Enabled != nil {
445 rt.DisableKeepAlives = !*h.KeepAlive.Enabled
446 }