【问题标题】:Gerrit installation on CentOS doesn't work在 CentOS 上安装 Gerrit 不起作用
【发布时间】:2013-10-05 14:14:02
【问题描述】:

我已经在我的 centos 服务器上安装了 gerrit,但是我的身份验证有问题。我想为给定组中的 centos 用户授予身份验证权限。基本上,gerrit 组中的每个用户都应该可以使用其密码登录。

但是,当我访问 gerrit 链接时,当我收到以下消息时会重定向到 gerrit:8081/login:

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

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

你有什么提示为什么这不起作用?

/etc/httpd/conf/httpd.conf 文件的 VirtualHost 部分如下所示:

<VirtualHost gerrit:8081>
    ServerName gerrit

    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 /etc/passwd
      Require valid-user
    </Location>


    AllowEncodedSlashes On
       ProxyPass /r http://localhost:8081/r nocanon
</VirtualHost>

还有 gerrit.config 文件:

[gerrit]
        basePath = /repos
        canonicalWebUrl = http://freshattitude.eu:8081/
[database]
        type = mysql
        hostname = localhost
        database = gerrit
        username = gerrit
[auth]
        type = HTTP
        emailFormat = {0}@example.com
[sendemail]
        smtpServer = localhost
        smtpUser = root
[container]
        user = gerrit
        javaHome = /usr/java/jdk1.7.0_25/jre
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = http://*:8081/
[cache]
        directory = cache

【问题讨论】:

    标签: linux git centos gerrit


    【解决方案1】:

    你犯了一些错误。一方面,你必须设置gerrit.config

    httpd.listenUrl = proxy-http://127.0.0.1:8081/
    

    让 Gerrit 知道它前面的代理。

    此外,您的 Apache 虚拟主机必须监听不同的端口(至少当两个服务在同一台服务器上运行时)。事实上,我想知道你是如何同时开始的 ;-)

    所以为端口 80 设置一个 apache vhost,而不是为端口 8081。然后用户将连接到http://freshattitude.eu/

    最后,再次在gerrit.config 中,您必须修复您的canonicalWebUrl 并删除:8081,因为您使用的是代理,这就是您告诉Gerrit 其指向外部世界的URL 的方式是。

    我认为你应该通过Gerrit docs on reverse proxy config 一次。

    之后,您将看到 Gerrit 仅在 localhost 端口 8081 上侦听,而 apache 则在端口 80 上侦听(当然,您可能想要使用 SSL,然后使用 gerrit.config 中的 proxy-https 变体)。

    【讨论】:

      【解决方案2】:

      这是运行并帮助您的配置https://groups.google.com/forum/?hl=en#!topic/repo-discuss/qwQxy_izXzo

      感谢和问候,
      阿洛克·萨克

      【讨论】:

      • 请注意,此配置不再对 Gerrit 2.6+ 有效,因为需要“AllowEncodedSlashes On”和“ProxyPass ... nocanon”!否则打开更改屏幕时会出现 404 错误。
      【解决方案3】:

      据我所知,Gerrit 要求在使用 HTTP 身份验证时在请求标头中提供身份验证详细信息。因此,当使用这种匿名访问时是不可能的。 因此,我将Location "/login/" 更改为Location "/",然后总是在转到 Gerrit 之前完成身份验证。它有效,我可以忍受它。

      这实际上可能是一些回归错误,它悄悄潜入某处,但我是如何让它工作的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-01
        • 1970-01-01
        • 2016-06-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-31
        • 2012-11-02
        相关资源
        最近更新 更多