<p>I have this ingress in my server.</p>
<pre><code>kind: Ingress
metadata:
  name: mycompany-production
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/proxy-connect-timeout: &quot;30&quot;
    nginx.ingress.kubernetes.io/proxy-read-timeout: &quot;1800&quot;
    nginx.ingress.kubernetes.io/proxy-send-timeout: &quot;1800&quot;
spec:
  tls:
    - hosts:
        - ra2.mycompany.com.br
      secretName: ra-production-us2-certmanager-certificate
  rules:
    - host: ra2.mycompany.com.br
      http:
        paths:
          - path: /
            backend:
              serviceName: mycompany-production-deployment-nodeport
              servicePort: 80
          - path: /conteudo/
            backend:
              serviceName: seo-production-deployment-nodeport
              servicePort: 80
</code></pre>
<p>Actually, I expect that when I call ra2.mycompany.com.br/conteudo/health, for exemple, it touch the <strong>seo-production-deployment-nodeport/health</strong>, but it is going to <strong>seo-production-deployment-nodeport/conteudo/health</strong> receiving an 404 answer.</p>
<p>Looking in my ingress it does not seems to have an error. I just do not know why it's not &quot;cleaning&quot; the path as expected. The requests in normal <strong>/</strong> path is happening as expected.</p>

Jonathan Silva
<pre><code>      - path: /conteudo/
        backend:
          serviceName: seo-production-deployment-nodeport
          servicePort: 80
</code></pre>
<p>You're hitting <code>ra2.mycompany.com.br/conteudo/health</code> so of course it goes to this backend, as defined in the ingress rules.</p>
<p><code>nginx.ingress.kubernetes.io/rewrite-target: /</code>  just means that <code>/</code> in your url is forwarded to <code>/</code> in the backend matching the path set in rules, <strong>not</strong> matching the rule serving <code>/</code></p>
<p>To make it easy to understand: when you run a webserver which only serves everything under a <strong>base path</strong> let's say <code>/mysite</code> but you do not want the people using your ingress to see /mysite/ you set your <code>nginx.ingress.kubernetes.io/rewrite-target: /mysite</code> and if they hit <code>&lt;domain&gt;/foo</code> it actually goes to your backend <code>/mysite/foo</code></p>
