Reputation: 53
I have the ingress setup for Kubernetes as the following
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: dev-ingress
#namespace: dev
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/use-regex: "true"
ingress.gcp.kubernetes.io/pre-shared-cert: "self-signed"
kubernetes.io/ingress.class: "nginx"
kubernetes.io/ingress.allow-http: "true"
spec:
rules:
- host: my.host.com
http:
paths:
- backend:
serviceName: webui-svc
servicePort: 80
path: /webui(/|$)(.*)
I am running an Angular app deployment under the webui-svc. The angular app is containerized using docker and I have included a Nginx configuration in the docker container like the following
# Expires map
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/json max;
application/javascript max;
~image/ max;
}
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
expires $expires;
gzip on;
}
When i am requesting for http://my.host.com/webui/ the internal calls are getting redirected without the webui prefixed to it for e.g
When i request for http://my.host.com/webui/ there are several calls made to get the main.js, vendor.js etc these all the requested via http://my.host.com/runtime.js so it fails, it would succeed if it would get redirected like http://my.host.com/webui/runtime.js
Is there a configuration in the angular application or the ingress that I am missing. Any help is very much appreciated, Thanks in advance
Upvotes: 2
Views: 1658
Reputation: 176
Your rewrite target is stripping off the /webui/
. Consider your path:
path: /webui(/|$)(.*)
Now check the rewrite-target
:
nginx.ingress.kubernetes.io/rewrite-target: /$2
.
If you remove this annotation (and you can remove the use-regex
annotation since it's now not needed), it will pass the /webui/
path onto your backend.
Upvotes: 3