Mercurial > hg > nginx-site
annotate xml/ru/docs/http/ngx_http_rewrite_module.xml @ 666:7465218cf964
Added pop3,imap and smtp mail modules to modules index.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 05 Sep 2012 15:25:26 +0000 |
parents | 764fbac1b8b4 |
children | f2d8603813b0 |
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" |
13 rev="1"> | |
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. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
41 Этот цикл может повторяться до 10 раз, после чего возвращается |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
42 ошибка <http-status code="500" text="Internal Server Error"/>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
43 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
44 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
45 </list> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 </section> |
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 |
382 | 51 <section id="directives" name="Директивы"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 <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
|
54 <syntax/> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
55 <default/> |
382 | 56 <context>server</context> |
57 <context>location</context> | |
58 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 <para> |
382 | 61 Завершает обработку текущего набора директив модуля |
62 <literal>ngx_http_rewrite_module</literal>. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 <para> |
382 | 66 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 <example> |
382 | 68 if ($slow) { |
69 limit_rate 10k; | |
70 break; | |
71 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 </directive> |
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 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 <directive name="if"> |
108
72524ae53106
Explicitly marked directives with the block syntax. Such directives will
Ruslan Ermilov <ru@nginx.com>
parents:
106
diff
changeset
|
79 <syntax block="yes">(<value>условие</value>)</syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
80 <default/> |
382 | 81 <context>server</context> |
82 <context>location</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
85 Проверяется указанное <value>условие</value>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
86 Если оно истинно, то выполняются указанные в фигурных скобках директивы |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
87 этого модуля и запросу назначается конфигурация, указанная внутри |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
88 директивы <literal>if</literal>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
89 Конфигурации внутри директив <literal>if</literal> наследуются с |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
90 предыдущего уровня конфигурации. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 |
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 <list type="bullet"> |
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 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
98 имя переменной; ложными значениями переменной являются пустая строка |
382 | 99 или любая строка, начинающаяся на “<literal>0</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 <listitem> |
382 | 103 сравнение переменной со строкой с помощью операторов |
104 “<literal>=</literal>” и “<literal>!=</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
108 соответствие переменной регулярному выражению с учётом |
382 | 109 регистра символов — “<literal>~</literal>” и без него — “<literal>~*</literal>”. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 В регулярных выражениях можно использовать выделения, которые затем |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
111 доступны в виде переменных <var>$1</var>..<var>$9</var>. |
382 | 112 Также можно использовать отрицательные операторы “<literal>!~</literal>” |
113 и “<literal>!~*</literal>”. | |
114 Если в регулярном выражении встречаются символы “<literal>}</literal>” | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
115 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 116 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 <listitem> |
382 | 120 проверка существования файла с помощью операторов “<literal>-f</literal>” |
121 и “<literal>!-f</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 <listitem> |
382 | 125 проверка существования каталога с помощью операторов “<literal>-d</literal>” |
126 и “<literal>!-d</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 |
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 проверка существования файла, каталога или символической ссылки |
382 | 131 с помощью операторов “<literal>-e</literal>” и “<literal>!-e</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 <listitem> |
382 | 135 проверка исполняемости файла с помощью операторов “<literal>-x</literal>” |
136 и “<literal>!-x</literal>”. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 </list> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 <para> |
382 | 143 Примеры: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 <example> |
382 | 145 if ($http_user_agent ~ MSIE) { |
146 rewrite ^(.*)$ /msie/$1 break; | |
147 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 |
382 | 149 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
150 set $id $1; | |
151 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
382 | 153 if ($request_method = POST) { |
154 return 405; | |
155 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 |
382 | 157 if ($slow) { |
158 limit_rate 10k; | |
159 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 |
382 | 161 if ($invalid_referer) { |
162 return 403; | |
163 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
165 <note> |
382 | 166 Значение встроенной переменной <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
|
167 <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
|
168 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 </directive> |
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 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 <directive name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
175 <syntax><value>код</value> [<value>текст</value>]</syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
176 <syntax><value>код</value> <value>URL</value></syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
177 <syntax><value>URL</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
178 <default/> |
382 | 179 <context>server</context> |
180 <context>location</context> | |
181 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
184 Завершает обработку и возвращает клиенту указанный <value>код</value>. |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
185 Нестандартный код 444 закрывает соединение без передачи |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 заголовка ответа. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
189 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
190 Начиная с версии 0.8.42 можно задать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
191 либо URL перенаправления (для кодов 301, 302, 303 и 307), |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
192 либо <value>текст</value> тела ответа (для остальных кодов). |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
193 В тексте тела ответа и URL перенаправления можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
194 Как частный случай, URL перенаправления может быть задан как URI, |
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 формируется согласно схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
197 <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
|
198 <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
|
199 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
200 |
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 <value>URL</value> для временного перенаправления с кодом 302. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
204 Такой параметр должен начинаться со строк “<literal>http://</literal>”, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
205 “<literal>https://</literal>” или “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
206 В <value>URL</value> можно использовать переменные. |
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 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
210 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
211 До версии 0.7.51 можно было возвращать только следующие коды: |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
212 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
|
213 </note> |
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 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
216 До версий 1.1.16 и 1.0.13 код 307 не обрабатывался как перенаправление. |
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 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
219 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
221 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 <directive name="rewrite"> |
382 | 224 <syntax> |
225 <value>regex</value> | |
226 <value>замена</value> | |
227 [<value>флаг</value>]</syntax> | |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
228 <default/> |
382 | 229 <context>server</context> |
230 <context>location</context> | |
231 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
234 Если указанное регулярное выражение соответствует URI, URI изменяется |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
235 в соответствии со строкой замены. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
236 Директивы <literal>rewrite</literal> выполняются последовательно, |
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 С помощью флагов можно прекратить дальнейшую обработку директив. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
239 Если строка замены начинается с “<literal>http://</literal>” или |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
240 “<literal>https://</literal>”, то обработка завершается и клиенту |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
241 возвращается перенаправление. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
245 Необязательный параметр <value>флаг</value> может быть одним из: |
382 | 246 <list type="tag"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 |
382 | 248 <tag-name><literal>last</literal></tag-name> |
249 <tag-desc> | |
250 завершает обработку текущего набора директив модуля | |
251 <literal>ngx_http_rewrite_module</literal>, | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
252 после чего ищется новый location, соответствующий изменённому URI; |
382 | 253 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 |
382 | 255 <tag-name><literal>break</literal></tag-name> |
256 <tag-desc> | |
257 завершает обработку текущего набора директив модуля | |
258 <literal>ngx_http_rewrite_module</literal>; | |
259 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 |
382 | 261 <tag-name><literal>redirect</literal></tag-name> |
262 <tag-desc> | |
263 возвращает временное перенаправление с кодом 302; | |
264 используется, если заменяющая строка не начинается с | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
265 “<literal>http://</literal>” или “<literal>https://</literal>”; |
382 | 266 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 |
382 | 268 <tag-name><literal>permanent</literal></tag-name> |
269 <tag-desc> | |
270 возвращает постоянное перенаправление с кодом 301. | |
271 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
274 Полный URL перенаправлений формируется согласно |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
275 схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
276 <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
|
277 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 <para> |
382 | 281 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 <example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
283 server { |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
284 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
285 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
286 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
287 return 403; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
288 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
289 } |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 <para> |
382 | 294 Если же эти директивы поместить в location “<literal>/download/</literal>”, |
295 то нужно заменить флаг <literal>last</literal> на <literal>break</literal>, | |
296 иначе nginx сделает 10 циклов и вернёт ошибку 500: | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 <example> |
382 | 298 location /download/ { |
299 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; | |
300 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; | |
301 return 403; | |
302 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
307 Если в строке замены указаны новые аргументы запроса, то предыдущие |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
308 аргументы запроса добавляются после них. |
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 указав в конце строки замены знак вопроса, например: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 <example> |
382 | 312 rewrite ^/users/(.*)$ /show?user=$1? last; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 <para> |
382 | 317 Если в регулярном выражении встречаются символы “<literal>}</literal>” |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
318 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 319 или двойные кавычки. |
76
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 </directive> |
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 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 <directive name="set"> |
382 | 326 <syntax><value>переменная</value> <value>значение</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
327 <default/> |
382 | 328 <context>server</context> |
329 <context>location</context> | |
330 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
331 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
332 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
333 Устанавливает значение указанной переменной. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
334 В качестве значения можно использовать текст, переменные и их комбинации. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
335 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
339 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
340 <directive name="uninitialized_variable_warn"> |
271 | 341 <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
|
342 <default>on</default> |
382 | 343 <context>http</context> |
344 <context>server</context> | |
345 <context>location</context> | |
346 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
347 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
348 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
349 Определяет, нужно ли писать в лог предупреждения о неинициализированных |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
350 переменных. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
351 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
352 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
353 </directive> |
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 </section> |
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 |
382 | 358 <section id="internals" name="Внутреннее устройство"> |
76
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 <para> |
382 | 361 Директивы модуля <literal>ngx_http_rewrite_module</literal> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
362 компилируются на стадии конфигурации во внутренние инструкции, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
363 интерпретируемые во время обработки запроса. |
382 | 364 Интерпретатор представляет из себя простую стековую виртуальную машину. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
365 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
366 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
367 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
368 Например, директивы |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
369 <example> |
382 | 370 location /download/ { |
371 if ($forbidden) { | |
372 return 403; | |
373 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
374 |
382 | 375 if ($slow) { |
376 limit_rate 10k; | |
377 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
378 |
382 | 379 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
380 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
381 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
382 будут транслированы в такие инструкции: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
383 <example> |
382 | 384 переменная $forbidden |
385 проверка на ноль | |
386 возврат 403 | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
387 завершение всего кода |
382 | 388 переменная $slow |
389 проверка на ноль | |
390 проверка регулярного выражения | |
391 копирование "/" | |
392 копирование $1 | |
393 копирование "/mp3/" | |
394 копирование $2 | |
395 копирование ".mp3" | |
396 завершение регулярного выражения | |
397 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
398 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
399 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
400 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
401 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
402 Обратите внимание, что инструкций для директивы |
382 | 403 <link doc="ngx_http_core_module.xml" id="limit_rate"/> |
404 нет, поскольку она не имеет отношения к модулю | |
405 <literal>ngx_http_rewrite_module</literal>. | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
406 Для блока <link id="if"/> создаётся отдельная конфигурация, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
407 Если условие истинно, запрос получает эту конфигурацию, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
408 и в ней <literal>limit_rate</literal> равен 10k. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
409 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
410 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
411 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
412 Директиву |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
413 <example> |
382 | 414 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
415 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
416 можно сделать на одну инструкцию меньше, если в регулярном выражении перенести |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
417 первый слэш внутрь скобок: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
418 <example> |
382 | 419 rewrite ^(<emphasis>/</emphasis>download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
420 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
421 Тогда соответствующие инструкции будут выглядеть так: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
422 <example> |
382 | 423 проверка регулярного выражения |
424 копирование $1 | |
425 копирование "/mp3/" | |
426 копирование $2 | |
427 копирование ".mp3" | |
428 завершение регулярного выражения | |
429 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
430 </example> |
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 </section> |
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 </module> |