server.basePath in version 5.2.2

Hello there,

Unfortunately, we are still running kibana in version 5.2.2. and we need to modify the server.basePath for multiple servers.

Here is our kibana.yml:

server.basePath: "/abc"

I know we have to rewrite the basePath in our proxy, https://github.com/elastic/kibana/issues/6665
so in our nginx, we have these blocks:

location = / {
  rewrite ^/abc /abc/app/kibana;
  proxy_pass http://127.0.0.1:5601;
  proxy_read_timeout 90;
}

location = /abc {
  rewrite ^/abc /abc/app/kibana;
  proxy_pass http://127.0.0.1:5601;
  proxy_read_timeout 90;
}

location /abc {
  rewrite ^/abc/(.*)$ /$1 break;
  proxy_pass http://127.0.0.1:5601;
  proxy_read_timeout 90;
}

The confusion I have is that:

  1. I know if we hit the url like this: http://xxx.xxx.com/abc without rewriting it, I will get a 404. That means I had to rewrite it. But will server.basePath be appended when I hit http://xxx.xxx.com automatically just because I have it in kibana.yml, will the url sent to the nginx transformed to: http://xxx.xxx.com/abc ?

  2. If server.basePath doesn't get appended to http://xxx.xxx.com, then that means http://xxx.xxx.com will go to the first the location block in nginx. But the rewrite rule in my first location block in nginx.conf is not necessary, since it doesn't have the regex \abc part.
    I should change it to something like this?

    location = / {
      proxy_pass http://127.0.0.1:5601;
      proxy_read_timeout 90;
    }

I do have this need to access both http://xxx.xxx.com/ and http://xxx.xxx.com/abc where I would expect different kibana instances would be available for me.
Bottom line, what should I do to make http://xxx.xxx.com/ work?

  1. If my understanding is right, the server.defaultRoute : /app/kibna already redirected the request to http://xxx.xxx.com/abc/app/kibana. Should I still do rewrite like this rewrite ^/abc /abc/app/kibana? If not, what's the best way to rewrite the basePath? What about when I hit http://xxx.xxx.com, would this be redirected to http://xxx.xxx.com/app/kibana without any rewriting rules?

I know I have a lot of questions and you guys are not nginx experts, but this basePath is really confusing. I read all related discussion topics, I still couldn't figure out.
Really appreciate your help!

Thank you.

1 Like