I have a Kibana dashboard that I currently access through the root of my host : https://my.host.com/
. I want to change it so I can access it through the path https://my.host.com/kibana/
. For this, I used the rewrite-target
annotation as provided in the main documentation:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: kibana-ing
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
kubernetes.io/ingress.class: kibana-ingress-class
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
rules:
- host: my.host.com
http:
paths:
- path: /kibana(/|$)(.*)
backend:
serviceName: kibana-svc
servicePort: 5601
I think this works to some extent because when hitting https://my.host.com/kibana/, I get redirected to the login page. But the login page is returned to my browser without the kibana prefix : https://my.host.com/app/login
and I get a 404.
How can I fix this?
EDIT:
This is currently what is happening when I hit https://my.host.com/kibana/
:
This sends back a HTTP 302 with a redirection to app/login
as you can see in the Location header. But when my browser asks back Nginx to fetch for this app/login, it rightfully gives a 404 since this path is unkown to it.
Is there a way (through an Ingress annotation maybe) to append the '/kibana' prefix to all the Location headers that are being returned?
EDIT2:
I managed to append the /kibana/
part in the Location header by adding these 2 annotations:
nginx.ingress.kubernetes.io/proxy-redirect-from: "/"
nginx.ingress.kubernetes.io/proxy-redirect-to: "/kibana/"
This makes the redirection point to kibana/app/login
, resulting in a 200 status. However more objects are being loaded by the page like a bootsrap.js and their location are hardcoded within the html page being sent back like this:
</script><script src="/bootstrap.js"></script></body></html>
Obviously this hits back with another 404 error on my browser end... I think I will have to deal with this on the application end instead.
I managed to fix this at the application level. In my kibana.yml
config file, I had to tell Kibana that it was running behind a reverse proxy. So I set server.basePath: /kibana
.
Note that the configuration I made above for the Ingress is still needed, as the application is still reacheable at the root of server but only the responses URLs will include the /kibana/
prefix.