Common nginx timeout configurations
Client_header_timeout
Syntax client_header_timeout time
The default value is 60 s.
Context http server
Specifies the timeout time (for example, GET/HTTP/1.1) for waiting for the client to send a request header. Timeout is calculated only when the request header is not received in one read operation. If the client does not send anything within the timeout period, nginx returns the HTTP status code 408 ("Request timed out ")
Client_body_timeout
Syntax client_body_timeout time
The default value is 60 s.
Context http server location
This command sets the read timeout time for the request body. It is set to time-out only when the request body is not obtained in one readstep. After the timeout, nginx returns the HTTP status code 408 ("Request timed out ")
Keepalive_timeout
Syntax: keepalive_timeout timeout [header_timeout]
The default value is 75 s.
Context http server location
The first parameter specifies the timeout time for the keep-alive connection to the client. The server will close the connection after this time. The second optional 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 will not send the Keep-Alive Response Header (although it is not up to this header to determine whether the connection is "keep-alive ")
The values of the two parameters may be different.
- Note how different browsers handle the "keep-alive" Header
- MSIE and Opera ignore "Keep-Alive: timeout = <N>" header.
- MSIE keeps the connection for about 60-65 seconds and then sends the TCP RST
- Opera permanent persistent connection
- Mozilla keeps the connection alive for N plus about 1-10 seconds.
- Konqueror maintains a persistent connection for N seconds
Lingering_timeout
Syntax: lingering_timeout time
Default 5S
Context http server location
After lingering_close takes effect, before closing the connection, the system checks whether user data has been sent to the server. If no data is readable after the lingering_timeout time expires, the connection is closed. Otherwise, the connection is closed only after the data in the connection buffer is read and discarded.
Resolver_timeout
Syntax resolver_timeout time
Default Value: 30 s
Context http server location
This command sets the DNS resolution timeout.
Proxy_connect_timeout
Syntax: proxy_connect_timeout time
The default value is 60 s.
Context http server location
This command sets the connection timeout time with upstream server. Remember that the timeout value cannot exceed 75 seconds.
This is not the time to wait for the backend to return the page. It is declared by proxy_read_timeout. If your upstream server is up but hanging is down (for example, there are not enough threads to process requests, so put your requests in the request pool for processing later ), this statement is useless because the connection to the upstream server has been established.
Proxy_read_timeout
Syntax: proxy_read_timeout time
The default value is 60 s.
Context http server location
This command sets the read timeout time for the proxy server. It determines how long nginx will wait to obtain the request response. This time is not the time for obtaining the entire response, but the time for two reading operations.
Proxy_send_timeout
Syntax: proxy_send_timeout time
The default value is 60 s.
Context http server location
This specifies the timeout time for sending a request to the upstream server. The timeout setting is not for the entire sending period, but for the two write operations. If the upstream does not receive new data after the timeout, nginx closes the connection.
Proxy_upstream_fail_timeout (fail_timeout)
Syntax server address [fail_timeout = 30 s]
The default value is 10 s.
Context upstream
Description: The parameters of the server commands in the Upstream module. after a specified number of failures (max_fails) of an upstream backend is set, the backend cannot be operated. The default value is 10 seconds.