]> git.kaiwu.me - nginx.git/commitdiff
Upstream: consistently initialize explicit upstreams.
authorRuslan Ermilov <ru@nginx.com>
Mon, 17 Oct 2016 11:14:02 +0000 (14:14 +0300)
committerRuslan Ermilov <ru@nginx.com>
Mon, 17 Oct 2016 11:14:02 +0000 (14:14 +0300)
When an upstream{} block follows a proxy_pass reference to it,
such an upstream inherited port and default_port settings from
proxy_pass.  This was different from when they came in another
order (see ticket #1059).  Explicit upstreams should not have
port and default_port in any case.

This fixes the following case:

server { location / { proxy_pass http://u; } ... }
upstream u { server 127.0.0.1; }
server { location / { proxy_pass https://u; } ... }

but not the following:

server { location / { proxy_pass http://u; } ... }
server { location / { proxy_pass https://u; } ... }
upstream u { server 127.0.0.1; }

src/http/ngx_http_upstream.c

index 55bd47d02bb1735117d0503b80a3b1ba8196173a..828b7d726cb3dcb3c6b0ed7bcf1ddf7b94ba5418 100644 (file)
@@ -5768,6 +5768,8 @@ ngx_http_upstream_add(ngx_conf_t *cf, ngx_url_t *u, ngx_uint_t flags)
 
         if (flags & NGX_HTTP_UPSTREAM_CREATE) {
             uscfp[i]->flags = flags;
+            uscfp[i]->port = 0;
+            uscfp[i]->default_port = 0;
         }
 
         return uscfp[i];