这两天在折腾敏捷开发,安装gerrit,折腾惨了。郁闷啊,主要是apache的配置文件不熟悉,好多配置都是瞎配置。导致到处出错。
系统:
root@pm:/var/www# uname -a
Linux pm 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
root@pm:/var/www#
Configuration Error
Check the HTTP server's authentication settings.
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 '/':
修改apache的ports.conf 文件,在里面添加对应的端口。
root@pm:/etc/apache2# cat ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
NameVirtualHost *:8090
Listen 80
Listen 8090
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
Listen 443
root@pm:/etc/apache2#
Check the HTTP server's authentication settings.
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 '/':
ServerName kona-gerrit
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
Order deny,allow
Allow from all
AuthType Basic
AuthName "Gerrit Code Review"
Require valid-user
...
ProxyPass / http://.../
解决:
是你的代理配置没有配好。
该死的,就这个错误和下面这个错误,害的我整了整整2天。郁闷死我了。
gerrit 重定向循环
解决:在gerrit的配置文件中增加:
root@pm:/data/app/git/review_site# cat etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://192.168.16.118:8090/ #这一句明确了,就可以解决重定向的错误。注意,此处是填写apache中配的代理地址,而不是gerrit的listenUrl地址。
apache2的配置:
ServerName 10.0.16.8
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
Order deny,allow
Allow from all
AuthType Basic
AuthName "Gerrit Code Review"
Require valid-user
AuthBasicProvider file
AuthUserFile /data/app/git/review_site/etc/passwd
ProxyPass / http://127.0.0.1:8080/
#ProxyPassReverse / http://127.0.0.1:8080/
#SetEnv force-proxy-request-1.0.1
#SetEnv proxy-nokeepalive 1
ports.conf文件:
root@pm:~/bin# cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
NameVirtualHost *:8090
Listen 80
Listen 8090
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
Listen 443
root@pm:~/bin#
root@pm:~/bin# cat /data/app/git/review_site/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://192.168.16.118:8090/
[database]
type = MYSQL
hostname = localhost
database = reviewdb
username = git
[auth]
type = HTTP
[sendemail]
smtpServer = localhost
[container]
user = git
javaHome = /usr/lib/jvm/jdk1.6.0_37/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
root@pm:~/bin#
http://stackoverflow.com/questions/18179728/set-up-gerrit-with-http-authentication
ProxyPass与ProxyPassReverse及ProxyPassMatch的概述
Gerrit简易安装入门
Ubuntu下安装Gerrit
Ubuntu 建立 Gerrit服务器 配置文件
烤鸭的gerrit使用说明