proxy_read_timeout
The `proxy_read_timeout` directive specifies the time to wait for a response from the proxied server. — NGINX HTTP Core
Описание
The `proxy_read_timeout` directive defines the timeout period for reading data from the proxied server (i.e., the server that NGINX is forwarding requests to). If the proxied server does not send any data within this time frame, then NGINX will terminate the connection and return an error to the client. This timeout is essential when dealing with slow backends where prolonged delays can occur during the read phase. The directive accepts a single parameter which indicates the timeout value. This value can be specified in seconds or using a time suffix (e.g., `m` for minutes, `h` for hours). The timeout settings are crucial for optimizing application performance and should be set based on the expected response times of the backend services. If a connection is idle for longer than the specified duration, it is closed by the NGINX server to prevent resources from being tied up. This directive can be configured in various contexts including `http`, `server`, and `location`. The scope of where the directive is applied can influence how timeouts work in relation to other proxy directives, such as `proxy_connect_timeout` and `proxy_send_timeout`. Making optimal configurations will ensure better resource management and user experience in handling requests through NGINX.
Пример конфига
location /api {
proxy_pass http://backend;
proxy_read_timeout 30s;
}Setting a timeout too low may lead to premature termination of valid connections, negatively impacting user experience.
This directive only affects the reading of a response, and not the time it takes to establish a connection or send requests.
Be sure to coordinate this directive with other timeout directives for coherent timeout handling across NGINX configurations.