Skip to content

Commit

Permalink
cmd: Add http proxy timeout config (#132)
Browse files Browse the repository at this point in the history
Add environment parameters (and description) to configure timeout settings of a server handled proxy requests.

It will help prevent a case of unexpected closing a client connection if an upstream request is executing more than default timeout.

Signed-off-by: Aleksei Piianin <[email protected]>
  • Loading branch information
7phs authored and aeneasr committed Nov 5, 2018
1 parent ee9dcdd commit b3718ce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/serve_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ OTHER CONTROLS
Default: RULES_REFRESH_INTERVAL=5s
--------------------------------------------------------------
- PROXY_SERVER_READ_TIMEOUT: The maximum duration for reading the entire request, including the body.
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
--------------------------------------------------------------
Default: PROXY_SERVER_READ_TIMEOUT=5s
--------------------------------------------------------------
- PROXY_SERVER_WRITE_TIMEOUT: The maximum duration before timing out writes of the response.
Increase this parameter to prevent unexpected closing a client connection if an upstream request is executing more than 10 seconds.
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
--------------------------------------------------------------
Default: PROXY_SERVER_WRITE_TIMEOUT=10s
--------------------------------------------------------------
- PROXY_SERVER_IDLE_TIMEOUT: The maximum amount of time to wait for any action of a request session, reading data or writing the response.
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
--------------------------------------------------------------
Default: PROXY_SERVER_IDLE_TIMEOUT=120s
--------------------------------------------------------------
` + corsMessage,
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -243,6 +261,9 @@ OTHER CONTROLS
TLSConfig: &tls.Config{
Certificates: certs,
},
ReadTimeout: viper.GetDuration("PROXY_SERVER_READ_TIMEOUT"),
WriteTimeout: viper.GetDuration("PROXY_SERVER_WRITE_TIMEOUT"),
IdleTimeout: viper.GetDuration("PROXY_SERVER_IDLE_TIMEOUT"),
})

if err := graceful.Graceful(func() error {
Expand Down

0 comments on commit b3718ce

Please sign in to comment.