使用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";
}
# -c /etc/nginx/.htpasswd yuan
New password: # set password
Re-type new password: # confirm
Adding password for user yuan
#/etc/rc.d/init.d/nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
再次访问网站的时候就会出现一个认证对话框!
阅读(403) | 评论(0) | 转发(0) |