Mercurial > hg > nginx-site
annotate xml/ru/docs/http/request_processing.xml @ 547:32dd85720515
Translated "configuring_https_servers" intro Russian.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sun, 24 Jun 2012 18:47:05 +0000 |
parents | ef11546f75ee |
children | be54c443235a |
rev | line source |
---|---|
522
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
2 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
3 <article name="Как nginx обрабатывает запросы" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
4 link="/ru/docs/http/request_processing.html" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
5 lang="ru" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
6 author="Игорь Сысоев" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
7 editor="Brian Mercer"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
8 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
9 <section name="Определение виртуального сервера по имени"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
10 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
11 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
12 nginx вначале решает, какой из серверов должен обработать запрос. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
13 Рассмотрим простую конфигурацию, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 где все три виртуальных сервера слушают на порту *:80: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
18 server_name example.org www.example.org; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
19 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
20 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
23 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
24 server_name example.net www.example.net; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
29 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
30 server_name example.com www.example.com; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
38 В этой конфигурации, чтобы определить, какому серверу следует направить |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
39 запрос, nginx проверяет только поле <header>Host</header> заголовка запроса. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
40 Если его значение не соответствует ни одному из имён серверов |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
41 или в заголовке запроса нет этого поля вовсе, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 nginx направит запрос в сервер по умолчанию для этого порта. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
43 В вышеприведённой конфигурации сервером по умолчанию будет первый сервер, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
44 что соответствует стандартному поведению nginx по умолчанию. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 Сервер по умолчанию можно задать явно с помощью параметра |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 <literal>default_server</literal> в директиве |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 <link doc="ngx_http_core_module.xml" id="listen"/>: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 listen 80 <b>default_server</b>; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 server_name example.net www.example.net; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
54 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 <note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 Параметр <literal>default_server</literal> появился в |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 версии 0.8.21. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 В более ранних версиях вместо него следует использовать параметр |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 <literal>default</literal>. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 </note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 Следует иметь в виду, что сервер по умолчанию является свойством |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
63 слушающего порта, а не имени сервера. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 Подробнее это обсуждается ниже. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
70 <section id="how_to_prevent_undefined_server_names" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 name="Как предотвратить обработку запросов без имени сервера"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
72 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
73 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 Если запросы без поля <header>Host</header> в заголовке не должны |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 обрабатываться, можно определить сервер, который будет их отклонять: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
77 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 server_name ""; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
80 return 444; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 Здесь в качестве имени сервера указана пустая строка, которая |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 соответствует запросам без поля <header>Host</header> в заголовке, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 и возвращается специальный для nginx код 444, который закрывает |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 соединение. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 <note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 Начиная с версии 0.8.48 настройка <literal>server_name ""</literal> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
89 является стандартной и может явно не указываться. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
90 В более ранних версиях в качестве стандартного имени сервера |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 выступало имя машины (hostname). |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 </note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
96 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
97 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
98 <section id="mixed_name_ip_based_servers" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
99 name="Определение виртуального сервера по имени и IP-адресу"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
100 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
101 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
102 Рассмотрим более сложную конфигурацию, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
103 в которой некоторые виртуальные серверы слушают на разных адресах: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
104 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
105 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
106 listen 192.168.1.1:80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
107 server_name example.org www.example.org; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
108 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
109 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
110 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
111 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
112 listen 192.168.1.1:80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
113 server_name example.net www.example.net; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
114 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
115 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
116 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
117 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
118 listen 192.168.1.2:80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 server_name example.com www.example.com; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
120 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
121 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
122 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
123 В этой конфигурации nginx вначале сопоставляет IP-адрес и порт |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
124 запроса с директивами |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 <link doc="ngx_http_core_module.xml" id="listen"/> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
126 в блоках |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
127 <link doc="ngx_http_core_module.xml" id="server"/>. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 Затем он сопоставляет значение поля <header>Host</header> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 заголовка запроса с директивами |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 <link doc="ngx_http_core_module.xml" id="server_name"/> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
131 в блоках |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
132 <link doc="ngx_http_core_module.xml" id="server"/>, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
133 которые соответствуют IP-адресу и порту. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
134 Если имя сервера не найдено, запрос будет обработан в |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
135 сервере по умолчанию. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
136 Например, запрос <url>www.example.com</url>, пришедший на порт |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
137 192.168.1.1:80, будет обработан сервером по умолчанию для порта |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
138 192.168.1.1:80, т.е. первым сервером, т.к. для этого порта |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
139 <url>www.example.com</url> не указан в списке имён серверов. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
140 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
141 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
142 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 Как уже говорилось, сервер по умолчанию является свойством слушающего порта, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 поэтому у разных портов могут быть определены свои серверы по умолчанию: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
145 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
147 listen 192.168.1.1:80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 server_name example.org www.example.org; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
149 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
150 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
151 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
152 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 listen 192.168.1.1:80 <b>default_server</b>; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 server_name example.net www.example.net; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
155 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
156 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
157 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
158 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
159 listen 192.168.1.2:80 <b>default_server</b>; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
160 server_name example.com www.example.com; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
161 ... |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
162 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
163 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
164 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
165 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
166 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
167 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 <section id="simple_php_site_configuration" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 name="Конфигурация простого сайта PHP"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
172 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
173 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
174 Теперь посмотрим на то, как nginx выбирает <i>location</i> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
175 для обработки запроса на примере обычного простого PHP-сайта: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
176 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
177 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
178 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
179 server_name example.org www.example.org; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
180 root /data/www; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 location / { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 index index.html index.php; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
184 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
185 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
186 location ~* \.(gif|jpg|png)$ { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 expires 30d; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
188 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
189 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
190 location ~ \.php$ { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
191 fastcgi_pass localhost:9000; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
192 fastcgi_param SCRIPT_FILENAME |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
193 $document_root$fastcgi_script_name; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
194 include fastcgi_params; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
195 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
196 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
197 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
198 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
199 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
200 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
201 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
202 nginx вначале ищет среди всех префиксных location’ов, заданных строками, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
203 максимально совпадающий. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
204 В вышеприведённой конфигурации |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
205 указан только один префиксный location “<literal>/</literal>”, и поскольку |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
206 он подходит под любой запрос, он и будет использован, если других |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
207 совпадений не будет найдено. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
208 Затем nginx проверяет location’ы, заданные регулярными выражениями, в |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
209 порядке их следования в конфигурационном файле. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
210 При первом же совпадении поиск прекращается и nginx использует |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
211 совпавший location. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
212 Если запросу не соответствует ни одно из регулярных выражений, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
213 nginx использует максимально совпавший префиксный location, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
214 найденный ранее. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
215 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
216 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
217 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
218 Следует иметь в виду, что location’ы всех типов сопоставляются только с |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
219 URI-частью строки запроса без аргументов. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
220 Так делается потому, что аргументы в строке запроса могут быть |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
221 заданы различными способами, например: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
222 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
223 /index.php?user=john&page=1 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
224 /index.php?page=1&user=john |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
225 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
226 Кроме того, в строке запроса можно запросить что угодно: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
227 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 /index.php?page=1&something+else&user=john |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
232 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
233 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 Теперь посмотрим, как бы обрабатывались запросы |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
235 в вышеприведённой конфигурации: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 <list type="bullet" compact="no"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
237 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
238 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
239 Запросу “<literal>/logo.gif</literal>” во-первых соответствует префиксный |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
240 location “<literal>/</literal>”, а во-вторых—регулярное выражение |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 “<literal>\.(gif|jpg|png)$</literal>”, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 поэтому он обрабатывается location’ом регулярного выражения. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 Согласно директиве “<literal>root /data/www</literal>” запрос |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
244 отображается в файл <path>/data/www/logo.gif</path>, который |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
245 и посылается клиенту. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
246 </listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
247 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
248 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
249 Запросу “<literal>/index.php</literal>” также во-первых соответствует префиксный |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
250 location “<literal>/</literal>”, а во-вторых—регулярное выражение |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
251 “<literal>\.(php)$</literal>”. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 Следовательно, он обрабатывается location’ом регулярного выражения |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
253 и запрос передаётся FastCGI-серверу, слушающему на localhost:9000. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 Директива |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_param"/> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
256 устанавливает FastCGI-параметр |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
257 <literal>SCRIPT_FILENAME</literal> в “<literal>/data/www/index.php</literal>”, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
258 и сервер FastCGI выполняет указанный файл. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
259 Переменная <var>$document_root</var> равна |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
260 значению директивы |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
261 <link doc="ngx_http_core_module.xml" id="root"/>, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
262 а переменная <var>$fastcgi_script_name</var> равна |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
263 URI запроса, т.е. “<literal>/index.php</literal>”. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
264 </listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
265 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
266 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
267 Запросу “<literal>/about.html</literal>” соответствует только префиксный |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
268 location “<literal>/</literal>”, поэтому запрос обрабатывается в нём. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
269 Согласно директиве “<literal>root /data/www</literal>” запрос |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
270 отображается в файл <path>/data/www/about.html</path>, который |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
271 и посылается клиенту. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
272 </listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
273 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
274 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
275 Обработка запроса “<literal>/</literal>” более сложная. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
276 Ему соответствует только префиксный location “<literal>/</literal>”, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
277 поэтому запрос обрабатывается в нём. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
278 Затем директива |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
279 <link doc="ngx_http_index_module.xml" id="index"/> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
280 проверяет существование индексных файлов согласно своих параметров |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
281 и директиве “<literal>root /data/www</literal>”. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
282 Если файл <path>/data/www/index.html</path> не существует, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
283 а файл <path>/data/www/index.php</path> существует, то |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
284 директива делает внутреннее перенаправление на “<literal>/index.php</literal>” |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
285 и nginx снова сопоставляет его с location’ами, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
286 как если бы такой запрос был послан клиентом. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
287 Как мы видели ранее, перенаправленный запрос будет в конечном итоге |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
288 обработан сервером FastCGI. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
289 </listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
290 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
291 </list> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
292 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
293 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
294 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
295 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
296 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
297 </article> |