Re: Fixing (and making easier) Apache mod_proxy_fcgi with PHP-FPM
| From: | David Muir | Date: | Sat, 14 Jun 2014 04:57:55 +0000 |
| Subject: | Re: Fixing (and making easier) Apache mod_proxy_fcgi with PHP-FPM | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74896@lists.php.net to get a copy of this message | ||
On 13 Jun 2014, at 5:47 am, David Zuelke <dz@heroku.com> wrote:
> Hi everyone (already discussed this a bit off-list with Julien),
>
> Ilia and I sat down last week at International PHP Conference to discuss
> https://bugs.php.net/bug.php?id=65641.
>
> This is a pretty critical issue with Apache 2.4, since it leads to an incorrect SCRIPT_NAME
> (and thus also PHP_SELF) value if PATH_INFO is given, and frameworks such as CodeIgniter (I know…)
> break under these circumstances. Ilia has remarked that the emalloc() that never gets free()d might
> not be ideal with debug on, but it's hard to do in this case, so not sure how critical the
> patch is. It may need some comments though explaining that if SCRIPT_NAME contains PATH_INFO, the
> latter is stripped from it again.
>
> More importantly:
>
> We also looked at a related thing together: support for a new way of proxying requests to
> PHP-FPM in Apache trunk (and the feature will now be backported to Apache 2.4.x, so it'll be in
> the next release).
>
> This is *very* big news for PHP-FPM, because the current two options for using mod_proxy_fcgi
> (which is the future-proof way of connecting Apache and FPM) are both far from ideal:
>
> 1) ProxyPassMatch: skips all .htaccess rewrites etc
> 2) Default mod_rewrite rules on VirtualHost level: will always have to take precedence over
> certain user-land rewrites, so there's always conflicts, redirect loops and so forth (I've
> tried, it's messy).
>
> The new approach, which can also be built as a standalone module for older versions of Apache
> (https://gist.github.com/progandy/6ed4eeea60f6277c3e39), works like this:
>
> <FilesMatch \.php$>
> SetHandler proxy:fcgi://localhost:9000
> </FilesMatch>
>
> It's very simple, and very similar to how mod_php is used in Apache, so that'll make
> it very easy and convenient for users to use FPM with Apache 2.4.10+
This sounds great! And I see in the comments on github that it works with unix sockets too! I just
wasted several hours trying to get my user-land rewrites working... I had to swap to using a
RewriteRule instead of ProxyPassMatch, but I could not get it working with a unix socket. In the end
I had to reconfigure FPM to listen to a tcp socket instead. Very annoying, but I’m very happy to
see a much simpler and cleaner solution just around the corner! Hopefully I’ll actually be able to
start using 5.5 in production soon.
Cheers,
David