Details on nginx timeout Settings

  • 2020-05-13 04:31:55
  • OfStack

Common timeout configuration instructions for nginx

client_header_timeout

Grammar client_header_timeout time
The default value of 60 s
Context http server
Specifies the timeout time to wait for client to send 1 request header (e.g., GET/HTTP/1.1). A timeout is only considered if no request header is received in read once. If client does not send anything during the timeout period, nginx returns HTTP status code 408(" Request timed out ")

client_body_timeout

Grammar client_body_timeout time
The default value of 60 s
Context http server location
This instruction sets the read timeout time for the request body (request body). Timeout is set to only if the body of the request is not received in readstep 1 time. After a timeout, nginx returns the HTTP status code 408(" Request timed out ")

keepalive_timeout

Syntax keepalive_timeout timeout [header_timeout]
The default value 75 s
Context http server location
Note that the first parameter specifies the keep-alive connection timeout with client. The server will close the connection after this time. The optional second parameter specifies the time value in the response header Keep-Alive: timeout=time. This header allows some browsers to actively close the connection so that the server does not have to close the connection. Without this parameter, nginx does not send the Keep-Alive response header (although it is not the header that determines whether the connection is "keep-alive")
The values of the two parameters may not be the same

Note how different browsers handle the "keep-alive" header MSIE and Opera ignore "Keep-Alive: timeout= < N > " header. MSIE hold the connection for about 60-65 seconds, then send TCP RST Opera permanently maintains long connections Mozilla keeps the connection alive for N plus about 1-10 seconds. Konqueror maintains a long connection N seconds

lingering_timeout

Grammar lingering_timeout time
The default value of 5 s
Context http server location
Note: after lingering_close takes effect, before closing the connection, it will detect whether any data sent by the user has arrived at the server. If there is no data readable after lingering_timeout, it will directly close the connection. Otherwise, the connection must be closed after the data on the connection buffer has been read and discarded.

resolver_timeout

Grammar resolver_timeout time
30 s default values
Context http server location
This instruction sets the DNS parse timeout

proxy_connect_timeout

Grammar proxy_connect_timeout time
The default value of 60 s
Context http server location
Note that this directive sets the connection timeout with upstream server, and it is important to remember that this timeout cannot exceed 75 seconds.
This is not the time to wait for the back end to return to the page, which is declared by proxy_read_timeout. If your upstream server is up, but hanging is live (for example, there are not enough threads to process the request, so put your request in the request pool for later processing), then this declaration is useless because the connection to the upstream server has already been established.

proxy_read_timeout

Grammar proxy_read_timeout time
The default value of 60 s
Context http server location
Explains that this directive sets the read timeout with the proxy server. It determines how long nginx will wait to get a response to a request. This time is not the time to obtain the entire response, but the time for the two reading operations.

proxy_send_timeout

Grammar proxy_send_timeout time
The default value of 60 s
Context http server location
Note that this specification sets the timeout time for sending the request to the upstream server. The timeout is not set for the entire send period, but for the two write operations. If upstream does not receive new data after the timeout, nginx closes the connection

proxy_upstream_fail_timeout (fail_timeout)

Syntax server address [fail_timeout=30s]
The default value of 10 s
Context upstream
To specify the parameters of the server directive under the Upstream module, set the time when a certain upstream backend fails for a specified number of times (max_fails), and the default time is 10 seconds


Related articles: