<p>Usually ingress rewrite target works as follows:</p>

<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /
</code></pre>

<p>This will rewrite the target of your service names as they are in the root directory. So if I have this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: demo-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  tls:
  rules:
    http:
      paths:
      - path: /
        backend:
          serviceName: front-main
          servicePort: 80
      - path: /api
        backend:
          serviceName: back-main
          servicePort: 80
</code></pre>

<p>My services are going to receive data as they are in <code>/</code>. However, I would like for my service <code>front-main</code> to send root <code>/</code> and for the server <code>back-main</code> to send <code>/someotherpath/</code>. How can I do this?</p>

<p>Is there something like the following line?</p>

<pre><code>nginx.ingress.kubernetes.io/rewrite-target: "front-main: / ; back-main: /someotherpath"
</code></pre>

<p>I don't seem to find the answer in the documentation.</p>

<p>Unfortunately, Ingress based on free version of Nginx do not have that feature.</p>
<p>But, if you can use <a href="https://github.com/nginxinc/kubernetes-ingress" rel="nofollow noreferrer">Nginx Plus based Ingress</a>, you can do it by annotation.</p>
<p>Here is an <a href="https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/rewrites" rel="nofollow noreferrer">example</a> from official repo:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: cafe-ingress
  annotations:
    nginx.org/rewrites: &quot;serviceName=tea-svc rewrite=/;serviceName=coffee-svc rewrite=/beans/&quot;
spec:
  rules:
  - host: cafe.example.com
    http:
      paths:
      - path: /tea/
        backend:
          serviceName: tea-svc
          servicePort: 80
      - path: /coffee/
        backend:
          serviceName: coffee-svc
          servicePort: 80
</code></pre>
<p>Below are the examples of how the URI of requests to the <code>tea-svc</code> are rewritten (Note that the /tea requests are redirected to /tea/).</p>
<pre><code>/tea/ -&gt; /
/tea/abc -&gt; /abc
</code></pre>
<p>Below are the examples of how the URI of requests to the <code>coffee-svc</code> are rewritten (Note that the /coffee requests are redirected to /beans/).</p>
<pre><code>/coffee/ -&gt; /beans/
/coffee/abc -&gt; /beans/abc
</code></pre>
