为ElasticSearch添加HTTP基本认证 https://github.com/Asquera/elasticsearch-http-basic/releases
ES的HTTP连接没有提供任何的权限控制措施,一旦部署在公共网络就容易有数据泄露的风险,尤其是加上类似elasticsearch-head这样友好的前端界面,简直让你的数据瞬间裸奔在黑客的眼皮底下。项目上线前做十万伏特的防护当然不现实,但至少,我们不要裸奔,穿一套比基尼吧。而做一个简单的HTTP认证并不需要从头造轮子,elasticsearch-http-basic就提供了针对ES HTTP连接的IP白名单、密码权限和信任代理功能。
安装
elasticsearch-http-basic还不支持ES标准的bin/plugin install [github-name]/[repo-name]
的安装方式,但作者有提供编译好的jar包,不需要下载源码重新编译。GitHub上目前的最新版本是对应ES的1.4.0版本,但验证过1.5.2也是同样可用的。
插件的安装步骤如下:
- 从elasticsearch-http-basic的发布版下载对应版本的jar包
mkdir -p plugins/http-basic; mv elasticsearch-http-basic-x.x.x.jar plugins/http-basic
(注意文件夹的名称)- 重启ES进程
- 验证插件是否生效:
curl localhost:9200/_nodes/[your-node-name]/plugins?pretty=true
(如果看到plugins
列表包含有http-basic-server-plugin
就说明插件生效了)
配置
elasticsearch-http-basic和其他ES插件一样,在config/elasticsearch.yml
中统一配置:
配置名 | 默认值 | 说明 |
---|---|---|
http.basic.enabled | true | 开关,开启会接管全部HTTP连接 |
http.basic.user | "admin" | 账号 |
http.basic.password | "admin_pw" | 密码 |
http.basic.ipwhitelist | ["localhost", "127.0.0.1"] | 白名单内的ip访问不需要通过账号和密码,支持ip和主机名,不支持ip区间或正则 |
http.basic.trusted_proxy_chains | [] | 信任代理列表 |
http.basic.log | false | 把无授权的访问事件添加到ES的日志 |
http.basic.xforward | "" | 记载代理路径的header字段名 |
测试
- Shell
# 无账号密码,不可访问
>>> curl http://[your-node-name]:[your-port]/[your-index]/_count?pretty=true
Authentication Required
# 通过user选项带上账号密码,返回正常数据
>>> curl --user [your-admin]:[your-password] http://[your-node-name]:[your-port]/[your-index]/_count?pretty=true
{
"count" : xxx,
"_shards" : {
"total" : xxx,
"successful" : xxx,
"failed" : 0
}
}
- 添加了HTTP基本认证后,
elasticsearch-head
同样会弹窗要求你先进行权限认证
Python
ES官方的Python客户端可以通过http_auth
配置账号密码:
from elasticsearch import Elasticsearch
es = Elasticsearch(['localhost'], http_auth=('your-admin', 'your-password'), port=...)
为ElasticSearch添加HTTP基本认证 https://github.com/Asquera/elasticsearch-http-basic/releases的更多相关文章
- 为ElasticSearch添加HTTP基本认证
ES的HTTP连接没有提供任何的权限控制措施,一旦部署在公共网络就容易有数据泄露的风险,尤其是加上类似elasticsearch-head这样友好的前端界面,简直让你的数据瞬间裸奔在黑客的眼皮底下.项 ...
- 为添加了自定义域名的GitHub Pages添加SSL,启用强制HTTPS(小绿锁)
直奔主题 为什么要使用https协议? 提高网站访问安全性,网络连接都是加密的 (PS:虽然SSL并不是无懈可击的,但是我们应该尽可能提高窃听成本). 目前越来越多的浏览器会判断当前站点支不支持htt ...
- 为Elasticsearch添加中文分词,对比分词器效果
http://keenwon.com/1404.html Elasticsearch中,内置了很多分词器(analyzers),例如standard (标准分词器).english(英文分词)和chi ...
- elasticsearch添加head插件
首先,肯定是安装elasticsearch啦,我这里是直接在官网上下载rpm包安装的. 官网:https://www.elastic.co/downloads/elasticsearch elasti ...
- 为 Elasticsearch 添加中文分词,对比分词器效果
转自:http://keenwon.com/1404.html 为 Elasticsearch 添加中文分词,对比分词器效果 Posted in 后端 By KeenWon On 2014年12月12 ...
- Elasticsearch添加Shield后TransportClient如何连接?
Elasticsearch添加Shield后TransportClient如何连接? 时间 2015-12-28 10:24:01 旁门左道 原文 http://log.medcl.net/ite ...
- 十四、.net core(.NET 6)搭建ElasticSearch(ES)系列之给ElasticSearch添加SQL插件和浏览器插件
给ES添加SQL插件的方法: 下载SQL插件地址:https://github.com/NLPchina/elasticsearch-sql 当前最新的是7.12版本,我的ES是7.13版本,暂且将 ...
- 转载请注明出处: https://github.com/qiu-deqing/FE-interview
转载请注明出处: https://github.com/qiu-deqing/FE-interview Table of Contents generated with DocToc FE-inter ...
- 为Asp.Net Web Api添加Http基本认证
Asp.net Web Api提供了RESTFul web服务的编程接口.默认RESTFul 服务没有提供任何验证或者基于角色的验证,这显然不适合Put.Post.Delete这些操作.Aps.net ...
随机推荐
- hdu1331(记忆化搜索)
#include<iostream> #include<stdio.h> #include<string.h> using namespace std; typed ...
- 跟着百度学PHP[13]-文件处理 文件后缀验证、设置随机文件名....
目录: 文件的处理:00x1 判断错误 文件的处理:00x2 判断类型 文件的处理:00x3 文件大小 ++++++++++++++++++++++++++++++++++++++++++++++++ ...
- CSS布局奇淫技巧之--各种居中<转>
居中是我们使用css来布局时常遇到的情况.使用css来进行居中时,有时一个属性就能搞定,有时则需要一定的技巧才能兼容到所有浏览器,本文就居中的一些常用方法做个简单的介绍. 注:本文所讲方法除了特别说明 ...
- 决Ubuntu使用`make menuconfig`配置Linux 内核时,出现缺少'ncurses-devel'库支持。
*** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' req ...
- ardunio I2C
I2C总线定义I2C(‘intel’ -Integrated Circuit)总线是一种由PHILIPS公司开发的两线式串行总线,用于连接微控制器及其外围设备.在主从通信中,可以有多个I2C总线器件同 ...
- C++ 指针引用
//指针引用 #include<iostream> using namespace std; struct Teacher{ ]; int age; }; int InitA(Teache ...
- 【BZOJ】1660: [Usaco2006 Nov]Bad Hair Day 乱发节(单调栈)
http://www.lydsy.com/JudgeOnline/problem.php?id=1660 单调栈裸题..累计比每一个点高的个数即可. #include <cstdio> # ...
- 转载: crypto:start() 错误。
错误信息: Eshell V5.10.3 (abort with ^G)1> crypto:start().** exception error: undefined function cry ...
- LandMVC HttpHandler web.config配置
<system.webServer> <validation validateIntegratedModeConfiguration="false" /> ...
- matlab判断图像是彩色图还是灰度图
matlab怎样看图像是彩色还是灰度_莹莹_新浪博客 http://blog.sina.com.cn/s/blog_76088a1f0101diq0.html 解决一: isrgb(A) 如果A是RG ...