我让 apache 在运行 https 的端口 443 上监听,并执行 ProxyPass 返回到同一服务器上的独立 jenkins 进程。
大部分时间,这都很好用,但经常会出现 502 错误。我可以通过加载 jenkin 的网页并让它自动刷新来重现此问题。通常在这样做的 20 分钟内,我就会得到一个 502 页面。
我在 Apache 中启用了调试日志记录,并在下面提供了我的配置 + apache 日志。Jenkins 日志没有显示任何内容(就像它从未收到过请求一样)。
我需要更多指示来追踪这个问题(并最终解决)。
Apache/2.2.3 Jenkins 版本 1.451
<Location />
ProxyPass http://jenkins.example.com:8080/
ProxyPassReverse http://jenkins.example.com:8080/
</Location>
/usr/lib/jvm/jre-1.6.0/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --daemon --httpPort=8080 --ajp13Port=8009 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
我自己收到错误:
192.168.186.207 - - [13/Mar/2013:09:23:16 -0400] "GET /?auto_refresh=true HTTP/1.1" 502 473
[Wed Mar 13 09:23:16 2013] [info] Initial (No.1) HTTPS request received for child 10 (server jenkins.example.com:443)
[Wed Mar 13 09:23:16 2013] [debug] mod_proxy_http.c(56): proxy: HTTP: canonicalising URL //jenkins.example.com:8080/
[Wed Mar 13 09:23:16 2013] [debug] proxy_util.c(1505): [client 192.168.186.207] proxy: http: found worker http://jenkins.example.com:8080/ for http://jenkins.example.com:8080/?auto_re
fresh=true, referer: https://jenkins.example.com/?auto_refresh=true
[Wed Mar 13 09:23:16 2013] [debug] mod_proxy.c(986): Running scheme http handler (attempt 0)
[Wed Mar 13 09:23:16 2013] [debug] mod_proxy_http.c(1982): proxy: HTTP: serving URL http://jenkins.example.com:8080/?auto_refresh=true
[Wed Mar 13 09:23:16 2013] [debug] proxy_util.c(2007): proxy: HTTP: has acquired connection for (jenkins.example.com)
[Wed Mar 13 09:23:16 2013] [debug] proxy_util.c(2063): proxy: connecting http://jenkins.example.com:8080/?auto_refresh=true to jenkins.example.com:8080
[Wed Mar 13 09:23:16 2013] [debug] proxy_util.c(2189): proxy: connected /?auto_refresh=true to jenkins.example.com:8080
[Wed Mar 13 09:23:16 2013] [error] [client 192.168.186.207] (104)Connection reset by peer: proxy: error reading status line from remote server jenkins.example.com, referer: https://jenkins.example.com/?auto_refresh=true
[Wed Mar 13 09:23:16 2013] [debug] mod_proxy_http.c(1484): [client 192.168.186.207] proxy: NOT Closing connection to client although reading from backend server jenkins.example.com failed., r
eferer: https://jenkins.example.com/?auto_refresh=true
[Wed Mar 13 09:23:16 2013] [error] [client 192.168.186.207] proxy: Error reading from remote server returned by /, referer: https://jenkins.example.com/?auto_refresh=true
[Wed Mar 13 09:23:16 2013] [debug] proxy_util.c(2025): proxy: HTTP: has released connection for (jenkins.example.com)
[Wed Mar 13 09:23:16 2013] [debug] ssl_engine_kernel.c(1823): OpenSSL: Write: SSL negotiation finished successfully
[Wed Mar 13 09:23:16 2013] [info] [client 192.168.186.207] Connection closed to child 10 with standard shutdown (server jenkins.example.com:443)
[Wed Mar 13 09:23:17 2013] [info] [client 192.168.186.207] Connection to child 7 established (server jenkins.example.com:443)
答案1
“502” 表示后端服务器有问题,而不是 Apache 有问题。您还可以在日志中看到以下内容:
[Wed Mar 13 09:23:16 2013] [error] [client 192.168.186.207] (104)Connection reset by peer: proxy: error reading status line from remote server jenkins.example.com, referer: https://jenkins.example.com/?auto_refresh=true
是你的 Jenkins 服务器挂在了 apache 服务器上。试试看直接在 Jenkins 实例(端口 8080)上执行此操作是否也会出现此问题。