]> git.kaiwu.me - nginx.git/commitdiff
Added clearing of r->valid_unparsed_uri on internal redirects.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 19 Dec 2011 14:11:48 +0000 (14:11 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 19 Dec 2011 14:11:48 +0000 (14:11 +0000)
This resolves issue with try_files (see ticket #70), configuration like

   location / { try_files $uri /index.php; }
   location /index.php { proxy_pass http://backend; }

caused nginx to use original request uri in a request to a backend.

Historically, not clearing of the r->valid_unparsed_uri on internal redirect
was a feature: it allowed to pass the same request to (another) upstream
server via error_page redirection.  Since then named locations appeared
though, and it's time to start resetting r->valid_unparsed_uri on internal
redirects.  Configurations still using this feature should be converted
to use named locations instead.

Patch by Lanshun Zhou.

src/http/ngx_http_core_module.c
src/http/ngx_http_upstream.c

index 3c571174817f6e9551a107bed1a193fe344aff30..1d5ee5dc6b9129df83f623c4498f7196ab20b935 100644 (file)
@@ -2506,6 +2506,7 @@ ngx_http_internal_redirect(ngx_http_request_t *r,
 #endif
 
     r->internal = 1;
+    r->valid_unparsed_uri = 0;
     r->add_uri_to_alias = 0;
     r->main->count++;
 
index 9f0ff3a546edf010e3d059a2de9ac50d59b2f8a4..68837d8b9a135680cfd2cdfa27d986ab9f8b217e 100644 (file)
@@ -1895,8 +1895,6 @@ ngx_http_upstream_process_headers(ngx_http_request_t *r, ngx_http_upstream_t *u)
             r->method = NGX_HTTP_GET;
         }
 
-        r->valid_unparsed_uri = 0;
-
         ngx_http_internal_redirect(r, uri, &args);
         ngx_http_finalize_request(r, NGX_DONE);
         return NGX_DONE;