How to configure Kibana 4 and elasticsearch behind nginx?

Ayman Al-Shorman picture Ayman Al-Shorman · Mar 10, 2015 · Viewed 31.7k times · Source

I have kibana 4 and elasticsearch running on the same server.

I need to access kibana through a domain but when I try I keep getting file not found.

I just create location /kibana in nginx and the proxy_pass is the ip:port of kibana.
Anyone had this?

Answer

psebos picture psebos · Mar 13, 2015

This workd for kibana 4.0.1. and I assume that you run kibana on the same host as nginx listening to port 5601.

Your nginx config should look like:

server {
  listen                *:80 ;

  server_name           server;
  access_log            /var/log/nginx/kibana.srv-log-dev.log;
  error_log            /var/log/nginx/kibana.srv-log-dev.error.log;

  location / {
    root  /var/www/kibana;
    index  index.html  index.htm;
  }

  location ~ ^/kibana4/.* {
    proxy_pass http://kibana4host:5601;
    rewrite ^/kibana4/(.*) /$1 break;
    proxy_set_header Host $host;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/conf.d/kibana.myhost.org.htpasswd;
  }
}

The lines

auth_basic "Restricted";
auth_basic_user_file /etc/nginx/conf.d/kibana.myhost.org.htpasswd;

can be used so that you provide a basic authentication to the site.

The access link will be http://server/kibana4