样例
location / {
auth_basic "closed site";
auth_basic_user_file conf/htpasswd;
}
指令
语法 | 默认 | 作用域 | 描述 |
---|---|---|---|
auth_basic string ? off; | off | http, server, location, limit_except | 使用HTTP Basic Authentication协议做身份验证 |
auth_basic_user_file file; | — | http, server, location, limit_except |
密码文件:
可以使用"htpasswd"生成
file
# comment
name1:password1
name2:password2:comment
name3:password3
参考:
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html