annotate xml/cn/docs/http/ngx_http_referer_module.xml @ 2735:ff357b676c2e

Removed trailing spaces.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 10 Jun 2021 18:27:24 +0300
parents ceb8a4e374b7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
792
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
1 <?xml version="1.0"?>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
2
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
3 <!--
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
4 Copyright (C) Igor Sysoev
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
5 Copyright (C) Nginx, Inc.
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
6 -->
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
7
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
9
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
10 <module name="ngx_http_referer_module模块"
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
11 link="/cn/docs/http/ngx_http_referer_module.html"
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
12 lang="cn"
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
13 translator="nigelzeng"
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14 rev="1">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16 <section id="summary">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
18 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
19 <literal>ngx_http_referer_module</literal>模块允许拦截<header>Referer</header>请求头中含有非法值的请求,阻止它们访问站点。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
20 需要注意的是伪造一个有效的<header>Referer</header>请求头是相当容易的,
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
21 因此这个模块的预期目的不在于彻底地阻止这些非法请求,而是为了阻止由正常浏览器发出的大规模此类请求。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
22 还有一点需要注意,即使正常浏览器发送的合法请求,也可能没有<header>Referer</header>请求头。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
23 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
24
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25 </section>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
26
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
27
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28 <section id="example" name="配置实例">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
29
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
30 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31 <example>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32 valid_referers none blocked server_names
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33 *.example.com example.* www.example.org/galleries/
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34 ~\.google\.;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
36 if ($invalid_referer) {
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37 return 403;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
38 }
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
39 </example>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
40 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
41
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
42 </section>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
43
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
44
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
45 <section id="directives" name="指令">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
47 <directive name="referer_hash_bucket_size">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48 <syntax><value>size</value></syntax>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49 <default>64</default>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
50 <context>server</context>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
51 <context>location</context>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
52 <appeared-in>1.0.5</appeared-in>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
53
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
54 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
55 设置用来存储有效referer的哈希表的表项长度。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
56 详细的情况参见<link doc="../hash.xml">哈希表设置</link>。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
57 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
58
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
59 </directive>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
60
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
61
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
62 <directive name="referer_hash_max_size">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
63 <syntax><value>size</value></syntax>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
64 <default>2048</default>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
65 <context>server</context>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
66 <context>location</context>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
67 <appeared-in>1.0.5</appeared-in>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
68
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
69 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
70 设置用来存储有效referer的哈希表最大<value>桶容量</value>。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
71 详细的情况参见<link doc="../hash.xml">哈希表设置</link>。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
72 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
73
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
74 </directive>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
75
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
76
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
77 <directive name="valid_referers">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
78 <syntax>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
79 <literal>none</literal> |
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
80 <literal>blocked</literal> |
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
81 <literal>server_names</literal> |
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
82 <value>string</value>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
83 ...</syntax>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
84 <default/>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
85 <context>server</context>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
86 <context>location</context>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
87
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
88 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
89 <header>Referer</header>请求头为指定值时,内嵌变量<var>$invalid_referer</var>被设置为空字符串,
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
90 否则这个变量会被置成“<literal>1</literal>”。查找匹配时不区分大小写。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
91 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
92
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
93 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
94 该指令的参数可以为下面的内容:
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
95 <list type="tag">
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
96
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
97 <tag-name><literal>none</literal></tag-name>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
98 <tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
99 缺少<header>Referer</header>请求头;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
100 </tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
101
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
102 <tag-name><literal>blocked</literal></tag-name>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
103 <tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
104 <header>Referer</header> 请求头存在,但是它的值被防火墙或者代理服务器删除;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
105 这些值都不以“<literal>http://</literal>” 或者 “<literal>https://</literal>”字符串作为开头;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
106 </tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
107
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
108 <tag-name><literal>server_names</literal></tag-name>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
109 <tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
110 <header>Referer</header> 请求头包含某个虚拟主机名;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
111 </tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
112
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
113 <tag-name>任意字符串</tag-name>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
114 <tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
115 定义一个服务器名和可选的URI前缀。服务器名允许在开头或结尾使用“<literal>*</literal>”符号。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
116 当nginx检查时,<header>Referer</header>请求头里的服务器端口将被忽略。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
117 </tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
118
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
119 <tag-name>正则表达式</tag-name>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
120 <tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
121 必须以“<literal>~</literal>”符号作为开头。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
122 需要注意的是表达式会从“<literal>http://</literal>”或者“<literal>https://</literal>”之后的文本开始匹配。
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
123 </tag-desc>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
124
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
125 </list>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
126 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
127
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
128 <para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
129 实例:
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
130 <example>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
131 valid_referers none blocked server_names
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
132 *.example.com example.* www.example.org/galleries/
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
133 ~\.google\.;
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
134 </example>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
135 </para>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
136
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
137 </directive>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
138
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
139 </section>
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
140
ceb8a4e374b7 Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
141 </module>