项目场景:
Gerrit服务器搭建完成后,用户可以通过Git
上传代码至gerrit web供代码审核人员审核。
问题描述
此时,代码审核人员在gerrit web上审核时,点开代码文件,无法查看代码diff。显示错误An error occurred You might have not enough privileges. Error 404 (Not Found): Not found.
原因分析:
gerrit2.6+以上的版本,使用了apache作为反向代理,需要进行一些额外的参数设置。在httpd.conf
文件中配置。
<VirtualHost xxx>
ServerName xxx
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Require all granted
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Gerrit Code Review"
Require valid-user
AuthUserFile xxx
</Location>
AllowEncodedSlashes On
ProxyPass / xxx/ nocanon
</VirtualHost>
解决方案:
在ProxyPass后面加上nocanon
。
提示:如果不能显示中文注释,可将源文件编码格式改为
UTF-8
。方法为用记事本打开文件,选择另存为,底下编码栏选择UTF-8
,保存再提交至gerrit即可。