Nginx作反向代理保护Kibana

安装 Nginx ,先安装 EPEL repository

$ yum install epel-release
$ yum install nginx
$ systemctl start nginx
$ systemctl enable nginx

httpd-tools, setting up an HTTP authentication

$ yum install httpd-tools
  • create a “.htpasswd” file to store our credential data such as Usernames and Passwords in an encrypted format

    $ htpasswd -c [filename] username
    

Configuring Nginx

$ /etc/nginx/nginx.conf
  • Find the “server” directive and change it like below:

    server {
        listen 80;
        server_name \_;
        location ~ ^/kibana/(.\*)$ {
            rewrite /kibana/(.\*) /$1 break;
            proxy_pass http://127.0.0.1:9396;
            auth_basic "Restricted";
            auth_basic_user_file /etc/nginx/.htpasswd;
        }
    }
    
  • 检查 Nginx 配置

    $ nginx -t
    
  • 重启 Nginx

    $ systemctl restart nginx
    

Configuring Kibnana

  • 打开配置文件

    $ vim /etc/kibana/kibana.yml
    
  • 添加

    server.basePath: "/kibana"
    
  • 重启 Kibana

    $ systemctl restart Kibana