<p>I try to run my web application with two backend containers.</p>
<ul>
<li>/ should be routed to the frontend container</li>
<li>everything starting with /backend/ should go to the backend container.</li>
</ul>
<p>So fare, so good, but now the css &amp; js files from the /backend are not loaded because the files are referenced in the HTML file like &quot;/bundles/css/style.css&quot; and now ingress controller route this request to the frontend container instead of to the backend.</p>
<p>How can I fix this issue?</p>
<ul>
<li>Can I fix that with a smart Ingress rule?</li>
<li>Do I need to update the app root of the backend container?</li>
</ul>
<p>Here my Ingress resource</p>
<pre><code>apiVersion: networking.k8s.io/v1 # for versions before 1.14 use extensions/v1beta1
kind: Ingress
metadata:
 name: example
 namespace: example
 annotations:
   kubernetes.io/ingress.class: &quot;nginx&quot;
   cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;

   nginx.ingress.kubernetes.io/rewrite-target: /$2

spec:
 tls:
 - hosts:
   - www.example.ch
   secretName: tls-example.ch
 rules:
 - host: www.example.ch
   http:
     paths:
     - path: /backend(/|$)(.*)
       pathType: Prefix
       backend:
         service:
           name: example-backend-svc
           port:
             number: 8081
     - path: /
       pathType: Prefix
       backend:
         service:
           name: example-frontend-svc
           port:
             number: 8080
</code></pre>

<p>You can add another path if all files are located in /bundles/* path.
I have given an example manifest file below.</p>
<pre><code>apiVersion: networking.k8s.io/v1 # for versions before 1.14 use extensions/v1beta1
kind: Ingress
metadata:
 name: example
 namespace: example
 annotations:
   kubernetes.io/ingress.class: &quot;nginx&quot;
   cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;

   nginx.ingress.kubernetes.io/rewrite-target: /$2

spec:
 tls:
 - hosts:
   - www.example.ch
   secretName: tls-example.ch
 rules:
 - host: www.example.ch
   http:
     paths:
     - path: /backend(/|$)(.*)
       pathType: Prefix
       backend:
         service:
           name: example-backend-svc
           port:
             number: 8081
     - path: /bundles
       pathType: Prefix
       backend:
         service:
           name: example-backend-svc
           port:
             number: 8081
     - path: /
       pathType: Prefix
       backend:
         service:
           name: example-frontend-svc
           port:
             number: 8080
</code></pre>
