<p>I need to service gitlab, nexus and jupyterhub based on URL using one open port using k8s ingress.</p>
<p>If the path is written as &quot;/&quot; when create ingress, it works normally, but if you write &quot;/nexus&quot; like this, a problem occurs during the redirection process.</p>
<p>Have any of you solved the same problem? Please help.</p>
<p><a href="https://i.stack.imgur.com/9h1HM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9h1HM.png" alt="enter image description here" /></a></p>
<p>my ingress.yaml as below</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  creationTimestamp: &quot;2022-04-06T05:56:40Z&quot;
  generation: 7
  name: nexus-ing
  namespace: nexus
  resourceVersion: &quot;119075924&quot;
  selfLink: /apis/extensions/v1beta1/namespaces/nexus/ingresses/nexus-ing
  uid: 4b4f97e4-225e-4faa-aba3-6af73f69c21d
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - backend:
          serviceName: nexus-service
          servicePort: 8081
        path: /nexus(/|$)(.*)
        pathType: ImplementationSpecific
status:
  loadBalancer:
    ingress:
    - ip: 172.30.1.87
</code></pre>

<p>I solve this problem by myself</p>
<ol>
<li>I edited my pc hosts file</li>
</ol>
<pre><code>172.30.1.87     nexus.k8s.io
172.30.1.87     gitlab.k8s.io
</code></pre>
<ol start="2">
<li>I edited each Ingress in same service namespace</li>
</ol>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
  namespace: nexus
spec:
  ingressClassName: nginx
  rules:
  - host: nexus.k8s.io
    http:
      paths:
      - backend:
          serviceName: nexus-service
          servicePort: 8081
        path: /
status:
  loadBalancer:
    ingress:
    - ip: 172.30.1.87
</code></pre>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: gitlab-ingress
  namespace: gitlab
spec:
  ingressClassName: nginx
  rules:
  - host: gitlab.k8s.io
    http:
      paths:
      - backend:
          serviceName: gitlab-webservice
          servicePort: 8181
        path: /
status:
  loadBalancer:
    ingress:
    - ip: 172.30.1.87
</code></pre>
<ol start="3">
<li>connect test
ingress Hostname + ingress Controller Nodeport</li>
</ol>
<p><a href="https://i.stack.imgur.com/v2nYv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v2nYv.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/tU4e9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tU4e9.png" alt="enter image description here" /></a></p>
