Kibana and Nginx in subpath

Is Kibana really ready to be used behind a reverse proxy who use subpath instead of domain name ?

Absolutely!

Here is a configuration that worked for me:

kibana.yml

server:
  basePath: "/awesome"
  host: "tim-virtual-machine.local"
  ssl:
    key: "/home/tim/server.key"
    cert: "/home/tim/server.crt"

nginx.conf

  # proxy kibana with a /awesome base path
  server {
    listen 5665;
    access_log  logs/proxy.access-kbn.log  main;
    server_name tim-virtual-machine.local;

    ssl_certificate /home/tim/server.crt;
    ssl_certificate_key /home/tim/server.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    location /awesome {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;

      proxy_pass  https://tim-virtual-machine.local:5601/;
      rewrite ^/awesome/(.*)$ /$1 break;
    }
  }

Now when I got to https://tim-virtual-machine.local:5665/awesome, I'm able to access Kibana.

I prefer adding the rewrite rule because it makes it explicit that the proxy needs to remove the base path from requests before they hit the Kibana server. There is a simpler, more implicit way to do this by adding slashes in the config appropriately. What I mean is, the following nginx config does the same thing, but the path removal is done automatically by nginx (note that the location line now has a slash at the end):

    location /awesome/ {
      proxy_pass https://tim-virtual-machine.local:5601/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
5 Likes