我刚刚完成了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)断管:
[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 some@email.com
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
答案 0 :(得分:3)
最后,错误502(坏网关)与问题的根本原因无关。要为快照版本发布的工件上列出的版本不符合Nexus策略,这是触发错误。
答案 1 :(得分:0)
就我而言,这是从Nexus2到Nexus3的升级问题:此处的组件网址已从https://nexus.yourcompany.com/content/repositories/releases更改为 到https://nexus.yourcompany.com/repository/releases。
答案 2 :(得分:0)
我遇到了同样的问题,因为我的python脚本跳过了基本身份验证。强制执行后,问题得以解决。
这很奇怪,因为上传tar.gz可以正常工作,但是上传zip却给我502错误。
答案 3 :(得分:0)
将此添加到您的pom文件
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>