基于ngx_http_auth_basic_module模块,默认可用
语法:
auth_basic “提示信息”;
auth_basic_user_file /etc/nginx/htpasswd;
配置实现:
①创建用户名和密码存储文件
shell > yum -y install httpd-tools
shell > cd /usr/local/nginx/conf
#生成用户名称和密码(这两个参数自定义)
shell > htpasswd -c ./password.db snljh
#输入密码并再次确认密码
#查看password.db文件是否创建成功
shell > ls