<p>I already have on my Ingress a lot of domains with so many paths as this is an environment with many microservices.</p>
<p>How can I edit my ingress in some way that when someone access to path <code>/servicex</code> it gets instead <code>/serviceb</code> for example</p>
<p>My current ingress is as follow (for simplicity I'm omitting some path from other hosts)</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: main-ingress
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/proxy-body-size: &quot;100m&quot;
    nginx.ingress.kubernetes.io/max-worker-connections: &quot;0&quot;
    nginx.ingress.kubernetes.io/max-worker-open-files: &quot;0&quot;
    nginx.ingress.kubernetes.io/client-header-buffer-size: &quot;4k&quot;
spec:
  tls:
  - hosts:
    - subdomain-a.domain.com
    - subdomain-b.domain.com
    - subdomain-c.domain.com
    - subdomain-d.domain.com
    - subdomain-e.domain.com
    secretName: domain-com-secret
  rules:
  - host: subdomain-a.domain.com
    http:
      paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: default-service
              port:
                number: 80
        - path: /serviceb
          pathType: Prefix
          backend:
            service:
              name: b-service
              port:
                number: 80
        - path: /servicec
          pathType: Prefix
          backend:
            service:
              name: c-service
              port:
                number: 80
        - path: /serviced
          pathType: Prefix
          backend:
            service:
              name: d-service
              port:
                number: 80
        - path: /servicee
          pathType: Prefix
          backend:
            service:
              name: e-service
              port:
                number: 80
        - path: /servicee
          pathType: Prefix
          backend:
            service:
              name: e-service
              port:
                number: 80
        - path: /servicef
          pathType: Prefix
          backend:
            service:
              name: f-service
              port:
                number: 80
        - path: /serviceg
          pathType: Prefix
          backend:
            service:
              name: g-service
              port:
                number: 80

  - host: subdomain-b.domain.com
    &lt; tons of other rules &gt;

  - host: subdomain-c.domain.com
    &lt; tons of other rules &gt;

  - host: subdomain-d.domain.com
    &lt; tons of other rules &gt;

  - host: subdomain-e.domain.com
    &lt; tons of other rules &gt;
</code></pre>
<p>In other words we want to get access to the <code>/serviceb</code> if the user enters any of the following:</p>
<ul>
<li><a href="https://subdomain-a.domain.com/serviceb" rel="nofollow noreferrer">https://subdomain-a.domain.com/serviceb</a> -&gt; nothing to do here as we already have this covered</li>
<li><a href="https://subdomain-a.domain.com/servicex" rel="nofollow noreferrer">https://subdomain-a.domain.com/servicex</a> -&gt; this should be transformed into <a href="https://subdomain-a.domain.com/serviceb" rel="nofollow noreferrer">https://subdomain-a.domain.com/serviceb</a></li>
</ul>
<p>I have reviewed the rewrite option but its seems to me that if I add the annotation <code>nginx.ingress.kubernetes.io/rewrite-target: /servicex/$2</code> for example and then try to do something like:</p>
<pre><code>- path: /serviceb(/|$)(.*)
          pathType: Prefix
          backend:
            service:
              name: serviceb
              port:
                number: 80
</code></pre>
<p>Won't work because first, we already have that path taken and second I think that the annotation will apply to the whole thing and this will damage all the other routes.</p>
<p>Thanks in advance, any help would be appreciated</p>

William Añez
<p>NGINX ingress is almost the same as in the NGINX. In most of the cases, the built-in annotation helps you to configure the standard operation in NGINX.</p>
<p>However, if you have encountered any kind of customization like your case, you are also free to input the server or configuration snippet through these two annotations.</p>
<p><code>nginx.ingress.kubernetes.io/server-snippet</code> and <code>nginx.ingress.kubernetes.io/configuration-snippet</code>.</p>
<p>Inside the snippet, you can do whatever you want like an ordinary NGINX.</p>
<p>Grabbing the configuration from your reply here for others' information.</p>
<pre><code>nginx.ingress.kubernetes.io/configuration-snippet: |-
  rewrite ^(/servicex)(.*) /serviceb$2 last; 
</code></pre>
