使用 Nginx 反向代理 Kibana 并配置访问基本认证

安装nginx

apt-get install nginx

使用openssl创建一个管理员用户,例如“admin”,可以访问Kibana Web界面

echo "admin:`openssl passwd -apr1`" | tee -a /etc/nginx/conf.d/htpasswd.users

配置nginx

vim /etc/nginx/conf.d/default.conf
server {
    listen 80;
    server_name example.com;
    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/conf.d/htpasswd.users;
    location / {
        proxy_pass http://localhost: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;
    }
}

检查配置并重启nginx

nginx -t
systemctl restart nginx
posted @ 2021-08-20 08:59  Varden  阅读(269)  评论(0编辑  收藏  举报