proxy_connect_timeout

The `proxy_connect_timeout` directive configures the maximum time to wait for a connection to a proxied server to be established.

Syntaxproxy_connect_timeout time;
Default60s
Context
Arguments1

Description

In the context of the NGINX SRT module, the proxy_connect_timeout directive plays a critical role in managing timeouts for connection attempts to upstream servers. This directive specifies the period during which NGINX will wait for a connection to be successfully established to a proxied server before timing out. When this duration is exceeded, an error is returned, preventing the NGINX server from hanging indefinitely while trying to connect to a potentially unreachable server.

This directive takes one argument, specifying the timeout duration. The format can be in seconds (e.g., 30s) or can be expressed using time units like m for minutes, h for hours, etc. If not specified, it defaults to a predefined value within the server's configuration. It's crucial to configure this timeout based on the network environment to optimize application reliability and performance.

For scenarios with dynamic upstream servers or network connections that may experience varying latency, adjusting the proxy_connect_timeout can significantly improve user experience by minimizing wait times and permitting rapid failovers to alternate proxies if the primary server is unavailable.

Config Example

server {
    listen 4321;
    proxy_connect_timeout 30s;
    proxy_pass tcp://127.0.0.1:5678;
}

Setting the timeout too low may result in premature connection failures, especially in high-latency networks.

If using HTTP/1.1 or keep-alive connections, ensure that this timeout is balanced with other timeout settings to prevent unexpected terminations.

← Back to all directives