Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus returns error 502 (Bad Gateway) when publishing artifacts

Tags:

jenkins

nexus

I've just completed the installation of Sonatype Nexus 3.2.1-01 and I'm trying to publish some artifacts using a Jenkins job and the Nexus Artifact Uploader 2.9 plugin.

The upload starts fine:

100 % completed (572 kB / 572 kB).

But then it throws the the error:

Return code is: 502, ReasonPhrase:Bad Gateway.

Both the Jenkins and Nexus servers run behind a reverse proxy which I believe are the source of the issue.

The Apache log seems to suggest that the request was not replied by 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 ()

This is my VirtualHost config in Apache for the Sonar server:

<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>

I've tried to add the following, as explained in other answers, but did not help:

1) Disabling the check on the SSL certificates (although these are valid):

SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off

2) Forcing the requests headers:

RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"

3) Settting the timeouts and keepalive options in the ProxyPass line:

ProxyPass / http://0.0.0.0:8081/ retry=1 acquire=3000 timeout=600 Keepalive=On
like image 278
Tedi Avatar asked Feb 04 '23 17:02

Tedi


1 Answers

At the end the error 502 (bad gateway) had nothing to do with the root cause of the problem. The version listed on the artifact to be published for the snapshot version did not comply with the Nexus policy and this was triggering the error.

like image 168
Tedi Avatar answered Feb 07 '23 09:02

Tedi