You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Santiago DIEZ <sa...@caoba.fr> on 2015/01/28 21:26:11 UTC

[users@httpd] Configure remote php-fpm server with SetHandler

Hi there,


I have an *httpd-2.4.10* server (ip 5.39.81.177:80) with htdocs files
located in */var/www/*.

I have a remote *php-fpm* server (ip 91.121.180.140:9000) with htdocs files
mounted in */htdocs/5-39-81-177/*.

The httpd server currently passes php execution to the remote php-fpm
server with the following configuration :
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
ProxyPassMatch \.php$ fcgi://91.121.180.140:9000/htdocs/5-39-81-188/

*It works fine*.



Now that I'm done fooling around with ProxyPassMatch, I'd like to play
around with SetHandler.

I tried the following configuration :
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
<FilesMatch \.php$>
    SetHandler "proxy:fcgi://91.121.180.140:9000/htdocs/5-39-81-188/"
</FilesMatch>

But I get a *404: Not Found*.

I read in the logs the following :
mod_proxy_fcgi.c(786): [client 127.0.0.1:41289] AH01076: url: fcgi://
91.121.180.140:9000/htdocs/5-39-81-188//var/www/info.php proxyname: (null)
proxyport: 0

So the error makes sense because the file on the fpm server is
/htdocs/5-39-81-188/info.php and not /htdocs/5-39-81-188/var/www/info.php.


*My question: How can I tell the directive to skip the /var/www/ part when
proxying the request?*


Let's be clear on my purpose here. I'm strictly playing with SetHandler and
yes my fpm server is on a different machine.
You might think "it's wrong practice"... I don't care.
You might want to say "stick to ProxyPassMatch if it works"... NO I want to
play with SetHandler.
You might want to offer an alternative... Fine, do it. But I don't care, my
toy IS SetHandler.

Thanks you all for your help.
-------------------------
*Santiago DIEZ*
-------------------------

<http://www.google.com/url?q=http%3A%2F%2Fsantiago.news.free.fr%2Flogo.png&sa=D&sntz=1&usg=AFrqEzfmW2Io3OI5IqEGiVeDRebZgD4TaQ>
-------------------------
*Quark Systems & CAOBA*

*23 rue du Buisson Saint-Louis, 75010 Paris*-------------------------

Re: [users@httpd] Configure remote php-fpm server with SetHandler

Posted by Eric Covener <co...@gmail.com>.
On Thu, Jan 29, 2015 at 9:34 AM, Santiago DIEZ <sa...@caoba.fr>
wrote:

> The directive that I fail to work out is *SetHandler*.
>

​SetHandler will always pass the full path as mapped by the core of Apache
to the fcgi server (that is one of the benefits).

Perhaps for your case, changing where the file is mapped inside of Apache
would help -- mod_rewrite or maybe even just Alias?

-- 
Eric Covener
covener@gmail.com

Re: [users@httpd] Configure remote php-fpm server with SetHandler

Posted by Santiago DIEZ <sa...@caoba.fr>.
Thanks Marcello but my ProxyPassMatch directive works fine.
You've rightfully pointed out that I forgot the $1 though.
That's a copy/paste mistake. The $1 appears in my directive.

The directive that I fail to work out is *SetHandler*.
That's the one for which I need help.

-------------------------
*Santiago DIEZ*
*+33 6 37 90 81 98*
-------------------------

<http://www.google.com/url?q=http%3A%2F%2Fsantiago.news.free.fr%2Flogo.png&sa=D&sntz=1&usg=AFrqEzfmW2Io3OI5IqEGiVeDRebZgD4TaQ>
-------------------------
*Quark Systems & CAOBA*

*23 rue du Buisson Saint-Louis, 75010 Paris*-------------------------

On Wed, Jan 28, 2015 at 9:32 PM, Marcello Lorenzi <ml...@sorint.it>
wrote:

>  Try with this:
>
> <VirtualHost *:80>
> ...
> 	 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/mnt/app/test/$1
> ...
> </VirtualHost>
>
>
> On 01/28/2015 09:26 PM, Santiago DIEZ wrote:
>
>  Hi there,
>
>
>  I have an *httpd-2.4.10* server (ip 5.39.81.177:80) with htdocs files
> located in */var/www/*.
>
>  I have a remote *php-fpm* server (ip 91.121.180.140:9000) with htdocs
> files mounted in */htdocs/5-39-81-177/*.
>
> The httpd server currently passes php execution to the remote php-fpm
> server with the following configuration :
>  LoadModule proxy_module modules/mod_proxy.so
> LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
> ProxyPassMatch \.php$ fcgi://91.121.180.140:9000/htdocs/5-39-81-188/
>
>  *It works fine*.
>
>
>
>  Now that I'm done fooling around with ProxyPassMatch, I'd like to play
> around with SetHandler.
>
> I tried the following configuration :
> LoadModule proxy_module modules/mod_proxy.so
> LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
> <FilesMatch \.php$>
>     SetHandler "proxy:fcgi://91.121.180.140:9000/htdocs/5-39-81-188/"
> </FilesMatch>
>
> But I get a *404: Not Found*.
>
> I read in the logs the following :
> mod_proxy_fcgi.c(786): [client 127.0.0.1:41289] AH01076: url: fcgi://
> 91.121.180.140:9000/htdocs/5-39-81-188//var/www/info.php proxyname:
> (null) proxyport: 0
>
> So the error makes sense because the file on the fpm server is
> /htdocs/5-39-81-188/info.php and not /htdocs/5-39-81-188/var/www/info.php.
>
>
> *My question: How can I tell the directive to skip the /var/www/ part when
> proxying the request?*
>
>
> Let's be clear on my purpose here. I'm strictly playing with SetHandler
> and yes my fpm server is on a different machine.
>  You might think "it's wrong practice"... I don't care.
>  You might want to say "stick to ProxyPassMatch if it works"... NO I want
> to play with SetHandler.
>  You might want to offer an alternative... Fine, do it. But I don't care,
> my toy IS SetHandler.
>
>  Thanks you all for your help.
>    -------------------------
> *Santiago DIEZ*
> -------------------------
>
> <http://www.google.com/url?q=http%3A%2F%2Fsantiago.news.free.fr%2Flogo.png&sa=D&sntz=1&usg=AFrqEzfmW2Io3OI5IqEGiVeDRebZgD4TaQ>
> -------------------------
> *Quark Systems & CAOBA*
>
> *23 rue du Buisson Saint-Louis, 75010 Paris *-------------------------
>
>
>

Re: [users@httpd] Configure remote php-fpm server with SetHandler

Posted by Marcello Lorenzi <ml...@sorint.it>.
Try with this:

<VirtualHost *:80>
...
	 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/mnt/app/test/$1
...
</VirtualHost>


On 01/28/2015 09:26 PM, Santiago DIEZ wrote:
> Hi there,
>
>
> I have an /*httpd-2.4.10*/ server (ip 5.39.81.177:80 
> <http://5.39.81.177:80>) with htdocs files located in _/var/www/_.
>
> I have a remote /*php-fpm*/ server (ip 91.121.180.140:9000 
> <http://91.121.180.140:9000>) with htdocs files mounted in 
> _/htdocs/5-39-81-177/_.
>
> The httpd server currently passes php execution to the remote php-fpm 
> server with the following configuration :
> LoadModule proxy_module modules/mod_proxy.so
> LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
> ProxyPassMatch \.php$ fcgi://91.121.180.140:9000/htdocs/5-39-81-188/ 
> <http://91.121.180.140:9000/htdocs/5-39-81-188/>
>
> *It works fine*.
>
>
>
> Now that I'm done fooling around with ProxyPassMatch, I'd like to play 
> around with SetHandler.
>
> I tried the following configuration :
> LoadModule proxy_module modules/mod_proxy.so
> LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
> <FilesMatch \.php$>
>     SetHandler "proxy:fcgi://91.121.180.140:9000/htdocs/5-39-81-188/ 
> <http://91.121.180.140:9000/htdocs/5-39-81-188/>"
> </FilesMatch>
>
> But I get a *404: Not Found*.
>
> I read in the logs the following :
> mod_proxy_fcgi.c(786): [client 127.0.0.1:41289 
> <http://127.0.0.1:41289>] AH01076: url: 
> fcgi://91.121.180.140:9000/htdocs/5-39-81-188//var/www/info.php 
> <http://91.121.180.140:9000/htdocs/5-39-81-188//var/www/info.php> 
> proxyname: (null) proxyport: 0
>
> So the error makes sense because the file on the fpm server is 
> /htdocs/5-39-81-188/info.php and not /htdocs/5-39-81-188/var/www/info.php.
>
>
> *My question: How can I tell the directive to skip the /var/www/ part 
> when proxying the request?*
>
>
> Let's be clear on my purpose here. I'm strictly playing with 
> SetHandler and yes my fpm server is on a different machine.
> You might think "it's wrong practice"... I don't care.
> You might want to say "stick to ProxyPassMatch if it works"... NO I 
> want to play with SetHandler.
> You might want to offer an alternative... Fine, do it. But I don't 
> care, my toy IS SetHandler.
>
> Thanks you all for your help.
> -------------------------
> *Santiago DIEZ*
> -------------------------
> <http://www.google.com/url?q=http%3A%2F%2Fsantiago.news.free.fr%2Flogo.png&sa=D&sntz=1&usg=AFrqEzfmW2Io3OI5IqEGiVeDRebZgD4TaQ>
> -------------------------
> *Quark Systems & CAOBA*
> /23 rue du Buisson Saint-Louis, 75010 Paris
> /-------------------------