<p>I have a frontend application built with React and backend on nodejs.
Both have a separate Docker image and therefore a separate deployment on k8s (gce).</p>
<p>Each deployment has a corresponding k8s service, let's say <code>fe-serice</code> and <code>be-service</code>.</p>
<p>I am trying to setup an Ingress so that both services are exposed on a single domain in the following manner:</p>
<ul>
<li><code>/api/*</code> - are routed to <code>be-service</code></li>
<li>everything else is routed to <code>fe-service</code></li>
</ul>
<p>Here is my yaml file:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: my-host
    http:
      paths:
      - path: /*
        backend:
          serviceName: fe-service
          servicePort: 80
      - path: /api/*
        backend:
          serviceName: be-service
          servicePort: 5000
</code></pre>
<p>Here is what I get with curl:</p>
<p><code>curl [ip] --header &quot;Host: my-host&quot;</code> -&gt; React app (as expected)</p>
<p><code>curl [ip]/foo --header &quot;Host: my-host&quot;</code> -&gt; nginx 404 (why?)</p>
<p><code>curl [ip]/api --header &quot;Host: my-host&quot;</code> -&gt; nginx 404 (why?)</p>
<p><code>curl [ip]/api/ --header &quot;Host: my-host&quot;</code> -&gt; nodejs app</p>
<p><code>curl [ip]/api/foo --header &quot;Host: my-host&quot;</code> -&gt; nodejs app</p>
<p>As far as I can see a part with <code>api/</code> works fine, but I can't figure out everything else, I tried different combinations with/without wildcards, but it still does not work in the way I want it to work.</p>
<p>What am I missing? Is this even possible?
Thanks in advance!</p>

<p>I can't explain why /foo is not working </p>

<p>But</p>

<p>/api/* does not cover /api, it covers only anything after /api/</p>
