1 配置文件
server {
listen 80;server_name status.zyb.com;
location /status {
auth_basic "zyb training"; #用户和密码框提示字符
auth_basic_user_file /application/nginx/conf/htpasswd; #用户和密码存放的文件
stub_status on;
access_log off;
}
}
2 配置用户和密码
[root@centos-6-11 vhost]# yum install -y httpd
[root@centos-6-11 vhost]# which htpasswd
/usr/bin/htpasswd
[root@centos-6-11 vhost]# /usr/bin/htpasswd -bc /application/nginx/conf/htpasswd zyb 123456
Adding password for user zyb
[root@centos-6-11 vhost]# /application/nginx/sbin/nginx -s reload
3 测试结果