Mercurial > hg > nginx-site
changeset 1945:88477c5d2751
Moved "health_check" and "match" to ngx_http_upstream_hc_module.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 30 Mar 2017 21:26:44 +0300 |
parents | dbf6f05f0808 |
children | 37df1535ea91 |
files | xml/en/GNUmakefile xml/en/docs/http/ngx_http_status_module.xml xml/en/docs/http/ngx_http_upstream_hc_module.xml xml/en/docs/http/ngx_http_upstream_module.xml xml/en/docs/index.xml xml/ru/GNUmakefile xml/ru/docs/http/ngx_http_status_module.xml xml/ru/docs/http/ngx_http_upstream_hc_module.xml xml/ru/docs/http/ngx_http_upstream_module.xml xml/ru/docs/index.xml |
diffstat | 10 files changed, 727 insertions(+), 608 deletions(-) [+] |
line wrap: on
line diff
--- a/xml/en/GNUmakefile Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/en/GNUmakefile Thu Mar 30 21:26:44 2017 +0300 @@ -86,6 +86,7 @@ http/ngx_http_sub_module \ http/ngx_http_upstream_module \ http/ngx_http_upstream_conf_module \ + http/ngx_http_upstream_hc_module \ http/ngx_http_userid_module \ http/ngx_http_uwsgi_module \ http/ngx_http_v2_module \
--- a/xml/en/docs/http/ngx_http_status_module.xml Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/en/docs/http/ngx_http_status_module.xml Thu Mar 30 21:26:44 2017 +0300 @@ -9,7 +9,7 @@ <module name="Module ngx_http_status_module" link="/en/docs/http/ngx_http_status_module.html" lang="en" - rev="14"> + rev="15"> <section id="summary"> @@ -562,7 +562,7 @@ <tag-name><literal>checks</literal></tag-name> <tag-desc> The total number of -<link doc="ngx_http_upstream_module.xml" id="health_check">health check</link> +<link doc="ngx_http_upstream_hc_module.xml" id="health_check">health check</link> requests made. </tag-desc> @@ -581,7 +581,7 @@ <tag-desc> Boolean indicating if the last health check request was successful and passed -<link doc="ngx_http_upstream_module.xml" id="match">tests</link>. +<link doc="ngx_http_upstream_hc_module.xml" id="match">tests</link>. </tag-desc> </list>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xml/en/docs/http/ngx_http_upstream_hc_module.xml Thu Mar 30 21:26:44 2017 +0300 @@ -0,0 +1,348 @@ +<?xml version="1.0"?> + +<!-- + Copyright (C) Nginx, Inc. + --> + +<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> + +<module name="Module ngx_http_upstream_hc_module" + link="/en/docs/http/ngx_http_upstream_hc_module.html" + lang="en" + rev="1"> + +<section id="summary"> + +<para> +The <literal>ngx_http_upstream_hc_module</literal> module +allows enabling periodic health checks of the servers in a +<link doc="ngx_http_upstream_module.xml" id="upstream">group</link> +referenced in the surrounding location. +</para> + +<para> +<note> +This module is available as part of our +<commercial_version>commercial subscription</commercial_version>. +</note> +</para> + +</section> + + +<section id="example" name="Example Configuration"> + +<para> +<example> +upstream dynamic { + zone upstream_dynamic 64k; + + server backend1.example.com weight=5; + server backend2.example.com:8080 fail_timeout=5s slow_start=30s; + server 192.0.2.1 max_fails=3; + + server backup1.example.com:8080 backup; + server backup2.example.com:8080 backup; +} + +server { + location / { + proxy_pass http://dynamic; + health_check; + } +} +</example> +</para> + +</section> + + +<section id="directives" name="Directives"> + +<directive name="health_check"> +<syntax>[<value>parameters</value>]</syntax> +<default/> +<context>location</context> + +<para> +Enables periodic health checks of the servers in a +<link doc="ngx_http_upstream_module.xml" id="upstream">group</link> +referenced in the surrounding location. +</para> + +<para> +The following optional parameters are supported: +<list type="tag"> + +<tag-name id="interval"> +<literal>interval</literal>=<value>time</value> +</tag-name> +<tag-desc> +sets the interval between two consecutive health checks, +by default, 5 seconds. +</tag-desc> + +<tag-name id="health_check_jitter"> +<literal>jitter</literal>=<value>time</value> +</tag-name> +<tag-desc> +sets the time within which +each health check will be randomly delayed, +by default, there is no delay. +</tag-desc> + +<tag-name id="fails"> +<literal>fails</literal>=<value>number</value> +</tag-name> +<tag-desc> +sets the number of consecutive failed health checks of a particular server +after which this server will be considered unhealthy, +by default, 1. +</tag-desc> + +<tag-name id="passes"> +<literal>passes</literal>=<value>number</value> +</tag-name> +<tag-desc> +sets the number of consecutive passed health checks of a particular server +after which the server will be considered healthy, +by default, 1. +</tag-desc> + +<tag-name id="uri"> +<literal>uri</literal>=<value>uri</value> +</tag-name> +<tag-desc> +defines the URI used in health check requests, +by default, “<literal>/</literal>”. +</tag-desc> + +<tag-name id="health_check_mandatory"> +<literal>mandatory</literal> +</tag-name> +<tag-desc> +sets the initial “checking” state for a server +until the first health check is completed (1.11.7). +If the parameter is not specified, +the server will be initially considered healthy. +</tag-desc> + +<tag-name id="hc_match"> +<literal>match</literal>=<value>name</value> +</tag-name> +<tag-desc> +specifies the <literal>match</literal> block configuring the tests that a +response should pass in order for a health check to pass. +By default, the response should have status code 2xx or 3xx. +</tag-desc> + +<tag-name id="health_check_port"> +<literal>port</literal>=<value>number</value> +</tag-name> +<tag-desc> +defines the port used when connecting to a server +to perform a health check (1.9.7). +By default, equals the +<link doc="ngx_http_upstream_module.xml" id="server"/> port. +</tag-desc> + +</list> +</para> + +<para> +For example, +<example> +location / { + proxy_pass http://backend; + health_check; +} +</example> +will send “<literal>/</literal>” requests to each +server in the <literal>backend</literal> group every five seconds. +If any communication error or timeout occurs, or a +proxied server responds with the status code other than +2xx or 3xx, the health check will fail, and the server will +be considered unhealthy. +Client requests are not passed to unhealthy servers +and servers in the “checking” state. +</para> + +<para> +Health checks can be configured to test the status code of a response, +presence of certain header fields and their values, +and the body contents. +Tests are configured separately using the <link id="match"/> directive +and referenced in the <literal>match</literal> parameter. +For example: +<example> +http { + server { + ... + location / { + proxy_pass http://backend; + health_check match=welcome; + } + } + + match welcome { + status 200; + header Content-Type = text/html; + body ~ "Welcome to nginx!"; + } +} +</example> +This configuration shows that in order for a health check to pass, the response +to a health check request should succeed, +have status 200, content type “<literal>text/html</literal>”, +and contain “<literal>Welcome to nginx!</literal>” in the body. +</para> + +<para> +The server group must reside in the +<link doc="ngx_http_upstream_module.xml" id="zone">shared memory</link>. +</para> + +<para> +If several health checks are defined for the same group of servers, +a single failure of any check will make the corresponding server be +considered unhealthy. +</para> + +<para> +<note> +Please note that most of the variables will have empty values +when used with health checks. +</note> +</para> + +</directive> + + +<directive name="match"> +<syntax block="yes"><value>name</value></syntax> +<default/> +<context>http</context> + +<para> +Defines the named test set used to verify responses to health check requests. +</para> + +<para> +The following items can be tested in a response: +<list type="tag"> + +<tag-name><literal>status 200;</literal></tag-name> +<tag-desc>status is 200</tag-desc> + +<tag-name><literal>status ! 500;</literal></tag-name> +<tag-desc>status is not 500</tag-desc> + +<tag-name><literal>status 200 204;</literal></tag-name> +<tag-desc>status is 200 or 204</tag-desc> + +<tag-name><literal>status ! 301 302;</literal></tag-name> +<tag-desc>status is neither 301 nor 302</tag-desc> + +<tag-name><literal>status 200-399;</literal></tag-name> +<tag-desc>status is in the range from 200 to 399</tag-desc> + +<tag-name><literal>status ! 400-599;</literal></tag-name> +<tag-desc>status is not in the range from 400 to 599</tag-desc> + +<tag-name><literal>status 301-303 307;</literal></tag-name> +<tag-desc>status is either 301, 302, 303, or 307</tag-desc> + +</list> + +<list type="tag"> + +<tag-name><literal>header Content-Type = text/html;</literal></tag-name> +<tag-desc> +header contains <header>Content-Type</header> +with value <literal>text/html</literal> +</tag-desc> + +<tag-name><literal>header Content-Type != text/html;</literal></tag-name> +<tag-desc> +header contains <header>Content-Type</header> +with value other than <literal>text/html</literal> +</tag-desc> + +<tag-name><literal>header Connection ~ close;</literal></tag-name> +<tag-desc> +header contains <header>Connection</header> +with value matching regular expression <literal>close</literal> +</tag-desc> + +<tag-name><literal>header Connection !~ close;</literal></tag-name> +<tag-desc> +header contains <header>Connection</header> +with value not matching regular expression <literal>close</literal> +</tag-desc> + +<tag-name><literal>header Host;</literal></tag-name> +<tag-desc>header contains <header>Host</header></tag-desc> + +<tag-name><literal>header ! X-Accel-Redirect;</literal></tag-name> +<tag-desc>header lacks <header>X-Accel-Redirect</header></tag-desc> + +</list> + +<list type="tag"> + +<tag-name><literal>body ~ "Welcome to nginx!";</literal></tag-name> +<tag-desc> +body matches regular expression “<literal>Welcome to nginx!</literal>” +</tag-desc> + +<tag-name><literal>body !~ "Welcome to nginx!";</literal></tag-name> +<tag-desc> +body does not match regular expression “<literal>Welcome to nginx!</literal>” +</tag-desc> + +</list> +</para> + +<para> +If several tests are specified, +the response matches only if it matches all tests. +<note> +Only the first 256k of the response body are examined. +</note> +</para> + +<para> +Examples: +<example> +# status is 200, content type is "text/html", +# and body contains "Welcome to nginx!" +match welcome { + status 200; + header Content-Type = text/html; + body ~ "Welcome to nginx!"; +} +</example> + +<example> +# status is not one of 301, 302, 303, or 307, and header does not have "Refresh:" +match not_redirect { + status ! 301-303 307; + header ! Refresh; +} +</example> + +<example> +# status ok and not in maintenance mode +match server_ok { + status 200-399; + body !~ "maintenance mode"; +} +</example> + +</para> + +</directive> + +</section> + +</module>
--- a/xml/en/docs/http/ngx_http_upstream_module.xml Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/en/docs/http/ngx_http_upstream_module.xml Thu Mar 30 21:26:44 2017 +0300 @@ -10,7 +10,7 @@ <module name="Module ngx_http_upstream_module" link="/en/docs/http/ngx_http_upstream_module.html" lang="en" - rev="59"> + rev="60"> <section id="summary"> @@ -49,7 +49,8 @@ </para> <para> -Dynamically configurable group, +Dynamically configurable group with +periodic <link doc="ngx_http_upstream_hc_module.xml">health checks</link> is available as part of our <commercial_version>commercial subscription</commercial_version>: <example> @@ -321,7 +322,7 @@ <tag-desc> sets the <value>time</value> during which the server will recover its weight from zero to a nominal value, when unhealthy server becomes -<link id="health_check">healthy</link>, +<link doc="ngx_http_upstream_hc_module.xml" id="health_check">healthy</link>, or when the server becomes available after a period of time it was considered <link id="fail_timeout">unavailable</link>. Default value is zero, i.e. slow start is disabled. @@ -741,302 +742,6 @@ </directive> -<directive name="health_check"> -<syntax>[<value>parameters</value>]</syntax> -<default/> -<context>location</context> - -<para> -Enables periodic health checks of the servers in a -<link id="upstream">group</link> referenced in the surrounding location. -</para> - -<para> -The following optional parameters are supported: -<list type="tag"> - -<tag-name id="interval"> -<literal>interval</literal>=<value>time</value> -</tag-name> -<tag-desc> -sets the interval between two consecutive health checks, -by default, 5 seconds. -</tag-desc> - -<tag-name id="health_check_jitter"> -<literal>jitter</literal>=<value>time</value> -</tag-name> -<tag-desc> -sets the time within which -each health check will be randomly delayed, -by default, there is no delay. -</tag-desc> - -<tag-name id="fails"> -<literal>fails</literal>=<value>number</value> -</tag-name> -<tag-desc> -sets the number of consecutive failed health checks of a particular server -after which this server will be considered unhealthy, -by default, 1. -</tag-desc> - -<tag-name id="passes"> -<literal>passes</literal>=<value>number</value> -</tag-name> -<tag-desc> -sets the number of consecutive passed health checks of a particular server -after which the server will be considered healthy, -by default, 1. -</tag-desc> - -<tag-name id="uri"> -<literal>uri</literal>=<value>uri</value> -</tag-name> -<tag-desc> -defines the URI used in health check requests, -by default, “<literal>/</literal>”. -</tag-desc> - -<tag-name id="health_check_mandatory"> -<literal>mandatory</literal> -</tag-name> -<tag-desc> -sets the initial “checking” state for a server -until the first health check is completed (1.11.7). -If the parameter is not specified, -the server will be initially considered healthy. -</tag-desc> - -<tag-name id="hc_match"> -<literal>match</literal>=<value>name</value> -</tag-name> -<tag-desc> -specifies the <literal>match</literal> block configuring the tests that a -response should pass in order for a health check to pass. -By default, the response should have status code 2xx or 3xx. -</tag-desc> - -<tag-name id="health_check_port"> -<literal>port</literal>=<value>number</value> -</tag-name> -<tag-desc> -defines the port used when connecting to a server -to perform a health check (1.9.7). -By default, equals the <link id="server"/> port. -</tag-desc> - -</list> -</para> - -<para> -For example, -<example> -location / { - proxy_pass http://backend; - health_check; -} -</example> -will send “<literal>/</literal>” requests to each -server in the <literal>backend</literal> group every five seconds. -If any communication error or timeout occurs, or a -proxied server responds with the status code other than -2xx or 3xx, the health check will fail, and the server will -be considered unhealthy. -Client requests are not passed to unhealthy servers -and servers in the “checking” state. -</para> - -<para> -Health checks can be configured to test the status code of a response, -presence of certain header fields and their values, -and the body contents. -Tests are configured separately using the <link id="match"/> directive -and referenced in the <literal>match</literal> parameter. -For example: -<example> -http { - server { - ... - location / { - proxy_pass http://backend; - health_check match=welcome; - } - } - - match welcome { - status 200; - header Content-Type = text/html; - body ~ "Welcome to nginx!"; - } -} -</example> -This configuration shows that in order for a health check to pass, the response -to a health check request should succeed, -have status 200, content type “<literal>text/html</literal>”, -and contain “<literal>Welcome to nginx!</literal>” in the body. -</para> - -<para> -The server group must reside in the <link id="zone">shared memory</link>. -</para> - -<para> -If several health checks are defined for the same group of servers, -a single failure of any check will make the corresponding server be -considered unhealthy. -</para> - -<para> -<note> -Please note that most of the variables will have empty values -when used with health checks. -</note> -</para> - -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="match"> -<syntax block="yes"><value>name</value></syntax> -<default/> -<context>http</context> - -<para> -Defines the named test set used to verify responses to health check requests. -</para> - -<para> -The following items can be tested in a response: -<list type="tag"> - -<tag-name><literal>status 200;</literal></tag-name> -<tag-desc>status is 200</tag-desc> - -<tag-name><literal>status ! 500;</literal></tag-name> -<tag-desc>status is not 500</tag-desc> - -<tag-name><literal>status 200 204;</literal></tag-name> -<tag-desc>status is 200 or 204</tag-desc> - -<tag-name><literal>status ! 301 302;</literal></tag-name> -<tag-desc>status is neither 301 nor 302</tag-desc> - -<tag-name><literal>status 200-399;</literal></tag-name> -<tag-desc>status is in the range from 200 to 399</tag-desc> - -<tag-name><literal>status ! 400-599;</literal></tag-name> -<tag-desc>status is not in the range from 400 to 599</tag-desc> - -<tag-name><literal>status 301-303 307;</literal></tag-name> -<tag-desc>status is either 301, 302, 303, or 307</tag-desc> - -</list> - -<list type="tag"> - -<tag-name><literal>header Content-Type = text/html;</literal></tag-name> -<tag-desc> -header contains <header>Content-Type</header> -with value <literal>text/html</literal> -</tag-desc> - -<tag-name><literal>header Content-Type != text/html;</literal></tag-name> -<tag-desc> -header contains <header>Content-Type</header> -with value other than <literal>text/html</literal> -</tag-desc> - -<tag-name><literal>header Connection ~ close;</literal></tag-name> -<tag-desc> -header contains <header>Connection</header> -with value matching regular expression <literal>close</literal> -</tag-desc> - -<tag-name><literal>header Connection !~ close;</literal></tag-name> -<tag-desc> -header contains <header>Connection</header> -with value not matching regular expression <literal>close</literal> -</tag-desc> - -<tag-name><literal>header Host;</literal></tag-name> -<tag-desc>header contains <header>Host</header></tag-desc> - -<tag-name><literal>header ! X-Accel-Redirect;</literal></tag-name> -<tag-desc>header lacks <header>X-Accel-Redirect</header></tag-desc> - -</list> - -<list type="tag"> - -<tag-name><literal>body ~ "Welcome to nginx!";</literal></tag-name> -<tag-desc> -body matches regular expression “<literal>Welcome to nginx!</literal>” -</tag-desc> - -<tag-name><literal>body !~ "Welcome to nginx!";</literal></tag-name> -<tag-desc> -body does not match regular expression “<literal>Welcome to nginx!</literal>” -</tag-desc> - -</list> -</para> - -<para> -If several tests are specified, -the response matches only if it matches all tests. -<note> -Only the first 256k of the response body are examined. -</note> -</para> - -<para> -Examples: -<example> -# status is 200, content type is "text/html", -# and body contains "Welcome to nginx!" -match welcome { - status 200; - header Content-Type = text/html; - body ~ "Welcome to nginx!"; -} -</example> - -<example> -# status is not one of 301, 302, 303, or 307, and header does not have "Refresh:" -match not_redirect { - status ! 301-303 307; - header ! Refresh; -} -</example> - -<example> -# status ok and not in maintenance mode -match server_ok { - status 200-399; - body !~ "maintenance mode"; -} -</example> - -</para> - -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - -</directive> - - <directive name="queue"> <syntax> <value>number</value>
--- a/xml/en/docs/index.xml Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/en/docs/index.xml Thu Mar 30 21:26:44 2017 +0300 @@ -8,7 +8,7 @@ <article name="nginx documentation" link="/en/docs/" lang="en" - rev="37" + rev="38" toc="no"> @@ -445,6 +445,11 @@ </listitem> <listitem> +<link doc="http/ngx_http_upstream_hc_module.xml"> +ngx_http_upstream_hc_module</link> +</listitem> + +<listitem> <link doc="http/ngx_http_userid_module.xml"> ngx_http_userid_module</link> </listitem>
--- a/xml/ru/GNUmakefile Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/ru/GNUmakefile Thu Mar 30 21:26:44 2017 +0300 @@ -75,6 +75,7 @@ http/ngx_http_sub_module \ http/ngx_http_upstream_module \ http/ngx_http_upstream_conf_module \ + http/ngx_http_upstream_hc_module \ http/ngx_http_userid_module \ http/ngx_http_uwsgi_module \ http/ngx_http_v2_module \
--- a/xml/ru/docs/http/ngx_http_status_module.xml Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/ru/docs/http/ngx_http_status_module.xml Thu Mar 30 21:26:44 2017 +0300 @@ -9,7 +9,7 @@ <module name="Модуль ngx_http_status_module" link="/ru/docs/http/ngx_http_status_module.html" lang="ru" - rev="14"> + rev="15"> <section id="summary"> @@ -564,7 +564,7 @@ <tag-name><literal>checks</literal></tag-name> <tag-desc> Суммарное число запросов -<link doc="ngx_http_upstream_module.xml" id="health_check">проверки +<link doc="ngx_http_upstream_hc_module.xml" id="health_check">проверки работоспособности</link>. </tag-desc> @@ -583,7 +583,7 @@ <tag-desc> Логическое значение, означающее, была ли последняя проверка работоспособности удачной и удовлетворял ли ответ заданным -<link doc="ngx_http_upstream_module.xml" id="match">тестам</link>. +<link doc="ngx_http_upstream_hc_module.xml" id="match">тестам</link>. </tag-desc> </list>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xml/ru/docs/http/ngx_http_upstream_hc_module.xml Thu Mar 30 21:26:44 2017 +0300 @@ -0,0 +1,350 @@ +<?xml version="1.0"?> + +<!-- + Copyright (C) Nginx, Inc. + --> + +<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> + +<module name="Модуль ngx_http_upstream_hc_module" + link="/ru/docs/http/ngx_http_upstream_hc_module.html" + lang="ru" + rev="1"> + +<section id="summary"> + +<para> +Модуль <literal>ngx_http_upstream_hc_module</literal> +позволяет активировать периодические проверки работоспособности серверов в +<link doc="ngx_http_upstream_module.xml" id="upstream">группе</link>, +указанной в содержащем location. +</para> + +<para> +<note> +Модуль доступен как часть +<commercial_version>коммерческой подписки</commercial_version>. +</note> +</para> + +</section> + + +<section id="example" name="Пример конфигурации"> + +<para> +<example> +upstream dynamic { + zone upstream_dynamic 64k; + + server backend1.example.com weight=5; + server backend2.example.com:8080 fail_timeout=5s slow_start=30s; + server 192.0.2.1 max_fails=3; + + server backup1.example.com:8080 backup; + server backup2.example.com:8080 backup; +} + +server { + location / { + proxy_pass http://dynamic; + health_check; + } +} +</example> +</para> + +</section> + + +<section id="directives" name="Директивы"> + +<directive name="health_check"> +<syntax>[<value>параметры</value>]</syntax> +<default/> +<context>location</context> + +<para> +Активирует периодические проверки работоспособности серверов в +<link doc="ngx_http_upstream_module.xml" id="upstream">группе</link>, +указанной в содержащем location. +</para> + +<para> +Могут быть заданы следующие необязательные параметры: +<list type="tag"> + +<tag-name id="interval"> +<literal>interval</literal>=<value>время</value> +</tag-name> +<tag-desc> +задаёт интервал между двумя последовательными проверками, +по умолчанию 5 секунд. +</tag-desc> + +<tag-name id="health_check_jitter"> +<literal>jitter</literal>=<value>время</value> +</tag-name> +<tag-desc> +задаёт время, в пределах которого +случайным образом задерживается каждая проверка, +по умолчанию задержки нет. +</tag-desc> + +<tag-name id="fails"> +<literal>fails</literal>=<value>число</value> +</tag-name> +<tag-desc> +задаёт число последовательных неуспешных проверок для определённого сервера, +после которых сервер будет считаться неработоспособным, +по умолчанию 1. +</tag-desc> + +<tag-name id="passes"> +<literal>passes</literal>=<value>число</value> +</tag-name> +<tag-desc> +задаёт число последовательных успешных проверок для определённого сервера, +после которых сервер будет считаться работоспособным, +по умолчанию 1. +</tag-desc> + +<tag-name id="uri"> +<literal>uri</literal>=<value>uri</value> +</tag-name> +<tag-desc> +задаёт URI, используемый в запросах, проверяющих работоспособность, +по умолчанию “<literal>/</literal>”. +</tag-desc> + +<tag-name id="health_check_mandatory"> +<literal>mandatory</literal> +</tag-name> +<tag-desc> +устанавливает исходное состояние “checking” для сервера +до завершения первой проверки работоспособности (1.11.7). +Если параметр не указан, +то исходно сервер будет считаться работоспособным. +</tag-desc> + +<tag-name id="hc_match"> +<literal>match</literal>=<value>имя</value> +</tag-name> +<tag-desc> +указывает на блок <literal>match</literal> с условиями, которым должен +удовлетворять ответ, чтобы результат проверки считался успешным. +По умолчанию код ответа должен быть 2xx или 3xx. +</tag-desc> + +<tag-name id="health_check_port"> +<literal>port</literal>=<value>число</value> +</tag-name> +<tag-desc> +задаёт порт, используемый при подключении к серверу +для проверки его работоспособности (1.9.7). +По умолчанию совпадает с портом +<link doc="ngx_http_upstream_module.xml" id="server">сервера</link>. +</tag-desc> + +</list> +</para> + +<para> +В примере +<example> +location / { + proxy_pass http://backend; + health_check; +} +</example> +каждому серверу группы <literal>backend</literal> +с интервалом в 5 секунд посылаются запросы “<literal>/</literal>”. +Если происходит ошибка или таймаут при работе с сервером, или +код ответа проксируемого сервера не равен +2xx или 3xx, проверка считается неуспешной и сервер +признаётся неработоспособным. +На неработоспособные серверы и серверы в состоянии “checking” +клиентские запросы передаваться не будут. +</para> + +<para> +Проверки работоспособности могут тестировать код ответа, +наличие или отсутствие определённых полей заголовка и их значений, +а также содержимое тела ответа. +Тесты настраиваются отдельно при помощи директивы <link id="match"/> +и указываются в параметре <literal>match</literal>. +Например: +<example> +http { + server { + ... + location / { + proxy_pass http://backend; + health_check match=welcome; + } + } + + match welcome { + status 200; + header Content-Type = text/html; + body ~ "Welcome to nginx!"; + } +} +</example> +В такой конфигурации успешный ответ на проверочный запрос +должен иметь код 200, тип содержимого “<literal>text/html</literal>” +и “<literal>Welcome to nginx!</literal>” в теле ответа. +</para> + +<para> +Группа должна находиться в +<link doc="ngx_http_upstream_module.xml" id="zone">зоне разделяемой памяти</link>. +</para> + +<para> +Если для группы задано несколько проверок, +то при любой неуспешной проверке соответствующий сервер будет +считаться неработоспособным. +</para> + +<para> +<note> +Обратите внимание, что при использовании проверок +большинство переменных имеют пустые значения. +</note> +</para> + +</directive> + + +<directive name="match"> +<syntax block="yes"><value>имя</value></syntax> +<default/> +<context>http</context> + +<para> +Задаёт именованный набор тестов для анализа ответов +на запросы проверки работоспособности. +</para> + +<para> +В ответе могут быть протестированы следующие объекты: +<list type="tag"> + +<tag-name><literal>status 200;</literal></tag-name> +<tag-desc>код ответа равен 200</tag-desc> + +<tag-name><literal>status ! 500;</literal></tag-name> +<tag-desc>код ответа не равен 500</tag-desc> + +<tag-name><literal>status 200 204;</literal></tag-name> +<tag-desc>код ответа равен 200 или 204</tag-desc> + +<tag-name><literal>status ! 301 302;</literal></tag-name> +<tag-desc>код ответа не равен ни 301, ни 302</tag-desc> + +<tag-name><literal>status 200-399;</literal></tag-name> +<tag-desc>код ответа находится в диапазоне от 200 до 399</tag-desc> + +<tag-name><literal>status ! 400-599;</literal></tag-name> +<tag-desc>код ответа находится вне диапазона от 400 до 599</tag-desc> + +<tag-name><literal>status 301-303 307;</literal></tag-name> +<tag-desc>код ответа равен 301, 302, 303 или 307</tag-desc> + +</list> + +<list type="tag"> + +<tag-name><literal>header Content-Type = text/html;</literal></tag-name> +<tag-desc> +заголовок содержит <header>Content-Type</header> +со значением <literal>text/html</literal> +</tag-desc> + +<tag-name><literal>header Content-Type != text/html;</literal></tag-name> +<tag-desc> +заголовок содержит <header>Content-Type</header> +со значением, отличным от <literal>text/html</literal> +</tag-desc> + +<tag-name><literal>header Connection ~ close;</literal></tag-name> +<tag-desc> +заголовок содержит <header>Connection</header> +со значением, совпадающим с регулярным выражением <literal>close</literal> +</tag-desc> + +<tag-name><literal>header Connection !~ close;</literal></tag-name> +<tag-desc> +заголовок содержит <header>Connection</header> +со значением, не совпадающим с регулярным выражением <literal>close</literal> +</tag-desc> + +<tag-name><literal>header Host;</literal></tag-name> +<tag-desc>заголовок содержит <header>Host</header></tag-desc> + +<tag-name><literal>header ! X-Accel-Redirect;</literal></tag-name> +<tag-desc>заголовок не содержит <header>X-Accel-Redirect</header></tag-desc> + +</list> + +<list type="tag"> + +<tag-name><literal>body ~ "Welcome to nginx!";</literal></tag-name> +<tag-desc> +тело ответа совпадает с регулярным выражением +“<literal>Welcome to nginx!</literal>” +</tag-desc> + +<tag-name><literal>body !~ "Welcome to nginx!";</literal></tag-name> +<tag-desc> +тело ответа не совпадает с регулярным выражением +“<literal>Welcome to nginx!</literal>” +</tag-desc> + +</list> +</para> + +<para> +Если задано несколько тестов, +то ответ должен удовлетворять всем тестам. +<note> +Проверяются только первые 256 Кбайт тела ответа. +</note> +</para> + +<para> +Примеры: +<example> +# код ответа 200, тип содержимого "text/html" +# и тело ответа содержит "Welcome to nginx!" +match welcome { + status 200; + header Content-Type = text/html; + body ~ "Welcome to nginx!"; +} +</example> + +<example> +# код ответа не равен 301, 302, 303 и 307 и заголовок не содержит "Refresh:" +match not_redirect { + status ! 301-303 307; + header ! Refresh; +} +</example> + +<example> +# код ответа успешный и сервер не в сервисном режиме +match server_ok { + status 200-399; + body !~ "maintenance mode"; +} +</example> + +</para> + +</directive> + +</section> + +</module>
--- a/xml/ru/docs/http/ngx_http_upstream_module.xml Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/ru/docs/http/ngx_http_upstream_module.xml Thu Mar 30 21:26:44 2017 +0300 @@ -10,7 +10,7 @@ <module name="Модуль ngx_http_upstream_module" link="/ru/docs/http/ngx_http_upstream_module.html" lang="ru" - rev="59"> + rev="60"> <section id="summary"> @@ -50,7 +50,9 @@ </para> <para> -Динамически настраиваемая группа, +Динамически настраиваемая группа +с периодическими +<link doc="ngx_http_upstream_hc_module.xml">проверками работоспособности</link> доступна как часть <commercial_version>коммерческой подписки</commercial_version>: <example> @@ -324,7 +326,7 @@ задаёт <value>время</value>, в течение которого вес сервера восстановится от нуля до своего номинального значения в ситуации, когда неработоспособный (unhealthy) сервер вновь становится работоспособным -(<link id="health_check">healthy</link>) +(<link doc="ngx_http_upstream_hc_module.xml" id="health_check">healthy</link>) или когда сервер становится доступным по прошествии времени, в течение которого он считался <link id="fail_timeout">недоступным</link>. Значение по умолчанию равно нулю и означает, что медленный старт выключен. @@ -748,304 +750,6 @@ </directive> -<directive name="health_check"> -<syntax>[<value>параметры</value>]</syntax> -<default/> -<context>location</context> - -<para> -Активирует периодические проверки работоспособности серверов в -<link id="upstream">группе</link>, указанной в содержащем location. -</para> - -<para> -Могут быть заданы следующие необязательные параметры: -<list type="tag"> - -<tag-name id="interval"> -<literal>interval</literal>=<value>время</value> -</tag-name> -<tag-desc> -задаёт интервал между двумя последовательными проверками, -по умолчанию 5 секунд. -</tag-desc> - -<tag-name id="health_check_jitter"> -<literal>jitter</literal>=<value>время</value> -</tag-name> -<tag-desc> -задаёт время, в пределах которого -случайным образом задерживается каждая проверка, -по умолчанию задержки нет. -</tag-desc> - -<tag-name id="fails"> -<literal>fails</literal>=<value>число</value> -</tag-name> -<tag-desc> -задаёт число последовательных неуспешных проверок для определённого сервера, -после которых сервер будет считаться неработоспособным, -по умолчанию 1. -</tag-desc> - -<tag-name id="passes"> -<literal>passes</literal>=<value>число</value> -</tag-name> -<tag-desc> -задаёт число последовательных успешных проверок для определённого сервера, -после которых сервер будет считаться работоспособным, -по умолчанию 1. -</tag-desc> - -<tag-name id="uri"> -<literal>uri</literal>=<value>uri</value> -</tag-name> -<tag-desc> -задаёт URI, используемый в запросах, проверяющих работоспособность, -по умолчанию “<literal>/</literal>”. -</tag-desc> - -<tag-name id="health_check_mandatory"> -<literal>mandatory</literal> -</tag-name> -<tag-desc> -устанавливает исходное состояние “checking” для сервера -до завершения первой проверки работоспособности (1.11.7). -Если параметр не указан, -то исходно сервер будет считаться работоспособным. -</tag-desc> - -<tag-name id="hc_match"> -<literal>match</literal>=<value>имя</value> -</tag-name> -<tag-desc> -указывает на блок <literal>match</literal> с условиями, которым должен -удовлетворять ответ, чтобы результат проверки считался успешным. -По умолчанию код ответа должен быть 2xx или 3xx. -</tag-desc> - -<tag-name id="health_check_port"> -<literal>port</literal>=<value>число</value> -</tag-name> -<tag-desc> -задаёт порт, используемый при подключении к серверу -для проверки его работоспособности (1.9.7). -По умолчанию совпадает с портом <link id="server">сервера</link>. -</tag-desc> - -</list> -</para> - -<para> -В примере -<example> -location / { - proxy_pass http://backend; - health_check; -} -</example> -каждому серверу группы <literal>backend</literal> -с интервалом в 5 секунд посылаются запросы “<literal>/</literal>”. -Если происходит ошибка или таймаут при работе с сервером, или -код ответа проксируемого сервера не равен -2xx или 3xx, проверка считается неуспешной и сервер -признаётся неработоспособным. -На неработоспособные серверы и серверы в состоянии “checking” -клиентские запросы передаваться не будут. -</para> - -<para> -Проверки работоспособности могут тестировать код ответа, -наличие или отсутствие определённых полей заголовка и их значений, -а также содержимое тела ответа. -Тесты настраиваются отдельно при помощи директивы <link id="match"/> -и указываются в параметре <literal>match</literal>. -Например: -<example> -http { - server { - ... - location / { - proxy_pass http://backend; - health_check match=welcome; - } - } - - match welcome { - status 200; - header Content-Type = text/html; - body ~ "Welcome to nginx!"; - } -} -</example> -В такой конфигурации успешный ответ на проверочный запрос -должен иметь код 200, тип содержимого “<literal>text/html</literal>” -и “<literal>Welcome to nginx!</literal>” в теле ответа. -</para> - -<para> -Группа должна находиться в <link id="zone">зоне разделяемой памяти</link>. -</para> - -<para> -Если для группы задано несколько проверок, -то при любой неуспешной проверке соответствующий сервер будет -считаться неработоспособным. -</para> - -<para> -<note> -Обратите внимание, что при использовании проверок -большинство переменных имеют пустые значения. -</note> -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="match"> -<syntax block="yes"><value>имя</value></syntax> -<default/> -<context>http</context> - -<para> -Задаёт именованный набор тестов для анализа ответов -на запросы проверки работоспособности. -</para> - -<para> -В ответе могут быть протестированы следующие объекты: -<list type="tag"> - -<tag-name><literal>status 200;</literal></tag-name> -<tag-desc>код ответа равен 200</tag-desc> - -<tag-name><literal>status ! 500;</literal></tag-name> -<tag-desc>код ответа не равен 500</tag-desc> - -<tag-name><literal>status 200 204;</literal></tag-name> -<tag-desc>код ответа равен 200 или 204</tag-desc> - -<tag-name><literal>status ! 301 302;</literal></tag-name> -<tag-desc>код ответа не равен ни 301, ни 302</tag-desc> - -<tag-name><literal>status 200-399;</literal></tag-name> -<tag-desc>код ответа находится в диапазоне от 200 до 399</tag-desc> - -<tag-name><literal>status ! 400-599;</literal></tag-name> -<tag-desc>код ответа находится вне диапазона от 400 до 599</tag-desc> - -<tag-name><literal>status 301-303 307;</literal></tag-name> -<tag-desc>код ответа равен 301, 302, 303 или 307</tag-desc> - -</list> - -<list type="tag"> - -<tag-name><literal>header Content-Type = text/html;</literal></tag-name> -<tag-desc> -заголовок содержит <header>Content-Type</header> -со значением <literal>text/html</literal> -</tag-desc> - -<tag-name><literal>header Content-Type != text/html;</literal></tag-name> -<tag-desc> -заголовок содержит <header>Content-Type</header> -со значением, отличным от <literal>text/html</literal> -</tag-desc> - -<tag-name><literal>header Connection ~ close;</literal></tag-name> -<tag-desc> -заголовок содержит <header>Connection</header> -со значением, совпадающим с регулярным выражением <literal>close</literal> -</tag-desc> - -<tag-name><literal>header Connection !~ close;</literal></tag-name> -<tag-desc> -заголовок содержит <header>Connection</header> -со значением, не совпадающим с регулярным выражением <literal>close</literal> -</tag-desc> - -<tag-name><literal>header Host;</literal></tag-name> -<tag-desc>заголовок содержит <header>Host</header></tag-desc> - -<tag-name><literal>header ! X-Accel-Redirect;</literal></tag-name> -<tag-desc>заголовок не содержит <header>X-Accel-Redirect</header></tag-desc> - -</list> - -<list type="tag"> - -<tag-name><literal>body ~ "Welcome to nginx!";</literal></tag-name> -<tag-desc> -тело ответа совпадает с регулярным выражением -“<literal>Welcome to nginx!</literal>” -</tag-desc> - -<tag-name><literal>body !~ "Welcome to nginx!";</literal></tag-name> -<tag-desc> -тело ответа не совпадает с регулярным выражением -“<literal>Welcome to nginx!</literal>” -</tag-desc> - -</list> -</para> - -<para> -Если задано несколько тестов, -то ответ должен удовлетворять всем тестам. -<note> -Проверяются только первые 256 Кбайт тела ответа. -</note> -</para> - -<para> -Примеры: -<example> -# код ответа 200, тип содержимого "text/html" -# и тело ответа содержит "Welcome to nginx!" -match welcome { - status 200; - header Content-Type = text/html; - body ~ "Welcome to nginx!"; -} -</example> - -<example> -# код ответа не равен 301, 302, 303 и 307 и заголовок не содержит "Refresh:" -match not_redirect { - status ! 301-303 307; - header ! Refresh; -} -</example> - -<example> -# код ответа успешный и сервер не в сервисном режиме -match server_ok { - status 200-399; - body !~ "maintenance mode"; -} -</example> - -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - - <directive name="queue"> <syntax> <value>число</value>
--- a/xml/ru/docs/index.xml Wed Mar 29 22:55:20 2017 +0300 +++ b/xml/ru/docs/index.xml Thu Mar 30 21:26:44 2017 +0300 @@ -8,7 +8,7 @@ <article name="nginx: документация" link="/ru/docs/" lang="ru" - rev="37" + rev="38" toc="no"> @@ -445,6 +445,11 @@ </listitem> <listitem> +<link doc="http/ngx_http_upstream_hc_module.xml"> +ngx_http_upstream_hc_module</link> +</listitem> + +<listitem> <link doc="http/ngx_http_userid_module.xml"> ngx_http_userid_module</link> </listitem>