Kibana 5.4 behind Nginx

I just happened to get this working after quite a lot of effort so here it is to save other's some time. I haven't tested it extensively so ymmv. Make sure to set your server.basepath to /kibana in the kibana config.

# Exact URI match to load the base kibana page without a redirect
location = /kibana {
    proxy_pass http://127.0.0.1:5601/app/kibana;
    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;
}
# Catch for all other kibana resources. Removes proxy URI before passing on
location /kibana {
    rewrite ^/kibana/(.*)$ /$1 break;
    proxy_pass http://127.0.0.1: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;
}
# Catch for a stray kibana call that doesn't properly prepend the proxy URI
location /api {
    if ($http_referer ~ "^.*/kibana") {
        proxy_pass http://127.0.0.1:5601;
    }
}
2 Likes