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, 18:30 UTC
reverseproxy: set default values for keepalive if only some of them are set (#7318)
WeidiDeng committed
Oct 25, 2025 at 17:15 UTC
abe0acabb61b0151f58c7b750d3963dbbffe7270
1 file changed
+10
-5
modules/caddyhttp/reverseproxy/httptransport.go
+10
-5
@@ -204,11 +204,16 @@ func (h *HTTPTransport) Provision(ctx caddy.Context) error {
204
func (h *HTTPTransport) NewTransport(caddyCtx caddy.Context) (*http.Transport, error) {
205
// Set keep-alive defaults if it wasn't otherwise configured
206
if h.KeepAlive == nil {
207
- h.KeepAlive = &KeepAlive{
208
- ProbeInterval: caddy.Duration(30 * time.Second),
209
- IdleConnTimeout: caddy.Duration(2 * time.Minute),
210
- MaxIdleConnsPerHost: 32, // seems about optimal, see #2805
211
- }
207
+ h.KeepAlive = new(KeepAlive)
208
+ }
209
+ if h.KeepAlive.ProbeInterval == 0 {
210
+ h.KeepAlive.ProbeInterval = caddy.Duration(30 * time.Second)
211
+ }
212
+ if h.KeepAlive.IdleConnTimeout == 0 {
213
+ h.KeepAlive.IdleConnTimeout = caddy.Duration(2 * time.Minute)
214
+ }
215
+ if h.KeepAlive.MaxIdleConnsPerHost == 0 {
216
+ h.KeepAlive.MaxIdleConnsPerHost = 32 // seems about optimal, see #2805
217
}
218
219
// Set a relatively short default dial timeout.