Re: Re: ProxyPassMatch with Unix sockets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 18, 2014 at 2:48 AM, Igor Cicimov <icicimov@xxxxxxxxx> wrote:
>
> On 18/04/2014 10:43 AM, "Igor Cicimov" <icicimov@xxxxxxxxx> wrote:
>>
>>
>> On 18/04/2014 8:25 AM, "Marc Aymerich" <glicerinu@xxxxxxxxx> wrote:
>> >
>> > On Thu, Apr 17, 2014 at 11:18 PM, Marc Aymerich <glicerinu@xxxxxxxxx>
>> > wrote:
>> > > On Wed, Apr 16, 2014 at 11:17 PM, Marc Aymerich <glicerinu@xxxxxxxxx>
>> > > wrote:
>> > >> Hi,
>> > >> I have a PHP-FPM web application that I want it to be accessed under
>> > >> "/alias/" path. I'm trying to configure ProxyPassMatch with Unix
>> > >> sockets but it doesn't work because it passes "/alias/" to the web
>> > >> app, but this path doesn't exist :(
>> > >>
>> > >> What I have so far is this:
>> > >>
>> > >> ProxyPassMatch ^/alias/(.*\.php(/.*)?)$ \
>> > >> unix:/var/run/user-fpm.sock|fcgi://localhost/home/user/webapps/app1/
>> > >
>> > >
>> > > I think I got something :)
>> > >
>> > > if you guys like to comment on the following solution it would be
>> > > great! (I'm kind of newbie)
>> > >
>> > > # Rewrite the URL before proxying
>> > > RewriteRule ^/alias(.*\.php)$ $1 [L,PT]
>> > >
>> > > ProxyPassMatch ^/?(.*\.php)$
>> > > unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app1/
>> > >
>> > > # Create an alias for app1 static content
>> > > Alias /alias /home/user/webapps/app1/
>> >
>> >
>> > Well, actually this doesn't solve my original problem which is having
>> > two different php-fpm apps under the same VirtualHost.
>> >
>> > Based on the previous directives I kind of expected something like the
>> > following to work:
>> >
>> > <LocationMatch ^/app1(.*\.php)$>
>> >     RewriteRule $1 [L,PT]
>> >     ProxyPassMatch
>> > unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app1/
>> > </LocationMatch>
>> >
>> > <LocationMatch ^/app2(.*\.php)$>
>> >     RewriteRule $1 [L,PT]
>> >     ProxyPassMatch
>> > unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app2/
>> > </LocationMatch>
>> >
>> >
>> > But it doesn't, the RewriteRule seems to be totally ignored inside a
>> > LocationMatch no matter what I put there.
>> >
>> Did you read
>> http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassmatch
>>
> And
> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
> Pay attention to the Context which explains where the directive should be
> used.


Thanks Igor for pointing out these documents.

I've read them carefully this morning and done some more tests, none
of them worked as I wanted to.

I have concluded that it is not possible to have multiple fcgi socket
apps on the same VirtualHost using mod proxy.

At least not by using the functionality available on current stable 2.4.9.

But I'd love someone to prove me wrong :)



Here the summary of the 3 ways I've tried:

1) The first thing is trying to pass the matched part of a URL using
ProxyPassMatch.

But the obvious way of doing this doesn't work:

ProxyPassMatch ^/alias(.*\.php)$
unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app1/$1

[Fri Apr 18 13:32:21.367171 2014] [proxy:error] [pid 29185:tid
139735912711936] (111)Connection refused: AH00957: FCGI: attempt to
connect to 127.0.0.1:8000 (*) failed
[Fri Apr 18 13:32:21.367226 2014] [proxy_fcgi:error] [pid 29185:tid
139735912711936] [client 10.0.3.64:35267] AH01079: failed to make
connection to backend: 127.0.0.1

What makes proxy_fcgi break is the ending $1. Without it no error is
reported by Apache.
However the backend server will receive the full path, a GET
/alias/info.php request.


2) Contrary on what is stated on the ProxyPassMatch documentation[1]
it seems that you can NOT use mod rewrite to do more advanced stuff.
At least not in an obvious way, something like this will not work:

RewriteRule ^/alias(.*\.php)$
unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app1$1
[P,NE]

because it gets actually rewritten as:

http://domain/unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app1/info.php


3) Also you can not use a Location block to limit the effect of a
RewriteRule+ProxyPassMatch, i.e.

<LocationMatch ^/app1(.*\.php)$>
    RewriteRule $1 [L,PT]
    ProxyPassMatch
unix:/var/run/user.sock|fcgi://127.0.0.1/home/user/webapps/app1/
</LocationMatch>

According to the documentation RewriteRules have no effect inside a
Location block, but still is syntactically correct :).



[1] http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassmatch


-- 
Marc

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux