使用nginx作为网站服务,在访问网站首页的时候添加一个简单的认证;
# yum -y install httpd-tools
# vim /etc/nginx/conf.d/default.conf
# add follows in "server" section
location /basic {
auth_basic "Basic Auth";
auth_basic_user_file "/etc/nginx/.htpasswd";
}
auth_basic "Basic Auth";
auth_basic_user_file "/etc/nginx/.htpasswd";
}
New password:
# set password
Re-type new password: # confirm
Adding password for user yuan
# /etc/rc.d/init.d/nginx restart
Re-type new password: # confirm
Adding password for user yuan
# /etc/rc.d/init.d/nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
Starting nginx: [ OK ]
再次访问网站的时候就会出现一个认证对话框!
转载于:https://blog.51cto.com/kernal/1540530