nginx代理kibana

nginx代理kibana

nginx代理kibana

节点规划

  • 192.168.80.106:es1+kibana1
  • 192.168.80.107:es2+kibana2
  • 192.168.80.108:nginx

安装nginx

[root@logstash-108 ~]# yum install -y nginx

配置nginx代理kibana

[root@logstash-108 ~]# cd /etc/nginx/conf.d/
[root@logstash-108 conf.d]# cat kibana.conf 
upstream kibana_server {
	server 192.168.80.106:5601 weight=1 max_fails=2 fail_timeout=60;

}

server {

	listen 80;
	server_name kibana.com;
	auth_basic "require password";
	auth_basic_user_file /etc/nginx/conf.d/htpasswd.users;
	
	location / {
		proxy_pass http://kibana_server;
	}
}

# 定义了kibana做后端组,并将主机头是kibana.com请求转发到该主机组,即后端的kibana组
[root@logstash-108 conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

配置nginx用户

[root@logstash-108 conf.d]# yum install -y httpd-tools

[root@logstash-108 conf.d]# htpasswd -bc /etc/nginx/conf.d/htpasswd.users li li
Adding password for user li
[root@logstash-108 conf.d]# cat /etc/nginx/conf.d/htpasswd.users 
li:$apr1$Xl/HCtIL$AZRBzJ15Ff3p8LNx.3CVD/
[root@logstash-108 conf.d]# htpasswd -b /etc/nginx/conf.d/htpasswd.users wang wang
Adding password for user wang

[root@logstash-108 conf.d]# systemctl start nginx

创建可以通过认证的用户和密码

访问测试

  1. 写入客户端的hosts文件

    192.168.80.108 kibana.com
    

    浏览器访问时,提示输入密码即可,nginx成功反代kibana,多个kibana实例的情况下,可以做负载均衡

    image-20201215112240744

image-20201215112254118

updatedupdated2020-12-172020-12-17
加载评论