Nginx反向代理kibana实现认证访问
转载于:https://www.cnblogs.com/yanshicheng/articles/9426884.html 如有侵权请联系删除
Nginx反向代理kibana实现认证访问
一 修改kibana配置文件
[[email protected] ~]# vim /etc/kibana/kibana.yml server.host: "127.0.0.1"
二 安装Nginx并启动测试
[[email protected] ~]# yum -y install nginx [[email protected] ~]# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [[email protected] ~]# systemctl start nginx [[email protected] ~]# 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生成用户密码
[[email protected] nginx]# yum -y install httpd-tools [[email protected] nginx]# htpasswd -bc /etc/nginx/httppass.txt kibana 123.com Adding password for user kibana [[email protected] nginx]# cat /etc/nginx/httppass.txt kibana:$apr1$dGp8h60Q$uPxB.anbrH9XgX0/h3FmF. [[email protected] nginx]# ll /etc/nginx/httppass.txt -rw-r--r-- 1 root root 45 8月 5 19:20 /etc/nginx/httppass.txt [[email protected] nginx]# chown nginx.nginx /etc/nginx/httppass.txt [[email protected] nginx]# ll /etc/nginx/httppass.txt -rw-r--r-- 1 nginx nginx 45 8月 5 19:20 /etc/nginx/httppass.txt
四 修改Nginx conf文件配置代理
[[email protected] ~]# 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; } } [[email protected] ~]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [[email protected] ~]# systemctl restart nginx
六 浏览器访问测试
输入密码后验证成功 用户名:kibana 密码:123.com
作者:闫世成
出处:http://cnblogs.com/yanshicheng
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,如有问题或建议,请多多赐教,非常感谢。