Opened 13 years ago
Closed 13 years ago
#183 closed defect (invalid)
Incorrect $document_root for root/alias inside location block which is different from server root
| Reported by: | Hari G | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | nginx-core | Version: | 1.3.x |
| Keywords: | php fcgi document_root alias root | Cc: | |
| uname -a: | none | ||
| nginx -V: |
$ nginx.exe -V
nginx version: nginx/1.3.1 TLS SNI support enabled configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=lo gs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-te mp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-s cgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msv c8/lib/pcre-8.30 --with-zlib=objs.msvc8/lib/zlib-1.2.5 --with-select_module --with-http_realip_module --with-http_additi on_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-htt p_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-mail - -with-openssl=objs.msvc8/lib/openssl-1.0.1c --with-openssl-opt=enable-tlsext --with-http_ssl_module --with-mail_ssl_modu le --with-ipv6 |
||
Description
$document_root points to wrong location when one location directive (which handles .php files) is applied to another location which has a specific root/alias set. See the following config. The outcome is strange because regular files are served correctly from the aliased/new root path for this particular location but what is passed on to PHP appears wrong.
The documentation says:
"""
$document_root
root or alias directive's value for the current request
"""
events {
worker_connections 1024;
}
http
{
server {
listen 80;
server_name localhost;
root /www/;
index none;
autoindex on;
location ~* \.php$
{
location ~ \..*/.*\.php$ {return 404;}
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /rg/
{
root /tm/dh/;
# if the following is specified FCGI gets the .php files inside this block
# else it looks at the root mentioned in server block
# location ~* \.php$
# {
# fastcgi_pass 127.0.0.1:9000;
# include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# }
}
}
}
Note:
See TracTickets
for help on using tickets.

Unless you uncomment "location ~* \.php$" inside "location /rg/", with your config all php files are processed in "location ~* \.php$" specified at server level, with root set to "/www/" (and $document_root will resolve to "/www/" as well). This is correct and expected behaviour, see http://nginx.org/r/location.