Lor*_*ein 6 virtualhost sni jenkins apache-2.2
我正在设置一个 Jenkins 服务器,在 Apache 后面的 Tomcat 下运行。我正在使用 SNI 使用带有 SSL 的虚拟主机,所以我可以在https://jenkins.example.com访问它,并在http://www.example.com上提供其他服务。
我已经启动并运行了,但是当我单击“管理 Jenkins”时,它告诉我您的反向代理设置似乎已损坏。
请注意,我使用的是自签名 SSL 证书,并且 jenkins.example.com 不是默认的虚拟主机。
相关的 apache 配置如下所示:
<VirtualHost *:80>
ServerName jenkins.example.com
Redirect / https://jenkins.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName jenkins.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/jenkins.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/jenkins.example.com.key
<Location />
AuthType Digest
AuthName "Jenkins"
AuthUserFile "/etc/htpasswords"
Require valid-user
</Location>
ProxyRequests Off
ProxyPreserveHost On
<Proxy http://localhost:8080*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyPassReverse / https://jenkins.example.com
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
如果我做:
curl --user "username:password" --digest -k https://jenkins.example.com/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test -L
Run Code Online (Sandbox Code Playgroud)
然后我看到输出:
<div/>
Run Code Online (Sandbox Code Playgroud)
如果我使用调试运行 wget,那么我会在某个时候看到 wget 获取指向 http 而不是 https 的指针,不确定为什么会发生这种情况或是否相关,但它确实正确重定向:
---response begin---
HTTP/1.1 302 Moved Temporarily
Date: Tue, 17 Jan 2012 19:47:16 GMT
Server: Apache-Coyote/1.1
Location: http://jenkins.example.com/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test-for-reverse-proxy-setup
Content-Length: 0
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/plain
Run Code Online (Sandbox Code Playgroud)
我在 Ubuntu 11.04、Apache 2.2.17、Tomcat 6.0.28、Jenkins 1.448 上运行。
我在您的配置中看到的一个问题是:
ProxyPassReverse / https://jenkins.example.com
Run Code Online (Sandbox Code Playgroud)
应该:
ProxyPassReverse / https://jenkins.example.com/
Run Code Online (Sandbox Code Playgroud)
似乎该服务正在发送http://而不是https://位置标头(可能是因为您从 Apache 到其侦听器的连接在 localhost 侦听器上未加密),在这种情况下,您需要添加:
ProxyPassReverse / http://jenkins.example.com/
Run Code Online (Sandbox Code Playgroud)
那么,什么是可能发生的是目前API调用失败,因为它得到一个http://在地址Location:重定向的报头(这是在错过了联合国的翻译ProxyPassReverse,因为它不是http)。
它发送请求到该位置,并得到另一重定向响应,从你的<VirtualHost *:80>。他们的有效性检查器知道这是不对的和错误的,同时curl遵循另一个重定向并获得有效的响应。
添加ProxyPassReverse了http://上述这应该可以解决问题,如果我是对的。