From:             phodur at zoznam dot sk
Operating system: FreeBSD (all UNIX like OS)
PHP version:      5.3.17
Package:          CGI/CLI related
Bug Type:         Bug
Bug description:force-cgi-redirect does not works under FastCGI

Description:
------------
This is same as #37157. But may be I will better describe the problem.
Because Dmitry closed #37157 as NOT A BUG.

Ok, test environment is Apache 2.2.X with PHP 5.3.X. Base Apache config
is:

--- CUT ---

Alias /php-bin/                        /www/php-bin/php5

<Directory /www/php-bin/>

   Options ExecCGI
   SetHandler fastcgi-script

</Directory>

AddHandler                              php5-script     .php
Action                                  php5-script     /php-bin/php5

--- CUT ---

FastCGI (mod_fastcgi) related config is (this is not important for
reproducing this bug, it is provided only FYI):

--- CUT ---

FastCgiIpcDir                           /var/run/apache22/fastcgi/
FastCgiWrapper                          On
FastCgiConfig                           -idle-timeout 30 -killInterval 300
-maxClassProcesses 1 -maxProcesses 100 -minProcesses 0 -pass-header
HTTP_AUTHORIZATION -restart-delay 2 -singleThreshold 100

--- CUT ---

PHP was compiled only with CGI SAPI support and is run with following
wrapper (it's /www/php-bin/php5 file mentioned earlier):

--- CUT ---

#!/bin/sh

PHP_CGI=/usr/local/bin/php-cgi
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=500

export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS

exec $PHP_CGI

--- CUT ---

Ok, last but not least the PHP's FastCGI config:

--- CUT ---

;doc_root
;user_dir
cgi.force_redirect = 1
cgi.fix_pathinfo = 0

--- CUT ---


Ok, so when you hit:

http://[domain]/index.php

it works, the Apache translates this request according to Action directive
to

http://[domain]/php-bin/php5/index.php

and you will see the results.

When you hit http://[domain]/php-bin/php5/index.php directly, it will also
works (FastCGI PHP SAPI incorrectly does not check the REDIRECT_STATUS
environmental variable for value of 200).

When you change PHP cgi.fix_pathinfo to 1 (so the environmental variables
conforms to FastCGI/CGI specs), the last request incorrectly determine the
/www/php-bin/php5 as the PHP script and executes it. This is because one of
the main jobs of FastCGI/CGI SAPI is to determine WHAT to execute. When
fix_pathinfo is set to 1, it uses also REDIRECT_URL env variable, which is
not set when you access directly interpreter with passed script as
PATH_INFO (http://[domain]/php-bin/php5/index.php).

The only workaround at this time is use mod_rewrite and disable access to
the interpreter:

RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^/php-bin/php5 - [F]


Conclusion, this is NOT actually mod_fastcgi and/or configuration issue,
this is really bug in FastCGI/CGI SAPI of PHP (in opossite what Dmitry says
in #37157)





Test script:
---------------
See above

Expected result:
----------------
See above

Actual result:
--------------
See above

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63231&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63231&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63231&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63231&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63231&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63231&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63231&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63231&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63231&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63231&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63231&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63231&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63231&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63231&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63231&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63231&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63231&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63231&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63231&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63231&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63231&r=mysqlcfg

Reply via email to