Nginx 超时配置

client_header_timeout

客户端向服务端发送一个完整的 request header 的超时时间。如果客户端在指定时间内没有发送一个完整的 request header,Nginx 返回 HTTP 408(Request Timed Out)。

Defines a timeout for reading client request header. If a client does not transmit the entire header within this time,
the 408 (Request Time-out) error is returned to the client.


client_body_timeout

指定客户端与服务端建立连接后发送 request body 的超时时间。如果客户端在指定时间内没有发送任何内容,Nginx 返回 HTTP 408(Request Timed Out)。

Defines a timeout for reading client request body. The timeout is set only for a period between two successive read operations, not for the transmission of the whole request body.
If a client does not transmit anything within this time,
the 408 (Request Time-out) error is returned to the client.


send_timeout

服务端向客户端传输数据的超时时间,是连续两次发送数据的间隔时间,非整个请求传输时间。

Sets a timeout for transmitting a response to the client. The timeout is set only between two successive write operations,
not for the transmission of the whole response. If the client does not receive anything within this time, the connection is closed.


proxy_connect_timeout

Nginx 与 upstream server 的连接超时时间。

Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.


proxy_read_timeout

Nginx 接收 upstream server 数据超时, 默认60s, 如果连续的60s内没有收到1个字节, 连接关闭。

Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.


proxy_send_timeout

Nginx 发送数据至 upstream server 超时,默认60s, 如果连续的60s内没有发送1个字节, 连接关闭。

Sets a timeout for transmitting a request to the proxied server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the proxied server does not receive anything within this time, the connection is closed.


keepalive_timeout

Nginx 和客户端之间的长连接保持时间,指定每个 TCP 连接最多可以保持多长时间。Nginx 的默认值是75秒,若将它设置为0,就禁止了 keepalive 连接。

The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections.
The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field. Two parameters may differ.