changeset 2767:c56adb7148a4

Described more details about server selection. In particular, this covers how the large_client_header_buffers (ticket #1523) and underscores_in_headers (ticket #1987) directives work in virtual servers.
author Yaroslav Zhuravlev <yar@nginx.com>
date Tue, 13 Jul 2021 13:44:05 +0100
parents 167329042128
children 9dd8c203a54a
files xml/en/docs/http/server_names.xml xml/ru/docs/http/server_names.xml
diffstat 2 files changed, 176 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/xml/en/docs/http/server_names.xml	Tue Sep 07 18:28:11 2021 +0300
+++ b/xml/en/docs/http/server_names.xml	Tue Jul 13 13:44:05 2021 +0100
@@ -8,7 +8,7 @@
 <article name="Server names"
          link="/en/docs/http/server_names.html"
          lang="en"
-         rev="3"
+         rev="4"
          author="Igor Sysoev"
          editor="Brian Mercer">
 
@@ -337,6 +337,93 @@
 </section>
 
 
+<section id="virtual_server_selection"
+        name="Virtual server selection">
+
+<para>
+First, a connection is created in a default server context.
+Then, the server name can be determined
+in the following request processing stages,
+each involved in server configuration selection:
+
+<list type="bullet">
+
+<listitem>
+<para>
+during SSL handshake, in advance, according to
+<link doc="configuring_https_servers.xml" id="sni">SNI</link>
+</para>
+</listitem>
+
+<listitem>
+<para>
+after processing the request line
+</para>
+</listitem>
+
+<listitem>
+<para>
+after processing the <literal>Host</literal> header field
+</para>
+</listitem>
+
+<listitem>
+<para>
+if the server name was not determined after processing the request line or
+from the <literal>Host</literal> header field,
+nginx will use the empty name as the server name.
+</para>
+</listitem>
+
+</list>
+
+At each of these stages, different server configurations can be applied.
+As such, certain directives should be specified with caution:
+<list type="bullet">
+
+<listitem>
+in case of the
+<link doc="ngx_http_ssl_module.xml" id="ssl_protocols"/> directive,
+the protocol list is set by the OpenSSL library before
+the server configuration could be applied according to the name
+requested through SNI,
+thus, protocols should be specified only for a default server;
+</listitem>
+
+<listitem>
+the
+<link doc="ngx_http_core_module.xml" id="client_header_buffer_size"/>
+and
+<link doc="ngx_http_core_module.xml" id="merge_slashes"/> directives
+are involved before reading the request line,
+thus, such directives use a default server configuration or
+the server configuration chosen by SNI;
+</listitem>
+
+<listitem>
+in case of the
+<link doc="ngx_http_core_module.xml" id="ignore_invalid_headers"/>,
+<link doc="ngx_http_core_module.xml" id="large_client_header_buffers"/>,
+and
+<link doc="ngx_http_core_module.xml" id="underscores_in_headers"/> directives
+involved in processing request header fields,
+it additionally depends
+whether the server configuration was updated
+according to the request line or the <literal>Host</literal> header field;
+</listitem>
+
+<listitem>
+an error response will be handled with
+the <link doc="ngx_http_core_module.xml" id="error_page"/> directive
+in the server that currently fulfills the request.
+</listitem>
+
+</list>
+</para>
+
+</section>
+
+
 <section id="optimization"
         name="Optimization">
 
--- a/xml/ru/docs/http/server_names.xml	Tue Sep 07 18:28:11 2021 +0300
+++ b/xml/ru/docs/http/server_names.xml	Tue Jul 13 13:44:05 2021 +0100
@@ -8,7 +8,7 @@
 <article name="Имена сервера"
          link="/ru/docs/http/server_names.html"
          lang="ru"
-         rev="3"
+         rev="4"
          author="Игорь Сысоев"
          editor="Brian Mercer">
 
@@ -342,6 +342,93 @@
 </section>
 
 
+<section id="virtual_server_selection"
+        name="Выбор виртуального сервера">
+
+<para>
+Сначала соединение создаётся в контесте сервера по умолчанию.
+Затем имя сервера может быть определено
+на следующих стадиях обработки запроса,
+каждая из которых участвует в выборе конфигурации:
+
+<list type="bullet">
+
+<listitem>
+<para>
+предварительно во время операции SSL handshake согласно
+<link doc="configuring_https_servers.xml" id="sni">SNI</link>
+</para>
+</listitem>
+
+<listitem>
+<para>
+после обработки строки запроса
+</para>
+</listitem>
+
+<listitem>
+<para>
+после обработки поля <literal>Host</literal> заголовка запроса
+</para>
+</listitem>
+
+<listitem>
+<para>
+если после обработки строки запроса или
+поля <literal>Host</literal> заголовка запроса имя сервера не было выбрано,
+то nginx будет использовать пустое имя в качестве имени сервера.
+</para>
+</listitem>
+
+</list>
+
+На каждой из этих стадий могут применяться различные конфигурации сервера.
+Таким образом, некоторые директивы следует указывать с осторожностью:
+<list type="bullet">
+
+<listitem>
+в случае использования
+директивы <link doc="ngx_http_ssl_module.xml" id="ssl_protocols"/>
+список протоколов задаётся библиотекой OpenSSL
+перед применением конфигурации сервера согласно имени,
+запрашиваемого через SNI.
+Таким образом, протоколы должны быть заданы только для сервера по умолчанию;
+</listitem>
+
+<listitem>
+директивы
+<link doc="ngx_http_core_module.xml" id="client_header_buffer_size"/>

+<link doc="ngx_http_core_module.xml" id="merge_slashes"/>
+задействуются перед чтением строки запроса,
+таким образом они используют конфигурацию сервера по умолчанию или
+конфигурацию сервера, выбранного через SNI;
+</listitem>
+
+<listitem>
+в случае использования директив
+<link doc="ngx_http_core_module.xml" id="ignore_invalid_headers"/>,
+<link doc="ngx_http_core_module.xml" id="large_client_header_buffers"/>

+<link doc="ngx_http_core_module.xml" id="underscores_in_headers"/>,
+которые участвуют в обработке полей заголовка запроса,
+выбор сервера дополнительно зависит от того,
+была ли обновлена конфигурация сервера
+согласно строке запроса или полю заголовка <literal>Host</literal>;
+</listitem>
+
+<listitem>
+ошибочный ответ будет обработан с помощью
+директивы <link doc="ngx_http_core_module.xml" id="error_page"/>
+в том сервере, который в настоящий момент выполняет запрос.
+</listitem>
+
+</list>
+</para>
+
+</section>
+
+
 <section id="optimization"
         name="Оптимизация">