问题原文
原帖链接 · Sander Marechal · CC BY-SA 4.0
I use PHP-FPM in a shared hosting configuration. Each FPM pool runs as a different user. Apache runs as www-data. Apache connects via a socket using mod_proxy_fcgi. I allow users to use .htaccess files.
How do I prevent a user from connecting to the wrong FPM pool?
The vhost looks something like this:
<VirtualHost *:80>
ServerName foo.com
DocumentRoot /var/www/sites/foo.com/html
<FilesMatch "\.php$">
SetHandler "proxy:unix:/var/run/foo-com-fpm.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
But, the foo-com user can easily override that handler from his .htaccess:
<FilesMatch "\.php$">
SetHandler "proxy:unix:/var/run/bar-com-fpm.sock|fcgi://localhost"
</FilesMatch>
This would allow him to run PHP scripts as a different user. How can I prevent that, without disallowing FileInfo overrides?
已采纳解答
原帖链接 · fuero · CC BY-SA 4.0
AllowOverrideList allows to further restrict .htaccess directives to the specified list.
Quote from the docs:
When this directive is set to
NoneandAllowOverrideis set toNone, then .htaccessfiles are completely ignored. In this case, the server will not even attempt to read.htaccessfiles in the filesystem.Example:
AllowOverride None AllowOverrideList Redirect RedirectMatchIn the example above, only the
RedirectandRedirectMatchdirectives are allowed. All others will cause an internal server error.Example:
AllowOverride AuthConfig AllowOverrideList CookieTracking CookieNameIn the example above,
AllowOverridegrants permission to theAuthConfigdirective grouping andAllowOverrideListgrants permission to only two directives from theFileInfodirective grouping. All others will cause an internal server error.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
