Opened 14 years ago
Closed 14 years ago
#70 closed defect (fixed)
url not properly handled in ngx_http_internal_redirect
| Reported by: | lanshun zhou | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | nginx-core | Version: | 1.1.x |
| Keywords: | url proxy | Cc: | op-dev@… |
| uname -a: | Linux xxxx 2.6.18-164.6.1.el5xen #1 SMP Tue Oct 27 11:45:55 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux | ||
| nginx -V: |
nginx version: nginx/1.1.11
TLS SNI support disabled configure arguments: --with-pcre=/search/zls/nginx/pcre-8.12 --with-http_stub_status_module --with-http_ssl_module --with-http_ssl_module --with-debug --prefix=/usr/local/nginx --with-http_realip_module --add-module=/search/zls/nginx/nginx_upstream_hash-0.3.1 |
||
Description
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.
Reproduce config:
/test.html is sent to backend, which should be /back/test2.php
upstream not_exists {
server 127.0.0.1:1235;
}
server {
listen 9998;
location /test.html {
try_files /cache/test.html /back/test2.php;
}
location /back {
proxy_pass http://not_exists;
}
Attachments (1)
Change History (4)
by , 14 years ago
| Attachment: | valid_unparsed_uri.patch added |
|---|
follow-up: 2 comment:1 by , 14 years ago
| Status: | new → accepted |
|---|
Historically, such behaviour of the ngx_http_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 probably time to start resetting r->valid_unparsed_uri on internal redirects. (The try_files behaviour outlined above is certainly a bug.)
Could you please resubmit the patch via nginx-devel@ mailing list, and update it to remove (no longer needed) resetting of r->valid_unparsed_uri in ngx_http_upstream.c?
comment:2 by , 14 years ago
Yeah, resetting of r->valid_unparsed_uri is removed in the patch attached here, and I'll resubmit it to the mailing list. Thanks~
Replying to mdounin:
Historically, such behaviour of the ngx_http_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 probably time to start resetting r->valid_unparsed_uri on internal redirects. (The try_files behaviour outlined above is certainly a bug.)
Could you please resubmit the patch via nginx-devel@ mailing list, and update it to remove (no longer needed) resetting of r->valid_unparsed_uri in ngx_http_upstream.c?

simple patch