Mercurial > hg > nginx-site
changeset 1947:6b6d0e844bf7
Moved "health_check" and "match" to ngx_stream_upstream_hc_module.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Fri, 24 Mar 2017 19:48:53 +0300 |
parents | 37df1535ea91 |
children | 25962922969a |
files | xml/en/GNUmakefile xml/en/docs/http/ngx_http_status_module.xml xml/en/docs/index.xml xml/en/docs/stream/ngx_stream_upstream_hc_module.xml xml/en/docs/stream/ngx_stream_upstream_module.xml xml/ru/GNUmakefile xml/ru/docs/http/ngx_http_status_module.xml xml/ru/docs/index.xml xml/ru/docs/stream/ngx_stream_upstream_hc_module.xml xml/ru/docs/stream/ngx_stream_upstream_module.xml |
diffstat | 10 files changed, 77 insertions(+), 1626 deletions(-) [+] |
line wrap: on
line diff
--- a/xml/en/GNUmakefile +++ b/xml/en/GNUmakefile @@ -113,6 +113,7 @@ REFS = \ stream/ngx_stream_ssl_module \ stream/ngx_stream_ssl_preread_module \ stream/ngx_stream_upstream_module \ + stream/ngx_stream_upstream_hc_module \ stream/stream_processing \ ngx_google_perftools_module \ dev/development_guide \
--- a/xml/en/docs/http/ngx_http_status_module.xml +++ b/xml/en/docs/http/ngx_http_status_module.xml @@ -9,7 +9,7 @@ <module name="Module ngx_http_status_module" link="/en/docs/http/ngx_http_status_module.html" lang="en" - rev="15"> + rev="16"> <section id="summary"> @@ -961,7 +961,7 @@ threshold. <tag-name><literal>checks</literal></tag-name> <tag-desc> The total number of -<link doc="../stream/ngx_stream_upstream_module.xml" id="health_check">health check</link> +<link doc="../stream/ngx_stream_upstream_hc_module.xml" id="health_check">health check</link> requests made. </tag-desc> @@ -980,7 +980,7 @@ the server became unhealthy (state “<literal>unhealthy</literal>”). <tag-desc> Boolean indicating if the last health check request was successful and passed -<link doc="../stream/ngx_stream_upstream_module.xml" id="match">tests</link>. +<link doc="../stream/ngx_stream_upstream_hc_module.xml" id="match">tests</link>. </tag-desc> </list>
--- a/xml/en/docs/index.xml +++ b/xml/en/docs/index.xml @@ -8,7 +8,7 @@ <article name="nginx documentation" link="/en/docs/" lang="en" - rev="38" + rev="39" toc="no"> @@ -591,6 +591,11 @@ ngx_stream_ssl_preread_module</link> ngx_stream_upstream_module</link> </listitem> +<listitem> +<link doc="stream/ngx_stream_upstream_hc_module.xml"> +ngx_stream_upstream_hc_module</link> +</listitem> + </list> </para>
copy from xml/en/docs/stream/ngx_stream_upstream_module.xml copy to xml/en/docs/stream/ngx_stream_upstream_hc_module.xml --- a/xml/en/docs/stream/ngx_stream_upstream_module.xml +++ b/xml/en/docs/stream/ngx_stream_upstream_hc_module.xml @@ -6,18 +6,26 @@ <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> -<module name="Module ngx_stream_upstream_module" - link="/en/docs/stream/ngx_stream_upstream_module.html" +<module name="Module ngx_stream_upstream_hc_module" + link="/en/docs/stream/ngx_stream_upstream_hc_module.html" lang="en" - rev="24"> + rev="1"> <section id="summary"> <para> -The <literal>ngx_stream_upstream_module</literal> module (1.9.0) -is used to define groups of servers that can be referenced -by the <link doc="ngx_stream_proxy_module.xml" id="proxy_pass"/> -directive. +The <literal>ngx_stream_upstream_hc_module</literal> module (1.9.0) +allows enabling periodic health checks of the servers in a +<link doc="ngx_stream_upstream_module.xml" id="upstream">group</link>. +The server group must reside in the +<link doc="ngx_stream_upstream_module.xml" id="zone">shared memory</link>. +</para> + +<para> +<note> +This module is available as part of our +<commercial_version>commercial subscription</commercial_version>. +</note> </para> </section> @@ -27,47 +35,20 @@ directive. <para> <example> -upstream <emphasis>backend</emphasis> { - hash $remote_addr consistent; - - server backend1.example.com:12345 weight=5; - server backend2.example.com:12345; - server unix:/tmp/backend3; - - server backup1.example.com:12345 backup; - server backup2.example.com:12345 backup; -} - -server { - listen 12346; - proxy_pass <emphasis>backend</emphasis>; -} -</example> -</para> - -<para> -Dynamically configurable group, -available as part of our -<commercial_version>commercial subscription</commercial_version>: -<example> -resolver 10.0.0.1; - -upstream <emphasis>dynamic</emphasis> { - zone upstream_dynamic 64k; +upstream tcp { + zone upstream_tcp 64k; server backend1.example.com:12345 weight=5; server backend2.example.com:12345 fail_timeout=5s slow_start=30s; server 192.0.2.1:12345 max_fails=3; - server backend3.example.com:12345 resolve; - server backend4.example.com service=http resolve; server backup1.example.com:12345 backup; server backup2.example.com:12345 backup; } server { - listen 12346; - proxy_pass <emphasis>dynamic</emphasis>; + listen 12346; + proxy_pass tcp; health_check; } </example> @@ -78,420 +59,6 @@ server { <section id="directives" name="Directives"> -<directive name="upstream"> -<syntax block="yes"><value>name</value></syntax> -<default/> -<context>stream</context> - -<para> -Defines a group of servers. -Servers can listen on different ports. -In addition, servers listening on TCP and UNIX-domain sockets -can be mixed. -</para> - -<para> -Example: -<example> -upstream backend { - server backend1.example.com:12345 weight=5; - server 127.0.0.1:12345 max_fails=3 fail_timeout=30s; - server unix:/tmp/backend2; - server backend3.example.com:12345 resolve; - - server backup1.example.com:12345 backup; -} -</example> -</para> - -<para> -By default, connections are distributed between the servers using a -weighted round-robin balancing method. -In the above example, each 7 connections will be distributed as follows: -5 connections go to <literal>backend1.example.com:12345</literal> -and one connection to each of the second and third servers. -If an error occurs during communication with a server, the connection will -be passed to the next server, and so on until all of the functioning -servers will be tried. -If communication with all servers fails, the connection will be closed. -</para> - -</directive> - - -<directive name="server"> -<syntax><value>address</value> [<value>parameters</value>]</syntax> -<default/> -<context>upstream</context> - -<para> -Defines the <value>address</value> and other <value>parameters</value> -of a server. -The address can be specified as a domain name or IP address -with an obligatory port, or as a UNIX-domain socket path -specified after the “<literal>unix:</literal>” prefix. -A domain name that resolves to several IP addresses defines -multiple servers at once. -</para> - -<para> -The following parameters can be defined: -<list type="tag"> - -<tag-name id="weight"> -<literal>weight</literal>=<value>number</value> -</tag-name> -<tag-desc> -sets the weight of the server, by default, 1. -</tag-desc> - -<tag-name id="max_conns"> -<literal>max_conns</literal>=<value>number</value> -</tag-name> -<tag-desc> -limits the maximum <value>number</value> of simultaneous -connections to the proxied server (1.11.5). -Default value is zero, meaning there is no limit. -If the server group does not reside in the <link id="zone">shared memory</link>, -the limitation works per each worker process. -<note> -Prior to version 1.11.5, this parameter was available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</tag-desc> - -<tag-name id="max_fails"> -<literal>max_fails</literal>=<value>number</value> -</tag-name> -<tag-desc> -sets the number of unsuccessful attempts to communicate with the server -that should happen in the duration set by the <literal>fail_timeout</literal> -parameter to consider the server unavailable for a duration also set by the -<literal>fail_timeout</literal> parameter. -By default, the number of unsuccessful attempts is set to 1. -The zero value disables the accounting of attempts. -Here, an unsuccessful attempt is an error or timeout -while establishing a connection with the server. -</tag-desc> - -<tag-name id="fail_timeout"> -<literal>fail_timeout</literal>=<value>time</value> -</tag-name> -<tag-desc> -sets -<list type="bullet"> - -<listitem> -the time during which the specified number of unsuccessful attempts to -communicate with the server should happen to consider the server unavailable; -</listitem> - -<listitem> -and the period of time the server will be considered unavailable. -</listitem> - -</list> -By default, the parameter is set to 10 seconds. -</tag-desc> - -<tag-name id="backup"> -<literal>backup</literal> -</tag-name> -<tag-desc> -marks the server as a backup server. -Connections to the backup server will be passed -when the primary servers are unavailable. -</tag-desc> - -<tag-name id="down"> -<literal>down</literal> -</tag-name> -<tag-desc> -marks the server as permanently unavailable. -</tag-desc> - -</list> -</para> - -<para> -Additionally, -the following parameters are available as part of our -<commercial_version>commercial subscription</commercial_version>: -<list type="tag"> - -<tag-name id="resolve"> -<literal>resolve</literal> -</tag-name> -<tag-desc> -monitors changes of the IP addresses -that correspond to a domain name of the server, -and automatically modifies the upstream configuration -without the need of restarting nginx. -The server group must reside in the <link id="zone">shared memory</link>. -<para> -In order for this parameter to work, -the <link doc="ngx_stream_core_module.xml" id="resolver"/> directive -must be specified in the -<link doc="ngx_stream_core_module.xml" id="stream"/> block. -Example: -<example> -stream { - resolver 10.0.0.1; - - upstream u { - zone ...; - ... - server example.com:12345 resolve; - } -} -</example> -</para> -</tag-desc> - -<tag-name id="service"> -<literal>service</literal>=<value>name</value> -</tag-name> -<tag-desc> -enables resolving of DNS -<link url="https://tools.ietf.org/html/rfc2782">SRV</link> -records and sets the service <value>name</value> (1.9.13). -In order for this parameter to work, it is necessary to specify -the <link id="resolve"/> parameter for the server -and specify a hostname without a port number. -<para> -If the service name does not contain a dot (“<literal>.</literal>”), then -the <link url="https://tools.ietf.org/html/rfc2782">RFC</link>-compliant name -is constructed -and the TCP protocol is added to the service prefix. -For example, to look up the -<literal>_http._tcp.backend.example.com</literal> SRV record, -it is necessary to specify the directive: -<example> -server backend.example.com service=http resolve; -</example> -If the service name contains one or more dots, then the name is constructed -by joining the service prefix and the server name. -For example, to look up the <literal>_http._tcp.backend.example.com</literal> -and <literal>server1.backend.example.com</literal> SRV records, -it is necessary to specify the directives: -<example> -server backend.example.com service=_http._tcp resolve; -server example.com service=server1.backend resolve; -</example> -</para> - -<para> -Highest-priority SRV records -(records with the same lowest-number priority value) -are resolved as primary servers, -the rest of SRV records are resolved as backup servers. -If the <link id="backup"/> parameter is specified for the server, -high-priority SRV records are resolved as backup servers, -the rest of SRV records are ignored. -</para> -</tag-desc> - -<tag-name id="slow_start"> -<literal>slow_start</literal>=<value>time</value> -</tag-name> -<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>, -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. -<note> -The parameter cannot be used along with the -<link id="hash"/> load balancing method. -</note> -</tag-desc> - -</list> -</para> - -<para> -<note> -If there is only a single server in a group, <literal>max_fails</literal>, -<literal>fail_timeout</literal> and <literal>slow_start</literal> parameters -are ignored, and such a server will never be considered unavailable. -</note> -</para> - -</directive> - - -<directive name="zone"> -<syntax><value>name</value> [<value>size</value>]</syntax> -<default/> -<context>upstream</context> - -<para> -Defines the <value>name</value> and <value>size</value> of the shared -memory zone that keeps the group’s configuration and run-time state that are -shared between worker processes. -Several groups may share the same zone. -In this case, it is enough to specify the zone size only once. -</para> - -<para> -Additionally, -as part of our <commercial_version>commercial subscription</commercial_version>, -such groups allow changing the group membership -or modifying the settings of a particular server -without the need of restarting nginx. -The configuration is accessible via a special location -handled by -<link doc="../http/ngx_http_upstream_conf_module.xml" id="upstream_conf"/>. -</para> - -</directive> - - -<directive name="state"> -<syntax><value>file</value></syntax> -<default/> -<context>upstream</context> -<appeared-in>1.9.7</appeared-in> - -<para> -Specifies a <value>file</value> that keeps the state -of the dynamically configurable group. -</para> - -<para> -Examples: -<example> -state /var/lib/nginx/state/servers.conf; # path for Linux -state /var/db/nginx/state/servers.conf; # path for FreeBSD -</example> -</para> - -<para> -The state is currently limited to the list of servers with their parameters. -The file is read when parsing the configuration and is updated each time -the upstream configuration is -<link doc="ngx_http_upstream_conf_module.xml" id="upstream_conf">changed</link>. -Changing the file content directly should be avoided. -The directive cannot be used -along with the <link id="server"/> directive. -</para> - -<para> -<note> -Changes made during -<link doc="../control.xml" id="reconfiguration">configuration reload</link> -or <link doc="../control.xml" id="upgrade">binary upgrade</link> -can be lost. -</note> -</para> - -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="hash"> -<syntax><value>key</value> [<literal>consistent</literal>]</syntax> -<default/> -<context>upstream</context> - -<para> -Specifies a load balancing method for a server group -where client-server mapping is based on the hashed <value>key</value> value. -The <value>key</value> can contain text, variables, -and their combinations (1.11.2). -Usage example: -<example> -hash $remote_addr; -</example> -Note that adding or removing a server from the group -may result in remapping most of the keys to different servers. -The method is compatible with the -<link url="http://search.cpan.org/perldoc?Cache%3A%3AMemcached">Cache::Memcached</link> -Perl library. -</para> - -<para> -If the <literal>consistent</literal> parameter is specified, -the <link url="http://www.last.fm/user/RJ/journal/2007/04/10/392555/">ketama</link> -consistent hashing method will be used instead. -The method ensures that only a few keys -will be remapped to different servers -when a server is added to or removed from the group. -This helps to achieve a higher cache hit ratio for caching servers. -The method is compatible with the -<link url="http://search.cpan.org/perldoc?Cache%3A%3AMemcached%3A%3AFast">Cache::Memcached::Fast</link> -Perl library with the <value>ketama_points</value> parameter set to 160. -</para> - -</directive> - - -<directive name="least_conn"> -<syntax/> -<default/> -<context>upstream</context> - -<para> -Specifies that a server group should use a load balancing method -where a connection -is passed to the server with the least number of active connections, -taking into account weights of servers. -If there are several such servers, they are tried in turn using a -weighted round-robin balancing method. -</para> - -</directive> - - -<directive name="least_time"> -<syntax> - <literal>connect</literal> | - <literal>first_byte</literal> | - <literal>last_byte</literal> - [<literal>inflight</literal>]</syntax> -<default/> -<context>upstream</context> - -<para> -Specifies that a group should use a load balancing method where a connection -is passed to the server with the least average time and -least number of active connections, taking into account weights of servers. -If there are several such servers, they are tried in turn using a -weighted round-robin balancing method. -</para> - -<para> -If the <literal>connect</literal> parameter is specified, -time to connect to the upstream server is used. -If the <literal>first_byte</literal> parameter is specified, -time to receive the first byte of data is used. -If the <literal>last_byte</literal> is specified, -time to receive the last byte of data is used. -If the <literal>inflight</literal> parameter is specified (1.11.6), -incomplete connections are also taken into account. -<note> -Prior to version 1.11.6, -incomplete connections were taken into account by default. -</note> -</para> - -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - -</directive> - - <directive name="health_check"> <syntax>[<value>parameters</value>]</syntax> <default/> @@ -499,7 +66,7 @@ This directive is available as part of o <para> Enables periodic health checks of the servers in a -<link id="upstream">group</link>. +<link doc="ngx_stream_upstream_module.xml" id="upstream">group</link>. </para> <para> @@ -576,7 +143,8 @@ parameters. <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. +By default, equals the +<link doc="ngx_stream_upstream_module.xml" id="server"/> port. </tag-desc> <tag-name id="health_check_udp"> @@ -614,7 +182,8 @@ and referenced in the <literal>match</li </para> <para> -The server group must reside in the <link id="zone">shared memory</link>. +The server group must reside in the +<link doc="ngx_stream_upstream_module.xml" id="zone">shared memory</link>. </para> <para> @@ -623,13 +192,6 @@ a single failure of any check will make considered unhealthy. </para> -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - </directive> @@ -645,13 +207,6 @@ Overrides the value for health checks. </para> -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - </directive> @@ -747,79 +302,8 @@ bytes of data obtained from the server a </note> </para> -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - </directive> </section> - -<section id="variables" name="Embedded Variables"> - -<para> -The <literal>ngx_stream_upstream_module</literal> module -supports the following embedded variables: -<list type="tag"> - -<tag-name id="var_upstream_addr"><var>$upstream_addr</var></tag-name> -<tag-desc> -keeps the IP address and port, -or the path to the UNIX-domain socket of the upstream server (1.11.4). -If several servers were contacted during proxying, -their addresses are separated by commas, e.g. -“<literal>192.168.1.1:12345, 192.168.1.2:12345, unix:/tmp/sock</literal>”. -</tag-desc> - -<tag-name id="var_upstream_bytes_sent"><var>$upstream_bytes_sent</var></tag-name> -<tag-desc> -number of bytes sent to an upstream server (1.11.4). -Values from several connections -are separated by commas like addresses in the -<link id="var_upstream_addr">$upstream_addr</link> variable. -</tag-desc> - -<tag-name id="var_upstream_bytes_received"><var>$upstream_bytes_received</var></tag-name> -<tag-desc> -number of bytes received from an upstream server (1.11.4). -Values from several connections -are separated by commas like addresses in the -<link id="var_upstream_addr">$upstream_addr</link> variable. -</tag-desc> - -<tag-name id="var_upstream_connect_time"><var>$upstream_connect_time</var></tag-name> -<tag-desc> -time to connect to the upstream server (1.11.4); -the time is kept in seconds with millisecond resolution. -Times of several connections -are separated by commas like addresses in the -<link id="var_upstream_addr">$upstream_addr</link> variable. -</tag-desc> - -<tag-name id="var_upstream_first_byte_time"><var>$upstream_first_byte_time</var></tag-name> -<tag-desc> -time to receive the first byte of data (1.11.4); -the time is kept in seconds with millisecond resolution. -Times of several connections -are separated by commas like addresses in the -<link id="var_upstream_addr">$upstream_addr</link> variable. -</tag-desc> - -<tag-name id="var_upstream_session_time"><var>$upstream_session_time</var></tag-name> -<tag-desc> -session duration in seconds with millisecond resolution (1.11.4). -Times of several connections -are separated by commas like addresses in the -<link id="var_upstream_addr">$upstream_addr</link> variable. -</tag-desc> - -</list> -</para> - -</section> - </module>
--- a/xml/en/docs/stream/ngx_stream_upstream_module.xml +++ b/xml/en/docs/stream/ngx_stream_upstream_module.xml @@ -9,7 +9,7 @@ <module name="Module ngx_stream_upstream_module" link="/en/docs/stream/ngx_stream_upstream_module.html" lang="en" - rev="24"> + rev="25"> <section id="summary"> @@ -46,7 +46,8 @@ server { </para> <para> -Dynamically configurable group, +Dynamically configurable group with +periodic <link doc="ngx_stream_upstream_hc_module.xml">health checks</link> is available as part of our <commercial_version>commercial subscription</commercial_version>: <example> @@ -297,7 +298,7 @@ the rest of SRV records are ignored. <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_stream_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. @@ -491,271 +492,6 @@ This directive is available as part of o </directive> - -<directive name="health_check"> -<syntax>[<value>parameters</value>]</syntax> -<default/> -<context>server</context> - -<para> -Enables periodic health checks of the servers in a -<link id="upstream">group</link>. -</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="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 -successful connection should pass in order for a health check to pass. -By default, for TCP, only the ability -to establish a TCP connection with the server is checked. -For <link id="health_check_udp">UDP</link>, the absence of -ICMP “<literal>Destination Unreachable</literal>” message is expected -in reply to the sent string “<literal>nginx health check</literal>”. -<note> -Prior to version 1.11.7, by default, UDP health check -required a <link id="hc_match">match</link> block with the -<link id="match_send">send</link> and <link id="match_expect">expect</link> -parameters. -</note> -</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> - -<tag-name id="health_check_udp"> -<literal>udp</literal> -</tag-name> -<tag-desc> -specifies that the <literal>UDP</literal> protocol should be used for -health checks instead of the default <literal>TCP</literal> protocol (1.9.13). -</tag-desc> - -</list> -</para> - -<para> -For example, -<example> -server { - proxy_pass backend; - health_check; -} -</example> -will check the ability to establish a TCP connection to each server -in the <literal>backend</literal> group every five seconds. -When a connection to the server cannot be established, -the health check will fail, and the server will -be considered unhealthy. -Client connections are not passed to unhealthy servers -and servers in the “checking” state. -</para> - -<para> -Health checks can also be configured to test data obtained from the server. -Tests are configured separately using the <link id="match"/> directive -and referenced in the <literal>match</literal> parameter. -</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> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="health_check_timeout"> -<syntax><value>timeout</value></syntax> -<default>5s</default> -<context>stream</context> -<context>server</context> - -<para> -Overrides the -<link doc="ngx_stream_proxy_module.xml" id="proxy_timeout"/> -value for health checks. -</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>stream</context> - -<para> -Defines the named test set used to verify server responses to health checks. -</para> - -<para> -The following parameters can be configured: -<list type="tag"> - -<tag-name id="match_send"> -<literal>send</literal> <value>string</value>; -</tag-name> -<tag-desc> -sends a <value>string</value> to the server; -</tag-desc> - -<tag-name id="match_expect"> -<literal>expect</literal> <value>string</value> | -<literal>~</literal> <value>regex</value>; -</tag-name> -<tag-desc> -a literal string (1.9.12) or a regular expression -that the data obtained from the server should match. -The regular expression is specified with the preceding -“<literal>~*</literal>” modifier (for case-insensitive matching), or the -“<literal>~</literal>” modifier (for case-sensitive matching). -</tag-desc> - -</list> -Both <literal>send</literal> and <literal>expect</literal> parameters -can contain hexadecimal literals with the prefix “<literal>\x</literal>” -followed by two hex digits, for example, “<literal>\x80</literal>” (1.9.12). -</para> - -<para> -Health check is passed if: -<list type="bullet"> -<listitem> -the TCP connection was successfully established; -</listitem> - -<listitem> -the <value>string</value> from the <literal>send</literal> parameter, -if specified, was sent; -</listitem> - -<listitem> -the data obtained from the server matched the string or regular expression -from the <literal>expect</literal> parameter, if specified; -</listitem> - -<listitem> -the time elapsed does not exceed the value specified -in the <link id="health_check_timeout"/> directive. -</listitem> - -</list> -</para> - -<para> -Example: -<example> -upstream backend { - zone upstream_backend 10m; - server 127.0.0.1:12345; -} - -match http { - send "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n"; - expect ~ "200 OK"; -} - -server { - listen 12346; - proxy_pass backend; - health_check match=http; -} -</example> -</para> - -<para> -<note> -Only the first -<link doc="ngx_stream_proxy_module.xml" id="proxy_buffer_size"/> -bytes of data obtained from the server are examined. -</note> -</para> - -<para> -<note> -This directive is available as part of our -<commercial_version>commercial subscription</commercial_version>. -</note> -</para> - -</directive> - </section>
--- a/xml/ru/GNUmakefile +++ b/xml/ru/GNUmakefile @@ -102,6 +102,7 @@ REFS = \ stream/ngx_stream_ssl_module \ stream/ngx_stream_ssl_preread_module \ stream/ngx_stream_upstream_module \ + stream/ngx_stream_upstream_hc_module \ stream/stream_processing \ ngx_google_perftools_module \
--- a/xml/ru/docs/http/ngx_http_status_module.xml +++ b/xml/ru/docs/http/ngx_http_status_module.xml @@ -9,7 +9,7 @@ <module name="Модуль ngx_http_status_module" link="/ru/docs/http/ngx_http_status_module.html" lang="ru" - rev="15"> + rev="16"> <section id="summary"> @@ -952,7 +952,7 @@ 2xx, 4xx или 5xx. <tag-name><literal>checks</literal></tag-name> <tag-desc> Суммарное число запросов -<link doc="../stream/ngx_stream_upstream_module.xml" id="health_check">проверки +<link doc="../stream/ngx_stream_upstream_hc_module.xml" id="health_check">проверки работоспособности</link>. </tag-desc> @@ -971,7 +971,7 @@ 2xx, 4xx или 5xx. <tag-desc> Логическое значение, означающее, была ли последняя проверка работоспособности удачной и удовлетворял ли ответ заданным -<link doc="../stream/ngx_stream_upstream_module.xml" id="match">тестам</link>. +<link doc="../stream/ngx_stream_upstream_hc_module.xml" id="match">тестам</link>. </tag-desc> </list>
--- a/xml/ru/docs/index.xml +++ b/xml/ru/docs/index.xml @@ -8,7 +8,7 @@ <article name="nginx: документация" link="/ru/docs/" lang="ru" - rev="38" + rev="39" toc="no"> @@ -591,6 +591,11 @@ ngx_stream_ssl_preread_module</link> ngx_stream_upstream_module</link> </listitem> +<listitem> +<link doc="stream/ngx_stream_upstream_hc_module.xml"> +ngx_stream_upstream_hc_module</link> +</listitem> + </list> </para>
copy from xml/ru/docs/stream/ngx_stream_upstream_module.xml copy to xml/ru/docs/stream/ngx_stream_upstream_hc_module.xml --- a/xml/ru/docs/stream/ngx_stream_upstream_module.xml +++ b/xml/ru/docs/stream/ngx_stream_upstream_hc_module.xml @@ -6,18 +6,26 @@ <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> -<module name="Модуль ngx_stream_upstream_module" - link="/ru/docs/stream/ngx_stream_upstream_module.html" +<module name="Модуль ngx_stream_upstream_hc_module" + link="/ru/docs/stream/ngx_stream_upstream_hc_module.html" lang="ru" - rev="24"> + rev="1"> <section id="summary"> <para> -Модуль <literal>ngx_stream_upstream_module</literal> (1.9.0) -позволяет описывать группы серверов, -которые могут использоваться в директиве -<link doc="ngx_stream_proxy_module.xml" id="proxy_pass"/>. +Модуль <literal>ngx_stream_upstream_hc_module</literal> (1.9.0) +позволяет активировать периодические проверки работоспособности серверов в +<link doc="ngx_stream_upstream_module.xml" id="upstream">группе</link>. +Группа должна находиться в +<link doc="ngx_stream_upstream_module.xml" id="zone">зоне разделяемой памяти</link>. +</para> + +<para> +<note> +Модуль доступен как часть +<commercial_version>коммерческой подписки</commercial_version>. +</note> </para> </section> @@ -27,47 +35,20 @@ <para> <example> -upstream <emphasis>backend</emphasis> { - hash $remote_addr consistent; - - server backend1.example.com:12345 weight=5; - server backend2.example.com:12345; - server unix:/tmp/backend3; - - server backup1.example.com:12345 backup; - server backup2.example.com:12345 backup; -} - -server { - listen 12346; - proxy_pass <emphasis>backend</emphasis>; -} -</example> -</para> - -<para> -Динамически настраиваемая группа, -доступна как часть -<commercial_version>коммерческой подписки</commercial_version>: -<example> -resolver 10.0.0.1; - -upstream <emphasis>dynamic</emphasis> { - zone upstream_dynamic 64k; +upstream tcp { + zone upstream_tcp 64k; server backend1.example.com:12345 weight=5; server backend2.example.com:12345 fail_timeout=5s slow_start=30s; server 192.0.2.1:12345 max_fails=3; - server backend3.example.com:12345 resolve; - server backend4.example.com service=http resolve; server backup1.example.com:12345 backup; server backup2.example.com:12345 backup; } server { - listen 12346; - proxy_pass <emphasis>dynamic</emphasis>; + listen 12346; + proxy_pass tcp; health_check; } </example> @@ -78,420 +59,6 @@ server { <section id="directives" name="Директивы"> -<directive name="upstream"> -<syntax block="yes"><value>название</value></syntax> -<default/> -<context>stream</context> - -<para> -Описывает группу серверов. -Серверы могут слушать на разных портах. -Кроме того, можно одновременно использовать серверы, -слушающие на TCP- и UNIX-сокетах. -</para> - -<para> -Пример: -<example> -upstream backend { - server backend1.example.com:12345 weight=5; - server 127.0.0.1:12345 max_fails=3 fail_timeout=30s; - server unix:/tmp/backend2; - server backend3.example.com:12345 resolve; - - server backup1.example.com:12345 backup; -} -</example> -</para> - -<para> -По умолчанию соединения распределяются по серверам циклически -(в режиме round-robin) с учётом весов серверов. -В вышеприведённом примере каждые 7 соединений будут распределены так: -5 соединений на <literal>backend1.example.com:12345</literal> -и по одному соединению на второй и третий серверы. -Если при попытке работы с сервером происходит ошибка, то соединение -передаётся следующему серверу, и так далее до тех пор, пока не будут опробованы -все работающие серверы. -Если связь с серверами не удалась, соединение будет закрыто. -</para> - -</directive> - - -<directive name="server"> -<syntax><value>адрес</value> [<value>параметры</value>]</syntax> -<default/> -<context>upstream</context> - -<para> -Задаёт <value>адрес</value> и другие <value>параметры</value> -сервера. -Адрес может быть указан в виде доменного имени или IP-адреса, -и обязательного порта, или в виде пути UNIX-сокета, который -указывается после префикса “<literal>unix:</literal>”. -Доменное имя, которому соответствует несколько IP-адресов, -задаёт сразу несколько серверов. -</para> - -<para> -Могут быть заданы следующие параметры: -<list type="tag"> - -<tag-name id="weight"> -<literal>weight</literal>=<value>число</value> -</tag-name> -<tag-desc> -задаёт вес сервера, по умолчанию 1. -</tag-desc> - -<tag-name id="max_conns"> -<literal>max_conns</literal>=<value>число</value> -</tag-name> -<tag-desc> -ограничивает максимальное <value>число</value> одновременных -соединений к проксируемому серверу (1.11.5). -Значение по умолчанию равно 0 и означает, что ограничения нет. -Если группа не находится в <link id="zone">зоне разделяемой памяти</link>, -то ограничение работает отдельно для каждого рабочего процесса. -<note> -До версии 1.11.5 этот параметр был доступен как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</tag-desc> - -<tag-name id="max_fails"> -<literal>max_fails</literal>=<value>число</value> -</tag-name> -<tag-desc> -задаёт число неудачных попыток работы с сервером, которые должны произойти -в течение времени, заданного параметром <literal>fail_timeout</literal>, -чтобы сервер считался недоступным на период времени, также заданный -параметром <literal>fail_timeout</literal>. -По умолчанию число попыток устанавливается равным 1. -Нулевое значение отключает учёт попыток. -В данном случае неудачной попыткой считается ошибка или таймаут -при установке соединения с сервером. -</tag-desc> - -<tag-name id="fail_timeout"> -<literal>fail_timeout</literal>=<value>время</value> -</tag-name> -<tag-desc> -задаёт -<list type="bullet"> - -<listitem> -время, в течение которого должно произойти заданное число неудачных -попыток работы с сервером для того, чтобы сервер считался недоступным; -</listitem> - -<listitem> -и время, в течение которого сервер будет считаться недоступным. -</listitem> - -</list> -По умолчанию параметр равен 10 секундам. -</tag-desc> - -<tag-name id="backup"> -<literal>backup</literal> -</tag-name> -<tag-desc> -помечает сервер как запасной сервер. -На него будут передаваться соединения в случае, -если не работают основные серверы. -</tag-desc> - -<tag-name id="down"> -<literal>down</literal> -</tag-name> -<tag-desc> -помечает сервер как постоянно недоступный. -</tag-desc> - -</list> -</para> - -<para> -Кроме того, -следующие параметры доступны как часть -<commercial_version>коммерческой подписки</commercial_version>: -<list type="tag"> - -<tag-name id="resolve"> -<literal>resolve</literal> -</tag-name> -<tag-desc> -отслеживает изменения IP-адресов, соответствующих доменному имени сервера, -и автоматически изменяет конфигурацию группы -без необходимости перезапуска nginx. -Группа должна находиться в <link id="zone">зоне разделяемой памяти</link>. -<para> -Для работы этого параметра -директива <link doc="ngx_stream_core_module.xml" id="resolver"/> -должна быть задана в блоке -<link doc="ngx_stream_core_module.xml" id="stream"/>. -Пример: -<example> -stream { - resolver 10.0.0.1; - - upstream u { - zone ...; - ... - server example.com:12345 resolve; - } -} -</example> -</para> -</tag-desc> - -<tag-name id="service"> -<literal>service</literal>=<value>имя</value> -</tag-name> -<tag-desc> -включает преобразование -<link url="https://tools.ietf.org/html/rfc2782">SRV</link>-записей -DNS и задаёт <value>имя</value> сервиса (1.9.13). -Для работы параметра необходимо указать -параметр <link id="resolve"/> для сервера -и не указывать порт сервера. -<para> -Если имя сервиса не содержит точку (“<literal>.</literal>”), то -имя составляется в соответствии с -<link url="https://tools.ietf.org/html/rfc2782">RFC</link> -и в префикс службы добавляется протокол TCP. -Например, для получения -SRV-записи <literal>_http._tcp.backend.example.com</literal> -необходимо указать директиву: -<example> -server backend.example.com service=http resolve; -</example> -Если имя сервиса содержит одну и более точек, то имя составляется -при помощи соединения префикса службы и имени сервера. -Например, для получения SRV-записей -<literal>_http._tcp.backend.example.com</literal> -и <literal>server1.backend.example.com</literal> -необходимо указать директивы: -<example> -server backend.example.com service=_http._tcp resolve; -server example.com service=server1.backend resolve; -</example> -</para> - -<para> -SRV-записи с наивысшим приоритетом -(записи с одинаковым наименьшим значением приоритета) -преобразуются в основные серверы, -остальные SRV-записи преобразуются в запасные серверы. -Если в конфигурации сервера указан параметр <link id="backup"/>, -высокоприоритетные SRV-записи преобразуются в запасные серверы, -остальные SRV-записи игнорируются. -</para> -</tag-desc> - -<tag-name id="slow_start"> -<literal>slow_start</literal>=<value>время</value> -</tag-name> -<tag-desc> -задаёт <value>время</value>, в течение которого вес сервера -восстановится от нуля до своего номинального значения в ситуации, когда -неработоспособный (unhealthy) сервер вновь становится работоспособным -(<link id="health_check">healthy</link>) -или когда сервер становится доступным по прошествии времени, -в течение которого он считался <link id="fail_timeout">недоступным</link>. -Значение по умолчанию равно нулю и означает, что медленный старт выключен. -<note> -Параметр нельзя использовать совместно с -методом балансировки нагрузки <link id="hash"/>. -</note> -</tag-desc> - -</list> -</para> - -<para> -<note> -Если в группе только один сервер, параметры <literal>max_fails</literal>, -<literal>fail_timeout</literal> и <literal>slow_start</literal> -игнорируются и такой сервер никогда не будет считаться недоступным. -</note> -</para> - -</directive> - - -<directive name="zone"> -<syntax><value>имя</value> [<value>размер</value>]</syntax> -<default/> -<context>upstream</context> - -<para> -Задаёт <value>имя</value> и <value>размер</value> зоны разделяемой памяти, -в которой хранятся конфигурация группы и её рабочее состояние, -разделяемые между рабочими процессами. -В одной и той же зоне могут быть сразу несколько групп. -В этом случае достаточно указать <value>размер</value> только один раз. -</para> - -<para> -Дополнительно, как часть -<commercial_version>коммерческой подписки</commercial_version>, -в таких группах для изменения состава группы -или настроек отдельных серверов -нет необходимости перезапускать nginx. -Конфигурация доступна через специальный location, -в котором указана директива -<link doc="../http/ngx_http_upstream_conf_module.xml" id="upstream_conf"/>. -</para> - -</directive> - - -<directive name="state"> -<syntax><value>файл</value></syntax> -<default/> -<context>upstream</context> -<appeared-in>1.9.7</appeared-in> - -<para> -Задаёт <value>файл</value>, в котором хранится состояние -динамически настраиваемой группы. -</para> - -<para> -Примеры: -<example> -state /var/lib/nginx/state/servers.conf; # путь для Linux -state /var/db/nginx/state/servers.conf; # путь для FreeBSD -</example> -</para> - -<para> -В данный момент состояние ограничено списком серверов с их параметрами. -Файл читается при парсинге конфигурации и обновляется каждый раз при -<link doc="ngx_http_upstream_conf_module.xml" id="upstream_conf">изменении</link> -конфигурации группы. -Изменение содержимого файла напрямую не рекомендуется. -Директиву нельзя использовать -совместно с директивой <link id="server"/>. -</para> - -<para> -<note> -Изменения, совершённые в момент -<link doc="../control.xml" id="reconfiguration">перезагрузки конфигурации</link> -или <link doc="../control.xml" id="upgrade">обновления бинарного файла</link>, -могут быть потеряны. -</note> -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="hash"> -<syntax><value>ключ</value> [<literal>consistent</literal>]</syntax> -<default/> -<context>upstream</context> - -<para> -Задаёт метод балансировки нагрузки для группы, при котором -соответствие клиента серверу определяется при помощи -хэшированного значения <value>ключа</value>. -В качестве <value>ключа</value> может использоваться текст, переменные -и их комбинации (1.11.2). -Пример использования: -<example> -hash $remote_addr; -</example> -Следует отметить, что любое добавление или удаление серверов в группе -может привести к перераспределению большинства ключей на другие серверы. -Метод совместим с библиотекой Perl -<link url="http://search.cpan.org/perldoc?Cache%3A%3AMemcached">Cache::Memcached</link>. -</para> - -<para> -Если задан параметр <literal>consistent</literal>, то вместо -вышеописанного метода будет использоваться метод консистентного хэширования -<link url="http://www.last.fm/user/RJ/journal/2007/04/10/392555/">ketama</link>. -Метод гарантирует, что при добавлении сервера в группу или его удалении -на другие серверы будет перераспределено минимальное число ключей. -Применение метода для кэширующих серверов обеспечивает -больший процент попаданий в кэш. -Метод совместим с библиотекой Perl -<link url="http://search.cpan.org/perldoc?Cache%3A%3AMemcached%3A%3AFast">Cache::Memcached::Fast</link> -при значении параметра <value>ketama_points</value> равным 160. -</para> - -</directive> - - -<directive name="least_conn"> -<syntax/> -<default/> -<context>upstream</context> - -<para> -Задаёт для группы метод балансировки нагрузки, при котором соединение -передаётся серверу с наименьшим числом активных соединений, -с учётом весов серверов. -Если подходит сразу несколько серверов, они выбираются циклически -(в режиме round-robin) с учётом их весов. -</para> - -</directive> - - -<directive name="least_time"> -<syntax> - <literal>connect</literal> | - <literal>first_byte</literal> | - <literal>last_byte</literal> - [<literal>inflight</literal>]</syntax> -<default/> -<context>upstream</context> - -<para> -Задаёт для группы метод балансировки нагрузки, при котором соединение -передаётся серверу с наименьшими средним временем ответа и -числом активных соединений с учётом весов серверов. -Если подходит сразу несколько серверов, то они выбираются циклически -(в режиме round-robin) с учётом их весов. -</para> - -<para> -Если указан параметр <literal>connect</literal>, -то учитывается время соединения с сервером группы. -Если указан параметр <literal>first_byte</literal>, -то учитывается время получения первого байта данных. -Если указан параметр <literal>last_byte</literal>, -то учитывается время получения ответа. -Если указан параметр <literal>inflight</literal> (1.11.6), -то также учитываются незавершённые соединения. -<note> -До версии 1.11.6 -незавершённые соединения учитывались по умолчанию. -</note> -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - - <directive name="health_check"> <syntax>[<value>параметры</value>]</syntax> <default/> @@ -499,7 +66,7 @@ hash $remote_addr; <para> Активирует периодические проверки работоспособности серверов в -<link id="upstream">группе</link>. +<link doc="ngx_stream_upstream_hc_module.xml" id="upstream">группе</link>. </para> <para> @@ -575,7 +142,8 @@ hash $remote_addr; <tag-desc> задаёт порт, используемый при подключении к серверу для проверки его работоспособности (1.9.7). -По умолчанию совпадает с портом <link id="server">сервера</link>. +По умолчанию совпадает с портом +<link doc="ngx_stream_upstream_module.xml" id="server">сервера</link>. </tag-desc> <tag-name id="health_check_udp"> @@ -614,7 +182,8 @@ server { </para> <para> -Группа должна находиться в <link id="zone">зоне разделяемой памяти</link>. +Группа должна находиться в +<link doc="ngx_stream_upstream_module.xml" id="zone">зоне разделяемой памяти</link>. </para> <para> @@ -623,13 +192,6 @@ server { считаться неработоспособным. </para> -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - </directive> @@ -645,13 +207,6 @@ server { для проверок работоспособности. </para> -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - </directive> @@ -750,78 +305,8 @@ server { </note> </para> -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - </directive> </section> - -<section id="variables" name="Встроенные переменные"> - -<para> -Модуль <literal>ngx_stream_upstream_module</literal> -поддерживает следующие встроенные переменные: -<list type="tag"> - -<tag-name id="var_upstream_addr"><var>$upstream_addr</var></tag-name> -<tag-desc> -хранит IP-адрес и порт или путь к UNIX-сокету сервера группы (1.11.4). -Если при проксировании были сделаны обращения к нескольким серверам, -то их адреса разделяются запятой, например -“<literal>192.168.1.1:12345, 192.168.1.2:12345, unix:/tmp/sock</literal>”. -</tag-desc> - -<tag-name id="var_upstream_bytes_sent"><var>$upstream_bytes_sent</var></tag-name> -<tag-desc> -число байт, переданных на сервер группы (1.11.4). -Значения нескольких соединений -разделяются запятыми подобно адресам в переменной -<link id="var_upstream_addr">$upstream_addr</link>. -</tag-desc> - -<tag-name id="var_upstream_bytes_received"><var>$upstream_bytes_received</var></tag-name> -<tag-desc> -число байт, полученных от сервера группы (1.11.4). -Значения нескольких соединений -разделяются запятыми подобно адресам в переменной -<link id="var_upstream_addr">$upstream_addr</link>. -</tag-desc> - -<tag-name id="var_upstream_connect_time"><var>$upstream_connect_time</var></tag-name> -<tag-desc> -время установки соединения с сервером группы (1.11.4); -время хранится в секундах с точностью до миллисекунд. -Времена нескольких соединений -разделяются запятыми подобно адресам в переменной -<link id="var_upstream_addr">$upstream_addr</link>. -</tag-desc> - -<tag-name id="var_upstream_first_byte_time"><var>$upstream_first_byte_time</var></tag-name> -<tag-desc> -время получения первого байта данных (1.11.4); -время хранится в секундах с точностью до миллисекунд. -Времена нескольких соединений -разделяются запятыми подобно адресам в переменной -<link id="var_upstream_addr">$upstream_addr</link>. -</tag-desc> - -<tag-name id="var_upstream_session_time"><var>$upstream_session_time</var></tag-name> -<tag-desc> -длительность сессии в секундах с точностью до миллисекунд (1.11.4). -Времена нескольких соединений -разделяются запятыми подобно адресам в переменной -<link id="var_upstream_addr">$upstream_addr</link>. -</tag-desc> - -</list> -</para> - -</section> - </module>
--- a/xml/ru/docs/stream/ngx_stream_upstream_module.xml +++ b/xml/ru/docs/stream/ngx_stream_upstream_module.xml @@ -9,7 +9,7 @@ <module name="Модуль ngx_stream_upstream_module" link="/ru/docs/stream/ngx_stream_upstream_module.html" lang="ru" - rev="24"> + rev="25"> <section id="summary"> @@ -46,7 +46,9 @@ server { </para> <para> -Динамически настраиваемая группа, +Динамически настраиваемая группа +с периодическими +<link doc="ngx_stream_upstream_hc_module.xml">проверками работоспособности</link> доступна как часть <commercial_version>коммерческой подписки</commercial_version>: <example> @@ -298,7 +300,7 @@ SRV-записи с наивысшим приоритетом задаёт <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>. Значение по умолчанию равно нулю и означает, что медленный старт выключен. @@ -491,274 +493,6 @@ hash $remote_addr; </directive> - -<directive name="health_check"> -<syntax>[<value>параметры</value>]</syntax> -<default/> -<context>server</context> - -<para> -Активирует периодические проверки работоспособности серверов в -<link id="upstream">группе</link>. -</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="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> с условиями, которым должно -удовлетворять соединение, чтобы результат проверки считался успешным. -По умолчанию для TCP проверяется -лишь возможность установки TCP-соединения с сервером, -для <link id="health_check_udp">UDP</link> проверяется отсутствие -сообщения ICMP “<literal>Destination Unreachable</literal>” -в ответ на отправленную строку “<literal>nginx health check</literal>”. -<note> -До версии 1.11.7 по умолчанию для UDP -требовалось наличие блока <link id="hc_match">match</link> с параметрами -<link id="match_send">send</link> и <link id="match_expect">expect</link>. -</note> -</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> - -<tag-name id="health_check_udp"> -<literal>udp</literal> -</tag-name> -<tag-desc> -указывает, что для проверки работоспособности будет использоваться протокол -<literal>UDP</literal> -вместо протокола <literal>TCP</literal>, используемого по умолчанию (1.9.13). -</tag-desc> - -</list> -</para> - -<para> -В примере -<example> -server { - proxy_pass backend; - health_check; -} -</example> -для каждого сервера группы <literal>backend</literal> -с интервалом в 5 секунд проверяется возможность установки TCP-соединения. -Если соединение с сервером не может быть установлено, -проверка считается неуспешной и сервер -признаётся неработоспособным. -На неработоспособные серверы и серверы в состоянии “checking” -клиентские соединения передаваться не будут. -</para> - -<para> -Проверки работоспособности могут тестировать данные, полученные от сервера. -Тесты настраиваются отдельно при помощи директивы <link id="match"/> -и указываются в параметре <literal>match</literal>. -</para> - -<para> -Группа должна находиться в <link id="zone">зоне разделяемой памяти</link>. -</para> - -<para> -Если для группы задано несколько проверок, -то при любой неуспешной проверке соответствующий сервер будет -считаться неработоспособным. -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="health_check_timeout"> -<syntax><value>время</value></syntax> -<default>5s</default> -<context>stream</context> -<context>server</context> - -<para> -Переопределяет значение -<link doc="ngx_stream_proxy_module.xml" id="proxy_timeout"/> -для проверок работоспособности. -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - - -<directive name="match"> -<syntax block="yes"><value>имя</value> </syntax> -<default/> -<context>stream</context> - -<para> -Задаёт именованный набор тестов для для анализа ответов сервера -на запросы проверки работоспособности. -</para> - -<para> -Могут быть заданы следующие параметры: -<list type="tag"> - -<tag-name id="match_send"> -<literal>send</literal> <value>строка</value>; -</tag-name> -<tag-desc> -отправляет <value>строку</value> на сервер; -</tag-desc> - -<tag-name id="match_expect"> -<literal>expect</literal> <value>стока</value> | -<literal>~</literal> <value>regex</value>; -</tag-name> -<tag-desc> -текстовая строка (1.9.12) или регулярное выражение, -которым должны соответствовать данные, полученные с сервера. -Регулярное выражение задаётся либо с модификатором -“<literal>~*</literal>” (для поиска совпадения без учёта регистра символов), -либо с модификатором “<literal>~</literal>” (с учётом регистра). -</tag-desc> - -</list> -Параметры <literal>send</literal> и <literal>expect</literal> -могут содержать строки в шестнадцатеричном виде -с префиксом “<literal>\x</literal>” -и последующими двумя шестнадцатеричными цифрами, -например “<literal>\x80</literal>” (1.9.12). -</para> - -<para> -Проверка работоспособности считается успешной, если -<list type="bullet"> -<listitem> -TCP-соединение успешно установлено; -</listitem> - -<listitem> -<value>строка</value> из параметра <literal>send</literal> -была отправлена (если была задана); -</listitem> - -<listitem> -данные, полученные от сервера, совпали со строкой или регулярным выражением -из параметра <literal>expect</literal> (если был задан); -</listitem> - -<listitem> -истёкшее время не превышает значение, указанное -в директиве <link id="health_check_timeout"/>. -</listitem> - -</list> -</para> - -<para> -Пример: -<example> -upstream backend { - zone upstream_backend 10m; - server 127.0.0.1:12345; -} - -match http { - send "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n"; - expect ~ "200 OK"; -} - -server { - listen 12346; - proxy_pass backend; - health_check match=http; -} -</example> -</para> - -<para> -<note> -Проверяются лишь первые байты данных -<link doc="ngx_stream_proxy_module.xml" id="proxy_buffer_size"/>, -полученные от сервера. -</note> -</para> - -<para> -<note> -Эта директива доступна как часть -<commercial_version>коммерческой подписки</commercial_version>. -</note> -</para> - -</directive> - </section>