我正在尝试使用http baisc身份验证配置gerrit,我的httpd配置是
<VirtualHost *:8081>
ServerName localhost
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user
</Location>
ProxyPass / http://localhost:8081/
</VirtualHost>
我的gerrit.config是
[gerrit]
basePath = git
canonicalWebUrl = http://localhost:8081/
[database]
type = mysql
hostname = localhost
database = reviewdb
username = gerrit
[auth]
type = HTTP
[sendemail]
smtpServer = localhost
smtpUser = gerrit
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = proxy-http://*:8081/
[cache]
directory = cache
我不知道我哪里出错,但访问http://x.x.x.x:8081说
The HTTP server did not provide the username in the Authorization header when it forwarded the request to Gerrit Code Review.
If the HTTP server is Apache HTTPd, check the proxy configuration includes an authorization directive with the proper location, ensuring it ends with '/':
我的gerrit在inbuild码头计数器上运行,我的操作系统是6.4,
我哪里出错。?
答案 0 :(得分:5)
确定, 实际上我在端口8081上创建了一个虚拟主机,而我的码头(与gerrit一起出现)也在听同一个端口,我的配置几乎保持不变,但这些是额外的步骤: -
listen <port-no>
文件中添加行http conf
将虚拟主机更改为您的端口号 现在您的虚拟主机设置在端口8082上
<VirtualHost *:8082>
ServerName localhost
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user
</Location>
ProxyPass / http://localhost:8081/
将规范网址更改为端口8082(以便将其重定向到同一端口)
享受。!!
答案 1 :(得分:3)
Gerrit希望提供身份验证。使用HTTP身份验证时,它不允许匿名访问。
要使其工作,您需要在根目录进行身份验证,并且您的位置块应如下所示:
<Location "/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user
</Location>
答案 2 :(得分:1)
您的配置存在一些问题:
这是我推荐的配置:
<VirtualHost *:80>
ServerName localhost
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user
</Location>
AllowEncodedSlashes On
ProxyPass /r http://localhost:8081/r nocanon
</VirtualHost>
当然,不要忘记修改gerrit.config,canonicalWebUrl是你在地址栏中输入的内容,而不是apache用来查找gerrit的内容。
[gerrit]
basePath = git
canonicalWebUrl = http://localhost:8082/r
要防止显示apache默认页面,请在根文件夹中添加index.php,将您的浏览器重定向到子路径:
<?php
header('Location: http://localhost:8082/r/');
?>