部署完ELK后,可以直接在浏览器进入kibana页面进行访问,而这样对一些重要数据来说是不安全的,可以利用密码验证来设置权限访问。
环境
192.168.2.112 kibana
192.168.2.119 nginx
在kibana所在的服务器上安装nginx服务,利用nginx的转发指令实现。
安装好nginx后,进入nginx配置页面,修改如下:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#添加upstream模块
upstream kibana_web {
server 192.168.2.112:5601 weight=1 max_fails=2 fail_timeout=30s;
}
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_set_header Host $host;
proxy_pass http://kibana_web;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
开启nginx服务,在浏览器输入ip192.168.2.119后如下图所示
添加权限认证
在nginx.conf下的location /模块下添加
auth_basic "The Kibana Monitor Center";
auth_basic_user_file /usr/local/nginx/html/.htpasswd;
通过加密工具htpasswd生成账号和密码
[root@leeclient html]# htpasswd -c /usr/local/nginx/html/.htpasswd admin
New password:
Re-type new password:
Adding password for user admin
重启nginx,浏览器输入ip后显示如下图
输入账号密码后就可以进入kibana页面