[BUG] url not properly handled for try_files and error_page redirect in ngx_http_internal_redirect

lanshun zhou zls.sogou at gmail.com
Fri Dec 16 16:34:15 UTC 2011


url is changed in ngx_http_internal_redirect, but some flags like
r->valid_unparsed_uri
are not always reset. Then in ngx_http_proxy_create_request the
original uri is sent to
backends instead of the new one.

This affects the redirects in ngx_http_core_try_files_phase and
ngx_http_send_error_page.

simple fix:

diff -ruN nginx-1.1.11/src/http/ngx_http_core_module.c
nginx-1.1.11_zls/src/http/ngx_http_core_module.c
--- nginx-1.1.11/src/http/ngx_http_core_module.c        2011-12-06
21:23:37.000000000 +0800
+++ nginx-1.1.11_zls/src/http/ngx_http_core_module.c    2011-12-16
16:31:27.751927635 +0800
@@ -2481,6 +2481,8 @@

     r->uri = *uri;

+    r->valid_unparsed_uri = 0;
+
     if (args) {
         r->args = *args;

diff -ruN nginx-1.1.11/src/http/ngx_http_upstream.c
nginx-1.1.11_zls/src/http/ngx_http_upstream.c
--- nginx-1.1.11/src/http/ngx_http_upstream.c   2011-12-09
21:19:57.000000000 +0800
+++ nginx-1.1.11_zls/src/http/ngx_http_upstream.c       2011-12-16
16:30:25.399218885 +0800
@@ -1895,8 +1895,6 @@
             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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: valid_unparsed_uri.patch
Type: application/octet-stream
Size: 907 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20111217/6a55b384/attachment.obj>


More information about the nginx-devel mailing list