auth 在 apache 中不起作用

auth 在 apache 中不起作用

我试图在 中启用身份验证apache。我尝试了以下配置项。

<Directory "/var/www/html/balancer-manager">
    Order deny,allow
    AuthName "Restricted area for authorised users only"
    AuthType Basic
    AuthUserFile /etc/httpd/conf/admin.users
    Require valid-user
</Directory>
$ cat /etc/httpd/conf/admin.users
test:kWtP2lRnbgNaK31

但它并不要求提供凭据。我缺少什么?

请启用DEBUG模式后查找日志内容

[Fri Jan 18 10:48:34.663221 2019] [core:info] [pid 32043] AH00096: removed PID file /run/httpd/httpd.pid (pid=32043)
[Fri Jan 18 10:48:34.663282 2019] [mpm_prefork:notice] [pid 32043] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Jan 18 10:48:35.725075 2019] [suexec:notice] [pid 29306] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Jan 18 10:48:35.738035 2019] [auth_digest:notice] [pid 29306] AH01757: generating secret for digest authentication ...
[Fri Jan 18 10:48:35.738064 2019] [auth_digest:debug] [pid 29306] mod_auth_digest.c(250): AH01759: done
[Fri Jan 18 10:48:35.738672 2019] [slotmem_shm:debug] [pid 29306] mod_slotmem_shm.c(448): AH02301: attach looking for /run/httpd/slotmem-shm-mod_heartmonitor.shm
[Fri Jan 18 10:48:35.738688 2019] [lbmethod_heartbeat:notice] [pid 29306] AH02282: No slotmem from mod_heartmonitor
[Fri Jan 18 10:48:35.741178 2019] [proxy:debug] [pid 29308] proxy_util.c(1843): AH00925: initializing worker proxy:reverse shared
[Fri Jan 18 10:48:35.741214 2019] [proxy:debug] [pid 29308] proxy_util.c(1885): AH00927: initializing worker proxy:reverse local
[Fri Jan 18 10:48:35.741261 2019] [proxy:debug] [pid 29308] proxy_util.c(1936): AH00931: initialized single connection worker in child 29308 for (*)
[Fri Jan 18 10:48:35.741291 2019] [mpm_prefork:notice] [pid 29306] AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) configured -- resuming normal operations
[Fri Jan 18 10:48:35.741310 2019] [mpm_prefork:info] [pid 29306] AH00164: Server built: Oct  3 2017 09:37:04

答案1

我在这里的配置如下:

<Directory /var/www/html/balancer-manager>
    AuthType Basic
    AuthName "Restricted area for authorised users only"
    AuthUserFile /etc/httpd/conf/admin.users
    Require valid-user
 </Directory>

然后重新启动阿帕奇。

答案2

Directory当我用指令更改指令时为我工作Location。以下是片段

  <Location "/balancer-manager">
   AuthName "Restricted area for authorised users only"
   AuthType Basic
   AuthUserFile /etc/httpd/conf/admin.users
   Require valid-user
  </Location>

相关内容