mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-01 00:43:23 +08:00
reverseproxy: Adjust defaults, document defaults (#4436)
* reverseproxy: Adjust defaults, document defaults Related to some of the issues in https://github.com/caddyserver/caddy/issues/4245, a complaint about the proxy transport defaults not being properly documented in https://caddy.community/t/default-values-for-directives/14254/6. - Dug into the stdlib to find the actual defaults for some of the timeouts and buffer limits, documenting them in godoc so the JSON docs get them next release. - Moved the keep-alive and dial-timeout defaults from `reverseproxy.go` to `httptransport.go`. It doesn't make sense to set defaults in the proxy, because then any time the transport is configured with non-defaults, the keep-alive and dial-timeout defaults are lost! - Sped up the dial timeout from 10s to 3s, in practice it rarely makes sense to wait a whole 10s for dialing. A shorter timeout helps a lot with the load balancer retries, so using something lower helps with user experience. * reverseproxy: Make keepalive interval configurable via Caddyfile * fastcgi: DialTimeout default for fastcgi transport too
This commit is contained in:
@ -806,7 +806,9 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
|
||||
// tls_trusted_ca_certs <cert_files...>
|
||||
// tls_server_name <sni>
|
||||
// keepalive [off|<duration>]
|
||||
// keepalive_interval <interval>
|
||||
// keepalive_idle_conns <max_count>
|
||||
// keepalive_idle_conns_per_host <count>
|
||||
// versions <versions...>
|
||||
// compression off
|
||||
// max_conns_per_host <count>
|
||||
@ -966,6 +968,19 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||
}
|
||||
h.KeepAlive.IdleConnTimeout = caddy.Duration(dur)
|
||||
|
||||
case "keepalive_interval":
|
||||
if !d.NextArg() {
|
||||
return d.ArgErr()
|
||||
}
|
||||
dur, err := caddy.ParseDuration(d.Val())
|
||||
if err != nil {
|
||||
return d.Errf("bad interval value '%s': %v", d.Val(), err)
|
||||
}
|
||||
if h.KeepAlive == nil {
|
||||
h.KeepAlive = new(KeepAlive)
|
||||
}
|
||||
h.KeepAlive.ProbeInterval = caddy.Duration(dur)
|
||||
|
||||
case "keepalive_idle_conns":
|
||||
if !d.NextArg() {
|
||||
return d.ArgErr()
|
||||
|
Reference in New Issue
Block a user