Gerrit使用httpd反向代理认证
1. 修改selinux
[root@CentOS ~]# vim /etc/selinux/config
//修改selinux
SELINUX=disabled
[root@CentOS ~]# reboot
//重启生效
2. 安装相关软件
[root@CentOS ~]# yum -y install git lrzsz java
java-devel httpd
[root@CentOS ~]# vim /etc/profile //修改配置文件 增加java
export
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/bin
export JRE_HOME=$JAVA_HOME/jre
export
CLASSPATH=$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$CLASSPATH
[root@CentOS bin]# source /etc/profile //刷新配置文件
[root@CentOS ~]# java -version //验证是否成功
3.修改httpd配置文件
[root@CentOS conf]# vim
/etc/httpd/conf.d/gerrit.conf //添加gerrit反向代理配置
<VirtualHost *>
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 /gerrit.passwd
Require valid-user
</Location>
AllowEncodedSlashes On
ProxyPass /
http://127.0.0.1:8081/
</VirtualHost>
[root@CentOS bin]# vim /etc/httpd/conf/httpd.conf
//httpd监听端口修改
默认为80 修改为 Listen 880
创建http认证用户
touch /gerrit.passwd
htpasswd
/gerrit.passwd "admin"
systemctl start httpd //启动httpd
4. 登陆gerrit 安装
[gerrit@CentOS ~]$ java -jar
gerrit-2.14.3.war init -d ~/gerrit_test //全部默认设置,稍后修改配置文件
Authentication method [openid/?]: http
//此处输入http,其余全部默认回车
[root@CentOS bin]# vim
/root/gerrit-test/etc/gerrit.config //修改配置文件
[gerrit]
basePath = git
serverId =
1ca64609-8313-4b3a-b9b7-185ffc3501af
canonicalWebUrl =
http://192.168.109.130:880
[database]
type =
h2
database = /root/gerrit-test/db/ReviewDB
[index]
type = LUCENE
[auth]
type =
HTTP
[receive]
enableSignedPush = false
[sendemail]
smtpServer = localhost
[container]
user = root
javaHome =
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl =proxy-http://*:8081/
[cache]
directory = cache
7.防火墙放行端口
firewall-cmd --zone=public --add-port=880/tcp
--permanent
firewall-cmd --zone=public --add-port=8081/tcp
--permanent
firewall-cmd --zone=public --add-port=29418/tcp
--permanent
firewall-cmd --reload //重新加载防火墙策略
[root@CentOS ~]# /root/gerrit-test/bin/gerrit.sh start //启动gerrit
[root@CentOS ~]# netstat -ltnp 查看监听状态