Mercurial > hg > nginx-site
annotate xml/ru/docs/http/ngx_http_rewrite_module.xml @ 862:6a40b8e7219a
Documented the "fastcgi_catch_stderr" directive.
author | Homutov Vladimir <vl@nginx.com> |
---|---|
date | Tue, 12 Mar 2013 14:45:25 +0400 |
parents | 6ae71688f2c2 |
children | 95c3c3bbf1ce |
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" |
860
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
13 rev="4"> |
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 имя переменной; ложными значениями переменной являются пустая строка |
860
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
101 или “<literal>0</literal>”; |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
102 <note> |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
103 До версии 1.0.1 ложным значением также являлась любая строка, |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
104 начинающаяся на “<literal>0</literal>”. |
861 | 105 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 <listitem> |
382 | 109 сравнение переменной со строкой с помощью операторов |
110 “<literal>=</literal>” и “<literal>!=</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
114 соответствие переменной регулярному выражению с учётом |
382 | 115 регистра символов — “<literal>~</literal>” и без него — “<literal>~*</literal>”. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 В регулярных выражениях можно использовать выделения, которые затем |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
117 доступны в виде переменных <var>$1</var>..<var>$9</var>. |
382 | 118 Также можно использовать отрицательные операторы “<literal>!~</literal>” |
119 и “<literal>!~*</literal>”. | |
120 Если в регулярном выражении встречаются символы “<literal>}</literal>” | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
121 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 122 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 <listitem> |
382 | 126 проверка существования файла с помощью операторов “<literal>-f</literal>” |
127 и “<literal>!-f</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 <listitem> |
382 | 131 проверка существования каталога с помощью операторов “<literal>-d</literal>” |
132 и “<literal>!-d</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 <listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 проверка существования файла, каталога или символической ссылки |
382 | 137 с помощью операторов “<literal>-e</literal>” и “<literal>!-e</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 <listitem> |
382 | 141 проверка исполняемости файла с помощью операторов “<literal>-x</literal>” |
142 и “<literal>!-x</literal>”. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 </list> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 <para> |
382 | 149 Примеры: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 <example> |
382 | 151 if ($http_user_agent ~ MSIE) { |
152 rewrite ^(.*)$ /msie/$1 break; | |
153 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 |
382 | 155 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
156 set $id $1; | |
157 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 |
382 | 159 if ($request_method = POST) { |
160 return 405; | |
161 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 |
382 | 163 if ($slow) { |
164 limit_rate 10k; | |
165 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 |
382 | 167 if ($invalid_referer) { |
168 return 403; | |
169 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
171 <note> |
382 | 172 Значение встроенной переменной <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
|
173 <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
|
174 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 <directive name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
181 <syntax><value>код</value> [<value>текст</value>]</syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
182 <syntax><value>код</value> <value>URL</value></syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
183 <syntax><value>URL</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
184 <default/> |
382 | 185 <context>server</context> |
186 <context>location</context> | |
187 <context>if</context> | |
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> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
190 Завершает обработку и возвращает клиенту указанный <value>код</value>. |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
191 Нестандартный код 444 закрывает соединение без передачи |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 заголовка ответа. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
195 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
196 Начиная с версии 0.8.42 можно задать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
197 либо URL перенаправления (для кодов 301, 302, 303 и 307), |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
198 либо <value>текст</value> тела ответа (для остальных кодов). |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
199 В тексте тела ответа и URL перенаправления можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
200 Как частный случай, URL перенаправления может быть задан как URI, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
201 локальный для данного сервера, при этом полный URL перенаправления |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
202 формируется согласно схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
203 <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
|
204 <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
|
205 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
206 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
207 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
208 Кроме того, в качестве единственного параметра можно указать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
209 <value>URL</value> для временного перенаправления с кодом 302. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
210 Такой параметр должен начинаться со строк “<literal>http://</literal>”, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
211 “<literal>https://</literal>” или “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
212 В <value>URL</value> можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
213 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
214 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
215 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
216 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
217 До версии 0.7.51 можно было возвращать только следующие коды: |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
218 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
|
219 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
220 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
221 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
222 До версий 1.1.16 и 1.0.13 код 307 не обрабатывался как перенаправление. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
223 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
224 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
225 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 <directive name="rewrite"> |
382 | 230 <syntax> |
231 <value>regex</value> | |
232 <value>замена</value> | |
233 [<value>флаг</value>]</syntax> | |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
234 <default/> |
382 | 235 <context>server</context> |
236 <context>location</context> | |
237 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
240 Если указанное регулярное выражение соответствует URI, URI изменяется |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
241 в соответствии со строкой замены. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
242 Директивы <literal>rewrite</literal> выполняются последовательно, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
243 в порядке их следования в конфигурационном файле. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
244 С помощью флагов можно прекратить дальнейшую обработку директив. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
245 Если строка замены начинается с “<literal>http://</literal>” или |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
246 “<literal>https://</literal>”, то обработка завершается и клиенту |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
247 возвращается перенаправление. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
251 Необязательный параметр <value>флаг</value> может быть одним из: |
382 | 252 <list type="tag"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 |
382 | 254 <tag-name><literal>last</literal></tag-name> |
255 <tag-desc> | |
256 завершает обработку текущего набора директив модуля | |
257 <literal>ngx_http_rewrite_module</literal>, | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
258 после чего ищется новый location, соответствующий изменённому URI; |
382 | 259 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 |
382 | 261 <tag-name><literal>break</literal></tag-name> |
262 <tag-desc> | |
263 завершает обработку текущего набора директив модуля | |
264 <literal>ngx_http_rewrite_module</literal>; | |
265 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 |
382 | 267 <tag-name><literal>redirect</literal></tag-name> |
268 <tag-desc> | |
269 возвращает временное перенаправление с кодом 302; | |
270 используется, если заменяющая строка не начинается с | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
271 “<literal>http://</literal>” или “<literal>https://</literal>”; |
382 | 272 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 |
382 | 274 <tag-name><literal>permanent</literal></tag-name> |
275 <tag-desc> | |
276 возвращает постоянное перенаправление с кодом 301. | |
277 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
280 Полный URL перенаправлений формируется согласно |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
281 схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
282 <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
|
283 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 <para> |
382 | 287 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 <example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
289 server { |
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 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
292 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
293 return 403; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
294 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
295 } |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
296 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
298 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 <para> |
382 | 300 Если же эти директивы поместить в location “<literal>/download/</literal>”, |
301 то нужно заменить флаг <literal>last</literal> на <literal>break</literal>, | |
302 иначе nginx сделает 10 циклов и вернёт ошибку 500: | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 <example> |
382 | 304 location /download/ { |
305 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; | |
306 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; | |
307 return 403; | |
308 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
313 Если в строке замены указаны новые аргументы запроса, то предыдущие |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
314 аргументы запроса добавляются после них. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
315 Если такое поведение нежелательно, можно отказаться от этого добавления, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
316 указав в конце строки замены знак вопроса, например: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 <example> |
382 | 318 rewrite ^/users/(.*)$ /show?user=$1? last; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
319 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
320 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
321 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 <para> |
382 | 323 Если в регулярном выражении встречаются символы “<literal>}</literal>” |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
324 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 325 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
327 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
328 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
331 <directive name="rewrite_log"> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
332 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
333 <default>off</default> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
334 <context>http</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
335 <context>server</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
336 <context>location</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
337 <context>if</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
338 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
339 <para> |
703
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
340 Разрешает или запрещает записывать в |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
341 <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
|
342 на уровне <literal>notice</literal> |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
343 результаты обработки директив модуля <literal>ngx_http_rewrite_module</literal>. |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
344 </para> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
345 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
346 </directive> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
347 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
348 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
349 <directive name="set"> |
382 | 350 <syntax><value>переменная</value> <value>значение</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
351 <default/> |
382 | 352 <context>server</context> |
353 <context>location</context> | |
354 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
355 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
356 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
357 Устанавливает значение указанной переменной. |
76
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 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
360 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
361 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
362 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
363 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
364 <directive name="uninitialized_variable_warn"> |
271 | 365 <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
|
366 <default>on</default> |
382 | 367 <context>http</context> |
368 <context>server</context> | |
369 <context>location</context> | |
370 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
371 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
372 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
373 Определяет, нужно ли писать в лог предупреждения о неинициализированных |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
374 переменных. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
375 </para> |
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 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
378 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
379 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
380 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
381 |
382 | 382 <section id="internals" name="Внутреннее устройство"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
383 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
384 <para> |
382 | 385 Директивы модуля <literal>ngx_http_rewrite_module</literal> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
386 компилируются на стадии конфигурации во внутренние инструкции, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
387 интерпретируемые во время обработки запроса. |
382 | 388 Интерпретатор представляет из себя простую стековую виртуальную машину. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
389 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
390 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
391 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
392 Например, директивы |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
393 <example> |
382 | 394 location /download/ { |
395 if ($forbidden) { | |
396 return 403; | |
397 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
398 |
382 | 399 if ($slow) { |
400 limit_rate 10k; | |
401 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
402 |
382 | 403 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
404 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
405 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
406 будут транслированы в такие инструкции: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
407 <example> |
382 | 408 переменная $forbidden |
409 проверка на ноль | |
410 возврат 403 | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
411 завершение всего кода |
382 | 412 переменная $slow |
413 проверка на ноль | |
414 проверка регулярного выражения | |
415 копирование "/" | |
416 копирование $1 | |
417 копирование "/mp3/" | |
418 копирование $2 | |
419 копирование ".mp3" | |
420 завершение регулярного выражения | |
421 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
422 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
423 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
424 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
425 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
426 Обратите внимание, что инструкций для директивы |
382 | 427 <link doc="ngx_http_core_module.xml" id="limit_rate"/> |
428 нет, поскольку она не имеет отношения к модулю | |
429 <literal>ngx_http_rewrite_module</literal>. | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
430 Для блока <link id="if"/> создаётся отдельная конфигурация, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
431 Если условие истинно, запрос получает эту конфигурацию, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
432 и в ней <literal>limit_rate</literal> равен 10k. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
433 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
434 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
435 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
436 Директиву |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
437 <example> |
382 | 438 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
439 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
440 можно сделать на одну инструкцию меньше, если в регулярном выражении перенести |
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 rewrite ^(<emphasis>/</emphasis>download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
444 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
445 Тогда соответствующие инструкции будут выглядеть так: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
446 <example> |
382 | 447 проверка регулярного выражения |
448 копирование $1 | |
449 копирование "/mp3/" | |
450 копирование $2 | |
451 копирование ".mp3" | |
452 завершение регулярного выражения | |
453 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
454 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
455 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
456 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
457 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
458 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
459 </module> |