<p>I have this base url <code>api.example.com</code></p>
<p>So, <code>ingress-nginx</code> will get the request for <code>api.example.com</code> and it should do follow things.</p>
<p>Forward <code>api.example.com/customer</code> to <code>customer-srv</code></p>
<p>It doesn't work, it forwards whole mtach to customer-srv i.e. <code>/customer/requested_url</code></p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
spec:
  rules:
    - host: api.example.in
      http:
        paths:
          - path: /customer/?(.*)
            pathType: Prefix
            backend:
              service:
                name: customer-srv
                port:
                  number: 3000
</code></pre>
<p>I tried using rewrite annotation but that doesn't work either however this worked but this is not I want to achieve.</p>
<pre><code>    paths:
      - path: /?(.*)
        pathType: Prefix
        backend:
          service:
            name: customer-srv
            port:
              number: 3000
</code></pre>
<p>For example,</p>
<p><code>api.example.com/customer</code> should go to <code>http://localhost:3000</code> not <code>http://localhost:3000/customer</code></p>

confusedWarrior
<p>Here is the yaml I used:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: api.example.in
      http:
        paths:
          - path: /customer/?(.*)
            pathType: Prefix
            backend:
              service:
                name: customer-srv
                port:
                  number: 3000
</code></pre>
<p>For test purpouses I created an echo server:</p>
<pre><code>kubectl run --image mendhak/http-https-echo customer
</code></pre>
<p>And then a service:</p>
<pre><code>kubectl expose po customer --name customer-srv --port 3000 --target-port 80
</code></pre>
<p>I checked igress ip:</p>
<pre><code>$ kubectl get ingress
NAME                  CLASS    HOSTS               ADDRESS          PORTS   AGE
ingress-service       &lt;none&gt;   api.example.in      192.168.39.254   80      3m43s
</code></pre>
<p>And I did a curl to check it:</p>
<pre><code>curl 192.168.39.254/customer/asd -H &quot;Host: api.example.in&quot;           
{
  &quot;path&quot;: &quot;/asd&quot;,
  &quot;headers&quot;: {
    &quot;host&quot;: &quot;api.example.in&quot;,

...
}
</code></pre>
<p>Notice that the echo server echoed back a path that it received, and sice it received a path that got rewritten from <code>/customer/asd</code> to <code>/asd</code> it shows this exectly path (/asd).</p>
<p>So as you see this does work.</p>
