首页 > 解决方案 > Apache http文件身份验证不起作用?

问题描述

所以我以这种方式设置了我的虚拟主机:

<VirtualHost *:80>

        ProxyRequests Off
        ProxyVia Off
        ProxyPreserveHost On

        <Proxy *>
          Require all granted
          # Use following line instead of the previous two on Apache >= 2.4
          # Require all granted
        </Proxy>

        <Location "/">
          AuthType Basic
          AuthName "Gerrit Code Review"
          AuthBasicProvider file
          AuthUserFile /usr/local/apache/passwd/passwords
          Require valid-user
        </Location>

        AllowEncodedSlashes On
        ProxyPass /gerrit/ http://localhost:8087/ nocanon
        ProxyPassReverse /gerrit/ http://localhost:8087/ nocanon
</VirtualHost>

我以这种方式添加了一个用户htpasswd -c /usr/local/apache/passwd/passwords <username>

我可以看到我的用户在/usr/local/apache/passwd/passwords

重新启动阿帕奇sudo systemctl restart apache2

当我访问http://myIp/gerrit/时,我被要求输入我的登录名/密码,我这样做了,然后页面保持空白。

在 /var/log/apache2/error.log 我可以找到:

[Sat Feb 22 11:19:55.712602 2020] [authz_core:debug] [pid 13742:tid 140252920325888] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.712619 2020] [authz_core:debug] [pid 13742:tid 140252920325888] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.712885 2020] [authz_core:debug] [pid 13742:tid 140252920325888] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.712891 2020] [authz_core:debug] [pid 13742:tid 140252920325888] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.712901 2020] [core:info] [pid 13742:tid 140252920325888] [client 92.88.5.194:52583] AH00128: File does not exist: /var/www/html/fonts/Roboto-Medium.woff
[Sat Feb 22 11:19:55.713106 2020] [authz_core:debug] [pid 13741:tid 140253037823744] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.713118 2020] [authz_core:debug] [pid 13741:tid 140253037823744] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.713369 2020] [authz_core:debug] [pid 13741:tid 140253037823744] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.713380 2020] [authz_core:debug] [pid 13741:tid 140253037823744] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.713388 2020] [core:info] [pid 13741:tid 140253037823744] [client 92.88.5.194:52587] AH00128: File does not exist: /var/www/html/fonts/Roboto-Regular.woff2
[Sat Feb 22 11:19:55.713659 2020] [authz_core:debug] [pid 13742:tid 140252928718592] mod_authz_core.c(809): [client 92.88.5.194:52586] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.713673 2020] [authz_core:debug] [pid 13742:tid 140252928718592] mod_authz_core.c(809): [client 92.88.5.194:52586] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.713936 2020] [authz_core:debug] [pid 13742:tid 140252928718592] mod_authz_core.c(809): [client 92.88.5.194:52586] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.713943 2020] [authz_core:debug] [pid 13742:tid 140252928718592] mod_authz_core.c(809): [client 92.88.5.194:52586] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.713952 2020] [core:info] [pid 13742:tid 140252928718592] [client 92.88.5.194:52586] AH00128: File does not exist: /var/www/html/fonts/Roboto-Regular.woff
[Sat Feb 22 11:19:55.714144 2020] [authz_core:debug] [pid 13741:tid 140253004252928] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.714162 2020] [authz_core:debug] [pid 13741:tid 140253004252928] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.714448 2020] [authz_core:debug] [pid 13741:tid 140253004252928] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.714456 2020] [authz_core:debug] [pid 13741:tid 140253004252928] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.714465 2020] [core:info] [pid 13741:tid 140253004252928] [client 92.88.5.194:52585] AH00128: File does not exist: /var/www/html/fonts/RobotoMono-Regular.woff2
[Sat Feb 22 11:19:55.743133 2020] [authz_core:debug] [pid 13741:tid 140253063001856] mod_authz_core.c(809): [client 92.88.5.194:52582] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.743166 2020] [authz_core:debug] [pid 13741:tid 140253063001856] mod_authz_core.c(809): [client 92.88.5.194:52582] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.743456 2020] [authz_core:debug] [pid 13741:tid 140253063001856] mod_authz_core.c(809): [client 92.88.5.194:52582] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.743466 2020] [authz_core:debug] [pid 13741:tid 140253063001856] mod_authz_core.c(809): [client 92.88.5.194:52582] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.743484 2020] [core:info] [pid 13741:tid 140253063001856] [client 92.88.5.194:52582] AH00128: File does not exist: /var/www/html/elements/gr-app.js
[Sat Feb 22 11:19:55.749971 2020] [authz_core:debug] [pid 13742:tid 140252979074816] mod_authz_core.c(809): [client 92.88.5.194:52584] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.749994 2020] [authz_core:debug] [pid 13742:tid 140252979074816] mod_authz_core.c(809): [client 92.88.5.194:52584] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.750319 2020] [authz_core:debug] [pid 13742:tid 140252979074816] mod_authz_core.c(809): [client 92.88.5.194:52584] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.750328 2020] [authz_core:debug] [pid 13742:tid 140252979074816] mod_authz_core.c(809): [client 92.88.5.194:52584] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.750358 2020] [core:info] [pid 13742:tid 140252979074816] [client 92.88.5.194:52584] AH00128: File does not exist: /var/www/html/bower_components/webcomponentsjs/webcomponents-lite.js
[Sat Feb 22 11:19:55.750528 2020] [authz_core:debug] [pid 13742:tid 140252962289408] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.750542 2020] [authz_core:debug] [pid 13742:tid 140252962289408] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.750837 2020] [authz_core:debug] [pid 13742:tid 140252962289408] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.750847 2020] [authz_core:debug] [pid 13742:tid 140252962289408] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.750857 2020] [core:info] [pid 13742:tid 140252962289408] [client 92.88.5.194:52583] AH00128: File does not exist: /var/www/html/fonts/Roboto-Medium.woff2
[Sat Feb 22 11:19:55.751075 2020] [authz_core:debug] [pid 13741:tid 140253029431040] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.751095 2020] [authz_core:debug] [pid 13741:tid 140253029431040] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.751394 2020] [authz_core:debug] [pid 13741:tid 140253029431040] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.751401 2020] [authz_core:debug] [pid 13741:tid 140253029431040] mod_authz_core.c(809): [client 92.88.5.194:52585] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.751411 2020] [core:info] [pid 13741:tid 140253029431040] [client 92.88.5.194:52585] AH00128: File does not exist: /var/www/html/elements/gr-app.html
[Sat Feb 22 11:19:55.753488 2020] [authz_core:debug] [pid 13741:tid 140253177865984] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.753513 2020] [authz_core:debug] [pid 13741:tid 140253177865984] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.753821 2020] [authz_core:debug] [pid 13741:tid 140253177865984] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.753830 2020] [authz_core:debug] [pid 13741:tid 140253177865984] mod_authz_core.c(809): [client 92.88.5.194:52587] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.753841 2020] [core:info] [pid 13741:tid 140253177865984] [client 92.88.5.194:52587] AH00128: File does not exist: /var/www/html/fonts/RobotoMono-Regular.woff
[Sat Feb 22 11:19:55.774199 2020] [authz_core:debug] [pid 13742:tid 140252953896704] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Sat Feb 22 11:19:55.774222 2020] [authz_core:debug] [pid 13742:tid 140252953896704] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Sat Feb 22 11:19:55.774483 2020] [authz_core:debug] [pid 13742:tid 140252953896704] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of Require valid-user : granted
[Sat Feb 22 11:19:55.774488 2020] [authz_core:debug] [pid 13742:tid 140252953896704] mod_authz_core.c(809): [client 92.88.5.194:52583] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 11:19:55.774513 2020] [core:info] [pid 13742:tid 140252953896704] [client 92.88.5.194:52583] AH00128: File does not exist: /var/www/html/elements/gr-app.js

