SoFunction
Updated on 2025-03-04

Deploy Kibana and nginx proxy access environment

Kibana and nginx agent access environment deployment (access permission control).

Operation on the elk-node03:192.168.150.17 node machine:

Package name: kibana-7.2.0-x86_64.rpm

Install kibana configuration

[root@elk-node03 ~]#yum install kibana-7.2.0-x86_64.rpm

Since there are many business systems maintained, the access rights displayed by the business logs under each system on the Kibana interface are only open to the relevant personnel of the system, and are not open to personnel outside the system. So kibana permission control is needed.

This is implemented through nginx's access verification configuration.

You can configure multiple ports of kibana, each system opens a single kibana port number, for example, the financial system kibana uses port 5601, the rental system kibana uses 5602, and then nginx does the proxy access configuration.

The business logs of each system are displayed separately in the kibana interface of its corresponding port.

[root@elk-node03 ~]# cp -r /etc/kibana/ /etc/cw-5601-kibana
[root@elk-node03 ~]# cp -r /etc/kibana/ /etc/zl-5602-kibana
[root@elk-node03 ~]# vim /etc/cw-5601-kibana/
: 5601         // Listen to the port: "0.0.0.0"   //Supervising the host: ".cw-kibana"  //index: ["http://192.168.150.15:9200"] //You can add one host here, or you can add all three hosts.[root@elk-node03 ~]# vim /etc/zl-5602-kibana/
: 5602   // Listen to the port: "0.0.0.0"   //Supervising the host: ".zl-kibana"   //index: ["http://192.168.150.15:9200"]  

Provide service scripts

#cp -a /etc/systemd/system/ /etc/systemd/system/kibana_cw.service
Modify the script:
#vim  /etc/systemd/system/kibana_cw.service
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/cw-5601-kibana/"
​
#cp -a /etc/systemd/system/ /etc/systemd/system/kibana_zl.service
Modify the script:
#vim  /etc/systemd/system/kibana_zl.service
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/zl-5602-kibana/"

Reload the daemon

#systemctl daemon-reload

Start the service

#systemctl start kibana_cw.service kibana_zl.service
#systemctl enable kibana_cw.service kibana_zl.service

View the listening port

[root@elk-node03 ~]# lsof -i:5601
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 2603 kibana 18u IPv4 23553 0t0 TCP *:esmagent (LISTEN)
[root@elk-node03 ~]# lsof -i:5602
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 2632 kibana 18u IPv4 23663 0t0 TCP *:a1-msc (LISTEN)

Configure nginx's reverse proxy and access verification

Configure the extension source first:
# wget -O /etc// /repo/
downloadnginxServe:
# yum install nginx -y

Configure the virtual host

#vim  /etc/nginx//cw_kibana.conf
server {
listen 15601;
server_name localhost;
location / {
proxy_pass http://192.168.150.17:5601/;
auth_basic "Access Authorized";
auth_basic_user_file /etc/nginx//cw_auth_password;
}
}
#vim  /etc/nginx//zl_kibana.conf
server {
listen 15602;
server_name localhost;
location / {
proxy_pass http://192.168.150.17:5602/;
auth_basic "Access Authorized";
auth_basic_user_file /etc/nginx//zl_auth_password;
}
}

Set up verification file: (authenticated user cwlog/zllog and password)

# htpasswd -c /etc/nginx//cw_auth_password cwlog
# htpasswd -c /etc/nginx//zl_auth_password zllog

Start nginx

Check syntax before starting:
# nginx -t
Restart the service:
# systemctl restart nginx
Set up the power-on self-start:
# systemctl enable nginx

Finally: Log in to the browser with the master node IP address: 192.168.150.15:15061

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.