<p>Let me describe the situation what I faced today:</p>

<ol>
<li>I received NodeJS application image from Developers and published it to AKS(Azure Kubernetes Services)</li>
</ol>

<p>There is nothing specific in manifest of this application, this is simple deployment with service on 80 port.</p>

<ol start="2">
<li><p>I have configured Ingress using helm package and installed common one from helm repo:  stable/nginx-ingress . When it was installed - I have started to configure Ingress.</p></li>
<li><p>Below my yaml:</p></li>
</ol>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: app-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: ui-service
          servicePort: 80
        path: /(.*)
      - backend:
          serviceName: ui-service
          servicePort: 80
        path: /test-service/ui(/|$)(.*)
</code></pre>

<p>Okay, I'm trying to open page: <a href="http://1.2.3.4/" rel="nofollow noreferrer">http://1.2.3.4/</a> - everything works fine, I see web page which redirects me to:</p>

<p><a href="http://1.2.3.4/page1" rel="nofollow noreferrer">http://1.2.3.4/page1</a> , in case of I clicked something -
<a href="http://1.2.3.4/page2" rel="nofollow noreferrer">http://1.2.3.4/page2</a>
etc.</p>

<p>However, when I'm trying to open the same web application using:</p>

<p><a href="http://1.2.3.4/test-service/ui" rel="nofollow noreferrer">http://1.2.3.4/test-service/ui</a> , I got blank page and errors in console:</p>

<pre><code>Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://1.2.3.4/test-services/ui/static/css/test.css".
</code></pre>

<p>What a difference that I found:</p>

<p>In the second case all JS and CSS files has content-type: text/html.</p>

<p>Let me describe how I was managed to resolve the issue:</p>

<p>In the YAML settings, as you can see <code>nginx.ingress.kubernetes.io/rewrite-target: /$1</code></p>

<p>So, for root path directories and applications - it should be:</p>

<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /
</code></pre>

<p>For example.com/example/</p>

<p>It should be:</p>

<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /$1
</code></pre>

<p>etc.</p>

<p>Now, web page is showing correctly.</p>
