2、配置nginx虛擬主機(jī),實(shí)現(xiàn)域名訪問(wèn)kibana。

將 nginx 作為反向代理服務(wù)器,并增加登錄用戶認(rèn)證的目的,可以有效避免其 他人員隨意訪問(wèn) kibana 頁(yè)面。
安裝nginx

 tar xf nginx-1.10.3.tar.gz
./configure --prefix=/usr/local/nginx
make && make install

準(zhǔn)備 systemctl 啟動(dòng)文件

vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid #和 nginx 配置文件的保持一致
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target

配置并啟動(dòng) nginx

ln -sv /usr/local/nginx/sbin/nginx /usr/sbin/
useradd www -u 2000
chown www.www /usr/local/nginx/ -R
vim /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes 1;
pid /run/nginx.pid; #更改 pid 文件路徑與啟動(dòng)腳本必須一致

配置 nginx 代理 kibana:

實(shí)現(xiàn)登錄認(rèn)證

yum install httpd-tools –y
htpasswd -bc /usr/local/nginx/conf/htpasswd.users test123456
cat /usr/local/nginx/conf/htpasswd.users

vim /usr/local/nginx/conf/conf.d/kibana1512.conf
upstream kibana_server {
 server 127.0.0.1:5601 weight=1 max_fails=3 fail_timeout=60;
}
server {
 listen 80;
 server_name www.kibana1512.com;
 auth_basic "Restricted Access";
 auth_basic_user_file /usr/local/nginx/conf/htpasswd.users; 
 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;
 } 
}

重啟 nginx

chown www.www /usr/local/nginx/ -R
systemctl restart nginx
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容