-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix Apache 2.4.10+ SetHandler proxy:fcgi:// incompatibilities #694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Apache 2.4.10+ will allow the following: ``` <FilesMatch \.php$> SetHandler proxy:fcgi://localhost:9000 </FilesMatch> ``` This is much easier than using `ProxyPassMatch` (which prevents rewriting and other stuff) and rewrites (which are a bag of hurt because when combined with user-land `.htaccess` rewrites, there's always rewrite loops, prefix breakage etc (I've tried, for weeks). It's basically the future of using Apache (via `mod_proxy_fcgi`) together with PHP-FPM. It's also available for older versions as a standalone module, very easy to install: https://gist.github.com/progandy/6ed4eeea60f6277c3e39 However, the two bits of code this commit deletes interfere with that. They both cover CGI-only mode and were copied from that SAPI into the FPM source. See e.g. https://bugs.php.net/bug.php?id=47042 The first deleted part mangled `SCRIPT_NAME` if something like ``` RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) index.php/$1 [L] ``` is used (i.e. rewriting to `PATH_INFO`. The second part drops `PATH_INFO` if there was a `REDIRECT_URL` (with CGI mode, `SCRIPT_FILENAME` in Apache is the path to the PHP binary, and `PATH_INFO` contains the name of the script to run). Clearly, neither applies in the case of FPM, so both are safe to delete.
Comment on behalf of tyrael at php.net: I've merged it into PHP-5.6 |
Thanks for the merge @Tyrael but this addresses a different issue than bug 65641. That one is still unaddressed and should be re-opened. The NEWS entry for this PR should be something like "Support Apache 2.4.10+ SetHandler method for mod_proxy_fcgi and PHP-FPM". |
Comment on behalf of tyrael at php.net: closing again, had to open so I can link the PR from the newly created https://bugs.php.net/bug.php?id=67541 |
I've created a separate bug for this, linked the pr from the bug and updated the NEWS entry. |
I can confirm this patch works. I'm using Apache 2.4.9 from ppa:ondrej/apache2 w mod_proxy_handler manually compiled. So others can verify my findings I've posted my test script at https://gist.github.com/pbowyer/bba54cbf01cf6b250c71. ResultsUnder PHP 5.6.0RC2:
Under all previous versions of PHP (tested 5.5.10 and 5.3.28):
I would love to see this backported as far as PHP 5.3. If not I'm going to have to manually patch it. |
…41, fixes bug 67606
* PHP-5.6: (60 commits) new NEWS block for the next release Updated NEWS for #66091 Updated NEWS for #66091 Fixed #66091 updated NEWS updated NEWS updated NEWS backported the fix for bug #41577 fix the failing date tests introduced with the latest timezonedb update Derick confirmed on irc that the new/current behavior is the correct and that the tests should be updated to reflect it Fixed bug #67813 (CachingIterator::__construct InvalidArgumentException wrong message) NEWS entry for e6d93a1 / d73d44c restore FPM compatibility with mod_fastcgi broken since #694 / 67541, fixes bug 67606 Revert "Merge branch 'pull-request/694' into PHP-5.6" Add __debugInfo() to UPGRADING. fix TS build Update NEWS Update NEWS Update NEWS Bug #41631: Observe socket read timeouts in SSL streams wrap int8_t and int16_t with #ifdef to avoid possible clashes ... Conflicts: NEWS
Revised fix in #765 |
* master: (51 commits) Update Git rules Back to -dev (with EOL notice in NEWS) new NEWS block for the next release It's 2014 already, fix copyright year where user visible PHP 5.3.29 Some changes were lost in the merge commit of #66091 Updated NEWS for #66091 Fixed #66091 Updated NEWS for #66091 Updated NEWS for #66091 Fixed #66091 updated NEWS updated NEWS updated NEWS backported the fix for bug #41577 NEWS entry for e6d93a1 / d73d44c restore FPM compatibility with mod_fastcgi broken since #694 / 67541, fixes bug 67606 Revert "Merge branch 'pull-request/694' into PHP-5.6" PHP 5.3.29RC1 Fix missing type checks in various functions ... Conflicts: ext/date/php_date.c ext/standard/math.c
* PHP-5.4: fix NEWS for fcgi fix merge restore FPM compatibility with mod_fastcgi broken since #694 / 67541, fixes bug 67606
* PHP-5.5: fix NEWS for fcgi fix merge restore FPM compatibility with mod_fastcgi broken since #694 / 67541, fixes bug 67606
* PHP-5.6: fix NEWS for fcgi fix merge restore FPM compatibility with mod_fastcgi broken since #694 / 67541, fixes bug 67606
It still doesn't work well according to Apache documentation. It adds an additional trailing slash (/) at the beginning of SCRIPT_FILENAME if SetHandler ends with a trailing slash like in http://httpd.apache.org/docs/current/mod/mod_proxy.html#handler: The following one has no problems, of course: So, currently we still have the following problem: https://bugs.php.net/bug.php?id=67998 |
Those docs are wrong. Just omit the trailing slash. Either way, that is a separate issue from what this pull request addresses, @smtalk |
On:
I'm still running into some issues with mod_proxy_fcgi, sockets, SetHandler and mod_rewrite:
If I request But if I don't specify I also tested with mod_php, and then the rewriting works fine and whether or not I add |
@fkooman This is probably not the right place for extended discussion, but the patch we made in 2.4.21 to fix other FCGI backends with mod_proxy_fcgi broke the detection code @dzuelke was messing with in this series of patches. See apache/httpd@cab0bfb#commitcomment-20393588 and https://bz.apache.org/bugzilla/show_bug.cgi?id=59618 . We've written ourselves into a mutually dependent corner here and I'm trying to see if there's a way back out. |
What's the plan forward then, @jchampio... will this be reverted for 2.4.26? |
@dzuelke Yes. 2.4.26 won't release without a reversion unless my showstopper gets vetoed, and trunk contains a patch from @covener to hide these changes behind a (non-default) configuration directive. As for my plan forward (which is not guaranteed to be the plan forward):
Just those two alone will require a pretty good conversation. Is there a better place than your mailing list to have it? |
I asked myself the same question. I'll surface this on the PHP internals list to see if people have any preference. |
Just a FYI that discussions on the Apache dev side are occurring on: https://lists.apache.org/thread.html/d0f05cc71deb69ea472520fb655ca7504fec90850614f5680b42587a@%3Cdev.httpd.apache.org%3E |
Apache 2.4.10+ will allow the following:
This is much easier than using
ProxyPassMatch
(which prevents rewriting and other stuff) and rewrites (which are a bag of hurt because when combined with user-land.htaccess
rewrites, there's always rewrite loops, prefix breakage etc (I've tried, for weeks).It's basically the future of using Apache (via
mod_proxy_fcgi
) together with PHP-FPM. It's also available for older versions as a standalone module, very easy to install: https://gist.github.com/progandy/6ed4eeea60f6277c3e39However, the two bits of code this commit deletes interfere with that. They both cover CGI-only mode and were copied from that SAPI into the FPM source. See e.g. https://bugs.php.net/bug.php?id=47042
The first deleted part mangled
SCRIPT_NAME
if something likeis used (i.e. rewriting to
PATH_INFO
. The second part dropsPATH_INFO
if there was aREDIRECT_URL
(with CGI mode,SCRIPT_FILENAME
in Apache is the path to the PHP binary, andPATH_INFO
contains the name of the script to run).Clearly, neither applies in the case of FastCGI, so both are safe to delete.