location ~ /analytics/(?<kibana_uri>.*) {
proxy_pass http://127.0.0.1:5601/$kibana_uri;
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;
}
# optional block to handle landing url without trailing slash: `/analytics`
location = /analytics {
return 302 /analytics/;
}
This captures the part after /analytics/
to a $kibana_uri
variable, which is then used to set the proxy_pass destination.
This was tested for Kibana 5.2 too.