Apache版本:2.4.17
vhost.config:
Listen 1449
<VirtualHost *:1449>
DirectoryIndex /index.php index.php
ServerName 200.000.000.00:1449
ServerAdmin myname
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:5000/custom/$1
DocumentRoot /custom
<Directory /custom>
Options -Indexes -Includes
AllowOverride None
Allow from All
AuthBasicProvider file
AuthName "Restricted Area"
AuthType Basic
AuthUserFile "/passward/.main"
Require valid-user
</Directory>
</VirtualHost>
http.config中唯一的通用目录标记:
<Directory />
<LimitExcept GET POST HEAD>
deny from all
</LimitExcept>
Options -Indexes
AllowOverride none
Require all denied
</Directory>
我有另一个使用完全相同的设置和密码的虚拟主机,它正在运行。但我不知道为什么它不能在端口1449
中的特定虚拟主机中工作。当我浏览200.000.000.00:1449/custom/some.php
时,它不会显示要求输入密码的对话框。它只是直接到页面。我必须使用<Location>
标记来显示密码提示,但我读过它并不比<Directory>
更安全。根本没有错误日志。对我来说完全神秘。
有人能弄清楚设置有什么问题吗?
更新:
工作:
<Location />
AuthType Basic
.....
</Location>
不工作:
<Directory />
AuthType Basic
.....
</Directory>
不工作:
<Files "some.php">
AuthType Basic
.....
</Files>
文件路径:
/custom/some.php 0644
答案 0 :(得分:1)
使用ProxyPass/ProxyPassmatch
时,请求永远不会映射到磁盘上的任何位置,因此您无法使用<Directory>
部分。
FCGI的另一种形式是使用SetHandler
而不是ProxyPass/ProxyPassmatch
(它在手册中)延迟执行并允许正常映射到磁盘。如果你需要,试一试。