我不明白问题是什么。要求有效用户说拒绝然后授予。

请注意,如果我使用http://myIp:8087/访问 gerri它可以工作,那么它就是 apache 问题。

编辑

这是如果我删除块会发生什么:

[Sat Feb 22 16:55:37.968466 2020] [authz_core:debug] [pid 14944:tid 139858966181632] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:37.968544 2020] [authz_core:debug] [pid 14944:tid 139858966181632] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:37.968602 2020] [proxy:debug] [pid 14944:tid 139858966181632] mod_proxy.c(1229): [client 92.88.5.194:58216] AH01143: Running scheme http handler (attempt 0)
[Sat Feb 22 16:55:37.968633 2020] [proxy:debug] [pid 14944:tid 139858966181632] proxy_util.c(2153): AH00942: HTTP: has acquired connection for (localhost)
[Sat Feb 22 16:55:37.968644 2020] [proxy:debug] [pid 14944:tid 139858966181632] proxy_util.c(2206): [client 92.88.5.194:58216] AH00944: connecting http://localhost:8087/ to localhost:8087
[Sat Feb 22 16:55:37.968873 2020] [proxy:debug] [pid 14944:tid 139858966181632] proxy_util.c(2415): [client 92.88.5.194:58216] AH00947: connected / to localhost:8087
[Sat Feb 22 16:55:37.969003 2020] [proxy:debug] [pid 14944:tid 139858966181632] proxy_util.c(2881): AH02824: HTTP: connection established with [::1]:8087 (localhost)
[Sat Feb 22 16:55:37.969029 2020] [proxy:debug] [pid 14944:tid 139858966181632] proxy_util.c(3048): AH00962: HTTP: connection complete to [::1]:8087 (localhost)
[Sat Feb 22 16:55:37.983453 2020] [proxy:debug] [pid 14944:tid 139858966181632] proxy_util.c(2168): AH00943: http: has released connection for (localhost)
[Sat Feb 22 16:55:37.983715 2020] [deflate:debug] [pid 14944:tid 139858966181632] mod_deflate.c(853): [client 92.88.5.194:58216] AH01384: Zlib: Compressed 1480 to 491 : URL /gerrit/
[Sat Feb 22 16:55:38.044226 2020] [authz_core:debug] [pid 14944:tid 139859033323264] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.044285 2020] [authz_core:debug] [pid 14944:tid 139859033323264] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.044315 2020] [core:info] [pid 14944:tid 139859033323264] [client 92.88.5.194:58216] AH00128: File does not exist: /var/www/html/fonts/RobotoMono-Regular.woff2
[Sat Feb 22 16:55:38.047825 2020] [authz_core:debug] [pid 14945:tid 139859033323264] mod_authz_core.c(809): [client 92.88.5.194:58217] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.047849 2020] [authz_core:debug] [pid 14945:tid 139859033323264] mod_authz_core.c(809): [client 92.88.5.194:58217] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.047861 2020] [core:info] [pid 14945:tid 139859033323264] [client 92.88.5.194:58217] AH00128: File does not exist: /var/www/html/fonts/RobotoMono-Regular.woff
[Sat Feb 22 16:55:38.054823 2020] [authz_core:debug] [pid 14944:tid 139859016537856] mod_authz_core.c(809): [client 92.88.5.194:58221] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.054843 2020] [authz_core:debug] [pid 14944:tid 139859016537856] mod_authz_core.c(809): [client 92.88.5.194:58221] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.054854 2020] [core:info] [pid 14944:tid 139859016537856] [client 92.88.5.194:58221] AH00128: File does not exist: /var/www/html/styles/fonts.css
[Sat Feb 22 16:55:38.055009 2020] [authz_core:debug] [pid 14944:tid 139858949396224] mod_authz_core.c(809): [client 92.88.5.194:58219] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.055021 2020] [authz_core:debug] [pid 14944:tid 139858949396224] mod_authz_core.c(809): [client 92.88.5.194:58219] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.055030 2020] [core:info] [pid 14944:tid 139858949396224] [client 92.88.5.194:58219] AH00128: File does not exist: /var/www/html/fonts/Roboto-Regular.woff2
[Sat Feb 22 16:55:38.055241 2020] [authz_core:debug] [pid 14945:tid 139858932610816] mod_authz_core.c(809): [client 92.88.5.194:58218] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.055274 2020] [authz_core:debug] [pid 14945:tid 139858932610816] mod_authz_core.c(809): [client 92.88.5.194:58218] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.055282 2020] [core:info] [pid 14945:tid 139858932610816] [client 92.88.5.194:58218] AH00128: File does not exist: /var/www/html/styles/main.css
[Sat Feb 22 16:55:38.055421 2020] [authz_core:debug] [pid 14944:tid 139858932610816] mod_authz_core.c(809): [client 92.88.5.194:58220] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.055433 2020] [authz_core:debug] [pid 14944:tid 139858932610816] mod_authz_core.c(809): [client 92.88.5.194:58220] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.055441 2020] [core:info] [pid 14944:tid 139858932610816] [client 92.88.5.194:58220] AH00128: File does not exist: /var/www/html/fonts/Roboto-Regular.woff
[Sat Feb 22 16:55:38.064991 2020] [authz_core:debug] [pid 14944:tid 139858924218112] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.065008 2020] [authz_core:debug] [pid 14944:tid 139858924218112] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.065019 2020] [core:info] [pid 14944:tid 139858924218112] [client 92.88.5.194:58216] AH00128: File does not exist: /var/www/html/fonts/Roboto-Medium.woff2
[Sat Feb 22 16:55:38.075418 2020] [authz_core:debug] [pid 14945:tid 139858924218112] mod_authz_core.c(809): [client 92.88.5.194:58217] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.075449 2020] [authz_core:debug] [pid 14945:tid 139858924218112] mod_authz_core.c(809): [client 92.88.5.194:58217] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.075462 2020] [core:info] [pid 14945:tid 139858924218112] [client 92.88.5.194:58217] AH00128: File does not exist: /var/www/html/fonts/Roboto-Medium.woff
[Sat Feb 22 16:55:38.078811 2020] [authz_core:debug] [pid 14944:tid 139858915825408] mod_authz_core.c(809): [client 92.88.5.194:58221] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.078826 2020] [authz_core:debug] [pid 14944:tid 139858915825408] mod_authz_core.c(809): [client 92.88.5.194:58221] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.078835 2020] [core:info] [pid 14944:tid 139858915825408] [client 92.88.5.194:58221] AH00128: File does not exist: /var/www/html/bower_components/webcomponentsjs/webcomponents-lite.js
[Sat Feb 22 16:55:38.078945 2020] [authz_core:debug] [pid 14944:tid 139858907432704] mod_authz_core.c(809): [client 92.88.5.194:58220] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.078956 2020] [authz_core:debug] [pid 14944:tid 139858907432704] mod_authz_core.c(809): [client 92.88.5.194:58220] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.078964 2020] [core:info] [pid 14944:tid 139858907432704] [client 92.88.5.194:58220] AH00128: File does not exist: /var/www/html/elements/gr-app.js
[Sat Feb 22 16:55:38.079062 2020] [authz_core:debug] [pid 14944:tid 139858899040000] mod_authz_core.c(809): [client 92.88.5.194:58219] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.079079 2020] [authz_core:debug] [pid 14944:tid 139858899040000] mod_authz_core.c(809): [client 92.88.5.194:58219] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.079086 2020] [core:info] [pid 14944:tid 139858899040000] [client 92.88.5.194:58219] AH00128: File does not exist: /var/www/html/elements/gr-app.html
[Sat Feb 22 16:55:38.103156 2020] [authz_core:debug] [pid 14944:tid 139858890647296] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.103177 2020] [authz_core:debug] [pid 14944:tid 139858890647296] mod_authz_core.c(809): [client 92.88.5.194:58216] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.103196 2020] [core:info] [pid 14944:tid 139858890647296] [client 92.88.5.194:58216] AH00128: File does not exist: /var/www/html/fonts/RobotoMono-Regular.woff2
[Sat Feb 22 16:55:38.113410 2020] [authz_core:debug] [pid 14944:tid 139858882254592] mod_authz_core.c(809): [client 92.88.5.194:58221] AH01626: authorization result of Require all granted: granted
[Sat Feb 22 16:55:38.113426 2020] [authz_core:debug] [pid 14944:tid 139858882254592] mod_authz_core.c(809): [client 92.88.5.194:58221] AH01626: authorization result of <RequireAny>: granted
[Sat Feb 22 16:55:38.113436 2020] [core:info] [pid 14944:tid 139858882254592] [client 92.88.5.194:58221] AH00128: File does not exist: /var/www/html/elements/gr-app.js

标签: apache

解决方案


推荐阅读