From 364a94ecec13037126f28f91cf8f290979ffc229 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 23 Oct 2025 18:21:57 +0400 Subject: [PATCH] Upstream: reset local address in case of error. After f10bc5a763bb the address was set to NULL only when local address was not specified at all. In case complex value evaluated to an empty or invalid string, local address remained unchanged. Currenrly this is not a problem since the value is only set once. This change is a preparation for being able to change the local address after initial setting. --- src/http/ngx_http_upstream.c | 2 ++ src/stream/ngx_stream_proxy_module.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 07e51a966..66163548a 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -6898,6 +6898,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u, } if (val.len == 0) { + u->peer.local = NULL; return NGX_OK; } @@ -6914,6 +6915,7 @@ ngx_http_upstream_set_local(ngx_http_request_t *r, ngx_http_upstream_t *u, if (rc != NGX_OK) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "invalid local address \"%V\"", &val); + u->peer.local = NULL; return NGX_OK; } diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c index 6e51585f6..300bdf681 100644 --- a/src/stream/ngx_stream_proxy_module.c +++ b/src/stream/ngx_stream_proxy_module.c @@ -680,6 +680,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u, } if (val.len == 0) { + u->peer.local = NULL; return NGX_OK; } @@ -696,6 +697,7 @@ ngx_stream_proxy_set_local(ngx_stream_session_t *s, ngx_stream_upstream_t *u, if (rc != NGX_OK) { ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, "invalid local address \"%V\"", &val); + u->peer.local = NULL; return NGX_OK; }