Bug #67587 [NEW]: Redirection loop on nginx with FPM
| From: | cweiske@php.net | Date: | Mon, 07 Jul 2014 20:02:52 +0000 |
| Subject: | Bug #67587 [NEW]: Redirection loop on nginx with FPM | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186506@lists.php.net to get a copy of this message | ||
From: cweiske
Operating system:
PHP version: 5.6Git-2014-07-07 (Git)
Package: PHAR related
Bug Type: Bug
Bug description:Redirection loop on nginx with FPM
Description:
------------
nginx running php via fpm gives an endless redirection loop for .phar
files.
$ curl -si http://phorkie.kylewm.com/phpinfo.phar/www/index.php|grep
Location
Location: /phpinfo.phar/www/index.php
Problem is the CGI detection in Phar::webPhar() which only knows about
"cgi-fcgi" and "cgi", but not about "cgi-fpm" as it is reported here:
> if ((strlen(sapi_module.name) == sizeof("cgi-fcgi")-1 &&
!strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi")-1))
> || (strlen(sapi_module.name) == sizeof("cgi")-1 &&
!strncmp(sapi_module.name, "cgi", sizeof("cgi")-1))) {
http://git.php.net/?p=php-src.git;a=blob;f=ext/phar/phar_object.c;h=75aadfbc540b9929b0af563e365990c69b1ca315;hb=HEAD#l608
Seems similar to bug #53537.
Test script:
---------------
<?php
if (file_exists('phpinfo.phar')) {
unlink('phpinfo.phar');
}
$phar = new Phar('phpinfo.phar');
$phar->addFromString('www/index.php', '<?php phpinfo();?>');
$phar->setStub(
'<?php Phar::webPhar(null, "www/index.php"); echo "cli\n";
__HALT_COMPILER(); ?>'
);
?>
Expected result:
----------------
no redirection loop.
Actual result:
--------------
$ curl -si http://phorkie.kylewm.com/phpinfo.phar/www/index.php|grep
Location
Location: /phpinfo.phar/www/index.php
--
Edit bug report at https://bugs.php.net/bug.php?id=67587&edit=1
--