模块 ngx_http_access_module

示例
Directives
允许
deny

ngx_http_access_modulemodule 允许 限制对某些客户端地址的访问。

访问也可以通过密码子请求的结果、 或通过 JWT 获取。 通过地址和密码同时限制访问 通过 satisfy Directives。

示例配置

location / {
    deny  192.168.1.1;
    allow 192.168.1.0/24;
    allow 10.1.1.0/16;
    allow 2001:0db8::/32;
    deny  all;
}

将按顺序检查规则,直到找到第一个匹配项。 在此示例中,仅允许 IPv4 网络访问10.1.1.0/16192.168.1.0/24排除地址192.168.1.1, 和 IPv6 网络2001:0db8::/32. 在有很多规则的情况下,最好使用 ngx_http_geo_module 模块变量。

Directives

语法: allow address | CIDR | unix: | all;
默认值:
上下文: http,server,location,limit_except

允许访问指定的网络或地址。 如果 special valueunix:指定 (1.5.1)、 允许访问所有 UNIX 域套接字。

语法: deny address | CIDR | unix: | all;
默认值:
上下文: http,server,location,limit_except

拒绝对指定网络或地址的访问。 如果 special valueunix:指定 (1.5.1)、 拒绝对所有 UNIX 域套接字的访问。