我正在Apache服务器后面运行两项服务:Jenkins(端口8080)和SonarQube(端口9000)。
我的Apache配置看起来像这样:
<VirtualHost *:80>
ServerName server
Redirect permanent / https://server.domain.com/
</VirtualHost>
<VirtualHost *:80>
ServerName server.domain.com
Redirect permanent / https://server.domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName server.domain.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
ProxyPass /jenkins http://localhost:8080/jenkins nocanon
ProxyPassReverse /jenkins http://localhost:8080/jenkins
ProxyPassReverse /jenkins http://server.domain.com/jenkins
ProxyPassReverse /jenkins https://server.domain.com/jenkins
ProxyPass /sonar http://localhost:9000/sonar nocanon
ProxyPassReverse /sonar http://localhost:9000/sonar
AllowEncodedSlashes NoDecode
ProxyRequests Off
ProxyPreserveHost On
<Proxy http://localhost:8080/*>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
除了Jenkins抱怨此消息外,一切似乎都工作正常:反向代理设置似乎已损坏。
当我运行Jenkins提供的ReverseProxySetupMonitor测试时,错误消息表明未正确设置带有反向代理的内容,因为不会将https替换为https:
$ curl -iLk -e https://server.domain.com/jenkins/manage https://server.domain.com/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test
[...]
404 http://server.domain.com/jenkins/manage vs. https://server.domain.com/jenkins/manage
[...]
这仅在我在服务器上启用SSL(现在正在使用自签名证书)之后出现。
问题: 如何解决反向代理设置,让詹金斯感到高兴?奖励积分,提供有关如何改善apache配置文件的提示。
我已经检查了以下两个相关问题:
sudo a2enmod headers
,否则我会得到Invalid command 'RequestHeader'