I've got Apache/PHP setup exactly like this: https://wiki.apache.org/httpd/PHP-FPM
It includes the ProxyPassMatch
rule as mentioned:
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/path/to/files/$1
This sends all requests with .php
in it to a proxy, and ultimately serves the PHP just fine.
However, I've been trying to do some access control and the proxying seems to take precedence. My folder structure is like this:
/ <-- PHP files
/extra/ <-- PHP files
/css/
/img/
There should be access to the PHP files in the root directory, but I want to restrict access to the extra
dir. I've added these lines to my main config:
<Directory "/extra">
Order deny,allow
Deny from all
</Directory>
But the PHP files are still executed... When I put a different kind of file in the folder, it is successfully blocked, so the directive works. I'm guessing the ProxyPassMatch
rule is prohibiting it from working for PHP files.
I've tried a couple of things, like putting the ProxyPassMatch
rule inside a <Directory>
block (doesn't work, because you cannot use ProxyPassMatch
inside such blocks) and substituting ProxyPassMatch
for a RewriteRule
with the [P]
flag (similar to this: Apache 2.4 + PHP-FPM + ProxyPassMatch, but it didn't get proxied).
My question is almost exactly the same as this one: http://www.gossamer-threads.com/lists/apache/users/417758. However, it did not get a definitive answer.
What confuses me is you need to have the proxy-rule in place, but when you put it in, nothing else seems to matter (.htaccess also does not work anymore). Furthermore, this raises questions about security. Everything with .php
in it remains untouched by my fancy access provisions and goes straight through to the system's internals. How can I combine PHP-FPM with proper security rules in Apache?