Mercurial > hg > nginx-site
annotate xml/ru/docs/http/request_processing.xml @ 1559:d876f94135ac
Added info about limiting access to status.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Mon, 07 Sep 2015 09:06:49 +0300 |
parents | 130fad6dc1b4 |
children |
rev | line source |
---|---|
580
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
522
diff
changeset
|
1 <!-- |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
522
diff
changeset
|
2 Copyright (C) Igor Sysoev |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
522
diff
changeset
|
3 Copyright (C) Nginx, Inc. |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
522
diff
changeset
|
4 --> |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
522
diff
changeset
|
5 |
522
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
6 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
7 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
8 <article name="Как nginx обрабатывает запросы" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
9 link="/ru/docs/http/request_processing.html" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
10 lang="ru" |
589 | 11 rev="1" |
522
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
12 author="Игорь Сысоев" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
13 editor="Brian Mercer"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 <section name="Определение виртуального сервера по имени"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
18 nginx вначале решает, какой из серверов должен обработать запрос. |
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 где все три виртуальных сервера слушают на порту *:80: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 <programlisting> |
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.org www.example.org; |
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.net www.example.net; |
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 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 server_name example.com www.example.com; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 ... |
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 </programlisting> |
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 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
43 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
44 В этой конфигурации, чтобы определить, какому серверу следует направить |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 запрос, nginx проверяет только поле <header>Host</header> заголовка запроса. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 Если его значение не соответствует ни одному из имён серверов |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 или в заголовке запроса нет этого поля вовсе, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 nginx направит запрос в сервер по умолчанию для этого порта. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 В вышеприведённой конфигурации сервером по умолчанию будет первый сервер, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 что соответствует стандартному поведению nginx по умолчанию. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 Сервер по умолчанию можно задать явно с помощью параметра |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 <literal>default_server</literal> в директиве |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 <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
|
54 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 listen 80 <b>default_server</b>; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 server_name example.net www.example.net; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 ... |
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 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 <note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
63 Параметр <literal>default_server</literal> появился в |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 версии 0.8.21. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 В более ранних версиях вместо него следует использовать параметр |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 <literal>default</literal>. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 </note> |
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 Подробнее это обсуждается ниже. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 </para> |
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 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 |
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 <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
|
77 name="Как предотвратить обработку запросов без имени сервера"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
80 Если запросы без поля <header>Host</header> в заголовке не должны |
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 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 server_name ""; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 return 444; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 </programlisting> |
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 соответствует запросам без поля <header>Host</header> в заголовке, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 и возвращается специальный для nginx код 444, который закрывает |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 соединение. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 <note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 Начиная с версии 0.8.48 настройка <literal>server_name ""</literal> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 является стандартной и может явно не указываться. |
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 выступало имя машины (hostname). |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
98 </note> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
99 </para> |
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 </section> |
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 <section id="mixed_name_ip_based_servers" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
105 name="Определение виртуального сервера по имени и IP-адресу"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
106 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
107 <para> |
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 <programlisting> |
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.org www.example.org; |
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.1:80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 server_name example.net www.example.net; |
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 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
123 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
124 listen 192.168.1.2:80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 server_name example.com www.example.com; |
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 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 В этой конфигурации nginx вначале сопоставляет IP-адрес и порт |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 запроса с директивами |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
131 <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
|
132 в блоках |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
133 <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
|
134 Затем он сопоставляет значение поля <header>Host</header> |
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 <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
|
137 в блоках |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
138 <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
|
139 которые соответствуют IP-адресу и порту. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
140 Если имя сервера не найдено, запрос будет обработан в |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
141 сервере по умолчанию. |
593
130fad6dc1b4
Replaced the uses of "url" element with "literal".
Ruslan Ermilov <ru@nginx.com>
parents:
589
diff
changeset
|
142 Например, запрос <literal>www.example.com</literal>, пришедший на порт |
522
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 192.168.1.1:80, будет обработан сервером по умолчанию для порта |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 192.168.1.1:80, т.е. первым сервером, т.к. для этого порта |
593
130fad6dc1b4
Replaced the uses of "url" element with "literal".
Ruslan Ermilov <ru@nginx.com>
parents:
589
diff
changeset
|
145 <literal>www.example.com</literal> не указан в списке имён серверов. |
522
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
147 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 <para> |
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 <programlisting> |
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; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 server_name example.org www.example.org; |
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.1: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.net www.example.net; |
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 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
164 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
165 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
|
166 server_name example.com www.example.com; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
167 ... |
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 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 </para> |
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 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
174 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
175 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
176 <section id="simple_php_site_configuration" |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
177 name="Конфигурация простого сайта PHP"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
178 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
179 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
180 Теперь посмотрим на то, как nginx выбирает <i>location</i> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 для обработки запроса на примере обычного простого PHP-сайта: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 server { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
184 listen 80; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
185 server_name example.org www.example.org; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
186 root /data/www; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
188 location / { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
189 index index.html index.php; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
190 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
191 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
192 location ~* \.(gif|jpg|png)$ { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
193 expires 30d; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
194 } |
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 location ~ \.php$ { |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
197 fastcgi_pass localhost:9000; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
198 fastcgi_param SCRIPT_FILENAME |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
199 $document_root$fastcgi_script_name; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
200 include fastcgi_params; |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
201 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
202 } |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
203 </programlisting> |
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 </para> |
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 <para> |
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 В вышеприведённой конфигурации |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
211 указан только один префиксный location “<literal>/</literal>”, и поскольку |
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 совпадений не будет найдено. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
214 Затем nginx проверяет location’ы, заданные регулярными выражениями, в |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
215 порядке их следования в конфигурационном файле. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
216 При первом же совпадении поиск прекращается и nginx использует |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
217 совпавший location. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
218 Если запросу не соответствует ни одно из регулярных выражений, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
219 nginx использует максимально совпавший префиксный location, |
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 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
222 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
223 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
224 Следует иметь в виду, что location’ы всех типов сопоставляются только с |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
225 URI-частью строки запроса без аргументов. |
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 заданы различными способами, например: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 /index.php?user=john&page=1 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 /index.php?page=1&user=john |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 </programlisting> |
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 <programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 /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
|
235 </programlisting> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
237 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
238 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
239 <para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
240 Теперь посмотрим, как бы обрабатывались запросы |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 в вышеприведённой конфигурации: |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 <list type="bullet" compact="no"> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
244 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
245 Запросу “<literal>/logo.gif</literal>” во-первых соответствует префиксный |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
246 location “<literal>/</literal>”, а во-вторых—регулярное выражение |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
247 “<literal>\.(gif|jpg|png)$</literal>”, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
248 поэтому он обрабатывается location’ом регулярного выражения. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
249 Согласно директиве “<literal>root /data/www</literal>” запрос |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
250 отображается в файл <path>/data/www/logo.gif</path>, который |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
251 и посылается клиенту. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 </listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
253 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 Запросу “<literal>/index.php</literal>” также во-первых соответствует префиксный |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
256 location “<literal>/</literal>”, а во-вторых—регулярное выражение |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
257 “<literal>\.(php)$</literal>”. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
258 Следовательно, он обрабатывается location’ом регулярного выражения |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
259 и запрос передаётся FastCGI-серверу, слушающему на localhost:9000. |
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_fastcgi_module.xml" id="fastcgi_param"/> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
262 устанавливает FastCGI-параметр |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
263 <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
|
264 и сервер FastCGI выполняет указанный файл. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
265 Переменная <var>$document_root</var> равна |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
266 значению директивы |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
267 <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
|
268 а переменная <var>$fastcgi_script_name</var> равна |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
269 URI запроса, т.е. “<literal>/index.php</literal>”. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
270 </listitem> |
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 Запросу “<literal>/about.html</literal>” соответствует только префиксный |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
274 location “<literal>/</literal>”, поэтому запрос обрабатывается в нём. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
275 Согласно директиве “<literal>root /data/www</literal>” запрос |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
276 отображается в файл <path>/data/www/about.html</path>, который |
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 </listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
279 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
280 <listitem> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
281 Обработка запроса “<literal>/</literal>” более сложная. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
282 Ему соответствует только префиксный location “<literal>/</literal>”, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
283 поэтому запрос обрабатывается в нём. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
284 Затем директива |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
285 <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
|
286 проверяет существование индексных файлов согласно своих параметров |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
287 и директиве “<literal>root /data/www</literal>”. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
288 Если файл <path>/data/www/index.html</path> не существует, |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
289 а файл <path>/data/www/index.php</path> существует, то |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
290 директива делает внутреннее перенаправление на “<literal>/index.php</literal>” |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
291 и nginx снова сопоставляет его с location’ами, |
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 Как мы видели ранее, перенаправленный запрос будет в конечном итоге |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
294 обработан сервером FastCGI. |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
295 </listitem> |
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 </list> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
298 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
299 </para> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
300 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
301 </section> |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
302 |
ef11546f75ee
Translated "request_processing" into Russian, removed "virtual_hosts"
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
303 </article> |