ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

(修复方案)kibana 未授权访问漏洞

(修复方案)kibana 未授权访问漏洞

(修复方案)kibana 未授权访问漏洞

  • 1. 存在未授权访问,启用 xpack.security
  • 2. 不支持xpack,可以使用反向代理添加认证
  • 3. 设置访问白名单

1. 存在未授权访问,启用 xpack.security

(1)在 kibana.yml 中添加

elasticsearch.username:"kibana_system"elasticsearch.password:"your-password"xpack.security.enabled:true

(2)然后在 Elasticsearch 中启用内置用户并设置密码:

./bin/elasticsearch-setup-passwords interactive

(3)重启 Kibana 和 Elasticsearch 后,即可通过用户名密码访问

2. 不支持xpack,可以使用反向代理添加认证

在 Nginx 或 Apache 反向代理前面加一层 Basic Auth 或 OAuth 认证,以 Nginx + Basic Auth 为例:

(1) 安装 htpasswd 工具,这个工具用来生成 Basic Auth 的用户名密码文件

# CentOS/RHELsudoyuminstallhttpd-tools -y# Ubuntu/Debiansudoapt-getinstallapache2-utils -y

(2)创建认证文件

# admin 是用户名,输入后会让你设密码# 认证文件路径 /etc/nginx/.htpasswd 可以自定义sudohtpasswd -c /etc/nginx/.htpasswd admin

(3)配置 Nginx 反向代理

server{listen80;server_name kibana.example.com;location /{auth_basic"Restricted Access";auth_basic_user_file /etc/nginx/.htpasswd;proxy_pass http://127.0.0.1:5601;proxy_http_version1.1;proxy_set_header Upgrade$http_upgrade;proxy_set_header Connection'upgrade';proxy_set_header Host$host;proxy_cache_bypass$http_upgrade;}}

(4)重启 Nginx

sudosystemctl restart nginx

此时访问 http://kibana.example.com 时会要求输入账号密码

3. 设置访问白名单

仅允许内网或特定 IP 访问 Kibana 服务,在 kibana.yml 中配置绑定地址:

server.host:"127.0.0.1"

随后重启 Kibana

返回列表