I am trying to get Nexus3 to run behind Nginx.
Nginx is used as a reverse proxy and for SSL termination. When accessing the /nexus path through Nginx, I get multiple errors such as "Operation failed as server could not be reached" and "unable to detect which node you are connected to". Accessing the Nexus UI without going through Nginx works perfectly which lead me to think the error is on Nginx.
NginX Config File
location /nexus {
proxy_pass http://localhost:8081/nexus/;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
resolver 8.8.8.8 8.8.4.4 ipv6=off;
}
If you have more than one hosted repository, create another Nginx reverse proxy for it, then aggregate them using a parent Nginx reverse proxy that forwards the request according to certain criteria (.i.e: Host header). All Nexus repositories must have consistent configuration of authentication: Either all require authentication, or all don't.
The following Nginx configuration file is for a reverse proxy without the need to expose connector ports from nexus : docker pull cregistry.example.com/myimage lets Nginx forward the request to "docker-group" docker push cregistry.example.com/myimage lets Nginx forward the request to "docker-hosted"
Nginx is used as a reverse proxy and for SSL termination. When accessing the /nexus path through Nginx, I get multiple errors such as "Operation failed as server could not be reached" and "unable to detect which node you are connected to".
Nexus hostname is "nexus.example.com" Your nginx (with the nginx.conf of this gist) will run for example under cregistry.example.com The following Nginx configuration file is for a reverse proxy without the need to expose connector ports from nexus :
If you access the service using http://localhost:8081/nexus
, it works.
Your current configuration is using proxy_pass
to change the URI /nexus
to /nexus/
. Generally, it is advisable to have a trailing /
on both the location
and proxy_pass
URIs or on neither of them.
For example:
location /nexus {
proxy_pass http://localhost:8081/nexus;
...
}
In fact, you so not need to modify the URI at all, so you can remove it from the proxy_pass
directive altogether.
The following should be equivalent, but more efficient:
location /nexus {
proxy_pass http://localhost:8081;
...
}
By default, the Host
header is set to the value of the proxy_pass
directive (i.e. locatlhost:8081
), which is known to work correctly. You may find the your statement proxy_set_header Host $host:$server_port;
is unnecessary.
See this document for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With