]> git.kaiwu.me - nginx.git/commitdiff
Proxy: fixed incorrect URI change due to if (ticket #86).
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 9 Dec 2014 15:22:39 +0000 (18:22 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 9 Dec 2014 15:22:39 +0000 (18:22 +0300)
In the following configuration request was sent to a backend without
URI changed to '/' due to if:

    location /proxy-pass-uri {
        proxy_pass http://127.0.0.1:8080/;

        set $true 1;

        if ($true) {
            # nothing
        }
    }

Fix is to inherit conf->location from the location where proxy_pass was
configured, much like it's done with conf->vars.

src/http/modules/ngx_http_proxy_module.c

index 5b5ad07b9bd4be7a8e1644dd55517463c8c59528..f04436de4edb42445b8e41b19dd8267cbe27a409 100644 (file)
@@ -2997,6 +2997,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
         && conf->upstream.upstream == NULL && conf->proxy_lengths == NULL)
     {
         conf->upstream.upstream = prev->upstream.upstream;
+        conf->location = prev->location;
         conf->vars = prev->vars;
 
         conf->proxy_lengths = prev->proxy_lengths;
@@ -3011,7 +3012,6 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
         && (conf->upstream.upstream || conf->proxy_lengths))
     {
         clcf->handler = ngx_http_proxy_handler;
-        conf->location = prev->location;
     }
 
     if (conf->body_source.data == NULL) {