nginx 账号认证功能

nginx 账号认证功能

//创建账号密码
yum -y install httpd-tools
mkdir -p /usr/share/nginx/passwd
htpasswd -cbm /usr/share/nginx/passwd/.htpasswd user1 123456
htpasswd -bm /usr/share/nginx/passwd/.htpasswd user2 123456
//修改nginx配置文件
location = /login {
	root /usr/share/nginx/html/;
	index index.html;
	auth_basic	"login password";
	auth_basic_user_file /usr/share/nginx/passwd/.htpasswd;
}

nginx -s reload

image

输入账号密码后可以看到内容

posted @ 2022-08-29 18:40  liwenchao1995  阅读(40)  评论(0编辑  收藏  举报