Uninote
Uninote
用户根目录
emoji test🧚
欢迎你
爱神的飞刀
都市风光
🧚🧚
🧚🧚2
🧚🧚3
__import__
ELK集群部署
JS面向对象函数的四种调用模式
Java入门学习路线目录索引(持续更新中)
c
个人文库
掘金
ElasticSearch + Logstash进行数据库同步
ElasticSearch两个节点的情况下,shard是如何分配的
ElasticSearch安装教程
ElasticSearch设置用户名密码访问
ElasticSearch适用场景,功能以及特点介绍
Kali Linux安装教程
Linux设置虚拟内存教学和实战
Xdebug文档(一)基本特性
docker
init
vuex的源码一些理解
使用nginx控制ElasticSearch访问权限
使用python的scrapy来编写一个爬虫
再见 Docker,是时候拥抱下一代容器工具了
前端工具集(辅助工具、开发工具、技术栈、学习网站)
剖析ElasticSearch基础分布式架构
剖析ElasticSearch核心概念,NRT,索引,分片,副本等
原型链
推荐几款Linux下比Notepad++好的编辑器软件
搭了一个 wordpress 站点
收集整理的一些前端资源
浏览 GitHub 太卡了?教你两招!
用最简单的话告诉你什么是ElasticSearch
网络是怎样连接的?从浏览器输入URL开始
解决ChromeDriver安装与配置问题
**游记/杂记**
a
a
a
b
c
c
b
a
a
x
s
a
c
network
https
vue-src
index
_posts
hello
about
index
coc
index
menu
index
perf
index
support-vuejs
index
v2
api
index
cookbook
adding-instance-properties
avoiding-memory-leaks
client-side-storage
creating-custom-scroll-directives
debugging-in-vscode
dockerize-vuejs-app
editable-svg-icons
form-validation
index
packaging-sfc-for-npm
practical-use-of-scoped-slots
serverless-blog
unit-testing-vue-components
using-axios-to-consume-apis
examples
commits
deepstream
elastic-header
firebase
grid-component
hackernews
index
modal
select2
svg
todomvc
tree-view
guide
class-and-style
comparison
components
components-custom-events
components-dynamic-async
components-edge-cases
components-props
components-registration
components-slots
computed
conditional
custom-directive
deployment
events
filters
forms
index
installation
instance
join
list
migration
migration-vue-router
migration-vuex
mixins
plugins
reactivity
render-function
routing
single-file-components
ssr
state-management
syntax
team
transitioning-state
transitions
typescript
unit-testing
search
index
style-guide
index

介绍

由于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=<path> 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_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> 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

点赞(0) 阅读(36) 举报