最近在读 <
nginx http_auth_basic_module
模块为默认模块 不需要再编译时配置 可以直接 auth_basic
在location
块中设置
location / {
auth_basic "secret";
auth_basic_user_file /usr/local/nginx/passwd.db;
}
htpasswd -c /usr/local/nginx/passwd.db test //创建认证信息,test 为认证用户名
New password: ******* //输入认证密码
Re-type new password: ******** //再次输入认证密码
重启nginx
nginx -s reload
亲测有效