Invalid host. To browse Nexus, click here/. To use the Docker registry, point your client at when access to nexus in kubernetes

8/22/2020

I am using helm 3 to install nexus in kubernetes v1.18:

helm install stable/sonatype-nexus --name=nexus

and then expose nexus by using traefik 2.x to outside by using domian: nexus.dolphin.com. But when I using domain to access nexus servcie it give me this tips:

Invalid host. To browse Nexus, click here/. To use the Docker registry, point your client

and I have read this question, but It seem not suite for my situation. And this is my nexus yaml config now:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: nexus-sonatype-nexus
  namespace: infrastructure
  selfLink: /apis/apps/v1/namespaces/infrastructure/deployments/nexus-sonatype-nexus
  uid: 023de15b-19eb-442d-8375-11532825919d
  resourceVersion: '1710210'
  generation: 3
  creationTimestamp: '2020-08-16T07:17:07Z'
  labels:
    app: sonatype-nexus
    app.kubernetes.io/managed-by: Helm
    chart: sonatype-nexus-1.23.1
    fullname: nexus-sonatype-nexus
    heritage: Helm
    release: nexus
  annotations:
    deployment.kubernetes.io/revision: '1'
    meta.helm.sh/release-name: nexus
    meta.helm.sh/release-namespace: infrastructure
  managedFields:
    - manager: Go-http-client
      operation: Update
      apiVersion: apps/v1
      time: '2020-08-16T07:17:07Z'
      fieldsType: FieldsV1
    - manager: kube-controller-manager
      operation: Update
      apiVersion: apps/v1
      time: '2020-08-18T16:26:34Z'
      fieldsType: FieldsV1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sonatype-nexus
      release: nexus
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: sonatype-nexus
        release: nexus
    spec:
      volumes:
        - name: nexus-sonatype-nexus-data
          persistentVolumeClaim:
            claimName: nexus-sonatype-nexus-data
        - name: nexus-sonatype-nexus-backup
          emptyDir: {}
      containers:
        - name: nexus
          image: 'sonatype/nexus3:3.20.1'
          ports:
            - name: nexus-docker-g
              containerPort: 5003
              protocol: TCP
            - name: nexus-http
              containerPort: 8081
              protocol: TCP
          env:
            - name: install4jAddVmParams
              value: >-
                -Xms1200M -Xmx1200M -XX:MaxDirectMemorySize=2G
                -XX:+UnlockExperimentalVMOptions
                -XX:+UseCGroupMemoryLimitForHeap
            - name: NEXUS_SECURITY_RANDOMPASSWORD
              value: 'false'
          resources: {}
          volumeMounts:
            - name: nexus-sonatype-nexus-data
              mountPath: /nexus-data
            - name: nexus-sonatype-nexus-backup
              mountPath: /nexus-data/backup
          livenessProbe:
            httpGet:
              path: /
              port: 8081
              scheme: HTTP
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 30
            successThreshold: 1
            failureThreshold: 6
          readinessProbe:
            httpGet:
              path: /
              port: 8081
              scheme: HTTP
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 30
            successThreshold: 1
            failureThreshold: 6
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
        - name: nexus-proxy
          image: 'quay.io/travelaudience/docker-nexus-proxy:2.5.0'
          ports:
            - name: nexus-proxy
              containerPort: 8080
              protocol: TCP
          env:
            - name: ALLOWED_USER_AGENTS_ON_ROOT_REGEX
              value: GoogleHC
            - name: CLOUD_IAM_AUTH_ENABLED
              value: 'false'
            - name: BIND_PORT
              value: '8080'
            - name: ENFORCE_HTTPS
              value: 'false'
            - name: NEXUS_DOCKER_HOST
            - name: NEXUS_HTTP_HOST
            - name: UPSTREAM_DOCKER_PORT
              value: '5003'
            - name: UPSTREAM_HTTP_PORT
              value: '8081'
            - name: UPSTREAM_HOST
              value: localhost
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: nexus-sonatype-nexus
      serviceAccount: nexus-sonatype-nexus
      securityContext:
        fsGroup: 2000
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
status:
  observedGeneration: 3
  replicas: 1
  updatedReplicas: 1
  readyReplicas: 1
  availableReplicas: 1
  conditions:
    - type: Progressing
      status: 'True'
      lastUpdateTime: '2020-08-18T16:23:54Z'
      lastTransitionTime: '2020-08-18T16:23:54Z'
      reason: NewReplicaSetAvailable
      message: >-
        ReplicaSet "nexus-sonatype-nexus-79fd4488d5" has successfully
        progressed.
    - type: Available
      status: 'True'
      lastUpdateTime: '2020-08-18T16:26:34Z'
      lastTransitionTime: '2020-08-18T16:26:34Z'
      reason: MinimumReplicasAvailable
      message: Deployment has minimum availability.

why the domian could not access nexus by default? and what should I do to access nexus by domain?

-- Dolphin
kubernetes

1 Answer

8/25/2020

From the documentation you should set a property of the helm chart: nexusProxy.env.nexusHttpHost to nexus.dolphin.com

The docker image used here has a proxy that allows you to access the Nexus HTTP and Nexus Docker services by different domains, if you don't specify either then you get the behaviour you're seeing.

-- Mike Bryant
Source: StackOverflow