# HG changeset patch # User Maxim Dounin <mdou...@mdounin.ru> # Date 1746114911 -10800 # Thu May 01 18:55:11 2025 +0300 # Node ID 4053f6d9b5c0caca67365a320488154b84ebfba8 # Parent 01f2cc76e1a892ff2a9c848db91a0de1b3eb23a2 Stream: fixed timeout usage for proxy_protocol with SSL proxying.
Connection establishment with proxied server includes SSL handshake, and relevant timeout is set with the proxy_connect_timeout directive. Since proxy_protocol sending happens before SSL handshake, it should use proxy_connect_timeout as well. Further, the timeout should not be rearmed if it's already set. Additionally, read handler should be set as long as we are waiting for events, since it can be triggered. diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c --- a/src/stream/ngx_stream_proxy_module.c +++ b/src/stream/ngx_stream_proxy_module.c @@ -977,8 +977,11 @@ ngx_stream_proxy_send_proxy_protocol(ngx pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module); - ngx_add_timer(pc->write, pscf->timeout); - + if (!pc->write->timer_set) { + ngx_add_timer(pc->write, pscf->connect_timeout); + } + + pc->read->handler = ngx_stream_proxy_connect_handler; pc->write->handler = ngx_stream_proxy_connect_handler; return NGX_AGAIN;