https://issues.apache.org/bugzilla/show_bug.cgi?id=51517
--- Comment #3 from Jérôme Loyet <[email protected]> --- Hi I've made some more testing using apache 2.4.4. To ensure the results were not altered by FPM I've made a very simple perl script which act as a fastcgi server using either TCP or unix socket. It returns all the environment variables apache has sent. Here is the script: #!/usr/bin/perl use FCGI; use Socket; use FCGI::ProcManager; use Data::Dumper; $num_args = $#ARGV + 1; if ($num_args != 1) { print "\nUsage: fcgi.pl <socket>\n"; exit 1; } $proc_manager = FCGI::ProcManager->new( {n_processes => 1} ); $socket = FCGI::OpenSocket( $ARGV[0], 10 ) $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%req_params, $socket, &FCGI::FAIL_ACCEPT_ON_INTR ); $proc_manager->pm_manage(); if ($request) { while ( $request->Accept() >= 0 ) { $proc_manager->pm_pre_dispatch(); print("Content-type: text/plain\r\n\r\n"); print Dumper(\%req_params); } } FCGI::CloseSocket($socket); Here are the results I got with different configurations *** request /test.php?N=1 *** using ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 *** without proxy-fcgi-pathinfo 'SCRIPT_NAME' => '/test.php', 'PATH_INFO' => UNSET, 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => '/test.php', 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => UNSET, 'SCRIPT_URI' => UNSET, 'REQUEST_URI' => '/test.php?N=1', *** request /test.php/more?N=1 *** using ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 *** without proxy-fcgi-pathinfo 'SCRIPT_NAME' => '/test.php/more', 'PATH_INFO' => UNSET, 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php/more', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => '/test.php/more', 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => UNSET, 'SCRIPT_URI' => UNSET, 'REQUEST_URI' => '/test.php/more?N=1', *** request /test.php?N=1 *** using ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 *** with proxy-fcgi-pathinfo 'SCRIPT_NAME' => '', 'PATH_INFO' => '/test.php', 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => UNSET, 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => 'proxy:fcgi://127.0.0.1:9000/test.php/test.php', 'SCRIPT_URI' => UNSET, 'REQUEST_URI' => '/test.php?N=1', *** request /test.php/more?N=1 *** using ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 *** with proxy-fcgi-pathinfo 'SCRIPT_NAME' => '', 'PATH_INFO' => '/test.php/more', 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php/more', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => UNSET, 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => 'proxy:fcgi://127.0.0.1:9000/test.php/more/test.php/more', 'SCRIPT_URI' => UNSET, 'REQUEST_URI' => '/test.php/more?N=1', *** request /test.php?N=1 *** using RewriteRule ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 [P] *** without proxy-fcgi-pathinfo 'SCRIPT_NAME' => '/test.php', 'PATH_INFO' => UNSET, 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => '/test.php', 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => UNSET, 'SCRIPT_URI' => 'http://my.test.com/test.php', 'REQUEST_URI' => '/test.php?N=1', *** request /test.php/more?N=1 *** using RewriteRule ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 [P] *** without proxy-fcgi-pathinfo 'SCRIPT_NAME' => '/test.php/more', 'PATH_INFO' => UNSET, 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php/more', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => '/test.php/more', 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => UNSET, 'SCRIPT_URI' => 'http://my.test.com/test.php/more', 'REQUEST_URI' => '/test.php?N=1', *** request /test.php?N=1 *** using RewriteRule ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 [P] *** with proxy-fcgi-pathinfo 'SCRIPT_NAME' => '', 'PATH_INFO' => '/test.php', 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => '/test.php', 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => 'proxy:fcgi://127.0.0.1:9000/test.php/test.php', 'SCRIPT_URI' => 'http://my.test.com/test.php', 'REQUEST_URI' => '/test.php?N=1', *** request /test.php/more?N=1 *** using RewriteRule ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1 [P] *** with proxy-fcgi-pathinfo 'SCRIPT_NAME' => '', 'PATH_INFO' => '/test.php/more', 'SCRIPT_FILENAME' => 'proxy:fcgi://127.0.0.1:9000/test.php/more', 'QUERY_STRING' => 'N=1', 'SCRIPT_URL' => '/test.php', 'DOCUMENT_ROOT' => '/usr/local/apache-2.4/htdocs', 'PATH_TRANSLATED' => 'proxy:fcgi://127.0.0.1:9000/test.php/more/test.php/more', 'SCRIPT_URI' => 'http://my.test.com/test.php/more', 'REQUEST_URI' => '/test.php/more?N=1', Remarks: For a reminder, the RFC 3875 is available at http://www.ietf.org/rfc/rfc3875. *** PATH_INFO *** The PATH_INFO variable specifies a path to be interpreted by the CGI script. It identifies the resource or sub-resource to be returned by the CGI script, and is derived from the portion of the URI path hierarchy following the part that identifies the script itself. As I understand it, PATH_INFO should be empty or not set for URL like /test.php and should be set to /more for URL like /test.php/more. That's not what happened with mod_proxy_fcgi. Sometimes it's not set where it should be (without proxy-fcgi-pathinfo) and when proxy-fcgi-pathinfo is set, PATH_INFO is always set to /test.php or /test.php/more. If we assume that this is a normal behaviour without proxy-fcgi-pathinfo this is a bug when proxy-fcgi-pathinfo is set. *** PATH_TRANSLATED *** The PATH_TRANSLATED variable is derived by taking the PATH_INFO value, parsing it as a local URI in its own right, and performing any virtual-to-physical translation appropriate to map it onto the server's document repository structure. This is the file location that would be accessed by a request for <scheme> "://" <server-name> ":" <server-port> <extra-path> where <scheme> is the scheme for the original client request and <extra-path> is a URL-encoded version of PATH_INFO, with ";", "=" and "?" reserved. As I understand it, PATH_TRANSLATED is forged from PATH_INFO: map_to_physical(http://<server_name>:<server_port>/PATH_INFO) which should result in my test case (/test.php/more with DOCUMENT_ROOT set to /usr/local/apache-2.4/htdocs) to PATH_TRANSLATED=/usr/local/apache-2.4/htdocs/more But PATH_TRANSLATED is always an url begining with proxy:fcgi:// and the script name (/test.php) is also included. Moreover, the script_url (/test.php/more) appears twice in PATH_TRANSLATED. *** QUERY_STRING *** it is set correctly in all the case. *** SCRIPT_NAME *** The SCRIPT_NAME variable MUST be set to a URI path (not URL-encoded) which could identify the CGI script (rather than the script's output). The syntax is the same as for PATH_INFO (section 4.1.5) SCRIPT_NAME = "" | ( "/" path ) The leading "/" is not part of the path. It is optional if the path is NULL; however, the variable MUST still be set in that case. The SCRIPT_NAME string forms some leading part of the path component of the Script-URI derived in some implementation-defined manner. No PATH_INFO segment (see section 4.1.5) is included in the SCRIPT_NAME value. As I understand it, SCRIPT_NAME must always identifies the CGI script. In my test SCRIPT_NAME should be set to /test.php in all the case. This is not the case. When proxy-fcgi-pathinfo is set, SCRIPT_NAME is always empty. When proxy-fcgi-pathinfo is not set, SCRIPT_NAME always include what should be the PATH_INFO (/more): /test.php/more instead of /test.php *** DOCUMENT_ROOT *** Even if it's not defined in the RFC, the value is consistent in my tests and the value is correct. *** REQUEST_URI *** Even if it's not defined in the RFC, the value is consistent in my tests and the value is correct. *** SCRIPT_URI and SCRIPT_URL *** Those variables are set when using RewriteRule and are not set when using ProxyPass. Even if they are not defined in the RFC, the values seems correct when RewriteRule is used. *** SCRIPT_FILENAME *** Even if it's not defined in the RFC, the value is consistent in my tests. The value is an URI which does not make sense to me as the variable is named FILENAME. For me, the value should be set to DOCUMENT_ROOT + SCRIPT_NAME. For me, mod_fcgi does not respect the corresponding RFC and it makes fastcgi servers complex to match with apache fastcgi client implementation. PHP-FPM code for fastcgi is a mess and I'm trying to clean all this to make something consistent. But apache implementations (mod_fastcgi or mod_proxy_fcgi) make me do some very complex and dirty hacks to make things right. I would be greatful if apache mod_proxy_fcgi can be RFC compliant, not only for FPM but also for others fastcgi servers. Hope this comment is not too long or too messy. Hope it helps make things smoother :-) ++ Jerome -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
