<p>I have issue with url paths.</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: backend
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /v1/$1
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
spec:
  tls:
  - hosts:
    - backend.example.com
    secretName: backend-example-com
  rules:
  - host: backend.example.com
    http:
      paths:
      - path: /v9/anonymous/set-data/?(.*)
        backend:
          serviceName: backend2
          servicePort: 80
      - path: /v9/?(.*)
        backend:
          serviceName: backend1
          servicePort: 80
</code></pre>
<p>In service I'm getting</p>
<pre><code>/v1/
</code></pre>
<p>but I should get</p>
<pre><code>/v1/anonymous/set-data/foo/bar/
</code></pre>
<p>I need to rewrite all versions in path to <code>/v1/</code>
And some request should go to backend1, but some specific paths to backend2</p>

ivanovUA
<p>Found solution</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: backend
  annotations:
#    nginx.ingress.kubernetes.io/rewrite-target: /v1/$1
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^/v9/?(.*)$ /v1/$1 break;
spec:
  tls:
  - hosts:
    - backend.example.com
    secretName: backend-example-com
  rules:
  - host: backend.example.com
    http:
      paths:
      - path: /v9/anonymous/set-data/?(.*)
        backend:
          serviceName: backend2
          servicePort: 80
      - path: /v9/?(.*)
        backend:
          serviceName: backend1
          servicePort: 80
</code></pre>
<p>Everything rewrites to <code>/v1/</code> and working as should</p>
