Opened 12 years ago
Closed 12 years ago
#176 closed defect (duplicate)
Error handling fallback with variables when using try_files in a location with an alias
Reported by: | Jonathan Kolb | Owned by: | somebody |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | 1.3.x |
Keywords: | Cc: | ||
uname -a: | |||
nginx -V: |
nginx version: nginx/1.3.1
built by gcc 4.6.3 (Debian 4.6.3-1) TLS SNI support enabled configure arguments: --prefix=/opt/nginx --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=www-data --group=www-data --with-cc-opt=-O2 --with-ipv6 --with-debug --without-http_browser_module --without-http_charset_module --without-http_memcached_module --without-http_upstream_ip_hash_module --with-http_gzip_static_module --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module --with-http_stub_status_module --add-module=../simpl-ngx_devel_kit-24202b4 --add-module=../mdounin-ngx_http_auth_request_module-0.2 --add-module=../calio-beanstalkd-nginx-module-77306c9 --add-module=../FRiCKLE-ngx_cache_purge-1.5 --add-module=../agentzh-headers-more-nginx-module-v0.16 --add-module=../chaoslawful-lua-nginx-module-v0.5.0rc26 --add-module=../FRiCKLE-ngx_postgres-0.9rc2 --add-module=../simpl-ngx_http_set_hash-0.2.1 --add-module=../agentzh-set-misc-nginx-module-v0.22rc7 --add-module=../vkholodkov-nginx-udplog-module-1.0.0c --add-module=../anomalizer-ngx_upstream_status-01b36bb --add-module=../../kolbyjack-ngx_extravars-dev |
Description
When the fallback for a try_files in a static location with an alias set contains variables and expands to a value that starts with the location text, the resulting redirect leaves off the location text. This is not what I would expect. Here's an example:
# test: alias + try_files fallback
# expected result: internal redirect to /test/index.php
# result: internal redirect to /index.php
location /test {
alias /doesnt/exist;
try_files $uri $uri/ /test/index.php?$args;
}
and here's the debug log output generated from an error_log defined in that location:
2012/06/14 14:17:52 [debug] 17647#0: *15 http cl:-1 max:1048576
2012/06/14 14:17:52 [debug] 17647#0: *15 rewrite phase: 3
2012/06/14 14:17:52 [debug] 17647#0: *15 post rewrite phase: 4
2012/06/14 14:17:52 [debug] 17647#0: *15 generic phase: 5
2012/06/14 14:17:52 [debug] 17647#0: *15 generic phase: 6
2012/06/14 14:17:52 [debug] 17647#0: *15 generic phase: 7
2012/06/14 14:17:52 [debug] 17647#0: *15 access phase: 8
2012/06/14 14:17:52 [debug] 17647#0: *15 access phase: 9
2012/06/14 14:17:52 [debug] 17647#0: *15 access phase: 10
2012/06/14 14:17:52 [debug] 17647#0: *15 post access phase: 11
2012/06/14 14:17:52 [debug] 17647#0: *15 try files phase: 12
2012/06/14 14:17:52 [debug] 17647#0: *15 http script var: "/test/asdf"
2012/06/14 14:17:52 [debug] 17647#0: *15 trying to use file: "/asdf" "/doesnt/exist/asdf"
2012/06/14 14:17:52 [debug] 17647#0: *15 http script var: "/test/asdf"
2012/06/14 14:17:52 [debug] 17647#0: *15 trying to use dir: "/asdf" "/doesnt/exist/asdf"
2012/06/14 14:17:52 [debug] 17647#0: *15 http script copy: "/test/index.php?"
2012/06/14 14:17:52 [debug] 17647#0: *15 trying to use file: "/index.php?" "/doesnt/exist/index.php?"
2012/06/14 14:17:52 [debug] 17647#0: *15 internal redirect: "/index.php?"
If the fallback doesn't contain variables, then the try_files behaves as expected:
# test: alias + try_files fallback
# expected result: internal redirect to /test/index.php
# result: internal redirect to /test/index.php
location /test {
alias /doesnt/exist;
error_log /tmp/error.log debug;
try_files $uri $uri/ /test/index.php;
}
and debug log output:
2012/06/14 14:25:03 [debug] 17678#0: *17 http cl:-1 max:1048576
2012/06/14 14:25:03 [debug] 17678#0: *17 rewrite phase: 3
2012/06/14 14:25:03 [debug] 17678#0: *17 post rewrite phase: 4
2012/06/14 14:25:03 [debug] 17678#0: *17 generic phase: 5
2012/06/14 14:25:03 [debug] 17678#0: *17 generic phase: 6
2012/06/14 14:25:03 [debug] 17678#0: *17 generic phase: 7
2012/06/14 14:25:03 [debug] 17678#0: *17 access phase: 8
2012/06/14 14:25:03 [debug] 17678#0: *17 access phase: 9
2012/06/14 14:25:03 [debug] 17678#0: *17 access phase: 10
2012/06/14 14:25:03 [debug] 17678#0: *17 post access phase: 11
2012/06/14 14:25:03 [debug] 17678#0: *17 try files phase: 12
2012/06/14 14:25:03 [debug] 17678#0: *17 http script var: "/test/asdf"
2012/06/14 14:25:03 [debug] 17678#0: *17 trying to use file: "/asdf" "/doesnt/exist/asdf"
2012/06/14 14:25:03 [debug] 17678#0: *17 http script var: "/test/asdf"
2012/06/14 14:25:03 [debug] 17678#0: *17 trying to use dir: "/asdf" "/doesnt/exist/asdf"
2012/06/14 14:25:03 [debug] 17678#0: *17 trying to use file: "/test/index.php" "/doesnt/exist/test/index.php"
2012/06/14 14:25:03 [debug] 17678#0: *17 internal redirect: "/test/index.php?"
I can try reproducing without any third party modules if you need me to, but I don't think it'll make a difference.
Change History (2)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Yep, thank you for report. This is another case of try_files and alias problems as collected in ticket #97. Case added to the list there, closing this as duplicate to keep all the problems in a single ticket.
Reported by Layke in #nginx on freenode