nginx 后面的 GitBlit 在登录/注销操作上不断添加多余的 /gitblit/

nginx 后面的 GitBlit 在登录/注销操作上不断添加多余的 /gitblit/

我在服务器上的 Tomcat 中设置了 Gitblit。我希望它可以通过 访问https://git.mydomain.tld。到目前为止,这很有效,但它有一个小问题。每当用户登录 Gitblit 时,它都会重定向到,https://git.mydomain.tld/gitblit/;jsessionid=...并且 Tomcat 返回 404(当然)。

我在 nginx 中添加了 gitblit_ssl 配置,如下所示:

server {
    listen   git.mydomain.tld:443; ## listen for ipv4; this line is default and implied
    server_name git.mydomain.tld;
    root        /var/www;

    # left out SSL-Configuration

    location / {
        proxy_pass          http://localhost:8081/gitblit/;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    Host $host;
    }

    location /gitblit {
        proxy_pass          http://localhost:8081/gitblit/;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    Host $host;
    }
}

Apache Tomcat 设置为处理端口 8081 上的 HTTP 流量,并且 gitblit 部署到webapps/gitblit

我最后添加的“location /gitblit”是为了尝试捕获不必要的/gitblit,但没有帮助。

除了登录时出现故障外,其他一切都按预期运行,但登录后,我必须从 URL 中删除不必要的 /gitblit 才能使用 Web 界面。

答案1

在这个 gitlib git问题我发现你添加了

<Host name="gitblit" appBase="webapps" unpackWARs="true" autoDeploy="true"
          xmlValidation="true" xmlNamespaceAware="false">
    <Context path="" docBase="gitblit" reloadable="true" privileged="true"
          antiResourceLocking="false" anitJARLocking="false"/>
</Host>

您应该已经在中定义了 localhost 主机conf/server.xml

因此它使你的 gitlib 成为根应用程序http://gitblit:8081/例如,hostname 是服务器的 DNS。因此我猜您的情况是 localhost。

完成后,您可以像这样调整 nginx 中的代理配置:

location / {
    proxy_pass          http://localhost:8081/;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    Host $host;
}

我在 tomcat 7 上安装并设置了 gitlib (war),并且它可以运行。

相关内容