使用 Apache 密码保护目录:“无法检查用户。请检查您的身份验证提供商!”

使用 Apache 密码保护目录:“无法检查用户。请检查您的身份验证提供商!”

我正在尝试使用 apache 密码保护 Web 目录。我的网站设置如下:

D:/
   webapp/
      lib/
         .htpasswd
   document_root/
      admin/
         index.php
         .htaccess

具有.htaccess

AuthName "Authorization Required" 
AuthType Basic 
AuthUserFile D:\webapp\lib\.htpasswd
require valid-user

并且.htpasswd有:

user:passworddigest

当我尝试localhost/index.php在浏览器中访问时,出现 500 错误。Apache 错误日志包含以下内容:

["date"] [crit] [client "ip"] configuration error:  couldn't check user.  Check your authn provider!: /admin/

我已经在 Google 上搜索过了,但还是搞不清楚这个错误在我的服务器上下文中意味着什么。有人知道怎么回事吗?此外,如果有人有一个简单的方法,可以使用 apache 在 Windows 服务器上验证 Web 目录,那么我的问题就可以解决了。

答案1

如果不是 Jim B 上面提到的权限问题(我也怀疑),您可能没有加载 Apache 中的 authn 模块 - mod_authn。我不知道如何在 Windows 中执行此操作,但我确信如果您在 Google 上搜索,就会找到操作方法。

答案2

我还没有在 Windows 上这样做过,但请尝试在 httpd.conf 文件中启用 auth_digest 模块,方法是取消注释此行(如果注释掉了)。我知道默认情况下它是禁用的:

LoadModule auth_digest_module modules/mod_auth_digest.so

答案3

我认为您的 .htaccess 中的 auth-type(AuthType Basic)是错误的,查看它.htpasswd告诉我密码是由htdigest& 设置的而不是htpasswd(如果我错了请纠正我)因此配置错误。

为了解决这个问题,请尝试以下.htaccess信息,问题应该会消失:

AuthName "Authorization Required" 
AuthType Digest
AuthUserFile D:\webapp\lib\.htpasswd
require valid-user

但是我建议您使用上述方法,因为password is transmitted inMD5 Digest in the network whereasAuthType Basic` 以干净的文本传输密码。

但是,如果您坚持要这样做AuthType Basic,请尝试以下操作.htaccess

AuthName "Authorization Required" 
AuthType Basic
AuthUserFile D:\webapp\lib\.htpasswd
require valid-user

并从以下链接创建 htpassword:

http://www.htaccesstools.com/htpasswd-generator/

并更新您的.htpasswd文件。

相关内容