Mercurial > hg > nginx-site
annotate xml/ru/docs/http/ngx_http_rewrite_module.xml @ 784:7d15bd7fc58d
The "auth_basic" directive now supports variables.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 11 Dec 2012 16:59:18 +0000 |
parents | 57fe6d7d86b4 |
children | 9fce700e56d3 |
rev | line source |
---|---|
222
bfe3eff81d04
Removed redundant encoding specification.
Ruslan Ermilov <ru@nginx.com>
parents:
110
diff
changeset
|
1 <?xml version="1.0"?> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
580
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
3 <!-- |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
4 Copyright (C) Igor Sysoev |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
5 Copyright (C) Nginx, Inc. |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
6 --> |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
548
diff
changeset
|
7 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
382 | 10 <module name="Модуль ngx_http_rewrite_module" |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 link="/ru/docs/http/ngx_http_rewrite_module.html" |
589 | 12 lang="ru" |
703
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
13 rev="3"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
110
40eec261c2a6
Added proper support for anonymous sections, notably for the summary.
Ruslan Ermilov <ru@nginx.com>
parents:
108
diff
changeset
|
15 <section id="summary"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 <para> |
382 | 18 Модуль <literal>ngx_http_rewrite_module</literal> позволяет |
19 изменять URI с помощью регулярных выражений, делать перенаправления | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
20 и выбирать конфигурацию по условию. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
21 </para> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
22 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
23 <para> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
24 Директивы модуля <literal>ngx_http_rewrite_module</literal> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
25 обрабатываются в следующем порядке: |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
26 <list type="bullet"> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
27 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
28 <listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
29 выполняются директивы этого модуля, описанные на уровне |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
30 <link doc="ngx_http_core_module.xml" id="server">сервера</link>; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
31 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
32 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
33 <listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
34 ищется location для запроса; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
35 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
36 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
37 <listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
38 выполняются директивы этого модуля, описанные в выбранном |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
39 <link doc="ngx_http_core_module.xml" id="location"/>, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
40 и если они изменяли URI, то ищется новый location для уже нового URI. |
674
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
41 Этот цикл может повторяться до |
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
42 <link doc="ngx_http_core_module.xml" id="internal">10 раз</link>, |
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
43 после чего возвращается ошибка |
c48c0936b4df
Documented internal redirections limit.
Vladimir Homutov <vl@nginx.com>
parents:
673
diff
changeset
|
44 <http-status code="500" text="Internal Server Error"/>. |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
45 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
46 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
47 </list> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 |
382 | 53 <section id="directives" name="Директивы"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 <directive name="break"> |
102
c76a257f3fd4
The directive name is now automatically printed in <default> and <syntax>.
Ruslan Ermilov <ru@nginx.com>
parents:
99
diff
changeset
|
56 <syntax/> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
57 <default/> |
382 | 58 <context>server</context> |
59 <context>location</context> | |
60 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 <para> |
382 | 63 Завершает обработку текущего набора директив модуля |
64 <literal>ngx_http_rewrite_module</literal>. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 <para> |
382 | 68 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 <example> |
382 | 70 if ($slow) { |
71 limit_rate 10k; | |
72 break; | |
73 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 <directive name="if"> |
108
72524ae53106
Explicitly marked directives with the block syntax. Such directives will
Ruslan Ermilov <ru@nginx.com>
parents:
106
diff
changeset
|
81 <syntax block="yes">(<value>условие</value>)</syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
82 <default/> |
382 | 83 <context>server</context> |
84 <context>location</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
87 Проверяется указанное <value>условие</value>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
88 Если оно истинно, то выполняются указанные в фигурных скобках директивы |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
89 этого модуля и запросу назначается конфигурация, указанная внутри |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
90 директивы <literal>if</literal>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
91 Конфигурации внутри директив <literal>if</literal> наследуются с |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
92 предыдущего уровня конфигурации. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 В качестве условия могут быть заданы: |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 <list type="bullet"> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
100 имя переменной; ложными значениями переменной являются пустая строка |
382 | 101 или любая строка, начинающаяся на “<literal>0</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 <listitem> |
382 | 105 сравнение переменной со строкой с помощью операторов |
106 “<literal>=</literal>” и “<literal>!=</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
110 соответствие переменной регулярному выражению с учётом |
382 | 111 регистра символов — “<literal>~</literal>” и без него — “<literal>~*</literal>”. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 В регулярных выражениях можно использовать выделения, которые затем |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
113 доступны в виде переменных <var>$1</var>..<var>$9</var>. |
382 | 114 Также можно использовать отрицательные операторы “<literal>!~</literal>” |
115 и “<literal>!~*</literal>”. | |
116 Если в регулярном выражении встречаются символы “<literal>}</literal>” | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
117 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 118 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 <listitem> |
382 | 122 проверка существования файла с помощью операторов “<literal>-f</literal>” |
123 и “<literal>!-f</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 <listitem> |
382 | 127 проверка существования каталога с помощью операторов “<literal>-d</literal>” |
128 и “<literal>!-d</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 <listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 проверка существования файла, каталога или символической ссылки |
382 | 133 с помощью операторов “<literal>-e</literal>” и “<literal>!-e</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 <listitem> |
382 | 137 проверка исполняемости файла с помощью операторов “<literal>-x</literal>” |
138 и “<literal>!-x</literal>”. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 </list> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 <para> |
382 | 145 Примеры: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 <example> |
382 | 147 if ($http_user_agent ~ MSIE) { |
148 rewrite ^(.*)$ /msie/$1 break; | |
149 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 |
382 | 151 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
152 set $id $1; | |
153 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 |
382 | 155 if ($request_method = POST) { |
156 return 405; | |
157 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 |
382 | 159 if ($slow) { |
160 limit_rate 10k; | |
161 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 |
382 | 163 if ($invalid_referer) { |
164 return 403; | |
165 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
167 <note> |
382 | 168 Значение встроенной переменной <var>$invalid_referer</var> задаётся директивой |
106
56457a474903
If text of the link is not provided, the @id is used.
Ruslan Ermilov <ru@nginx.com>
parents:
102
diff
changeset
|
169 <link doc="ngx_http_referer_module.xml" id="valid_referers"/>. |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
170 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 <directive name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
177 <syntax><value>код</value> [<value>текст</value>]</syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
178 <syntax><value>код</value> <value>URL</value></syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
179 <syntax><value>URL</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
180 <default/> |
382 | 181 <context>server</context> |
182 <context>location</context> | |
183 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
186 Завершает обработку и возвращает клиенту указанный <value>код</value>. |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
187 Нестандартный код 444 закрывает соединение без передачи |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 заголовка ответа. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
191 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
192 Начиная с версии 0.8.42 можно задать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
193 либо URL перенаправления (для кодов 301, 302, 303 и 307), |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
194 либо <value>текст</value> тела ответа (для остальных кодов). |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
195 В тексте тела ответа и URL перенаправления можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
196 Как частный случай, URL перенаправления может быть задан как URI, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
197 локальный для данного сервера, при этом полный URL перенаправления |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
198 формируется согласно схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
199 <link doc="ngx_http_core_module.xml" id="server_name_in_redirect"/> и |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
200 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
201 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
202 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
203 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
204 Кроме того, в качестве единственного параметра можно указать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
205 <value>URL</value> для временного перенаправления с кодом 302. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
206 Такой параметр должен начинаться со строк “<literal>http://</literal>”, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
207 “<literal>https://</literal>” или “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
208 В <value>URL</value> можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
209 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
210 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
211 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
212 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
213 До версии 0.7.51 можно было возвращать только следующие коды: |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
214 204, 400, 402 — 406, 408, 410, 411, 413, 416 и 500 — 504. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
215 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
216 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
217 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
218 До версий 1.1.16 и 1.0.13 код 307 не обрабатывался как перенаправление. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
219 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
220 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
221 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 <directive name="rewrite"> |
382 | 226 <syntax> |
227 <value>regex</value> | |
228 <value>замена</value> | |
229 [<value>флаг</value>]</syntax> | |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
230 <default/> |
382 | 231 <context>server</context> |
232 <context>location</context> | |
233 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
236 Если указанное регулярное выражение соответствует URI, URI изменяется |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
237 в соответствии со строкой замены. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
238 Директивы <literal>rewrite</literal> выполняются последовательно, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
239 в порядке их следования в конфигурационном файле. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
240 С помощью флагов можно прекратить дальнейшую обработку директив. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
241 Если строка замены начинается с “<literal>http://</literal>” или |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
242 “<literal>https://</literal>”, то обработка завершается и клиенту |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
243 возвращается перенаправление. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
247 Необязательный параметр <value>флаг</value> может быть одним из: |
382 | 248 <list type="tag"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 |
382 | 250 <tag-name><literal>last</literal></tag-name> |
251 <tag-desc> | |
252 завершает обработку текущего набора директив модуля | |
253 <literal>ngx_http_rewrite_module</literal>, | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
254 после чего ищется новый location, соответствующий изменённому URI; |
382 | 255 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 |
382 | 257 <tag-name><literal>break</literal></tag-name> |
258 <tag-desc> | |
259 завершает обработку текущего набора директив модуля | |
260 <literal>ngx_http_rewrite_module</literal>; | |
261 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 |
382 | 263 <tag-name><literal>redirect</literal></tag-name> |
264 <tag-desc> | |
265 возвращает временное перенаправление с кодом 302; | |
266 используется, если заменяющая строка не начинается с | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
267 “<literal>http://</literal>” или “<literal>https://</literal>”; |
382 | 268 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 |
382 | 270 <tag-name><literal>permanent</literal></tag-name> |
271 <tag-desc> | |
272 возвращает постоянное перенаправление с кодом 301. | |
273 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
276 Полный URL перенаправлений формируется согласно |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
277 схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
278 <link doc="ngx_http_core_module.xml" id="server_name_in_redirect"/> и |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
279 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
281 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 <para> |
382 | 283 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 <example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
285 server { |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
286 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
287 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
288 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
289 return 403; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
290 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
291 } |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
295 <para> |
382 | 296 Если же эти директивы поместить в location “<literal>/download/</literal>”, |
297 то нужно заменить флаг <literal>last</literal> на <literal>break</literal>, | |
298 иначе nginx сделает 10 циклов и вернёт ошибку 500: | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 <example> |
382 | 300 location /download/ { |
301 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; | |
302 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; | |
303 return 403; | |
304 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
307 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
309 Если в строке замены указаны новые аргументы запроса, то предыдущие |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
310 аргументы запроса добавляются после них. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
311 Если такое поведение нежелательно, можно отказаться от этого добавления, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
312 указав в конце строки замены знак вопроса, например: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 <example> |
382 | 314 rewrite ^/users/(.*)$ /show?user=$1? last; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
318 <para> |
382 | 319 Если в регулярном выражении встречаются символы “<literal>}</literal>” |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
320 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 321 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
327 <directive name="rewrite_log"> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
328 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
329 <default>off</default> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
330 <context>http</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
331 <context>server</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
332 <context>location</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
333 <context>if</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
334 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
335 <para> |
703
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
336 Разрешает или запрещает записывать в |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
337 <link doc="../ngx_core_module.xml" id="error_log"/> |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
338 на уровне <literal>notice</literal> |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
339 результаты обработки директив модуля <literal>ngx_http_rewrite_module</literal>. |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
340 </para> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
341 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
342 </directive> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
343 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
344 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
345 <directive name="set"> |
382 | 346 <syntax><value>переменная</value> <value>значение</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
347 <default/> |
382 | 348 <context>server</context> |
349 <context>location</context> | |
350 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
351 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
352 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
353 Устанавливает значение указанной переменной. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
354 В качестве значения можно использовать текст, переменные и их комбинации. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
355 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
356 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
357 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
358 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
359 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
360 <directive name="uninitialized_variable_warn"> |
271 | 361 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
102
c76a257f3fd4
The directive name is now automatically printed in <default> and <syntax>.
Ruslan Ermilov <ru@nginx.com>
parents:
99
diff
changeset
|
362 <default>on</default> |
382 | 363 <context>http</context> |
364 <context>server</context> | |
365 <context>location</context> | |
366 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
367 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
368 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
369 Определяет, нужно ли писать в лог предупреждения о неинициализированных |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
370 переменных. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
371 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
372 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
373 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
374 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
375 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
376 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
377 |
382 | 378 <section id="internals" name="Внутреннее устройство"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
379 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
380 <para> |
382 | 381 Директивы модуля <literal>ngx_http_rewrite_module</literal> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
382 компилируются на стадии конфигурации во внутренние инструкции, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
383 интерпретируемые во время обработки запроса. |
382 | 384 Интерпретатор представляет из себя простую стековую виртуальную машину. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
385 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
386 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
387 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
388 Например, директивы |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
389 <example> |
382 | 390 location /download/ { |
391 if ($forbidden) { | |
392 return 403; | |
393 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
394 |
382 | 395 if ($slow) { |
396 limit_rate 10k; | |
397 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
398 |
382 | 399 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
400 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
401 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
402 будут транслированы в такие инструкции: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
403 <example> |
382 | 404 переменная $forbidden |
405 проверка на ноль | |
406 возврат 403 | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
407 завершение всего кода |
382 | 408 переменная $slow |
409 проверка на ноль | |
410 проверка регулярного выражения | |
411 копирование "/" | |
412 копирование $1 | |
413 копирование "/mp3/" | |
414 копирование $2 | |
415 копирование ".mp3" | |
416 завершение регулярного выражения | |
417 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
418 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
419 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
420 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
421 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
422 Обратите внимание, что инструкций для директивы |
382 | 423 <link doc="ngx_http_core_module.xml" id="limit_rate"/> |
424 нет, поскольку она не имеет отношения к модулю | |
425 <literal>ngx_http_rewrite_module</literal>. | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
426 Для блока <link id="if"/> создаётся отдельная конфигурация, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
427 Если условие истинно, запрос получает эту конфигурацию, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
428 и в ней <literal>limit_rate</literal> равен 10k. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
429 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
430 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
431 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
432 Директиву |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
433 <example> |
382 | 434 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
435 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
436 можно сделать на одну инструкцию меньше, если в регулярном выражении перенести |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
437 первый слэш внутрь скобок: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
438 <example> |
382 | 439 rewrite ^(<emphasis>/</emphasis>download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
440 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
441 Тогда соответствующие инструкции будут выглядеть так: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
442 <example> |
382 | 443 проверка регулярного выражения |
444 копирование $1 | |
445 копирование "/mp3/" | |
446 копирование $2 | |
447 копирование ".mp3" | |
448 завершение регулярного выражения | |
449 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
450 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
451 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
452 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
453 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
454 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
455 </module> |