<p>I've installed nginx using <a href="https://helm.nginx.com/stable" rel="nofollow noreferrer">nginx-stable</a> helm chart and configured ingress rules as follows. Though it's working only for root path as follows,</p>

<pre><code>/user/login - working
/user/register - working
/foo/user/login - not working
/foo/user/register - not working
</code></pre>

<p>I've configured rewrite target as mentioned in the document <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/#examples" rel="nofollow noreferrer">ingress nginx rewrite</a> but couldn't make it to work. Not sure what I'm doing wrong.</p>

<pre><code> apiVersion: networking.k8s.io/v1beta1
 kind: Ingress
 metadata:
   name: foosrv-ingress
   annotations:
     kubernetes.io/ingress.class: nginx
     nginx.ingress.kubernetes.io/rewrite-target: /$2
     nginx.ingress.kubernetes.io/use-regex: true
     nginx.ingress.kubernetes.io/ssl-redirect: false
     nginx.ingress.kubernetes.io/enable-rewrite-log: true
 spec:
   rules:
   - http:
       paths:
       - path: /foo(/|$)(.*)
         backend:
           serviceName: foosrv-service
           servicePort: 5500
       - path: /
         backend:
           serviceName: foosrv-service
           servicePort: 5500
</code></pre>

<p>Apparently, It doesn't even identify /foo(/|$)(.*) path rule. I don't see any logs in the pod when calls to foo path and ingress return 404 as follows,</p>

<pre><code>192.168.65.3 - - [23/May/2020:12:40:30 +0000] "GET /user/login HTTP/1.1" 200 1685 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" "-"
192.168.65.3 - - [23/May/2020:12:40:34 +0000] "GET /foo/user/login HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" "-"
</code></pre>

MarkiE
<p>There are <a href="https://www.nginx.com/products/nginx/kubernetes-ingress-controller/#compare-versions" rel="nofollow noreferrer">two nginx ingress controllers</a> OSS and Plus.You have installed the Plus but you need to install the OSS one <a href="https://kubernetes.github.io/ingress-nginx/deploy/#using-helm" rel="nofollow noreferrer">here</a> because you are using <code>nginx.ingress.kubernetes.io</code> in the annotations.</p>

<pre><code>helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install my-release ingress-nginx/ingress-nginx
</code></pre>

<p>Edit: </p>

<p><code>nginx.ingress.kubernetes.io/use-regex: true</code> should be removed because there is no regex in the path and so it's not necessary.</p>
