Nginx反向代理kibana实现认证访问

转载于:https://www.cnblogs.com/yanshicheng/articles/9426884.html 如有侵权请联系删除

Nginx反向代理kibana实现认证访问

一 修改kibana配置文件

[root@Centos-node6 ~]# vim /etc/kibana/kibana.yml
server.host: "127.0.0.1"

二 安装Nginx并启动测试

复制代码

[root@Centos-node6 ~]# yum -y install nginx
[root@Centos-node6 ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@Centos-node6 ~]# systemctl start nginx
[root@Centos-node6 ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2018-08-05 19:25:48 CST; 3min 18s ago
 Main PID: 15439 (nginx)
   CGroup: /system.slice/nginx.service
           ├─15439 nginx: master process /usr/sbin/nginx
           ├─15440 nginx: worker process
           └─15441 nginx: worker process

8月 05 19:25:48 Centos-node6 systemd[1]: Starting The nginx HTTP...
8月 05 19:25:48 Centos-node6 nginx[15433]: nginx: the configurat...
8月 05 19:25:48 Centos-node6 nginx[15433]: nginx: configuration ...
8月 05 19:25:48 Centos-node6 systemd[1]: Started The nginx HTTP ...
Hint: Some lines were ellipsized, use -l to show in full.

复制代码

三 使用http-tools生成用户密码

复制代码

[root@Centos-node6 nginx]# yum -y install httpd-tools
[root@Centos-node6 nginx]# htpasswd -bc /etc/nginx/httppass.txt kibana 123.com
Adding password for user kibana
[root@Centos-node6 nginx]# cat /etc/nginx/httppass.txt 
kibana:$apr1$dGp8h60Q$uPxB.anbrH9XgX0/h3FmF.
[root@Centos-node6 nginx]# ll /etc/nginx/httppass.txt 
-rw-r--r-- 1 root root 45 8月   5 19:20 /etc/nginx/httppass.txt
[root@Centos-node6 nginx]# chown nginx.nginx /etc/nginx/httppass.txt 
[root@Centos-node6 nginx]# ll /etc/nginx/httppass.txt 
-rw-r--r-- 1 nginx nginx 45 8月   5 19:20 /etc/nginx/httppass.txt

复制代码

四 修改Nginx conf文件配置代理

复制代码

[root@Centos-node6 ~]# cat /etc/nginx/conf.d/kibana.conf 
upstream kibana_server {
        server  127.0.0.1:5601 weight=1 max_fails=3  fail_timeout=60;
}

server {
        listen 80;
        server_name 192.168.10.142;
        auth_basic "Restricted Access";
        auth_basic_user_file /etc/nginx/httppass.txt;  
        location / {
        proxy_pass http://kibana_server;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        }
}

[root@Centos-node6 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@Centos-node6 ~]# systemctl restart nginx

复制代码

 

六 浏览器访问测试

 

输入密码后验证成功 用户名:kibana 密码:123.com

作者:闫世成

出处:http://cnblogs.com/yanshicheng

联系:yans121@sina.com

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,如有问题或建议,请多多赐教,非常感谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值