0

Apache 2.4 版本配置文件启用了“mod_rewrite”模块。

LoadModule rewrite_module modules/mod_rewrite.so

身份验证模块加载并共享命令的输出:apachectl -M | grep '身份验证'

auth_basic_module (shared)
auth_digest_module (shared)
authn_file_module (shared)
authn_anon_module (shared)
authn_dbm_module (shared)
authz_host_module (shared)
authz_user_module (shared)
authz_owner_module (shared)
authz_groupfile_module (shared)
authz_dbm_module (shared)
authnz_ldap_module (shared)
authz_core_module (shared)

在 apache2.4 - 应用程序目录的 Web 服务器配置文件

 <Directory /var/www/html/logfile>
 AllowOverride AuthConfig
 Require all granted
 </Directory>

.htaccess 文件放在 logfile 目录下

AuthType Basic
AuthName "Restricted Access"
AuthBasicProvider file
AuthUserFile "/home/ec2-user/htpasswd/.htpasswd"
Require user tom

通过 url 访问日志文件,它必须要求 url 身份验证,成功验证后将允许查看文件。

但它会生成500 - Internal server Error并共享 apache 服务器日志

.htaccess:无效命令“AuthType”,可能拼写错误或由服务器配置中未包含的模块定义

4

1 回答 1

0

需要在 Apache 2.4 上启用以下模块以进行 url 身份验证

LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_core_module modules/mod_authz_core.so

其他支持模块 - Authenticaiton 相关

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
于 2019-12-20T06:20:34.800 回答