Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/cn/docs/http/ngx_http_access_module.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Igor Sysoev
5
Copyright (C) Nginx, Inc.
6
-->
7
8
<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
9
10
<module name="ngx_http_access_module模块"
11
link="/cn/docs/http/ngx_http_access_module.html"
12
lang="cn"
13
translator="WenMing"
14
rev="1">
15
16
<section id="summary">
17
18
<para>
19
模块 <literal>ngx_http_access_module</literal> 允许限制某些IP地址的客户端访问。
20
</para>
21
22
<para>
23
也可以通过
24
<link doc="ngx_http_auth_basic_module.xml">密码</link>来限制访问。
25
使用
26
<link doc="ngx_http_core_module.xml" id="satisfy"/> 指令就能同时通过IP地址和密码来限制访问。
27
</para>
28
29
</section>
30
31
32
<section id="example" name="配置范例">
33
34
<para>
35
<example>
36
location / {
37
deny 192.168.1.1;
38
allow 192.168.1.0/24;
39
allow 10.1.1.0/16;
40
allow 2001:0db8::/32;
41
deny all;
42
}
43
</example>
44
</para>
45
46
<para>
47
规则按照顺序依次检测,直到匹配到第一条规则。
48
在这个例子里,IPv4的网络中只有
49
<literal>10.1.1.0/16</literal> <literal>192.168.1.0/24</literal>允许访问,但
50
<literal>192.168.1.1</literal>除外,
51
对于IPv6的网络,只有<literal>2001:0db8::/32</literal>允许访问。
52
在规则很多的情况下,使用
53
<link doc="ngx_http_geo_module.xml">ngx_http_geo_module</link>
54
模块变量更合适。
55
</para>
56
57
</section>
58
59
60
<section id="directives" name="指令">
61
62
<directive name="allow">
63
<syntax>
64
<value>address</value> |
65
<value>CIDR</value> |
66
<literal>all</literal></syntax>
67
<default/>
68
<context>http</context>
69
<context>server</context>
70
<context>location</context>
71
<context>limit_except</context>
72
73
<para>
74
允许指定的网络地址访问。
75
</para>
76
77
</directive>
78
79
80
<directive name="deny">
81
<syntax>
82
<value>address</value> |
83
<value>CIDR</value> |
84
<literal>all</literal></syntax>
85
<default/>
86
<context>http</context>
87
<context>server</context>
88
<context>location</context>
89
<context>limit_except</context>
90
91
<para>
92
拒绝指定的网络地址访问。
93
</para>
94
95
</directive>
96
97
</section>
98
99
</module>
100
101