设置Apache反向代理tomcat的正确方法是什么(Jenkins,Sonar)

时间:2017-05-27 15:19:45

标签: apache tomcat ssl jenkins proxy

我们正在尝试为我们的软件工厂设置反向代理。我们可以设法将所有Atlassian套件放在反向代理下,但是却很难与Jenkins和Sonar这样做。

这是apache配置:

<VirtualHost *:443>
            SSLCertificateFile /etc/apache2/ssl/atoe.crt
            SSLCertificateKeyFile /etc/apache2/ssl/atoe.key
            SSLCertificateChainFile /etc/apache2/ssl/bundle.crt

            ProxyRequests Off
            ProxyPreserveHost On
            ProxyVia Off

            <Proxy *>
                    Order deny,allow
                    Require all granted
            </Proxy>
            <Proxy http://localhost:9010/jenkins*>
                Order deny,allow
                Allow from all
            </Proxy>

            ProxyPass /confluence http://localhost:8090/confluence
            ProxyPassReverse /confluence http://localhost:8090/confluence

            ProxyPass /bitbucket http://localhost:7990/bitbucket
            ProxyPassReverse /bitbucket http://localhost:7990/bitbucket

            ProxyPass / http://localhost:8095/
            ProxyPassReverse / http://localhost:8095/

            ProxyPass /sonarqube http://localhost:9000/sonarqube
            ProxyPassReverse /sonarqube http://localhost:9000/sonarqube
</VirtualHost>

Sonarqube和Jenkins都在Tomcat 7.0.69下运行。我在sonar.properties和/ etc / default / jenkins中更改了它们的上下文,设置了如上所示的正确上下文。当尝试通过代理连接到这些工具时,我收到错误404。

apache2的日志中没有提到任何内容。

我错过了什么吗?

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

好吧,似乎ProxyPass的顺序很重要。如果我们定义一个&#34; /&#34;,则必须在最后定义它,否则在此之后不会考虑任何内容。

在我们的案例中,我们有:

        ProxyPass /confluence http://localhost:8090/confluence
        ProxyPassReverse /confluence http://localhost:8090/confluence

        ProxyPass /bitbucket http://localhost:7990/bitbucket
        ProxyPassReverse /bitbucket http://localhost:7990/bitbucket

        ProxyPass / http://localhost:8095/
        ProxyPassReverse / http://localhost:8095/

        ProxyPass /sonarqube http://localhost:9000/sonarqube
        ProxyPassReverse /sonarqube http://localhost:9000/sonarqube

要使它工作,我们必须颠倒最后两个:

        ProxyPass /confluence http://localhost:8090/confluence
        ProxyPassReverse /confluence http://localhost:8090/confluence

        ProxyPass /bitbucket http://localhost:7990/bitbucket
        ProxyPassReverse /bitbucket http://localhost:7990/bitbucket

        ProxyPass /sonarqube http://localhost:9000/sonarqube
        ProxyPassReverse /sonarqube http://localhost:9000/sonarqube

        ProxyPass / http://localhost:8095/
        ProxyPassReverse / http://localhost:8095/