首页 > 其他 > 详细

nginx 添加basic auth

时间:2018-11-16 14:57:25      阅读:169      评论:0      收藏:0      [点我收藏+]
生成密码文件

htpasswd -c -d conf/htpasswd kibana
printf "kibana:$(openssl passwd -crypt 4Bo*3Jdhk)\n" >>htpasswd

添加配置文件

server {} 中添加,还可以在http,location等配置段中添加
auth_basic "nginx basic auth";
auth_basic_user_file htpasswd;

nginx的启动和停止

/usr/sbin/nginx --启动
pkill nginx --停止
nginx -s reload --重新加载配置文件

限制:启用了upstream的不能添加

nginx_tcp_proxy_module

tcp {
upstream ha {
server 192.168.164.245:2255;
}

server {
listen 2255;
proxy_pass ha;

auth_basic "login test";
auth_basic_user_file conf/htpasswd;

}
}

nginx 添加basic auth

原文:http://blog.51cto.com/395469372/2317862

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!