博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用nginx控制ElasticSearch访问权限
阅读量:7090 次
发布时间:2019-06-28

本文共 2064 字,大约阅读时间需要 6 分钟。

介绍

由于ElasticSearch本身没有权限管理模块,只要获取服务器的地址和端口,任何人都可以随意读写ElasticSearch的API并获取数据,这样非常不安全。所以本文就介绍一下如何规避这种问题,实现方式其实有几种,本文将介绍使用nginx的basic_auth来控制的方式。

  • 好处 使用nginx的好处是轻便,不用涉及到Elasticsearch 或者 Kibana本身的配置上,
  • 坏处 可被暴力破解

环境

Centos 6.9 Elasticsearch 版本 6.4.0 Kibana 版本 6.4.0 Nginx 版本 1.11.6

安装nginx

  1. 下载nginx
[root@localhost ~]# wget http://nginx.org/download/nginx-1.11.6.tar.gz复制代码
  1. 解压ngxin
tar -zxvf nginx-1.11.6.tar.gz 复制代码
  1. 进入nginx目录
cd nginx-1.11.6复制代码
  1. 执行configure检查配置
./configure复制代码
4.1. 发现错误, 缺少 pcre 包```./configure: error: the HTTP rewrite module requires the PCRE library.复制代码

You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre= option. ```

  1. 安装pcre包
yum -y install pcre-devel复制代码
  1. 再次执行configure检查配置
./configure复制代码
6.1 发现还缺少一个zlib的包```./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using --without-http_gzip_moduleoption, or install the zlib library into the system, or build the zlib librarystatically from the source with nginx by using --with-zlib=
option.```复制代码
  1. 安装zlib包
yum -y install zlib-devel复制代码
  1. 执行configure
./configure复制代码
  1. 执行make install
make install复制代码
  1. 进入nginx目录启动nginx
cd  /usr/local/nginx/复制代码

启动nginx

./sbin/ngxin复制代码

可以进入你的浏览器输入你的ip地址看看是否能访问

配置ngxin

下面就开始对ngxin的配置文件做修改,修改/conf目录下面的nginx.conf

vim conf/nginx.conf复制代码

将里面的

location / {            root   html;            index  index.html index.htm;        }复制代码

改成

location / {            proxy_pass  http://0.0.0.0:5601;            auth_basic "登陆验证";            auth_basic_user_file /usr/local/nginx/htpasswd;        }复制代码

然后使用htpasswd命令生成密码文件

[root@test102 conf.d]# htpasswd -cm /usr/local/nginx/htpasswd kibana     #/usr/local/nginx/htpasswd就是配置文件里面配置的密码文件,kibana就是用户名New password:     #输入密码Re-type new password:     #再次输入密码,回车Adding password for user crystal复制代码

进入浏览器访问你的ip,会让你输入用户名和密码才能进入kibana了

输入用户名和密码

点击登陆就进入了kibana

转载于:https://juejin.im/post/5c9c593c5188251d730e37ee

你可能感兴趣的文章
[实战]MVC5+EF6+MySql企业网盘实战(5)——页面模板
查看>>
CSS 参考手册
查看>>
如何用c++发出音乐
查看>>
JLOI2015 城池攻占
查看>>
基本数据类型
查看>>
Can you solve this equation? 详细解答
查看>>
exit命令详解
查看>>
date命令详解
查看>>
C#序列化与反序列化
查看>>
首页logo的代码标志性写法,方便SEO
查看>>
Collection of Tools - Fix problems that programs cannot be installed or uninstalled
查看>>
DP+高精度 URAL 1036 Lucky Tickets
查看>>
Codeforces Round #208 (Div. 2) Problem B Dima and Text Messages(简单字符串处理)
查看>>
3D效果?
查看>>
20161028学习笔记
查看>>
浅谈UML的概念和模型之UML视图
查看>>
hive
查看>>
Jquery基础之DOM操作
查看>>
Linux系统学习笔记:文件描述符标志
查看>>
网页居中设置
查看>>