proxy_send_timeout

Sets the timeout for transmitting a request to the proxied server in NGINX. — NGINX HTTP Core

proxy_send_timeout
httpserverlocation
Синтаксисproxy_send_timeout time;
По умолчанию60s
Контекстhttp, server, location
МодульNGINX HTTP Core
Аргументы1

Описание

The `proxy_send_timeout` directive specifies the time period during which NGINX will attempt to send the request to a proxied server. This timeout is critical in controlling how long NGINX will wait for the server to accept the request before timing out. If the timeout is exceeded, NGINX will close the connection and log an error. The value can be specified in a variety of formats, such as seconds or with time suffixes (e.g., '30s' for 30 seconds). This directive must be set in one of three contexts: `http`, `server`, or `location`. It provides granular control over the timeout settings specific to proxied requests based on the application’s requirements. Adjusting this timeout might be necessary for applications that have variable response times or when dealing with high latency networks. If a request takes too long to send to the proxied server and the `proxy_send_timeout` threshold is reached, NGINX will log an error and return a 502 Bad Gateway response to the client. The `proxy_send_timeout` value should match the expected behavior of the proxied application. It should be set considering the application’s performance characteristics and anticipated load. If set too low, it may cause legitimate requests to fail, while a very high value may lead to resource contentions and affect the server's responsiveness.

Пример конфига

location /api {
    proxy_pass http://backend;
    proxy_send_timeout 30s;
}

Setting the timeout too low could lead to premature connection closures and increased error rates.

Not configuring this directive could result in default timeouts that may not align with the application's needs.