]> git.kaiwu.me - nginx.git/commitdiff
Upstream: handling of proxy_set_header at http level.
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 14 Oct 2016 16:48:26 +0000 (19:48 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 14 Oct 2016 16:48:26 +0000 (19:48 +0300)
When headers are set at the "http" level and not redefined in
a server block, we now preserve conf->headers into the "http"
section configuration to inherit it to all servers.

The same applies to conf->headers_cache, though it may not be effective
if no servers use cache at the "server" level as conf->headers_cache
is only initialized if cache is enabled on a given level.

Similar changes made in fastcgi/scgi/uwsgi to preserve conf->params
and conf->params_cache.

src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_uwsgi_module.c

index 62502b04f5a4d22e4d28d8863c2f6303d067d757..f6a8c6086868060dc244b529dd344f53ce990692 100644 (file)
@@ -3127,6 +3127,20 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
 
 #endif
 
+    /*
+     * special handling to preserve conf->params in the "http" section
+     * to inherit it to all servers
+     */
+
+    if (prev->params.hash.buckets == NULL
+        && conf->params_source == prev->params_source)
+    {
+        prev->params = conf->params;
+#if (NGX_HTTP_CACHE)
+        prev->params_cache = conf->params_cache;
+#endif
+    }
+
     return NGX_CONF_OK;
 }
 
index f7f91d66297db3286a075d7f57589eaf9b8242fb..480e9749a2ad6ebda442030effaf6e0d93df854e 100644 (file)
@@ -3357,6 +3357,20 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
 
 #endif
 
+    /*
+     * special handling to preserve conf->headers in the "http" section
+     * to inherit it to all servers
+     */
+
+    if (prev->headers.hash.buckets == NULL
+        && conf->headers_source == prev->headers_source)
+    {
+        prev->headers = conf->headers;
+#if (NGX_HTTP_CACHE)
+        prev->headers_cache = conf->headers_cache;
+#endif
+    }
+
     return NGX_CONF_OK;
 }
 
index 36656ec18e520de32a114f302e8d2e6a09724845..11714346810cb973dd4240f24facfac0129cdf4c 100644 (file)
@@ -1558,6 +1558,20 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
 
 #endif
 
+    /*
+     * special handling to preserve conf->params in the "http" section
+     * to inherit it to all servers
+     */
+
+    if (prev->params.hash.buckets == NULL
+        && conf->params_source == prev->params_source)
+    {
+        prev->params = conf->params;
+#if (NGX_HTTP_CACHE)
+        prev->params_cache = conf->params_cache;
+#endif
+    }
+
     return NGX_CONF_OK;
 }
 
index 7f916e84035ff4a7a5c523d68a3a20bdf6ccc5cb..b6ae0d80959f4076776c2f2eb269b29af8ce43e3 100644 (file)
@@ -1820,6 +1820,20 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
 
 #endif
 
+    /*
+     * special handling to preserve conf->params in the "http" section
+     * to inherit it to all servers
+     */
+
+    if (prev->params.hash.buckets == NULL
+        && conf->params_source == prev->params_source)
+    {
+        prev->params = conf->params;
+#if (NGX_HTTP_CACHE)
+        prev->params_cache = conf->params_cache;
+#endif
+    }
+
     return NGX_CONF_OK;
 }