diff options
author | Matt Holt <[email protected]> | 2022-09-02 16:59:11 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-02 16:59:11 -0600 |
commit | d3c3fa10bd72029720969cff0c29e2b79a1b2cdf (patch) | |
tree | 3c4789238dd88a45f5272940c31a9d865613bd14 /modules/caddyhttp | |
parent | 83b26975bd9330c4cfc44d52b106da739240e72b (diff) | |
download | caddy-d3c3fa10bd72029720969cff0c29e2b79a1b2cdf.tar.gz caddy-d3c3fa10bd72029720969cff0c29e2b79a1b2cdf.zip |
core: Refactor listeners; use SO_REUSEPORT on Unix (#4705)
* core: Refactor listeners; use SO_REUSEPORT on Unix
Just an experiment for now
* Fix lint by logging error
* TCP Keepalive configuration (#4865)
* initial attempt at TCP Keepalive configuration
* core: implement tcp-keepalive for linux
* move canSetKeepAlive interface
* Godoc for keepalive server parameter
* handle return values
* log keepalive errors
* Clean up after bad merge
* Merge in pluggable network types
From 1edc1a45e3aee1f7d86b68c3ddaf2fd16ba8ab73
* Slight refactor, fix from recent merge conflict
Co-authored-by: Karmanyaah Malhotra <[email protected]>
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r-- | modules/caddyhttp/app.go | 2 | ||||
-rw-r--r-- | modules/caddyhttp/server.go | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go index 3db87b184..e48f82864 100644 --- a/modules/caddyhttp/app.go +++ b/modules/caddyhttp/app.go @@ -384,7 +384,7 @@ func (app *App) Start() error { for portOffset := uint(0); portOffset < listenAddr.PortRangeSize(); portOffset++ { // create the listener for this socket hostport := listenAddr.JoinHostPort(portOffset) - ln, err := caddy.Listen(listenAddr.Network, hostport) + ln, err := caddy.ListenTimeout(listenAddr.Network, hostport, time.Duration(srv.KeepAliveInterval)) if err != nil { return fmt.Errorf("%s: listening on %s: %v", listenAddr.Network, hostport, err) } diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 1bba34ca8..e2da5319e 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -72,6 +72,11 @@ type Server struct { // 5m is applied to help avoid resource exhaustion. IdleTimeout caddy.Duration `json:"idle_timeout,omitempty"` + // KeepAliveInterval is the interval at which TCP keepalive packets + // are sent to keep the connection alive at the TCP layer when no other + // data is being transmitted. The default is 15s. + KeepAliveInterval caddy.Duration `json:"keepalive_interval,omitempty"` + // MaxHeaderBytes is the maximum size to parse from a client's // HTTP request headers. MaxHeaderBytes int `json:"max_header_bytes,omitempty"` |