Bug #67587 [Opn->Csd]: Redirection loop on nginx with FPM

From: Date: Tue, 08 Jul 2014 19:56:08 +0000
Subject: Bug #67587 [Opn->Csd]: Redirection loop on nginx with FPM
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186537@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67587&edit=1

 ID:                 67587
 Updated by:         stas@php.net
 Reported by:        cweiske@php.net
 Summary:            Redirection loop on nginx with FPM
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PHAR related
 PHP Version:        5.6Git-2014-07-07 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM


Previous Comments:
------------------------------------------------------------------------
[2014-07-07 20:06:02] cweiske@php.net

It's actually "fpm-fcgi", not "cgi-fpm".

------------------------------------------------------------------------
[2014-07-07 20:02:51] cweiske@php.net

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 this bug report at https://bugs.php.net/bug.php?id=67587&edit=1


Thread (3 messages)

« previous php.bugs (#186537) next »