Have you tried to set up Kibana in a subpath just to be met by the error {"statusCode":404,"error":"Not Found","message":"Not Found"}
?
Or maybe you want to secure your infrastructure using Nginx reverse proxy.
I will show you how to do these two things at the same time.
I’ve written this guide, because the information found here, was scattered through many pages and takes time to find out and test.
Setting the Nginx reverse proxy
There’s not much to it, just add the following snippet to your configuration:
1 | location ~ /kibana { |
Tgus tells Nginx to redirect all the traffic coming to the /kibana subpath to your Kibana server.
Setting Kibana
Now, there are two ways to set Kibana - environmental variables, when using a Docker container or through the kibana.yml.
Since I’m using Docker, let me start with this one.
1 | kibana: |
The two important things here are SERVER_BASEPATH
, which tells Kibana to server its pages from /kibana instead of /, andSERVER_REWRITEBASEPATH
, which tells Kibana to handle rewriting of page and API URL requests coming under the /kibana subpath.
You can set your server to do this, but using the Kibana setting is a lot easier, most of the time.
In the yml file, these two settings are called:
1 | server.basePath |
That’s it! I hope this saved you some time.
Additiopnal consideration
If you’re planning to expose your Kibana app to the internet, through reverse proxy, make sure you have the proper security configuration in place.
Inspiration:
https://serverfault.com/questions/775958/reverse-proxy-for-nginx-configuration-for-subpath
https://discuss.elastic.co/t/kibana-and-nginx-in-subpath/90280/5
https://www.elastic.co/guide/en/kibana/master/settings.html#server-rewriteBasePath
https://stackoverflow.com/questions/17423414/nginx-proxy-pass-subpaths-not-redirected
https://forum.chirpstack.io/t/running-application-behind-reverse-proxy-with-subpath/7057