1、生成密码文件
# 安装工具包 yum install httpd-tools -y # 生成密码,用户名 admin, !如果再次执行会被覆盖 htpasswd -c /usr/local/nginx/.htpasswd admin # 提示输入2遍密码
2、nginx 配置
server { listen 8001; server_name localhost; location / { # 设置 auth auth_basic "kibana login auth"; auth_basic_user_file /usr/local/nginx/.htpasswd; # 转发到 kibana proxy_pass http://127.0.0.1:5601; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
3、重新加载nginx配置:
nginx -s reload
4、访问测试
访问 nginx 地址,就会弹出认证窗口: