Kibana behind apache reverse proxy

Hi I'm trying to get kibana working behind and apache reverse proxy. I already have it working, but there's one issue (for which I already have a workaround) but I need to know if it's a configuration issue or a bug. The problem is that the Proxy/ProxyPass from "/" to "/kibana" doesn't work. Let me show you my setup.
kibana.yml

server.name: "kibana"
server.host: "0.0.0.0"
server.basePath: "/kibana"
server.rewriteBasePath: true
server.publicBaseUrl: "http://localhost:5601/kibana"

Config for apache

ProxyPass: '/ http://localhost:5601/kibana/'
ProxyPassReverse: '/ http://localhost:5601/kibana/'
ProxyPreserveHost: true
ProxyRequests: false

With this config running, theoretically, whenever I open "http://localhost/" I should land directly in Kibana, but instead I can see a redirect (http 302) towards "http://localhost/kibana/spaces/enter" with a "not found message" (http 404):

{"statusCode":404,"error":"Not Found","message":"Not Found"}

Has anyone had this same issue? I know the proxy works since everything is as expected if I just used the ProxyPass/ProxyPassReverse with "/kibana http://localhost:5601/kibana", so my only guess is that there's a bug in kibana or I am missing some config.

Workaround
The hack I found to make it work as I want is to use both "/ http://localhost:5601/kibana" and "/kibana http://localhost:5601/kibana" in the Proxy config, it works wonderful but is more of a hack than a propper solution.

@azasypkin can we please get some help here?

Thanks,
Bhavya

So turns out that the way I made it work was removing all the proxy related options.

server.basePath: "/kibana"
server.rewriteBasePath: true

Which I honestly find confusing, especially when the documentation and everywhere you look for, says you need those too in order to work with a reverse proxy...
Apparently, the code takes "/" as the base path if you don't specify 'server.basePath', which is what I was looking for, having also 'ProxyPass/ProxyPassReverse: / http://localhost:5601/'. This way you can simply access http://localhost:confused: and takes you to Kibana, no need to add all the paths to the reverse proxy...
Finally change 'server.host' to '127.0.0.1' and you don't have to worry about people trying to access kibana through the port, if they come from external connections.

Honestly, I'm a bit mad this case is not considered in the documentation, I feel like a lost more time than I'd like just because the documentation and everywhere I looked told me to use those parameters which aren't really needed.

Thanks for sharing the outcome!

Yeah, it's a bit confusing. The server.basePath: "/kibana" is used only when users direcly access Kibana through this specific base path (e.g. when you have multiple different applications on the same domain, and use different base path for every such app). In your proxy configuration you just path requests from the root (/) to /kibana, so users don't really see /kibana and Kibana doesn't need it either.

Having said that, we're going to collect more telemetry to better understand the use cases for using proxy for Kibana and know what proxy related docs would be beneficial for our users.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.