<p>My Kubernetes application uses an Ingress to proxy requests to different servers, according to the URL given: I want a fanout configuration. I want the URLs of the requests <strong>not to be rewritten</strong> when forwarded to the servers. How do I do that?</p>

<p>I want all the <code>/api</code> URLs forwarded to the <code>be</code> service, and all others forwarded to the <code>fe</code> service. But I want the URLs forwarded unchanged.
For example</p>

<ul>
<li>a request for <code>/api/users</code> should be forwarded to the <code>be</code> service as a request for <code>/api/users</code>.</li>
<li>a request for <code>/foo</code> should be forwarded to the <code>fe</code> service as a request for <code>/foo</code>.</li>
</ul>

<p>My current Ingress resource is like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  ...
spec:
  ...
  rules:
    - host: ...
    - http:
        paths:
          - path: /api
            backend:
              serviceName: be
              servicePort: 8080
          - path: /
            backend:
              serviceName: fe
              servicePort: 80
</code></pre>

<p>but that does not work; it gives 404 Not Found for requests.</p>

<p>The Kubernetes ingress isn't rewriting your request URLs, the ingress controller is doing this (whatever you happen to be using). For instance, if your ingress controller is Nginx, you can control this behavior with <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">annotations</a> on the ingress.</p>
