我正在尝试设置 gerrit HTTP 身份验证。我正在阅读gerrit http authentication的文档,该文档简要介绍了如何设置 apache,但我究竟应该在哪里放置这段代码并配置 apache tomcat?
否则,我研究并发现了用于 http 身份验证的“siteminder”;我应该改用它吗?
我的要求是我在自定义系统中有自己的一组用户帐户,并且我需要我的每个用户帐户都能够与 gerrit 交互,所以我认为 http 将允许自定义创建/复制每个用户帐户。
我正在尝试设置 gerrit HTTP 身份验证。我正在阅读gerrit http authentication的文档,该文档简要介绍了如何设置 apache,但我究竟应该在哪里放置这段代码并配置 apache tomcat?
否则,我研究并发现了用于 http 身份验证的“siteminder”;我应该改用它吗?
我的要求是我在自定义系统中有自己的一组用户帐户,并且我需要我的每个用户帐户都能够与 gerrit 交互,所以我认为 http 将允许自定义创建/复制每个用户帐户。
我花了一段时间才弄清楚这一点。
Tomcat 已安装并经过测试。
然后我把gerrit war文件复制过来,放到tomcat/webapps中。然后从tomcat管理器 http://[host]:8080/manager/ 我安装了它(通过点击开始按钮)
然后我不得不安装mysql J Connector。基本上从 Mysql 下载它并将 jar 文件复制到 tomcat/lib
接下来我在 tomcat/webapps/gerrit/META-INF 中创建了一个名为 Context.xml 的文件
<Context>
<Resource name="jdbc/ReviewDb" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="****" password="******" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/reviewdb"/>
</Context>
因为我在守护进程中使用了充气城堡,所以我不得不将 .jar 文件从原始安装复制到 tomcat/webapps/gerrit/WEB-INF/lib
然后我设法启动了gerrit,看看它是否有效。尝试访问 http://[host]:8080/gerrit 这应该会给您一个来自 gerrit 的关于错误 Apache conf 的错误。
比我像这样重新配置我的 apache 虚拟主机。所以我用http://gerrit/gerrit 访问 gerrit
然后在将您的请求传递到 tomcat 服务器之前使用 http auth。
<VirtualHost *:80>
ServerAdmin adrian@iceweasel
ServerName gerrit
ServerAlias gerrit
ErrorLog "logs/error_log"
CustomLog "logs/access_log" vcommon
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /gerrit/login/>
AuthType Basic
AuthName "Gerrit Code Review"
AuthUserFile /rddata/www/gerrit/users
AuthGroupFile /rddata/www/gerrit/groups
Require group review
Order Deny,Allow
Allow from all
</Location>
ProxyPass /gerrit/ http://127.0.0.1:8080/gerrit/
</VirtualHost>
试试这个(不需要tomcat)
初始化一个新项目
java -jar gerrit.war init -d review
等/gerrit.config
[gerrit]
...
canonicalWebUrl = http://hostname:9091/
...
[httpd]
listenUrl = http://*:9090/
...
apache的虚拟主机配置
Listen 9091
<VirtualHost *:9091>
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /login/>
AuthType Basic
AuthName "Gerrit Code Review"
AuthUserFile /path/to/gerrit-users
Require valid-user
Order Deny,Allow
Allow from all
</Location>
ProxyPass / http://127.0.0.1:9090/
</VirtualHost>
我知道这是一个旧线程,但我提供了关于 serverfault 的教程,用于在 tomcat 下设置 Gerrit。如果你还有兴趣,这里是:
https://serverfault.com/questions/383573/how-do-i-install-gerrit-under-tomcat-with-ldap