Elasticsearch 安全篇
为什么要开放外网访问Elasticsearch:
1.一些插件监听使用,方便及时了解线上数据的情况,比如说head插件等
2.为了HTTP直接访问,有的同学考虑到通过后台TCP查询,然后返回数据,还不如直接以Elasticsearch作为服务直接http查询提升效率
3.还有一些同学是因为Elasticsearch与被访问的工程不在一个局域网内
开放风险:
Elasticsearch被删库,有的甚至被加密后敲诈比特币
解决方案:
- 防火墙限制ip访问端口
- 采用Nginx http-basic,用域名的方式访问
upstream es.abc.com{ server 127.0.0.1:9100 weight=1 max_fails=2; #server 127.0.0.1:9101 weight=1 max_fails=2; } server { listen 80; server_name es.abc.com location ~* / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; auth_basic "login"; auth_basic_user_file /usr/local/openresty/nginx/conf/es; autoindex on; if ($host ~* es\.abc\.com) { proxy_pass http://es.abc.com; } } }
- 配置帐号密码访问
- 关闭外网访问
vi config/elasticsearch.yml
配置network.host : 127.0.0.1 即可
重启 Elasticsearch
Learn how to learn~~