使用nginx代理kibana並設置身份驗證


1、在es-sever上安裝nginx

# wget http://nginx.org/download/nginx-1.8.1.tar.gz 
# tar xvf nginx-1.8.1.tar.gz
# yum install -y gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel
# useradd nginx
# cd nginx-1.8.1/

# ./configure  --prefix=/usr/local/nginx  --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log  --http-log-path=/var/log/nginx/access.log  --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock  --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre 
# make 
# make install 

# mkdir -pv /var/tmp/nginx/client/
# /usr/local/nginx/sbin/nginx
# tail -f /var/log/nginx/access.log

2、添加一個單獨的nginx配置文件,設置轉發

# mkdir -pv /usr/local/nginx/conf/conf.d/
# vim /usr/local/nginx/conf/conf.d/kibana.conf
server {
	listen 80;
	server_name 192.168.135.136;   	#當前主機名
	auth_basic "Restricted Access";
	auth_basic_user_file /usr/local/nginx/conf/htpasswd.users;   	#登錄驗證
	location / {
	proxy_pass http://192.168.135.136:5601;  	#轉發到kibana
	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;
	}
}

3、修改nginx主配置文件導入配置

# vim /usr/local/nginx/conf/nginx.conf 
include /usr/local/nginx/conf/conf.d/*.conf;

4、配置登錄驗證

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

5、重啟nginx

# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx -s reload

6、用瀏覽器直接訪問80端口

http://192.168.135.136/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM