我刚刚完成 Sonatype Nexus 3.2.1-01 的安装,并且正在尝试使用 Jenkins 作业和 Nexus Artifact Uploader 2.9 插件发布一些工件。
上传开始正常:
100 % completed (572 kB / 572 kB).
但随后它会引发错误:
Return code is: 502, ReasonPhrase:Bad Gateway.
Jenkins 和 Nexus 服务器都在反向代理后面运行,我认为这是问题的根源。
Apache 日志似乎表明该请求尚未得到 Nexus 的回复:
[Thu Apr 06 18:50:46.128569 2017] [proxy:error] [pid 10327] (32)Broken pipe:
[client some_ip:57928] AH01084: pass request body failed to 0.0.0.0:8081 (0.0.0.0)
[Thu Apr 06 18:50:46.128649 2017] [proxy_http:error] [pid 10327] [client some_ip:57928] AH01097: pass request body failed to 0.0.0.0:8081 (0.0.0.0) from some_ip ()
这是我在 Apache 中为 Sonar 服务器配置的 VirtualHost 配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName some.website.com
ServerAlias nsome.website.com
DocumentRoot /srv/www/nexus/public_html/
ErrorLog /srv/www/nexus/logs/error.log
CustomLog /srv/www/nexus/logs/access.log combined
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8081/
ProxyPassReverse / http://0.0.0.0:8081/
ProxyPassReverse / https://some.website.com/
SSLCertificateFile /etc/letsencrypt/live/some.website.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/some.website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/some.website.com/chain.pem
</VirtualHost>
</IfModule>
我尝试添加以下内容(如其他答案中所述),但没有帮助:
1)禁用对 SSL 证书的检查(尽管这些证书有效):
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
2)强制请求标头:
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
3)在 ProxyPass 行中设置超时和保持活动选项:
ProxyPass / http://0.0.0.0:8081/ retry=1 acquire=3000 timeout=600 Keepalive=On
答案1
最后,错误 502(网关错误)与问题的根本原因无关。快照版本发布的工件上列出的版本不符合 Nexus 政策,这触发了错误。