title: Rewriting Kubernetes services in an Nginx ingress
body: <p>I have multiple APIs all listening on '/api' and a web front end listening on '/'.</p>
  
  <p>Is there a way which I can write my ingress definition to rewrite the paths to something like the following?</p>
  
  <pre><code>/api/      -&gt; /api/ on service1
  /api2/api/ -&gt; /api/ on service2
  /api3/api/ -&gt; /api/ on service3
  /          -&gt; /     on service4
  </code></pre>
  
  <p>I know I can change the APIs to listen to something else but don't want to do that. I know I can also just rewrite all to /api/ and let service3 act as the default but there may be other services which need routing elsewhere in the future.</p>
  
  <p>I've heard that you could use multiple ingresses but I'm not sure how that would affect performance and if it's best practice to do so.</p>
  
  <p>Also, is there any way to debug which route goes to which service?</p>
  
  <p>Thanks,
  James</p>