Elasticsearch安装http-basic插件
http-basic插件是对elasticsearch的http请求做验证的,安装之后所有不在白名单的客户机发起的http请求操作都需要用户名密码认证。
安装步骤如下:
wget https://github.com/Asquera/elasticsearch-http-basic/releases/download/v1.5.1/elasticsearch-http-basic-1.5.1.jar mkdir /usr/local/elasticsearch/plugins/http_base mv elasticsearch-http-basic-1.5.1.jar /usr/local/elasticsearch/plugins/http_base vim /usr/local/elasticsearch/config/elasticsearch.yml
增加如下配置
http.basic.enabled: true http.basic.user: "klpeng" http.basic.password: "www.ligphp.com" http.basic.ipwhitelist: ["localhost", "127.0.0.1"] http.basic.trusted_proxy_chains: [] http.basic.log: false http.basic.xforward: ""
保存之后重启
测试验证
curl http://[your-node-name]:[your-port]/[your-index]/_count?pretty=true # 无账号密码,不可访问 Authentication Required
curl --user [your-admin]:[your-password] http://[your-node-name]:[your-port]/[your-index]/_count?pretty=true # 通过user选项带上账号密码,返回正常数据
{ "count" : xxx, "_shards" : { "total" : xxx, "successful" : xxx, "failed" : 0 } }
需要注意的是白名单无法控制域名访问,所有域名访问都会验证用户名和密码。
原创文章如转载,请注明出处,本文首发于彭超的博客
文章版权声明:除非注明,否则均为彭超的博客原创文章,转载或复制请以超链接形式并注明出处。
继续浏览有关 elasticSearch 的文章
- 评论列表:
你好
发布于 2019-10-16 15:57:27 回复该评论- 有遇到过在plugins在目录下创建目录,就会报这个错误吗,Caused by: java.nio.file.NoSuchFileException: /home/elasticsearch-5.6.8/plugins/http-basic/plugin-descriptor.properties
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。