Upstream Probe#
The module implements active health probes for stream_upstream.
Configuration Example#
server {
listen ...;
# ...
proxy_pass backend;
upstream_probe_timeout 1s;
upstream_probe backend_probe
port=12345
interval=5s
test=$good
essential
fails=3
passes=3
max_response=512k
mode=onfail
"send=data:GET / HTTP/1.0\n\n";
}
Directives#
upstream_probe (PRO)#
Added in version 1.4.0: PRO
|
|
Default |
— |
server |
Defines an active health probe for peers within the upstream groups
that are specified for proxy_pass
in the same location
context with the upstream_probe
directive.
Subsequently, Angie regularly probes each peer of the upstream group
according to the parameters configured here.
A peer's probe is passed if the request to the peer succeeds, considering all
parameter settings of the upstream_probe
directive and the settings that
control how upstreams are used by the directive's location
context,
including the proxy_next_upstream directive.
To make use of the probes, the upstream must have a shared memory zone (zone). One upstream may be configured with several probes.
The following parameters are accepted:
|
Mandatory name of the probe. |
|
Alternative port number for the probe request. |
|
Interval between probes. |
|
The condition for the probe, defined as a string of variables.
If the variables' substitution yields |
|
If set, the initial state of the peer is being checked, so the peer doesn't receive client requests until the probe is passed. |
|
Setting this parameter requires enabling |
|
Number of subsequent failed probes that
renders the peer unhealthy. |
|
Number of subsequent passed probes that
renders the peer unhealthy. |
|
Maximum memory size for the response. If a zero
value is specified, response waiting is disabled. |
|
Probe mode, depending on the peers' health:
By default — |
|
If specified, the UDP protocol is used for probing. By default, TCP is used for probing. |
|
Data sent for the check;
this can be a string with the prefix |
Example:
upstream backend {
zone backend 1m;
server a.example.com;
server b.example.com;
}
map $upstream_probe_response $good {
~200 "1";
default "";
}
server {
listen ...;
# ...
proxy_pass backend;
upstream_probe_timeout 1s;
upstream_probe backend_probe
port=12345
interval=5s
test=$good
essential
persistent
fails=3
passes=3
max_response=512k
mode=onfail
"send=data:GET / HTTP/1.0\n\n";
}
Details of probe operation:
Initially, the peer won't receive client requests until it passes all
essential
probes configured for it, skippingpersistent
ones if the configuration was reloaded and the peer was deemed healthy prior to that. If there are no such probes, the peer is considered healthy.The peer is considered unhealthy and won't receive client requests, if any of the probes configured for it hits
fails
or the peer reaches max_fails.For an unhealthy peer to be considered healthy again, all probes configured for it must reach their respective
passes
; after that, max_fails is also considered.
Built-in Variables#
The stream_upstream
module supports the following built-in variables:
$upstream_probe
(PRO)#
Name of the currently active upstream_probe.
$upstream_probe_response
(PRO)#
Contents of the response received during an active probe configured by upstream_probe.