Mercurial > hg > nginx-site
annotate xml/ru/docs/http/ngx_http_rewrite_module.xml @ 2016:e6de97d14f81
Documented the mirror module.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Fri, 04 Aug 2017 18:24:38 +0300 |
parents | 2a3c58dcb3e8 |
children | dd78dd9e2cb7 |
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" |
1964
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
13 rev="8"> |
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> позволяет |
1723
065978f4ece1
Added info about PCRE in the rewrite module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1061
diff
changeset
|
19 изменять URI запроса с помощью регулярных выражений PCRE, делать перенаправления |
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> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
29 последовательно выполняются директивы этого модуля, описанные на уровне |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
30 <link doc="ngx_http_core_module.xml" id="server"/>; |
391
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> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
34 в цикле: |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
35 <list type="bullet"> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
36 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
37 <listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
38 ищется |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
39 <link doc="ngx_http_core_module.xml" id="location"/> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
40 по URI запроса; |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
41 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
42 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
43 <listitem> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
44 последовательно выполняются директивы этого модуля, |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
45 описанные в найденном location; |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
46 </listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
47 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
48 <listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
49 цикл повторяется, если URI запроса <link id="rewrite">изменялся</link>, |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
50 но не более |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
51 <link doc="ngx_http_core_module.xml" id="internal">10 раз</link>. |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
52 </listitem> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
53 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
54 </list> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
55 </listitem> |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
56 |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
57 </list> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 </para> |
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 </section> |
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 |
382 | 63 <section id="directives" name="Директивы"> |
76
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 <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
|
66 <syntax/> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
67 <default/> |
382 | 68 <context>server</context> |
69 <context>location</context> | |
70 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 <para> |
382 | 73 Завершает обработку текущего набора директив модуля |
74 <literal>ngx_http_rewrite_module</literal>. | |
76
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 <para> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
78 Если директива указана внутри |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
79 <link doc="ngx_http_core_module.xml" id="location"/>, |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
80 дальнейшая обработка запроса продолжается в этом location. |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
81 </para> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
82 |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
83 <para> |
382 | 84 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 <example> |
382 | 86 if ($slow) { |
87 limit_rate 10k; | |
88 break; | |
89 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 </example> |
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 </directive> |
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 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 <directive name="if"> |
108
72524ae53106
Explicitly marked directives with the block syntax. Such directives will
Ruslan Ermilov <ru@nginx.com>
parents:
106
diff
changeset
|
97 <syntax block="yes">(<value>условие</value>)</syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
98 <default/> |
382 | 99 <context>server</context> |
100 <context>location</context> | |
76
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 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
103 Проверяется указанное <value>условие</value>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
104 Если оно истинно, то выполняются указанные в фигурных скобках директивы |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
105 этого модуля и запросу назначается конфигурация, указанная внутри |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
106 директивы <literal>if</literal>. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
107 Конфигурации внутри директив <literal>if</literal> наследуются с |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
108 предыдущего уровня конфигурации. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 <para> |
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 <list type="bullet"> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 <listitem> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
116 имя переменной; ложными значениями переменной являются пустая строка |
860
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
117 или “<literal>0</literal>”; |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
118 <note> |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
119 До версии 1.0.1 ложным значением также являлась любая строка, |
9fce700e56d3
If: only empty strings and "0" evaluate to false.
Ruslan Ermilov <ru@nginx.com>
parents:
703
diff
changeset
|
120 начинающаяся на “<literal>0</literal>”. |
861 | 121 </note> |
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 сравнение переменной со строкой с помощью операторов |
126 “<literal>=</literal>” и “<literal>!=</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> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
130 соответствие переменной регулярному выражению с учётом |
382 | 131 регистра символов — “<literal>~</literal>” и без него — “<literal>~*</literal>”. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 В регулярных выражениях можно использовать выделения, которые затем |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
133 доступны в виде переменных <var>$1</var>..<var>$9</var>. |
382 | 134 Также можно использовать отрицательные операторы “<literal>!~</literal>” |
135 и “<literal>!~*</literal>”. | |
136 Если в регулярном выражении встречаются символы “<literal>}</literal>” | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
137 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 138 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 <listitem> |
382 | 142 проверка существования файла с помощью операторов “<literal>-f</literal>” |
143 и “<literal>!-f</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 <listitem> |
382 | 147 проверка существования каталога с помощью операторов “<literal>-d</literal>” |
148 и “<literal>!-d</literal>”; | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 <listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 проверка существования файла, каталога или символической ссылки |
382 | 153 с помощью операторов “<literal>-e</literal>” и “<literal>!-e</literal>”; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 <listitem> |
382 | 157 проверка исполняемости файла с помощью операторов “<literal>-x</literal>” |
158 и “<literal>!-x</literal>”. | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 </listitem> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 </list> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 <para> |
382 | 165 Примеры: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 <example> |
382 | 167 if ($http_user_agent ~ MSIE) { |
168 rewrite ^(.*)$ /msie/$1 break; | |
169 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 |
382 | 171 if ($http_cookie ~* "id=([^;]+)(?:;|$)") { |
172 set $id $1; | |
173 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 |
382 | 175 if ($request_method = POST) { |
176 return 405; | |
177 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 |
382 | 179 if ($slow) { |
180 limit_rate 10k; | |
181 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
382 | 183 if ($invalid_referer) { |
184 return 403; | |
185 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
187 <note> |
382 | 188 Значение встроенной переменной <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
|
189 <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
|
190 </note> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 </para> |
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 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 <directive name="return"> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
197 <syntax><value>код</value> [<value>текст</value>]</syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
198 <syntax><value>код</value> <value>URL</value></syntax> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
199 <syntax><value>URL</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
200 <default/> |
382 | 201 <context>server</context> |
202 <context>location</context> | |
203 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
206 Завершает обработку и возвращает клиенту указанный <value>код</value>. |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
207 Нестандартный код 444 закрывает соединение без передачи |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 заголовка ответа. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
211 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
212 Начиная с версии 0.8.42 можно задать |
1964
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
213 либо URL перенаправления (для кодов 301, 302, 303, 307 и 308) |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
214 либо <value>текст</value> тела ответа (для остальных кодов). |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
215 В тексте тела ответа и URL перенаправления можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
216 Как частный случай, URL перенаправления может быть задан как URI, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
217 локальный для данного сервера, при этом полный URL перенаправления |
966 | 218 формируется согласно схеме запроса (<var>$scheme</var>) и директивам |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
219 <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
|
220 <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
|
221 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
222 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
223 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
224 Кроме того, в качестве единственного параметра можно указать |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
225 <value>URL</value> для временного перенаправления с кодом 302. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
226 Такой параметр должен начинаться со строк “<literal>http://</literal>”, |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
227 “<literal>https://</literal>” или “<literal>$scheme</literal>”. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
228 В <value>URL</value> можно использовать переменные. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
229 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
230 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
231 <para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
232 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
233 До версии 0.7.51 можно было возвращать только следующие коды: |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
234 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
|
235 </note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
236 |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
237 <note> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
238 До версий 1.1.16 и 1.0.13 код 307 не обрабатывался как перенаправление. |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
239 </note> |
1964
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
240 |
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
241 <note> |
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
242 До версии 1.13.0 код 308 не обрабатывался как перенаправление. |
2a3c58dcb3e8
Documented support for the 308 Permanent Redirect.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1873
diff
changeset
|
243 </note> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
244 </para> |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
245 |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
246 <para> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
247 См. также директиву <link doc="ngx_http_core_module.xml" id="error_page"/>. |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
248 </para> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
249 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 <directive name="rewrite"> |
382 | 254 <syntax> |
255 <value>regex</value> | |
256 <value>замена</value> | |
257 [<value>флаг</value>]</syntax> | |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
258 <default/> |
382 | 259 <context>server</context> |
260 <context>location</context> | |
261 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 <para> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
264 Если указанное регулярное выражение соответствует URI запроса, URI изменяется |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
265 в соответствии со строкой замены. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
266 Директивы <literal>rewrite</literal> выполняются последовательно, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
267 в порядке их следования в конфигурационном файле. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
268 С помощью флагов можно прекратить дальнейшую обработку директив. |
1873
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
269 Если строка замены начинается с “<literal>http://</literal>”, |
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
270 “<literal>https://</literal>” или “<literal>$scheme</literal>”, |
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
271 то обработка завершается и клиенту возвращается перенаправление. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
275 Необязательный параметр <value>флаг</value> может быть одним из: |
382 | 276 <list type="tag"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 |
382 | 278 <tag-name><literal>last</literal></tag-name> |
279 <tag-desc> | |
280 завершает обработку текущего набора директив модуля | |
281 <literal>ngx_http_rewrite_module</literal>, | |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
282 после чего ищется новый location, соответствующий изменённому URI; |
382 | 283 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 |
382 | 285 <tag-name><literal>break</literal></tag-name> |
286 <tag-desc> | |
287 завершает обработку текущего набора директив модуля | |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
288 <literal>ngx_http_rewrite_module</literal> |
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
289 аналогично директиве <link id="break"/>; |
382 | 290 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 |
382 | 292 <tag-name><literal>redirect</literal></tag-name> |
293 <tag-desc> | |
294 возвращает временное перенаправление с кодом 302; | |
295 используется, если заменяющая строка не начинается с | |
1873
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
296 “<literal>http://</literal>”, “<literal>https://</literal>” |
2f851f71ff08
Documented $scheme support in the "rewrite" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
1723
diff
changeset
|
297 или “<literal>$scheme</literal>”; |
382 | 298 </tag-desc> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 |
382 | 300 <tag-name><literal>permanent</literal></tag-name> |
301 <tag-desc> | |
302 возвращает постоянное перенаправление с кодом 301. | |
303 </tag-desc> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 </list> |
548
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
306 Полный URL перенаправлений формируется согласно |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
307 схеме запроса (<var>$scheme</var>) и директив |
95a970603b0f
Brought the "return" documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
391
diff
changeset
|
308 <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
|
309 <link doc="ngx_http_core_module.xml" id="port_in_redirect"/>. |
76
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> |
382 | 313 Пример: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 <example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
315 server { |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
316 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
317 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
318 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra last; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
319 return 403; |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
320 ... |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
321 } |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 </para> |
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 <para> |
382 | 326 Если же эти директивы поместить в location “<literal>/download/</literal>”, |
327 то нужно заменить флаг <literal>last</literal> на <literal>break</literal>, | |
328 иначе nginx сделает 10 циклов и вернёт ошибку 500: | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 <example> |
382 | 330 location /download/ { |
331 rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; | |
332 rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra break; | |
333 return 403; | |
334 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
335 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
339 Если в строке замены указаны новые аргументы запроса, то предыдущие |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
340 аргументы запроса добавляются после них. |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
341 Если такое поведение нежелательно, можно отказаться от этого добавления, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
342 указав в конце строки замены знак вопроса, например: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
343 <example> |
382 | 344 rewrite ^/users/(.*)$ /show?user=$1? last; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
345 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
346 </para> |
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> |
382 | 349 Если в регулярном выражении встречаются символы “<literal>}</literal>” |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
350 или “<literal>;</literal>”, то всё выражение следует заключить в одинарные |
382 | 351 или двойные кавычки. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
352 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
353 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
354 </directive> |
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 |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
357 <directive name="rewrite_log"> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
358 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
359 <default>off</default> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
360 <context>http</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
361 <context>server</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
362 <context>location</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
363 <context>if</context> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
364 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
365 <para> |
703
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
366 Разрешает или запрещает записывать в |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
367 <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
|
368 на уровне <literal>notice</literal> |
57fe6d7d86b4
Slightly changed the wording when talking about the "rewrite_log" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
674
diff
changeset
|
369 результаты обработки директив модуля <literal>ngx_http_rewrite_module</literal>. |
673
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
370 </para> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
371 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
372 </directive> |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
373 |
f2d8603813b0
Documented the "rewrite_log" directive.
Vladimir Homutov <vl@nginx.com>
parents:
589
diff
changeset
|
374 |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
375 <directive name="set"> |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
376 <syntax><value>$переменная</value> <value>значение</value></syntax> |
99
1d315ef37215
The case <default/> is now language-agnostic.
Ruslan Ermilov <ru@nginx.com>
parents:
98
diff
changeset
|
377 <default/> |
382 | 378 <context>server</context> |
379 <context>location</context> | |
380 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
381 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
382 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
383 Устанавливает значение указанной переменной. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
384 В качестве значения можно использовать текст, переменные и их комбинации. |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
385 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
386 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
387 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
388 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
389 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
390 <directive name="uninitialized_variable_warn"> |
271 | 391 <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
|
392 <default>on</default> |
382 | 393 <context>http</context> |
394 <context>server</context> | |
395 <context>location</context> | |
396 <context>if</context> | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
397 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
398 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
399 Определяет, нужно ли писать в лог предупреждения о неинициализированных |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
400 переменных. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
401 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
402 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
403 </directive> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
404 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
405 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
406 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
407 |
382 | 408 <section id="internals" name="Внутреннее устройство"> |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
409 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
410 <para> |
382 | 411 Директивы модуля <literal>ngx_http_rewrite_module</literal> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
412 компилируются на стадии конфигурации во внутренние инструкции, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
413 интерпретируемые во время обработки запроса. |
382 | 414 Интерпретатор представляет из себя простую стековую виртуальную машину. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
415 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
416 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
417 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
418 Например, директивы |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
419 <example> |
382 | 420 location /download/ { |
421 if ($forbidden) { | |
422 return 403; | |
423 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
424 |
382 | 425 if ($slow) { |
426 limit_rate 10k; | |
427 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
428 |
382 | 429 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
430 } | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
431 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
432 будут транслированы в такие инструкции: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
433 <example> |
382 | 434 переменная $forbidden |
435 проверка на ноль | |
436 возврат 403 | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
437 завершение всего кода |
382 | 438 переменная $slow |
439 проверка на ноль | |
440 проверка регулярного выражения | |
441 копирование "/" | |
442 копирование $1 | |
443 копирование "/mp3/" | |
444 копирование $2 | |
445 копирование ".mp3" | |
446 завершение регулярного выражения | |
447 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
448 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
449 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
450 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
451 <para> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
452 Обратите внимание, что инструкций для директивы |
382 | 453 <link doc="ngx_http_core_module.xml" id="limit_rate"/> |
454 нет, поскольку она не имеет отношения к модулю | |
455 <literal>ngx_http_rewrite_module</literal>. | |
1061
cb63563024eb
Somewhat clarified how rewrite module works.
Ruslan Ermilov <ru@nginx.com>
parents:
966
diff
changeset
|
456 Для блока <link id="if"/> создаётся отдельная конфигурация. |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
457 Если условие истинно, запрос получает эту конфигурацию, |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
458 и в ней <literal>limit_rate</literal> равен 10k. |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
459 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
460 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
461 <para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
462 Директиву |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
463 <example> |
382 | 464 rewrite ^/(download/.*)/media/(.*)\..*$ /$1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
465 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
466 можно сделать на одну инструкцию меньше, если в регулярном выражении перенести |
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
467 первый слэш внутрь скобок: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
468 <example> |
382 | 469 rewrite ^(<emphasis>/</emphasis>download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break; |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
470 </example> |
391
1702722eca07
Cleaned up terminology and language used.
Ruslan Ermilov <ru@nginx.com>
parents:
382
diff
changeset
|
471 Тогда соответствующие инструкции будут выглядеть так: |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
472 <example> |
382 | 473 проверка регулярного выражения |
474 копирование $1 | |
475 копирование "/mp3/" | |
476 копирование $2 | |
477 копирование ".mp3" | |
478 завершение регулярного выражения | |
479 завершение всего кода | |
76
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
480 </example> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
481 </para> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
482 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
483 </section> |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
484 |
4a4caa566120
Russian documentation import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
485 </module> |