]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_proxy_hcheck.html.en
move es and fr targets to *.utf8 extension. Update transformation
[apache] / docs / manual / mod / mod_proxy_hcheck.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>mod_proxy_hcheck - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
18 <body>
19 <div id="page-header">
20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
21 <p class="apache">Apache HTTP Server Version 2.5</p>
22 <img alt="" src="../images/feather.png" /></div>
23 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
24 <div id="path">
25 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
26 <div id="page-content">
27 <div id="preamble"><h1>Apache Module mod_proxy_hcheck</h1>
28 <div class="toplang">
29 <p><span>Available Languages: </span><a href="../en/mod/mod_proxy_hcheck.html" title="English">&nbsp;en&nbsp;</a> |
30 <a href="../fr/mod/mod_proxy_hcheck.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
31 </div>
32 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Dynamic health check of Balancer members (workers) for
33 <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></td></tr>
34 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
35 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>proxy_hcheck_module</td></tr>
36 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_proxy_hcheck.c</td></tr>
37 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.4.21 and later</td></tr></table>
38 <h3>Summary</h3>
39
40     <p>This module provides for dynamic health checking of balancer
41         members (workers). This can be enabled on a worker-by-worker
42         basis. The health check is done independently of the
43         actual reverse proxy requests.</p>
44
45     <p>This module <em>requires</em> the service of <code class="module"><a href="../mod/mod_watchdog.html">mod_watchdog</a></code>.</p>
46
47 <div class="note"><h3>Parameters</h3>
48   <p>The health check mechanism is enabled via the use of additional
49      <code class="directive"><a href="../mod/mod_proxy.html#balancermember">BalancerMember</a></code> parameters, which are configured
50      in the standard way via <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code>:</p>
51
52   <p>A new BalancerMember <a href="mod_proxy.html#status_table">status</a> state (flag)
53      is defined via this module: "<code>C</code>".
54      When the worker is taken offline due to failures as determined by the health
55      check module, this flag is set, and can be seen (and modified) via the
56      <code>balancer-manager</code>.</p>
57
58     <table>
59     <tr><th>Parameter</th>
60         <th>Default</th>
61         <th>Description</th></tr>
62     <tr><td>hcmethod</td>
63         <td>None</td>
64         <td>No dynamic health check performed. Choices are:
65                 <table>
66                         <tr><th>Method</th><th>Description</th><th>Note</th></tr>
67                         <tr><td>None</td><td>No dynamic health checking done</td><td /></tr>
68                         <tr><td>TCP</td><td>Check that a socket to the backend can be created: e.g. "are you up"</td><td /></tr>
69                         <tr><td>OPTIONS</td><td>Send an <code>HTTP OPTIONS</code> request to the backend</td><td>*</td></tr>
70                         <tr><td>HEAD</td><td>Send an <code>HTTP HEAD</code> request to the backend</td><td>*</td></tr>
71                         <tr><td>GET</td><td>Send an <code>HTTP GET</code> request to the backend</td><td>*</td></tr>
72
73                                 <tr><td colspan="3" /></tr>
74                                 <tr><td colspan="3">*: Unless <code>hcexpr</code> is used, a 2xx or 3xx HTTP status will be interpreted as <em>passing</em> the health check</td></tr>
75                 </table>
76         </td></tr>
77     <tr><td>hcpasses</td>
78         <td>1</td>
79         <td>Number of successful health check tests before worker is re-enabled</td></tr>
80     <tr><td>hcfails</td>
81         <td>1</td>
82         <td>Number of failed health check tests before worker is disabled</td></tr>
83     <tr><td>hcinterval</td>
84         <td>30</td>
85         <td>Period of health checks in seconds (e.g. performed every 30 seconds).
86         Uses the <a href="directive-dict.html#Syntax">time-interval</a> directive syntax.</td></tr>
87     <tr><td>hcuri</td>
88         <td>&nbsp;</td>
89         <td>Additional URI to be appended to the worker URL for the health check.</td></tr>
90     <tr><td>hctemplate</td>
91         <td>&nbsp;</td>
92         <td>Name of template, created via <code class="directive"><a href="#proxyhctemplate">ProxyHCTemplate</a></code>,
93             to use for setting health check parameters for this worker</td></tr>
94     <tr><td>hcexpr</td>
95         <td>&nbsp;</td>
96         <td>Name of expression, created via <code class="directive"><a href="#proxyhcexpr">ProxyHCExpr</a></code>,
97             used to check response headers for health.<br />
98             <em>If not used, 2xx thru 3xx status codes imply success</em></td></tr>
99     </table>
100 </div>
101
102 </div>
103 <div id="quickview"><h3>Topics</h3>
104 <ul id="topics">
105 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Usage examples</a></li>
106 </ul><h3 class="directives">Directives</h3>
107 <ul id="toc">
108 <li><img alt="" src="../images/down.gif" /> <a href="#proxyhcexpr">ProxyHCExpr</a></li>
109 <li><img alt="" src="../images/down.gif" /> <a href="#proxyhctemplate">ProxyHCTemplate</a></li>
110 <li><img alt="" src="../images/down.gif" /> <a href="#proxyhctpsize">ProxyHCTPsize</a></li>
111 </ul>
112 <h3>Bugfix checklist</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">httpd changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&amp;list_id=144532&amp;product=Apache%20httpd-2&amp;query_format=specific&amp;order=changeddate%20DESC%2Cpriority%2Cbug_severity&amp;component=mod_proxy_hcheck">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2&amp;component=mod_proxy_hcheck">Report a bug</a></li></ul><h3>See also</h3>
113 <ul class="seealso">
114 <li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li>
115 <li><a href="#comments_section">Comments</a></li></ul></div>
116 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
117 <div class="section">
118 <h2><a name="examples" id="examples">Usage examples</a><a title="Permanent link" href="#examples" class="permalink">&para;</a></h2>
119
120         
121     <p>The following example shows how one might configured health checking
122         for various backend servers:</p>
123
124         
125         <pre class="prettyprint lang-config">ProxyHCExpr ok234 {%{REQUEST_STATUS} =~ /^[234]/}
126 ProxyHCExpr gdown {%{REQUEST_STATUS} =~ /^[5]/}
127 ProxyHCExpr in_maint {hc('body') !~ /Under maintenance/}
128
129 &lt;Proxy balancer://foo&gt;
130   BalancerMember http://www.example.com/  hcmethod=GET hcexpr=in_maint hcuri=/status.php
131   BalancerMember http://www2.example.com/ hcmethod=HEAD hcexpr=ok234 hcinterval=10
132   BalancerMember http://www3.example.com/ hcmethod=TCP hcinterval=5 hcpasses=2 hcfails=3
133   BalancerMember http://www4.example.com/
134 &lt;/Proxy&gt;
135
136 ProxyPass "/" "balancer://foo"
137 ProxyPassReverse "/" "balancer://foo"</pre>
138
139
140 <p>In this scenario, <code>http://www.example.com/</code> is health checked by sending a <code>GET /status.php</code>
141 request to that server and seeing that the returned page does not include the string <em>Under maintenance</em>. If
142 it does, that server is put in health-check fail mode, and disabled. This dynamic check is performed
143 every 30 seconds, which is the default.</p>
144
145 <p><code>http://www2.example.com/</code> is checked by sending a simple <code>HEAD</code> request every
146 10 seconds and making sure that the response status is 2xx, 3xx or 4xx. <code>http://www3.example.com/</code> is checked
147 every 5 seconds by simply ensuring that the socket to that server is up. If the backend is marked as
148 "down" and it passes 2 health check, it will be re-enabled and added back into the load balancer.
149 It takes 3 back-to-back health check failures to disable the server and move it out
150 of rotation. Finally, <code>http://www4.example.com/</code> is
151 not dynamically checked at all.</p>
152
153 </div>
154 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
155 <div class="directive-section"><h2><a name="ProxyHCExpr" id="ProxyHCExpr">ProxyHCExpr</a> <a name="proxyhcexpr" id="proxyhcexpr">Directive</a><a title="Permanent link" href="#proxyhcexpr" class="permalink">&para;</a></h2>
156 <table class="directive">
157 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Creates a named condition expression to use to determine health of the backend based on its response</td></tr>
158 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ProxyHCExpr <em>name</em> {<em>ap_expr expression</em>}</code></td></tr>
159 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
160 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
161 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
162 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy_hcheck</td></tr>
163 </table>
164     <p>The <code class="directive">ProxyHCExpr</code> directive allows
165        for creating a named condition expression that checks the response
166        headers of the backend server to determine its health. This named
167        condition can then be assigned to balancer members via the <code>hcexpr</code>
168        parameter.</p>
169
170     <div class="example"><h3>ProxyHCExpr: Allow for 2xx/3xx/4xx as passing</h3><pre class="prettyprint lang-config">ProxyHCExpr ok234 {%{REQUEST_STATUS} =~ /^[234]/}
171 ProxyPass "/apps"     "balancer://foo"
172
173 &lt;Proxy balancer://foo&gt;
174   BalancerMember http://www2.example.com/  hcmethod=HEAD hcexpr=ok234 hcinterval=10
175 &lt;/Proxy&gt;</pre>
176 </div>
177
178     <div class="note">
179     The <a href="../expr.html">expression</a> can use curly-parens ("{}") as
180     quoting deliminators in addition to normal quotes.
181     </div>
182
183     <p>If using a health check method (eg: <code>GET</code>) which results in a response
184     body, that body itself can be checked via <code>ap_expr</code> using the <code>hc()</code>
185     expression function, which is unique to this module.</p>
186
187     <p>In the following example, we send the backend a <code>GET</code> request
188     and if the response body contains the phrase <em>Under maintenance</em>,
189     we want to disable the backend.</p>
190
191     <div class="example"><h3>ProxyHCExpr: Checking response body</h3><pre class="prettyprint lang-config">ProxyHCExpr in_maint {hc('body') !~ /Under maintenance/}
192 ProxyPass "/apps"     "balancer://foo"
193
194 &lt;Proxy balancer://foo&gt;
195   BalancerMember http://www.example.com/ hcexpr=in_maint hcmethod=get hcuri=/status.php
196 &lt;/Proxy&gt;</pre>
197 </div>
198
199     <p><em>NOTE:</em> Since response body can quite large, it is best if used against specific status pages.</p>
200
201 </div>
202 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
203 <div class="directive-section"><h2><a name="ProxyHCTemplate" id="ProxyHCTemplate">ProxyHCTemplate</a> <a name="proxyhctemplate" id="proxyhctemplate">Directive</a><a title="Permanent link" href="#proxyhctemplate" class="permalink">&para;</a></h2>
204 <table class="directive">
205 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Creates a named template for setting various health check parameters</td></tr>
206 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ProxyHCTemplate <em>name</em> <em>parameter</em>=<em>setting</em> [...]</code></td></tr>
207 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
208 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
209 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
210 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy_hcheck</td></tr>
211 </table>
212     <p>The <code class="directive">ProxyHCTemplate</code> directive allows
213        for creating a named set (template) of health check parameters
214        that can then be assigned to balancer members via the <code>hctemplate</code>
215        parameter.</p>
216
217     <div class="example"><h3>ProxyHCTemplate</h3><pre class="prettyprint lang-config">ProxyHCTemplate tcp5 hcmethod=tcp hcinterval=5
218 ProxyPass "/apps"     "balancer://foo"
219
220 &lt;Proxy balancer://foo&gt;
221   BalancerMember http://www2.example.com/ hctemplate=tcp5
222 &lt;/Proxy&gt;</pre>
223 </div>
224
225
226 </div>
227 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
228 <div class="directive-section"><h2><a name="ProxyHCTPsize" id="ProxyHCTPsize">ProxyHCTPsize</a> <a name="proxyhctpsize" id="proxyhctpsize">Directive</a><a title="Permanent link" href="#proxyhctpsize" class="permalink">&para;</a></h2>
229 <table class="directive">
230 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the total server-wide size of the threadpool used for the health check workers</td></tr>
231 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ProxyHCTPsize <em>size</em></code></td></tr>
232 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ProxyHCTPsize 16</code></td></tr>
233 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
234 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
235 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy_hcheck</td></tr>
236 </table>
237     <p>If Apache httpd and APR are built with thread support, the health check
238        module will offload the work of the actual checking to a threadpool
239        associated with the Watchdog process, allowing for parallel checks.
240        The <code class="directive">ProxyHCTPsize</code> directive
241        determines the size of this threadpool. If set to <code>0</code>, no threadpool
242        is used at all, resulting in serialized health checks.</p>
243
244     <div class="example"><h3>ProxyHCTPsize</h3><pre class="prettyprint lang-config">ProxyHCTPsize 32</pre>
245 </div>
246
247
248 </div>
249 </div>
250 <div class="bottomlang">
251 <p><span>Available Languages: </span><a href="../en/mod/mod_proxy_hcheck.html" title="English">&nbsp;en&nbsp;</a> |
252 <a href="../fr/mod/mod_proxy_hcheck.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
253 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
254 <script type="text/javascript"><!--//--><![CDATA[//><!--
255 var comments_shortname = 'httpd';
256 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_proxy_hcheck.html';
257 (function(w, d) {
258     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
259         d.write('<div id="comments_thread"><\/div>');
260         var s = d.createElement('script');
261         s.type = 'text/javascript';
262         s.async = true;
263         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
264         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
265     }
266     else {
267         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
268     }
269 })(window, document);
270 //--><!]]></script></div><div id="footer">
271 <p class="apache">Copyright 2018 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
272 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
273 if (typeof(prettyPrint) !== 'undefined') {
274     prettyPrint();
275 }
276 //--><!]]></script>
277 </body></html>