<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>That's a problem with nexus itself. Your ingress works as intended, and you cannot do more from this side.</p>
<p>The problem here is that nexus webpage, i.e. index.html, requests resources in such a way that it's looking at the wrong place. You can see this by opening the network tab and inspecting the request URL of the missing statics.</p>
<p>To see what I mean, let's examine the below HTML image tags.</p>
<pre class="lang-html prettyprint-override"><code>&lt;img id=&quot;1&quot; src=&quot;./statics/some-image.svg&quot; alt=&quot;some image&quot; /&gt;

&lt;img id=&quot;2&quot; src=&quot;/statics/some-image.svg&quot; alt=&quot;some image&quot; /&gt;
</code></pre>
<p>You can see that the first one, is using relative path, and would work with your configuration since the request URL would be relative to the location in the browser and then the nexus part gets stripped by the ingress controller.</p>
<p>However, the second one is using absolute path, so it will not have the nexus part in the request URL and the ingress controller will not be able to route it to the correct service.</p>
<p>This is a common problem when stripping path prefixes. It only works fully when the application you are serving when stripping a prefix is correctly configured.</p>
<p>In your case this means, checking the documentation of the services, if you have any way to influence this.</p>
<p>It may be more straight forward to route based on hostname instead of path. I.e  <code>nexus.myhost.com</code>. For that, you would need a domain and point the corresponding A records to your ingress services IP / use a wildcard record.</p>
