Sonatype Nexus : NXRM

Helm Charts

URL Rewrite : //nexus

Request → App

To configure Nexus Repository Manager (NXRM) running in Kubernetes with Ingress-Nginx, while ensuring the /nexus context path is preserved, follow these steps:

1. Update Nexus Configuration (Set Context Path)

Since NXRM requires /nexus in its backend URLs, ensure the nexus-context-path is set correctly in the Pod.

Option A: Using nexus.properties (ConfigMap or Volume Mount)

  1. Create a ConfigMap with nexus.properties:

    apiVersion: v1
    kind: ConfigMap
    metadata:
     name: nexus-config
    data:
     nexus.properties: |
       nexus-context-path=/nexus  # Keep `/nexus` for backend compatibility
    
  2. Mount it in the Nexus Pod (in your Deployment/StatefulSet):

    volumes:
     - name: nexus-config
       configMap:
         name: nexus-config
    volumeMounts:
     - mountPath: /nexus-data/etc/nexus.properties
       subPath: nexus.properties
       name: nexus-config
    

Option B: Use Environment Variable (For NXRM 3.30+)

If your Nexus version supports it, override the context path via:

   env:
     - name: NEXUS_CONTEXT_PATH
       value: /nexus

2. Configure Ingress-Nginx

Use rewrite annotations to ensure /nexus is added to backend requests while hiding it from users.

Example Ingress YAML

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nexus-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /nexus/$2
    nginx.ingress.kubernetes.io/proxy-redirect-from: "http://$host/nexus/"
    nginx.ingress.kubernetes.io/proxy-redirect-to: "http://$host/"
spec:
  ingressClassName: nginx
  rules:
  - host: nexus.lime.lan
    http:
      paths:
      - path: /(.*)
        pathType: Prefix
        backend:
          service:
            name: nexus-service  # Your Nexus Service name
            port:
              number: 8081      # Nexus default port

Key Annotations Explained:


3. Verify Nexus Pod & Service

Ensure your Nexus Service is correctly targeting the Pod:

apiVersion: v1
kind: Service
metadata:
  name: nexus-service
spec:
  ports:
  - port: 8081
    targetPort: 8081
  selector:
    app: nexus

4. Test the Setup

  1. Access Nexus at http://nexus.lime.lan/ (no /nexus visible).
  2. Check Backend Requests:

    kubectl logs -l app.kubernetes.io/name=ingress-nginx --tail=100
    

    Look for requests to /nexus/... (rewrite working).


Troubleshooting


Final Notes