Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#321 closed defect (wontfix)

try_files & $fastcgi_path_info

Reported by: Данил Фартушный Owned by:
Priority: major Milestone:
Component: nginx-core Version: 1.2.x
Keywords: try_files, fastcgi, path info Cc:
uname -a: Linux nq 2.6.32-5-amd64 #1 SMP Sun May 6 04:00:17 UTC 2012 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.2.7
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6


I've been trying to configure Nginx + PHP-FPM with PATH_INFO support.
For this I've made following config:

  location ~ \.php {
    fastcgi_split_path_info ^(.+\.php)($|/.*);
    try_files $fastcgi_script_name =404;

    fastcgi_pass   unix:/var/run/php5-fpm.sock;
    fastcgi_index  index.php;  
    include fastcgi_params;    
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_ignore_client_abort     off;

It worked out, but $fastcgi_path_info was alway empty no matter what.
I've even tried to use debug version of Nginx and found out that variable
was sent in ngx_http_fastcgi_split function.

As it finds out try_files resets its value... Its not mentioned in documentation,
so I consider it a bug.

Change History (5)

comment:1 by Zakaria, 11 years ago

I've bitten by this bug. Here's work around from Francis Daly:

set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

More details here:,238825,238825

comment:2 by Maxim Dounin, 11 years ago

Resolution: wontfix
Status: newclosed

The try_files directive changes URI of a request to the one matched on the file system, and subsequent attempt to split the URI into $fastcgi_script_name and $fastcgi_path_info results in empty path info - as there is no path info in the URI after try_files.

I don't think this should be considered as a bug, rather than a feature of how try_files work. It makes try_files not very convenient for use with fastcgi_split_path_info, but there are more than one way to workaround it, including the one provided above.

comment:3 by Nilesh Govindrajan, 11 years ago

Feature or bug, I don't know and I don't care. My application doesn't work and I had to use the fix mentioned in comment 1.

I nearly had headaches and was almost going to put off the idea of serving dynamic from nginx.

The application in question is Magento and I tried with and without fastcgi_split_path_info both, and for every goddamn request, PATH_INFO was blank crippling various parts of the application.

As such, I love nginx for the performance. But this is serious!

comment:4 by Arnold Ewin, 10 years ago

Thanks Zakaria ): I created an account here just to say thank you for the fix!

comment:5 by riaqn@…, 9 years ago

Thanks. have spent a whole afternoon to address this issue, so I created an account just to say thank you!

Note: See TracTickets for help on using tickets.