带有HTTP身份验证的Gerrit会引发配置错误

时间:2014-05-15 08:33:20

标签: apache gerrit http-basic-authentication

我已经阅读了一些这方面的帖子,但它并没有说明我的案件究竟出了什么问题。我在gerrit中创建了一个名为/etc/apache2/sites-available/的新配置文件,并在/etc/apache2/sites-enabled/中创建了一个符号链接。该文件看起来像这样。

   <VirtualHost *:80>
        ProxyRequests Off
        ProxyVia Off
        ProxyPreserveHost On

        ServerName localhost

        <Location "/r/login/">
            AuthType Basic
            AuthName "Gerrit Code Review"
            AuthBasicProvider file
            AuthUserFile /home/gerrit/passwd/passwords
            Require valid-user
        </Location>

        AllowEncodedSlashes On
        ProxyPass /r/ http://localhost:8900/r/ nocanon
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
</VirtualHost>

我使用htpasswd -c /home/gerrit/passwd/passwords <user-name>创建了密码文件。

我的gerrit配置看起来像这样。

[gerrit]
        basePath = git
[database]
        type = mysql
        hostname = localhost
        database = reviewdb
        username = gerrit
[auth]
        type = HTTP
[sendemail]
        smtpServer = localhost
        smtpUser = example@example.com
[container]
        user = gerrit
        javaHome = /usr/lib/jvm/java-6-openjdk/jre
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = proxy-http://localhost:8900/r/
[cache]
        directory = cache

我并不完全理解配置文件的所有部分。重新启动gerrit并重新加载config / restarting apache2服务器后,我尝试访问http://localhost:8900/r/,重定向到http://localhost:8900/r/login/并说

  

HTTP服务器未在授权中提供用户名   将请求转发给Gerrit Code Review时的标题。

     

如果HTTP服务器是Apache HTTPd,请检查代理配置   包括具有适当位置的授权指令,确保   它以'/'结尾:

请指出任何明显的错误!!感谢

2 个答案:

答案 0 :(得分:0)

您必须通过http://localhost/r/(端口80)访问它。否则,Apache代理不会对您进行身份验证。

答案 1 :(得分:0)

我的gerrit版本 v2.16.4 。最初,我也得到了相同的“配置错误”页面,但是在做了以下更改之后 1. vi /etc/httpd/conf/httpd.conf

changed VirtualHost *:82 and add Listen 82  

2。配置/home/gerrit2/gerrit_site/etc/gerrit.config

[gerrit]  
  basePath = git  
  serverId = 41b98026-b39d-4c6c-bb9e-88b89a304727  
  canonicalWebUrl = http://your-gerrit-ip:8088/  
[database]  
  type = mysql  
  hostname = yczc5  
  database = reviewdb  
  username = gerrit2  
[index]  
  type = LUCENE  
[auth]  
  type = HTTP  
[receive]  
  enableSignedPush = false  
[sendemail]  
  smtpServer = yczc5  
[container]  
  user = gerrit2  
  javaHome = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64/jre  
[sshd]  
  listenAddress = *:29418  
[httpd]  
  listenUrl = proxy-http://*:8088/  
[cache]  
  directory = cache  

以上错误已解决,您应该检查 [gerrit] [httpd]