HTTP Basic Auth 不会在 <Directory> <Location> Apache 2.4 中显示密码提示



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
使用

ProxyPass/ProxyPassmatch 时,请求永远不会映射到磁盘上的任何位置,因此不能使用<Directory>节。

FCGI 还有另一种形式,它使用 SetHandler 而不是 ProxyPass/ProxyPassmatch(它在手册中),延迟执行并允许正常映射到磁盘。 如果需要,请尝试一下。

最新更新