Nexus Repository Manager behind traefik issue

I am trying to run nexus as a docker service in our docker swarm, but although the service is up and running, the web page simply shows “initializing” with a few mini image icons.
We are using traefik as our proxy/load balancer also running in the swarm and using traefik labels to redirect traffic based on the url to the correct running service on the backend. I have attached the stack file that we are using to spin up the service. Traefik listens for the path sandbox.ui.docker.bah.com/nexus and forwards to the nexus container on port 8081, but for some reason we receive the screenshot showed below. I have tried changing the port the nexus app is running on to 8080 and adding the X-Forwarded-Proto:https label to traefik, but am not sure what the actual issue is.
I am able to run nexus as a standalone container and see the ui, but we want to run it as a service behind traefik.

The issue seems to be that the images, gifs, and js for the welcome page are not loading and are sending a 404 not found error. I think this is because they are looking at sandbox.ui.docker.bah.com/pathtoimages instead of /nexus/pathtoimages and I am not sure how to fix this.

I submitted a support ticket with sonotype support and they recommended I change the web app context path

ie. sonatype-work/nexus3/etc/nexus.properties should contain

nexus-webapp-context=/nexus

If anyone has any experience running nexus behind traefik or has an idea of what might be wrong your assistance would be greatly appreciated. Thanks.

That is correct. In general, when running behind a reverse proxy, like apache httpd, nginx, or traefik, the web context in traefik should match that of the backend Nexus application.

You will likely also need to set other http headers. We have examples for apache and nginx at Run Behind a Reverse Proxy.

Also, as mentioned, the webapp context can be changed via nexus.properties. More nexus.properties settings are described at Configuring the Runtime Environment

p.s. the setting for Nexus 3.x is named nexus-context-path. the setting for Nexus 2.x is named nexus-webapp-context-path

5 Likes

I had to deal with the exact same issue.

The Nexus container has an environment variable set up in the nexus.properties file that looks like the following:
nexus-context-path=/${NEXUS_CONTEXT}

So in my docker-compose I had to add:

nexus:
image: sonatype/nexus3:3.9.0
environment:
NEXUS_CONTEXT: “nexus”
labels:
- traefik.enable=true
- traefik.frontend.rule=PathPrefix:/nexus
- traefik.port=8081

It worked after that.