模块 ngx_http_auth_basic_module
auth_basic auth_basic_user_file 的配置 Directives 示例 |
该模块允许
通过验证用户名和密码来限制对资源的访问
使用 “HTTP Basic Authentication” 协议。ngx_http_auth_basic_module
访问也可以通过地址、子请求的结果、 或通过 JWT 获取。 通过地址和密码同时限制访问 通过 satisfy Directives。
示例配置
location / { auth_basic "closed site"; auth_basic_user_file conf/htpasswd; }
Directives
语法: |
auth_basic |
---|---|
默认值: |
auth_basic off; |
上下文: |
http , , ,server location limit_except |
使用
“HTTP 基本身份验证”协议。
指定的参数用作 .
参数值可以包含变量 (1.3.10, 1.2.7)。
特殊值取消效果
Directives
继承自之前的配置级别。realm
off
auth_basic
语法: |
auth_basic_user_file |
---|---|
默认值: | — |
上下文: |
http , , ,server location limit_except |
指定一个保存用户名和密码的文件, 格式如下:
# comment name1:password1 name2:password2:comment name3:password3
名称可以包含变量。file
支持以下密码类型:
- 使用函数加密;可以使用
Apache HTTP Server 中的 “” 实用程序
distribution 或 “” 命令;
crypt()
htpasswd
openssl passwd
- 使用基于 MD5 的密码算法 (apr1) 的 Apache 变体进行哈希处理; 可以使用相同的工具生成;
- 由
“”
语法 (1.0.3+),如 RFC 2307 中所述;
当前实现的方案包括 (一个示例
不应使用)、(1.3.13)(普通 SHA-1
哈希,不应使用)和(加盐 SHA-1 哈希、
被一些软件包使用,特别是 OpenLDAP 和 Dovecot)。
{
scheme
}
data
PLAIN
SHA
SSHA
添加对 scheme 的支持只是为了帮助 从其他 Web 服务器迁移。 它不应用于新密码,因为未加盐的 SHA-1 哈希 它所采用的容易受到 Rainbow Table 的攻击。
SHA