63
MaxConnsPerHost int `json:"max_conns_per_host,omitempty"`
64
65
// How long to wait before timing out trying to connect to
66
- // an upstream.
66
+ // an upstream. Default: `3s`.
67
DialTimeout caddy.Duration `json:"dial_timeout,omitempty"`
68
69
// How long to wait before spawning an RFC 6555 Fast Fallback
70
- // connection. A negative value disables this.
70
+ // connection. A negative value disables this. Default: `300ms`.
71
FallbackDelay caddy.Duration `json:"dial_fallback_delay,omitempty"`
72
73
- // How long to wait for reading response headers from server.
73
+ // How long to wait for reading response headers from server. Default: No timeout.
74
ResponseHeaderTimeout caddy.Duration `json:"response_header_timeout,omitempty"`
75
76
// The length of time to wait for a server's first response
77
// headers after fully writing the request headers if the
78
- // request has a header "Expect: 100-continue".
78
+ // request has a header "Expect: 100-continue". Default: No timeout.
79
ExpectContinueTimeout caddy.Duration `json:"expect_continue_timeout,omitempty"`
80
81
- // The maximum bytes to read from response headers.
81
+ // The maximum bytes to read from response headers. Default: `10MiB`.
82
MaxResponseHeaderSize int64 `json:"max_response_header_size,omitempty"`
83
84
- // The size of the write buffer in bytes.
84
+ // The size of the write buffer in bytes. Default: `4KiB`.
85
WriteBufferSize int `json:"write_buffer_size,omitempty"`
86
87
- // The size of the read buffer in bytes.
87
+ // The size of the read buffer in bytes. Default: `4KiB`.
88
ReadBufferSize int `json:"read_buffer_size,omitempty"`
89
90
// The versions of HTTP to support. As a special case, "h2c"
147
148
// NewTransport builds a standard-lib-compatible http.Transport value from h.
149
func (h *HTTPTransport) NewTransport(ctx caddy.Context) (*http.Transport, error) {
150
+ // Set keep-alive defaults if it wasn't otherwise configured
151
+ if h.KeepAlive == nil {
152
+ h.KeepAlive = &KeepAlive{
153
+ ProbeInterval: caddy.Duration(30 * time.Second),
154
+ IdleConnTimeout: caddy.Duration(2 * time.Minute),
155
+ MaxIdleConnsPerHost: 32, // seems about optimal, see #2805
156
+ }
157
+ }
158
+
159
+ // Set a relatively short default dial timeout.
160
+ // This is helpful to make load-balancer retries more speedy.
161
+ if h.DialTimeout == 0 {
162
+ h.DialTimeout = caddy.Duration(3 * time.Second)
163
+ }
164
+
165
dialer := &net.Dialer{
166
Timeout: time.Duration(h.DialTimeout),
167
FallbackDelay: time.Duration(h.FallbackDelay),
318
// option except in testing or local development environments.
319
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
320
306
- // The duration to allow a TLS handshake to a server.
321
+ // The duration to allow a TLS handshake to a server. Default: No timeout.
322
HandshakeTimeout caddy.Duration `json:"handshake_timeout,omitempty"`
323
324
// The server name (SNI) to use in TLS handshakes.
420
// Whether HTTP Keep-Alive is enabled. Default: true
421
Enabled *bool `json:"enabled,omitempty"`
422
408
- // How often to probe for liveness.
423
+ // How often to probe for liveness. Default: `30s`.
424
ProbeInterval caddy.Duration `json:"probe_interval,omitempty"`
425
426
// Maximum number of idle connections. Default: 0, which means no limit.
429
// Maximum number of idle connections per host. Default: 32.
430
MaxIdleConnsPerHost int `json:"max_idle_conns_per_host,omitempty"`
431
417
- // How long connections should be kept alive when idle. Default: 0, which means no timeout.
432
+ // How long connections should be kept alive when idle. Default: `2m`.
433
IdleConnTimeout caddy.Duration `json:"idle_timeout,omitempty"`
434
}
435