<p>I have two ASP.NET Core applications app1 and app2. Inside these apps I have routes as defined in this simplified code:</p>
<p>app1:</p>
<pre><code>endpoints.MapGet(&quot;/app1ep1&quot;, async context =&gt;
{
    await context.Response.WriteAsync(&quot;x1&quot;);
});

endpoints.MapGet(&quot;/app1ep2&quot;, async context =&gt;
{
    await context.Response.WriteAsync(&quot;x2&quot;);
});
</code></pre>
<p>app2:</p>
<pre><code>endpoints.MapGet(&quot;/app2ep1&quot;, async context =&gt;
{
    await context.Response.WriteAsync(&quot;y1&quot;);
});

endpoints.MapGet(&quot;/app2ep2&quot;, async context =&gt;
{
    await context.Response.WriteAsync(&quot;y2&quot;);
});
</code></pre>
<p>I am trying to define without success an ingress rule that will apply the following routings:</p>
<ul>
<li>myhost.com/app1/app1ep1 will route to the service app1 and then internal routing to ep1</li>
<li>myhost.com/app2/app2ep1 will route to the service app2 and then internal routing to ep1</li>
<li>the point goes on, please comment if extra clarification required</li>
</ul>
<p>My ingress rule:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: myhost.com
    http:
      paths:
      - path: /app1
        pathType: Prefix
        backend:
          service:
            name: myservice1
            port:
              number: 80
      - path: /app2
        pathType: Prefix
        backend:
          service:
            name: myservice2
            port:
              number: 80
</code></pre>
<p>Actual result is that the services are found but I get 404 error. In other words, browsing to myhost.com/app1/app1ep1 (or any other combination) routes to the service (myservice1) but then internal route is lost.
Is there any way to fix this?
Thanks for helping</p>
<p>Edit:
I am noticing some other problem. I tried to reduce the problem to a single service. So my ingress now looks like:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: myhost.com
    http:
      paths:
      - path: /app1
        pathType: Prefix
        backend:
          service:
            name: myservice1
            port:
              number: 80
</code></pre>
<p>Also added this controller to the &quot;myservice1&quot; app:</p>
<pre><code>endpoints.MapGet(&quot;/&quot;, async context =&gt;
{
    await context.Response.WriteAsync(&quot;x&quot;);
});
</code></pre>
<p>Going to myhost.com/app1 returns 404. That again means that the app is found but the route isn't found in the application (although I defined &quot;/&quot; route).
Maybe this information can help discover the problem</p>

Ohad
<p>I have solved this issue with the following ingress rule:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
  - host: myhost.com
    http:
      paths:
      - path: /app1(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: myservice1
            port:
              number: 80
      - path: /app2(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: myservice2
            port:
              number: 80
</code></pre>
