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

HTTP Basic Auth not bring up password prompt in <Directory> but in <Location> in 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/ 

    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(在手册中),它会延迟执行并允许正常映射到磁盘。如果需要,请尝试一下。