Bug 54616 - ProxyPassMatch not allowed in <Directory> </Directory>
Summary: ProxyPassMatch not allowed in <Directory> </Directory>
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy (show other bugs)
Version: 2.4.4
Hardware: PC Linux
: P2 normal with 8 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-27 23:11 UTC by phpfpm1
Modified: 2013-05-21 00:57 UTC (History)
1 user (show)



Attachments
Fixes RewriteRule in Directory context. (665 bytes, patch)
2013-05-14 10:38 UTC, phpfpm1
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description phpfpm1 2013-02-27 23:11:10 UTC
Hello,

In http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassmatch it is said:
Context:	server config, virtual host, directory

However, it's not allowed to be used in directory, the following error is thrown:
ProxyPassMatch cannot occur within <Directory> section

Is it a bug in documentation or Apache?
Comment 1 frank 2013-03-22 13:41:59 UTC
Could this bug please be fixed? Thank you. :)
Comment 2 Ro 2013-03-23 20:34:01 UTC
Hello,

we have really big problem: we are using ProxyPass and <IF> - statements and since 2.4.4 that no longer works! Error message:
ProxyPass cannot occur within <IF> section

I think, my problem has the same reason, so, please - fix this bug as soon as possible!

Thanks in advance!

P.S.: In 2.4.3 always worked fine ...
Comment 3 Eric Covener 2013-03-23 20:51:32 UTC
(In reply to comment #2)
> Hello,
> 
> we have really big problem: we are using ProxyPass and <IF> - statements and
> since 2.4.4 that no longer works! Error message:
> ProxyPass cannot occur within <IF> section
> 
> I think, my problem has the same reason, so, please - fix this bug as soon
> as possible!
> 
> Thanks in advance!
> 
> P.S.: In 2.4.3 always worked fine ...

If your problem only started in 2.4.4, I think you need a separate bug.  I think this bug has been this way for the life of 2.4.x
Comment 4 ubunciak 2013-03-27 13:42:11 UTC
Guys, it's critical to use with php-fpm, it's not safe now, it's very important!
Comment 5 apdani 2013-04-24 09:08:37 UTC
any news? we have a lot of trouble with this issue
Comment 6 Eric Covener 2013-04-24 12:18:49 UTC
(In reply to comment #5)
> any news? we have a lot of trouble with this issue

Can you elaborate on what your configuration is and when it broke?
Comment 7 phpfpm1 2013-04-25 10:18:10 UTC
Password protected directories, index pages (if it should load .html firstly, not the .php file) and some other things do not work correctly when ProxyPassMatch is outside the Directory block. 

For example, the following works:
ProxyPassMatch ^/(.*\.php(/.*)?)$ 
fcgi://127.0.0.1:9000/var/www/html/mysite.com/public_htm/$1 
<Directory /var/www/html/mysite.com/public_html>
Options +Indexes +FollowSymLinks +Includes +MultiViews 
</Directory>

And the following does not work:
<Directory /var/www/html/mysite.com/public_html>
Options +Indexes +FollowSymLinks +Includes +MultiViews 
ProxyPassMatch ^/(.*\.php(/.*)?)$ 
fcgi://127.0.0.1:9000/var/www/html/mysite.com/public_htm/$1 
</Directory>

However, according to documentation (http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassmatch), it should work there, however, it throws errors:
ProxyPassMatch cannot occur within <Directory> section

Another way (workaround) is to use rewrite rules, however, we use https://issues.apache.org/bugzilla/show_bug.cgi?id=54101 and for some reason RewriteRule acts differently in Directory block than outside it. If we provide:
RewriteRule ^/(.*\.php(/.*)?)$ fcgi://socket=\%2fusr\%2flocal\%2fsockets\%2fmysite.sock|DOCROOT|/$1 [P,E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

Placed outside "Directory" it works correctly, path to the socket is /usr/local/sockets/mysite.sock

If placed in "Directory" block it does not work, because it thinks that the socket is placed here (that's the full path it converts to and it's incorrect, of course):
fusrflocalfsocketsfmysite.sock

So, it's another bug of wrong RewriteRule behaviour.
Comment 8 Eric Covener 2013-04-25 11:04:56 UTC
> However, according to documentation
> (http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassmatch), it
> should work there, however, it throws errors:
> ProxyPassMatch cannot occur within <Directory> section
> 

When did this last work and do what you expected (accepted in directory context and successfully proxied)?  It's probably blocked from that context because it didn't work in that context when it was accepted.
Comment 9 phpfpm1 2013-04-25 14:12:56 UTC
It did not work when we first tried it (about 3months ago), so I think "directory" should be removed from http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassmatch, or support for it added, because now documentation is misleading. Without it, the only way to run php-fpm with unix sockets (https://issues.apache.org/bugzilla/show_bug.cgi?id=54101) would be using RewriteRule, but it doesn't work correctly too (in the previous comment it was explained), so, for now the following are true:
* It is impossible to run PHP-FPM correctly with apache using unix domain sockets (https://issues.apache.org/bugzilla/show_bug.cgi?id=54101)
* It is impossible to run PHP-FPM using port number correctly, unless using RewriteRule in "Directory" block (http://wiki.apache.org/httpd/PHP-FPM does not work, if placed in "Directory"

Possible solutions:
* Drop https://issues.apache.org/bugzilla/show_bug.cgi?id=54101 from apache trunk or fix the RewriteRule behavior in "Directory"
* Remove "directory" from http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassmatch, or add support for it in apache code
Comment 10 Eric Covener 2013-04-25 14:37:06 UTC
The original report is resolved by making the documentation match the restriction in the code.

If anyone is interested in using ProxyPassMatch in <Directory> context,  try removing the restriction  against coding it that way in the configuration (mod_proxy.c:1390) and report back under what configurations it succeeds to actually proxy

* if it works, open a new bug report
* If it doesn't work (my suspicon) , open an enhancement ticket in bugzilla
Comment 11 phpfpm1 2013-05-14 10:38:48 UTC
Created attachment 30283 [details]
Fixes RewriteRule in Directory context.
Comment 12 Mike Rumph 2013-05-21 00:57:28 UTC
*** Bug 54965 has been marked as a duplicate of this bug. ***