Let me describe the situation what I faced today:
There is nothing specific in manifest of this application, this is simple deployment with service on 80 port.
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.
Below my yaml:
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(/|$)(.*)
Okay, I'm trying to open page: http://1.2.3.4/ - everything works fine, I see web page which redirects me to:
http://1.2.3.4/page1 , in case of I clicked something - http://1.2.3.4/page2 etc.
However, when I'm trying to open the same web application using:
http://1.2.3.4/test-service/ui , I got blank page and errors in console:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://1.2.3.4/test-services/ui/static/css/test.css".
What a difference that I found:
In the second case all JS and CSS files has content-type: text/html.
Let me describe how I was managed to resolve the issue:
In the YAML settings, as you can see nginx.ingress.kubernetes.io/rewrite-target: /$1
So, for root path directories and applications - it should be:
nginx.ingress.kubernetes.io/rewrite-target: /
For example.com/example/
It should be:
nginx.ingress.kubernetes.io/rewrite-target: /$1
etc.
Now, web page is showing correctly.