实现步骤
~]# yum install httpd-tools -y
~]# htpasswd -cbm /apps/nginx/conf/.htpasswd user1 123456
~]# htpasswd -bm /apps/nginx/conf/.htpasswd user2 123456
~]# tail /apps/nginx/conf/.htpasswd
user1:$apr1$Rjm0u2Kr$VHvkAIc5OYg.3ZoaGwaGq/ user2:$apr1$nIqnxoJB$LR9W1DTJT.viDJhXa6wHv.
~]# vim /apps/nginx/conf/conf.d/pc.conf
location = /login/ {
root /data/nginx/html/pc;
index index.html;
auth_basic "login password";
auth_basic_user_file /apps/nginx/conf/.htpasswd;
}
# 重启 Nginx 并测试