changeset 6787:640e1e778de6

Upstream: consistently initialize explicit upstreams. 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; }
author Ruslan Ermilov <ru@nginx.com>
date Mon, 17 Oct 2016 14:14:02 +0300
parents 906ac20234ed
children 3fa5983b6b44
files src/http/ngx_http_upstream.c
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -5768,6 +5768,8 @@ ngx_http_upstream_add(ngx_conf_t *cf, ng
 
         if (flags & NGX_HTTP_UPSTREAM_CREATE) {
             uscfp[i]->flags = flags;
+            uscfp[i]->port = 0;
+            uscfp[i]->default_port = 0;
         }
 
         return uscfp[i];