details:   http://freenginx.org/hg/nginx/rev/196e9f3db2b0
branches:  
changeset: 9355:196e9f3db2b0
user:      Maxim Dounin <mdou...@mdounin.ru>
date:      Wed May 14 01:15:24 2025 +0300
description:
Stream: fixed timeout usage for proxy_protocol with SSL proxying.

Connection establishment with a proxied server includes SSL handshake,
and the 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.

diffstat:

 src/stream/ngx_stream_proxy_module.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (17 lines):

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;

Reply via email to