May 05, 2013 07:04AM
Francis Daly Wrote:
-------------------------------------------------------
> Hi there,
> > And the result with cgi.fix_pathinfo = 1 (the default)

> As an aside -- I find that "cgi.fix_pathinfo = 1" removes the "do what
> I say" part of php configuration, so I run without it. But I don't
> believe that that's relevant here.

cgi.fix_pathinfo=0 gives incorrect PHP_SELF.

> > 'PATH_INFO' => '',
> > 'TEST_PATH_INFO' => '',

> Thanks for testing that. It suggests to me that the problem is on the
> nginx side: $fastcgi_path_info is empty at the time the fastcgi_param
> directive takes effect.

> > So here's my request to you all:
> > 1. Is my config correct? I'm sure it is.

> It doesn't do what you want it to do, which is a strong hint in one
> direction ;-)

> But I don't see any reason why that should be the case.

> I do see two possible config changes you could make, each of which
> seems
> enough to get things working as you want.

> Either: remove the "try_files" line; or replace the "fastcgi_param
> PATH_INFO" line with two lines:

> fastcgi_param PATH_INFO $mypath;
> set $mypath $fastcgi_path_info;

> These seem to work because $fastcgi_path_info does have the correct
> value in the "rewrite" phase, but loses it after the "try files"
> phase. I don't understand why that is the case. That upsets me.

Thank you for confirm it.
Its nginx bug #321 http://trac.nginx.org/nginx/ticket/321

For the benefit of the man from the future (http://xkcd.com/979/),
here's my final configuration:
------------------------------------------------------------
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Save the $fastcgi_path_info before try_files clear it
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
try_files $fastcgi_script_name =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
------------------------------------------------------------

with /test.php:
------------------------------------------------------------
<pre><?php var_export($_SERVER) ?></pre>
------------------------------------------------------------

and php.ini cgi.fix_pathinfo = 1 (the default).

When given request http://lemp.test/test.php/foo/bar.php?v=1 would produce:
------------------------------------------------------------
array (
'USER' => 'www-data',
'HOME' => '/var/www',
'FCGI_ROLE' => 'RESPONDER',
'PATH_INFO' => '/foo/bar.php',
'QUERY_STRING' => 'v=1',
'REQUEST_METHOD' => 'GET',
'CONTENT_TYPE' => '',
'CONTENT_LENGTH' => '',
'SCRIPT_FILENAME' => '/var/www/test.php',
'SCRIPT_NAME' => '/test.php',
'REQUEST_URI' => '/test.php/foo/bar.php?v=1',
'DOCUMENT_URI' => '/test.php',
'DOCUMENT_ROOT' => '/var/www',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_SOFTWARE' => 'nginx/1.1.19',
'REMOTE_ADDR' => '192.168.56.1',
'REMOTE_PORT' => '46281',
'SERVER_ADDR' => '192.168.56.3',
'SERVER_PORT' => '80',
'SERVER_NAME' => 'localhost',
'HTTPS' => '',
'REDIRECT_STATUS' => '200',
'HTTP_HOST' => 'lemp.test',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
'HTTP_CONNECTION' => 'keep-alive',
'PHP_SELF' => '/test.php/foo/bar.php',
'REQUEST_TIME' => 1367750028,
)
------------------------------------------------------------

> > 3. Is there something wrong on the latest ubuntu precise?
> > Or is it just my imagination that I have it working before? :)

> Were you perhaps previously using an older nginx version where it
> worked as expected?

> Or is the "try_files" line a new addition since Friday?

Most probably, I forget to reload the server after I changed the config
(combining try_files with fastcgi_split_path_info),
try it in the browser thinking all is well.

Thank you all for helping this nginx newbie.

> f
> --
> Francis Daly francis@daoine.org

-- Zakaria
Subject Author Posted

Problem with fastcgi_split_path_info on ubuntu precise

zakaria May 03, 2013 09:44PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

GreenGecko May 03, 2013 09:56PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

zakaria May 03, 2013 11:23PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

Francis Daly May 04, 2013 07:58AM

Re: Problem with fastcgi_split_path_info on ubuntu precise

zakaria May 04, 2013 07:41PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

B.R. May 04, 2013 08:16PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

zakaria May 04, 2013 09:02PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

Francis Daly May 05, 2013 04:00AM

Re: Problem with fastcgi_split_path_info on ubuntu precise

zakaria May 05, 2013 07:04AM

Re: Problem with fastcgi_split_path_info on ubuntu precise

Francis Daly May 07, 2013 04:38PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

vilsack May 13, 2013 02:49PM

Re: Problem with fastcgi_split_path_info on ubuntu precise

Francis Daly May 14, 2013 05:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 249
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready