<p>i have tomcat backend service running on kubernetes cluster try  to rewrite using ingress with path /blob/api/v1/test-backend &gt; /api/v1/test-backend so
the configuration now is running so can hit to xx.somedomain.com/blob/api/v1/test-backend and i want change to xx.somedomain.com/api/v1/test-backend with rewrites</p>
<p>my basic ingress</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-blob
  namespace: blob-test
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
spec:
  tls:
  - hosts:
    - xx.somedomain.com
    secretName: cert-key
  rules:
  - host: xx.somedomain.com
    http:
      paths:
      - path: /blob/
        backend:
          serviceName: blob-service
          servicePort: 8080
      - path: /
        backend:
          serviceName: web-service
          servicePort: 80
</code></pre>
<p>and this is yaml for rewrite /blob/</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-blob
  namespace: blob-test
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
  - hosts:
    - xx.somedomain.com
    secretName: cert-key
  rules:
  - host: xx.somedomain.com
    http:
      paths:
      - path: /blob/api/v1/some-backend
        backend:
          serviceName: blob-service
          servicePort: 8080
</code></pre>
<p>when i test with api tester like talend is got 405 error</p>

<p>Try this</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /something(/|$)(.*)
</code></pre>
<p>For example, the ingress definition above will result in the following rewrites:</p>
<pre><code>rewrite.bar.com/something rewrites to rewrite.bar.com/
rewrite.bar.com/something/ rewrites to rewrite.bar.com/
rewrite.bar.com/something/new rewrites to rewrite.bar.com/new
</code></pre>
<p>Refer : <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a></p>
