每次配置 gerrit 需要用反向代理来实现auth_basic_user_file,以前用apache 进行配置,但不喜欢 apache 要换成 nginx,结果换成 nginx 之后,登录后打开project页报错“The page you requested was not found, or you do not have permission to view this page”

    <Location /login/>
        AuthType Basic
        AuthName "Gerrit Code Review"
        Require valid-user
        AuthUserFile /home/myname/gerrit/etc/passwords
    </Location>
    ProxyPass / http://127.0.0.1:8080/ nocanon

改成 nginx 之后配置

server{
       listen 80;
       server_name  localhost;
       index index.html;
       auth_basic "Gerrit Code Review";
       auth_basic_user_file /diskc/rd/gerrit/etc/passwords;

       location /
       {
               proxy_pass http://127.0.0.1:8080;
       }
}

报错原因:
“proxy_pass http://127.0.0.1:8080;”时,不会把“http://xxxx/projects/xxx%2Fxxx/config”中的 %2F 转义,所以能成功,而配置成“proxy_pass http://127.0.0.1:8080/;”后 %2F 会被转义,因此返回 404。
参考地址:
https://blog.csdn.net/zzhongcy/article/details/130492402

posted on 2023-12-06 15:33  步孤天  阅读(355)  评论(0编辑  收藏  举报