blob: 99e32c8830d457857ed1e41afbaf15ba2f39a8c5 [file] [log] [blame]
Willy Tarreau6a06a402007-07-15 20:15:28 +02001 ----------------------
Willy Tarreau8317b282014-04-23 01:49:41 +02002 HAProxy
Willy Tarreau6a06a402007-07-15 20:15:28 +02003 Configuration Manual
4 ----------------------
Willy Tarreau15480d72014-06-19 21:10:58 +02005 version 1.6
Willy Tarreau6a06a402007-07-15 20:15:28 +02006 willy tarreau
Willy Tarreau8747b6d2015-03-11 23:57:23 +01007 2015/03/11
Willy Tarreau6a06a402007-07-15 20:15:28 +02008
9
10This document covers the configuration language as implemented in the version
11specified above. It does not provide any hint, example or advice. For such
Willy Tarreau0ba27502007-12-24 16:55:16 +010012documentation, please refer to the Reference Manual or the Architecture Manual.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013The summary below is meant to help you search sections by name and navigate
14through the document.
Willy Tarreau6a06a402007-07-15 20:15:28 +020015
Willy Tarreauc57f0e22009-05-10 13:12:33 +020016Note to documentation contributors :
Jamie Gloudonaaa21002012-08-25 00:18:33 -040017 This document is formatted with 80 columns per line, with even number of
Willy Tarreauc57f0e22009-05-10 13:12:33 +020018 spaces for indentation and without tabs. Please follow these rules strictly
19 so that it remains easily printable everywhere. If a line needs to be
20 printed verbatim and does not fit, please end each line with a backslash
Willy Tarreau62a36c42010-08-17 15:53:10 +020021 ('\') and continue on next line, indented by two characters. It is also
22 sometimes useful to prefix all output lines (logs, console outs) with 3
23 closing angle brackets ('>>>') in order to help get the difference between
24 inputs and outputs when it can become ambiguous. If you add sections,
25 please update the summary below for easier searching.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020026
27
28Summary
29-------
30
311. Quick reminder about HTTP
321.1. The HTTP transaction model
331.2. HTTP request
341.2.1. The Request line
351.2.2. The request headers
361.3. HTTP response
371.3.1. The Response line
381.3.2. The response headers
39
402. Configuring HAProxy
412.1. Configuration file format
422.2. Time format
Patrick Mezard35da19c2010-06-12 17:02:47 +0200432.3. Examples
Willy Tarreauc57f0e22009-05-10 13:12:33 +020044
453. Global parameters
463.1. Process management and security
473.2. Performance tuning
483.3. Debugging
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +0100493.4. Userlists
Cyril Bontédc4d9032012-04-08 21:57:39 +0200503.5. Peers
Willy Tarreauc57f0e22009-05-10 13:12:33 +020051
524. Proxies
534.1. Proxy keywords matrix
544.2. Alphabetically sorted keywords reference
55
Willy Tarreau086fbf52012-09-24 20:34:51 +0200565. Bind and Server options
575.1. Bind options
585.2. Server and default-server options
Willy Tarreauc57f0e22009-05-10 13:12:33 +020059
606. HTTP header manipulation
61
Willy Tarreau74ca5042013-06-11 23:12:07 +0200627. Using ACLs and fetching samples
637.1. ACL basics
647.1.1. Matching booleans
657.1.2. Matching integers
667.1.3. Matching strings
677.1.4. Matching regular expressions (regexes)
687.1.5. Matching arbitrary data blocks
697.1.6. Matching IPv4 and IPv6 addresses
707.2. Using ACLs to form conditions
717.3. Fetching samples
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200727.3.1. Converters
737.3.2. Fetching samples from internal states
747.3.3. Fetching samples at Layer 4
757.3.4. Fetching samples at Layer 5
767.3.5. Fetching samples from buffer contents (Layer 6)
777.3.6. Fetching HTTP samples (Layer 7)
Willy Tarreau74ca5042013-06-11 23:12:07 +0200787.4. Pre-defined ACLs
Willy Tarreauc57f0e22009-05-10 13:12:33 +020079
808. Logging
818.1. Log levels
828.2. Log formats
838.2.1. Default log format
848.2.2. TCP log format
858.2.3. HTTP log format
William Lallemand48940402012-01-30 16:47:22 +0100868.2.4. Custom log format
Willy Tarreau5f51e1a2012-12-03 18:40:10 +0100878.2.5. Error log format
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200888.3. Advanced logging options
898.3.1. Disabling logging of external tests
908.3.2. Logging before waiting for the session to terminate
918.3.3. Raising log level upon errors
928.3.4. Disabling logging of successful connections
938.4. Timing events
948.5. Session state at disconnection
958.6. Non-printable characters
968.7. Capturing HTTP cookies
978.8. Capturing HTTP headers
988.9. Examples of logs
99
1009. Statistics and monitoring
1019.1. CSV format
1029.2. Unix Socket commands
103
104
1051. Quick reminder about HTTP
106----------------------------
107
108When haproxy is running in HTTP mode, both the request and the response are
109fully analyzed and indexed, thus it becomes possible to build matching criteria
110on almost anything found in the contents.
111
112However, it is important to understand how HTTP requests and responses are
113formed, and how HAProxy decomposes them. It will then become easier to write
114correct rules and to debug existing configurations.
115
116
1171.1. The HTTP transaction model
118-------------------------------
119
120The HTTP protocol is transaction-driven. This means that each request will lead
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +0100121to one and only one response. Traditionally, a TCP connection is established
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200122from the client to the server, a request is sent by the client on the
123connection, the server responds and the connection is closed. A new request
124will involve a new connection :
125
126 [CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ...
127
128In this mode, called the "HTTP close" mode, there are as many connection
129establishments as there are HTTP transactions. Since the connection is closed
130by the server after the response, the client does not need to know the content
131length.
132
133Due to the transactional nature of the protocol, it was possible to improve it
134to avoid closing a connection between two subsequent transactions. In this mode
135however, it is mandatory that the server indicates the content length for each
136response so that the client does not wait indefinitely. For this, a special
137header is used: "Content-length". This mode is called the "keep-alive" mode :
138
139 [CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ...
140
141Its advantages are a reduced latency between transactions, and less processing
142power required on the server side. It is generally better than the close mode,
143but not always because the clients often limit their concurrent connections to
Patrick Mezard9ec2ec42010-06-12 17:02:45 +0200144a smaller value.
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200145
146A last improvement in the communications is the pipelining mode. It still uses
147keep-alive, but the client does not wait for the first response to send the
148second request. This is useful for fetching large number of images composing a
149page :
150
151 [CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ...
152
153This can obviously have a tremendous benefit on performance because the network
154latency is eliminated between subsequent requests. Many HTTP agents do not
155correctly support pipelining since there is no way to associate a response with
156the corresponding request in HTTP. For this reason, it is mandatory for the
Cyril Bonté78caf842010-03-10 22:41:43 +0100157server to reply in the exact same order as the requests were received.
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200158
Willy Tarreau70dffda2014-01-30 03:07:23 +0100159By default HAProxy operates in keep-alive mode with regards to persistent
160connections: for each connection it processes each request and response, and
161leaves the connection idle on both sides between the end of a response and the
162start of a new request.
Patrick Mezard9ec2ec42010-06-12 17:02:45 +0200163
Willy Tarreau70dffda2014-01-30 03:07:23 +0100164HAProxy supports 5 connection modes :
165 - keep alive : all requests and responses are processed (default)
166 - tunnel : only the first request and response are processed,
167 everything else is forwarded with no analysis.
168 - passive close : tunnel with "Connection: close" added in both directions.
169 - server close : the server-facing connection is closed after the response.
170 - forced close : the connection is actively closed after end of response.
171
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200172
1731.2. HTTP request
174-----------------
175
176First, let's consider this HTTP request :
177
178 Line Contents
Willy Tarreaud72758d2010-01-12 10:42:19 +0100179 number
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200180 1 GET /serv/login.php?lang=en&profile=2 HTTP/1.1
181 2 Host: www.mydomain.com
182 3 User-agent: my small browser
183 4 Accept: image/jpeg, image/gif
184 5 Accept: image/png
185
186
1871.2.1. The Request line
188-----------------------
189
190Line 1 is the "request line". It is always composed of 3 fields :
191
192 - a METHOD : GET
193 - a URI : /serv/login.php?lang=en&profile=2
194 - a version tag : HTTP/1.1
195
196All of them are delimited by what the standard calls LWS (linear white spaces),
197which are commonly spaces, but can also be tabs or line feeds/carriage returns
198followed by spaces/tabs. The method itself cannot contain any colon (':') and
199is limited to alphabetic letters. All those various combinations make it
200desirable that HAProxy performs the splitting itself rather than leaving it to
201the user to write a complex or inaccurate regular expression.
202
203The URI itself can have several forms :
204
205 - A "relative URI" :
206
207 /serv/login.php?lang=en&profile=2
208
209 It is a complete URL without the host part. This is generally what is
210 received by servers, reverse proxies and transparent proxies.
211
212 - An "absolute URI", also called a "URL" :
213
214 http://192.168.0.12:8080/serv/login.php?lang=en&profile=2
215
216 It is composed of a "scheme" (the protocol name followed by '://'), a host
217 name or address, optionally a colon (':') followed by a port number, then
218 a relative URI beginning at the first slash ('/') after the address part.
219 This is generally what proxies receive, but a server supporting HTTP/1.1
220 must accept this form too.
221
222 - a star ('*') : this form is only accepted in association with the OPTIONS
223 method and is not relayable. It is used to inquiry a next hop's
224 capabilities.
Willy Tarreaud72758d2010-01-12 10:42:19 +0100225
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200226 - an address:port combination : 192.168.0.12:80
227 This is used with the CONNECT method, which is used to establish TCP
228 tunnels through HTTP proxies, generally for HTTPS, but sometimes for
229 other protocols too.
230
231In a relative URI, two sub-parts are identified. The part before the question
232mark is called the "path". It is typically the relative path to static objects
233on the server. The part after the question mark is called the "query string".
234It is mostly used with GET requests sent to dynamic scripts and is very
235specific to the language, framework or application in use.
236
237
2381.2.2. The request headers
239--------------------------
240
241The headers start at the second line. They are composed of a name at the
242beginning of the line, immediately followed by a colon (':'). Traditionally,
243an LWS is added after the colon but that's not required. Then come the values.
244Multiple identical headers may be folded into one single line, delimiting the
245values with commas, provided that their order is respected. This is commonly
246encountered in the "Cookie:" field. A header may span over multiple lines if
247the subsequent lines begin with an LWS. In the example in 1.2, lines 4 and 5
248define a total of 3 values for the "Accept:" header.
249
250Contrary to a common mis-conception, header names are not case-sensitive, and
251their values are not either if they refer to other header names (such as the
252"Connection:" header).
253
254The end of the headers is indicated by the first empty line. People often say
255that it's a double line feed, which is not exact, even if a double line feed
256is one valid form of empty line.
257
258Fortunately, HAProxy takes care of all these complex combinations when indexing
259headers, checking values and counting them, so there is no reason to worry
260about the way they could be written, but it is important not to accuse an
261application of being buggy if it does unusual, valid things.
262
263Important note:
264 As suggested by RFC2616, HAProxy normalizes headers by replacing line breaks
265 in the middle of headers by LWS in order to join multi-line headers. This
266 is necessary for proper analysis and helps less capable HTTP parsers to work
267 correctly and not to be fooled by such complex constructs.
268
269
2701.3. HTTP response
271------------------
272
273An HTTP response looks very much like an HTTP request. Both are called HTTP
274messages. Let's consider this HTTP response :
275
276 Line Contents
Willy Tarreaud72758d2010-01-12 10:42:19 +0100277 number
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200278 1 HTTP/1.1 200 OK
279 2 Content-length: 350
280 3 Content-Type: text/html
281
Willy Tarreau816b9792009-09-15 21:25:21 +0200282As a special case, HTTP supports so called "Informational responses" as status
283codes 1xx. These messages are special in that they don't convey any part of the
284response, they're just used as sort of a signaling message to ask a client to
Willy Tarreau5843d1a2010-02-01 15:13:32 +0100285continue to post its request for instance. In the case of a status 100 response
286the requested information will be carried by the next non-100 response message
287following the informational one. This implies that multiple responses may be
288sent to a single request, and that this only works when keep-alive is enabled
289(1xx messages are HTTP/1.1 only). HAProxy handles these messages and is able to
290correctly forward and skip them, and only process the next non-100 response. As
291such, these messages are neither logged nor transformed, unless explicitly
292state otherwise. Status 101 messages indicate that the protocol is changing
293over the same connection and that haproxy must switch to tunnel mode, just as
294if a CONNECT had occurred. Then the Upgrade header would contain additional
295information about the type of protocol the connection is switching to.
Willy Tarreau816b9792009-09-15 21:25:21 +0200296
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200297
2981.3.1. The Response line
299------------------------
300
301Line 1 is the "response line". It is always composed of 3 fields :
302
303 - a version tag : HTTP/1.1
304 - a status code : 200
305 - a reason : OK
306
307The status code is always 3-digit. The first digit indicates a general status :
Willy Tarreau816b9792009-09-15 21:25:21 +0200308 - 1xx = informational message to be skipped (eg: 100, 101)
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200309 - 2xx = OK, content is following (eg: 200, 206)
310 - 3xx = OK, no content following (eg: 302, 304)
311 - 4xx = error caused by the client (eg: 401, 403, 404)
312 - 5xx = error caused by the server (eg: 500, 502, 503)
313
314Please refer to RFC2616 for the detailed meaning of all such codes. The
Willy Tarreaud72758d2010-01-12 10:42:19 +0100315"reason" field is just a hint, but is not parsed by clients. Anything can be
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200316found there, but it's a common practice to respect the well-established
317messages. It can be composed of one or multiple words, such as "OK", "Found",
318or "Authentication Required".
319
320Haproxy may emit the following status codes by itself :
321
322 Code When / reason
323 200 access to stats page, and when replying to monitoring requests
324 301 when performing a redirection, depending on the configured code
325 302 when performing a redirection, depending on the configured code
326 303 when performing a redirection, depending on the configured code
Willy Tarreaub67fdc42013-03-29 19:28:11 +0100327 307 when performing a redirection, depending on the configured code
328 308 when performing a redirection, depending on the configured code
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200329 400 for an invalid or too large request
330 401 when an authentication is required to perform the action (when
331 accessing the stats page)
332 403 when a request is forbidden by a "block" ACL or "reqdeny" filter
333 408 when the request timeout strikes before the request is complete
334 500 when haproxy encounters an unrecoverable internal error, such as a
335 memory allocation failure, which should never happen
336 502 when the server returns an empty, invalid or incomplete response, or
337 when an "rspdeny" filter blocks the response.
338 503 when no server was available to handle the request, or in response to
339 monitoring requests which match the "monitor fail" condition
340 504 when the response timeout strikes before the server responds
341
342The error 4xx and 5xx codes above may be customized (see "errorloc" in section
3434.2).
344
345
3461.3.2. The response headers
347---------------------------
348
349Response headers work exactly like request headers, and as such, HAProxy uses
350the same parsing function for both. Please refer to paragraph 1.2.2 for more
351details.
352
353
3542. Configuring HAProxy
355----------------------
356
3572.1. Configuration file format
358------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +0200359
360HAProxy's configuration process involves 3 major sources of parameters :
361
362 - the arguments from the command-line, which always take precedence
363 - the "global" section, which sets process-wide parameters
364 - the proxies sections which can take form of "defaults", "listen",
365 "frontend" and "backend".
366
Willy Tarreau0ba27502007-12-24 16:55:16 +0100367The configuration file syntax consists in lines beginning with a keyword
368referenced in this manual, optionally followed by one or several parameters
369delimited by spaces. If spaces have to be entered in strings, then they must be
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +0100370preceded by a backslash ('\') to be escaped. Backslashes also have to be
Willy Tarreau0ba27502007-12-24 16:55:16 +0100371escaped by doubling them.
372
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200373
3742.2. Time format
375----------------
376
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +0100377Some parameters involve values representing time, such as timeouts. These
Willy Tarreau0ba27502007-12-24 16:55:16 +0100378values are generally expressed in milliseconds (unless explicitly stated
379otherwise) but may be expressed in any other unit by suffixing the unit to the
380numeric value. It is important to consider this because it will not be repeated
381for every keyword. Supported units are :
382
383 - us : microseconds. 1 microsecond = 1/1000000 second
384 - ms : milliseconds. 1 millisecond = 1/1000 second. This is the default.
385 - s : seconds. 1s = 1000ms
386 - m : minutes. 1m = 60s = 60000ms
387 - h : hours. 1h = 60m = 3600s = 3600000ms
388 - d : days. 1d = 24h = 1440m = 86400s = 86400000ms
389
390
Patrick Mezard35da19c2010-06-12 17:02:47 +02003912.3. Examples
392-------------
393
394 # Simple configuration for an HTTP proxy listening on port 80 on all
395 # interfaces and forwarding requests to a single backend "servers" with a
396 # single server "server1" listening on 127.0.0.1:8000
397 global
398 daemon
399 maxconn 256
400
401 defaults
402 mode http
403 timeout connect 5000ms
404 timeout client 50000ms
405 timeout server 50000ms
406
407 frontend http-in
408 bind *:80
409 default_backend servers
410
411 backend servers
412 server server1 127.0.0.1:8000 maxconn 32
413
414
415 # The same configuration defined with a single listen block. Shorter but
416 # less expressive, especially in HTTP mode.
417 global
418 daemon
419 maxconn 256
420
421 defaults
422 mode http
423 timeout connect 5000ms
424 timeout client 50000ms
425 timeout server 50000ms
426
427 listen http-in
428 bind *:80
429 server server1 127.0.0.1:8000 maxconn 32
430
431
432Assuming haproxy is in $PATH, test these configurations in a shell with:
433
Willy Tarreauccb289d2010-12-11 20:19:38 +0100434 $ sudo haproxy -f configuration.conf -c
Patrick Mezard35da19c2010-06-12 17:02:47 +0200435
436
Willy Tarreauc57f0e22009-05-10 13:12:33 +02004373. Global parameters
Willy Tarreau6a06a402007-07-15 20:15:28 +0200438--------------------
439
440Parameters in the "global" section are process-wide and often OS-specific. They
441are generally set once for all and do not need being changed once correct. Some
442of them have command-line equivalents.
443
444The following keywords are supported in the "global" section :
445
446 * Process management and security
Emeric Brunc8e8d122012-10-02 18:42:10 +0200447 - ca-base
Willy Tarreau6a06a402007-07-15 20:15:28 +0200448 - chroot
Emeric Brunc8e8d122012-10-02 18:42:10 +0200449 - crt-base
Willy Tarreau6a06a402007-07-15 20:15:28 +0200450 - daemon
Simon Horman98637e52014-06-20 12:30:16 +0900451 - external-check
Willy Tarreau6a06a402007-07-15 20:15:28 +0200452 - gid
453 - group
454 - log
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100455 - log-send-hostname
Willy Tarreau6a06a402007-07-15 20:15:28 +0200456 - nbproc
457 - pidfile
458 - uid
459 - ulimit-n
460 - user
Willy Tarreaufbee7132007-10-18 13:53:22 +0200461 - stats
Emeric Brun850efd52014-01-29 12:24:34 +0100462 - ssl-server-verify
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +0200463 - node
464 - description
Willy Tarreauceb24bc2010-11-09 12:46:41 +0100465 - unix-bind
Willy Tarreaud72758d2010-01-12 10:42:19 +0100466
Willy Tarreau6a06a402007-07-15 20:15:28 +0200467 * Performance tuning
Willy Tarreau1746eec2014-04-25 10:46:47 +0200468 - max-spread-checks
Willy Tarreau6a06a402007-07-15 20:15:28 +0200469 - maxconn
Willy Tarreau81c25d02011-09-07 15:17:21 +0200470 - maxconnrate
William Lallemandd85f9172012-11-09 17:05:39 +0100471 - maxcomprate
William Lallemand072a2bf2012-11-20 17:01:01 +0100472 - maxcompcpuusage
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100473 - maxpipes
Willy Tarreau93e7c002013-10-07 18:51:07 +0200474 - maxsessrate
Willy Tarreau403edff2012-09-06 11:58:37 +0200475 - maxsslconn
Willy Tarreaue43d5322013-10-07 20:01:52 +0200476 - maxsslrate
Willy Tarreau6a06a402007-07-15 20:15:28 +0200477 - noepoll
478 - nokqueue
479 - nopoll
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100480 - nosplice
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300481 - nogetaddrinfo
Willy Tarreaufe255b72007-10-14 23:09:26 +0200482 - spread-checks
Willy Tarreau27a674e2009-08-17 07:23:33 +0200483 - tune.bufsize
Willy Tarreau43961d52010-10-04 20:39:20 +0200484 - tune.chksize
William Lallemandf3747832012-11-09 12:33:10 +0100485 - tune.comp.maxlevel
Willy Tarreau193b8c62012-11-22 00:17:38 +0100486 - tune.http.cookielen
Willy Tarreauac1932d2011-10-24 19:14:41 +0200487 - tune.http.maxhdr
Willy Tarreau7e312732014-02-12 16:35:14 +0100488 - tune.idletimer
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100489 - tune.lua.forced-yield
Willy Tarreau32f61e22015-03-18 17:54:59 +0100490 - tune.lua.maxmem
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100491 - tune.lua.session-timeout
492 - tune.lua.task-timeout
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100493 - tune.maxaccept
494 - tune.maxpollevents
Willy Tarreau27a674e2009-08-17 07:23:33 +0200495 - tune.maxrewrite
Willy Tarreauf3045d22015-04-29 16:24:50 +0200496 - tune.pattern.cache-size
Willy Tarreaubd9a0a72011-10-23 21:14:29 +0200497 - tune.pipesize
Willy Tarreaue803de22010-01-21 17:43:04 +0100498 - tune.rcvbuf.client
499 - tune.rcvbuf.server
500 - tune.sndbuf.client
501 - tune.sndbuf.server
Willy Tarreau6ec58db2012-11-16 16:32:15 +0100502 - tune.ssl.cachesize
Willy Tarreaubfd59462013-02-21 07:46:09 +0100503 - tune.ssl.lifetime
Emeric Brun8dc60392014-05-09 13:52:00 +0200504 - tune.ssl.force-private-cache
Willy Tarreaubfd59462013-02-21 07:46:09 +0100505 - tune.ssl.maxrecord
Remi Gacognef46cd6e2014-06-12 14:58:40 +0200506 - tune.ssl.default-dh-param
William Lallemanda509e4c2012-11-07 16:54:34 +0100507 - tune.zlib.memlevel
508 - tune.zlib.windowsize
Willy Tarreaud72758d2010-01-12 10:42:19 +0100509
Willy Tarreau6a06a402007-07-15 20:15:28 +0200510 * Debugging
511 - debug
512 - quiet
Willy Tarreau6a06a402007-07-15 20:15:28 +0200513
514
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005153.1. Process management and security
Willy Tarreau6a06a402007-07-15 20:15:28 +0200516------------------------------------
517
Emeric Brunc8e8d122012-10-02 18:42:10 +0200518ca-base <dir>
519 Assigns a default directory to fetch SSL CA certificates and CRLs from when a
Emeric Brunfd33a262012-10-11 16:28:27 +0200520 relative path is used with "ca-file" or "crl-file" directives. Absolute
521 locations specified in "ca-file" and "crl-file" prevail and ignore "ca-base".
Emeric Brunc8e8d122012-10-02 18:42:10 +0200522
Willy Tarreau6a06a402007-07-15 20:15:28 +0200523chroot <jail dir>
524 Changes current directory to <jail dir> and performs a chroot() there before
525 dropping privileges. This increases the security level in case an unknown
526 vulnerability would be exploited, since it would make it very hard for the
527 attacker to exploit the system. This only works when the process is started
528 with superuser privileges. It is important to ensure that <jail_dir> is both
529 empty and unwritable to anyone.
Willy Tarreaud72758d2010-01-12 10:42:19 +0100530
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100531cpu-map <"all"|"odd"|"even"|process_num> <cpu-set>...
532 On Linux 2.6 and above, it is possible to bind a process to a specific CPU
533 set. This means that the process will never run on other CPUs. The "cpu-map"
534 directive specifies CPU sets for process sets. The first argument is the
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100535 process number to bind. This process must have a number between 1 and 32 or
536 64, depending on the machine's word size, and any process IDs above nbproc
537 are ignored. It is possible to specify all processes at once using "all",
538 only odd numbers using "odd" or even numbers using "even", just like with the
539 "bind-process" directive. The second and forthcoming arguments are CPU sets.
540 Each CPU set is either a unique number between 0 and 31 or 63 or a range with
541 two such numbers delimited by a dash ('-'). Multiple CPU numbers or ranges
542 may be specified, and the processes will be allowed to bind to all of them.
543 Obviously, multiple "cpu-map" directives may be specified. Each "cpu-map"
544 directive will replace the previous ones when they overlap.
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100545
Emeric Brunc8e8d122012-10-02 18:42:10 +0200546crt-base <dir>
547 Assigns a default directory to fetch SSL certificates from when a relative
548 path is used with "crtfile" directives. Absolute locations specified after
549 "crtfile" prevail and ignore "crt-base".
550
Willy Tarreau6a06a402007-07-15 20:15:28 +0200551daemon
552 Makes the process fork into background. This is the recommended mode of
553 operation. It is equivalent to the command line "-D" argument. It can be
554 disabled by the command line "-db" argument.
555
Simon Horman98637e52014-06-20 12:30:16 +0900556external-check
557 Allows the use of an external agent to perform health checks.
558 This is disabled by default as a security precaution.
559 See "option external-check".
560
Willy Tarreau6a06a402007-07-15 20:15:28 +0200561gid <number>
562 Changes the process' group ID to <number>. It is recommended that the group
563 ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
564 be started with a user belonging to this group, or with superuser privileges.
Michael Schererab012dd2013-01-12 18:35:19 +0100565 Note that if haproxy is started from a user having supplementary groups, it
566 will only be able to drop these groups if started with superuser privileges.
Willy Tarreau6a06a402007-07-15 20:15:28 +0200567 See also "group" and "uid".
Willy Tarreaud72758d2010-01-12 10:42:19 +0100568
Willy Tarreau6a06a402007-07-15 20:15:28 +0200569group <group name>
570 Similar to "gid" but uses the GID of group name <group name> from /etc/group.
571 See also "gid" and "user".
Willy Tarreaud72758d2010-01-12 10:42:19 +0100572
Willy Tarreau18324f52014-06-27 18:10:07 +0200573log <address> [len <length>] <facility> [max level [min level]]
Willy Tarreau6a06a402007-07-15 20:15:28 +0200574 Adds a global syslog server. Up to two global servers can be defined. They
575 will receive logs for startups and exits, as well as all logs from proxies
Robert Tsai81ae1952007-12-05 10:47:29 +0100576 configured with "log global".
577
578 <address> can be one of:
579
Willy Tarreau2769aa02007-12-27 18:26:09 +0100580 - An IPv4 address optionally followed by a colon and a UDP port. If
Robert Tsai81ae1952007-12-05 10:47:29 +0100581 no port is specified, 514 is used by default (the standard syslog
582 port).
583
David du Colombier24bb5f52011-03-17 10:40:23 +0100584 - An IPv6 address followed by a colon and optionally a UDP port. If
585 no port is specified, 514 is used by default (the standard syslog
586 port).
587
Robert Tsai81ae1952007-12-05 10:47:29 +0100588 - A filesystem path to a UNIX domain socket, keeping in mind
589 considerations for chroot (be sure the path is accessible inside
590 the chroot) and uid/gid (be sure the path is appropriately
591 writeable).
592
Willy Tarreaudad36a32013-03-11 01:20:04 +0100593 Any part of the address string may reference any number of environment
594 variables by preceding their name with a dollar sign ('$') and
595 optionally enclosing them with braces ('{}'), similarly to what is done
596 in Bourne shell.
597
Willy Tarreau18324f52014-06-27 18:10:07 +0200598 <length> is an optional maximum line length. Log lines larger than this value
599 will be truncated before being sent. The reason is that syslog
600 servers act differently on log line length. All servers support the
601 default value of 1024, but some servers simply drop larger lines
602 while others do log them. If a server supports long lines, it may
603 make sense to set this value here in order to avoid truncating long
604 lines. Similarly, if a server drops long lines, it is preferable to
605 truncate them before sending them. Accepted values are 80 to 65535
606 inclusive. The default value of 1024 is generally fine for all
607 standard usages. Some specific cases of long captures or
608 JSON-formated logs may require larger values.
609
Robert Tsai81ae1952007-12-05 10:47:29 +0100610 <facility> must be one of the 24 standard syslog facilities :
Willy Tarreau6a06a402007-07-15 20:15:28 +0200611
612 kern user mail daemon auth syslog lpr news
613 uucp cron auth2 ftp ntp audit alert cron2
614 local0 local1 local2 local3 local4 local5 local6 local7
615
616 An optional level can be specified to filter outgoing messages. By default,
Willy Tarreauf7edefa2009-05-10 17:20:05 +0200617 all messages are sent. If a maximum level is specified, only messages with a
618 severity at least as important as this level will be sent. An optional minimum
619 level can be specified. If it is set, logs emitted with a more severe level
620 than this one will be capped to this level. This is used to avoid sending
621 "emerg" messages on all terminals on some default syslog configurations.
622 Eight levels are known :
Willy Tarreau6a06a402007-07-15 20:15:28 +0200623
Cyril Bontédc4d9032012-04-08 21:57:39 +0200624 emerg alert crit err warning notice info debug
Willy Tarreau6a06a402007-07-15 20:15:28 +0200625
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100626log-send-hostname [<string>]
627 Sets the hostname field in the syslog header. If optional "string" parameter
628 is set the header is set to the string contents, otherwise uses the hostname
629 of the system. Generally used if one is not relaying logs through an
630 intermediate syslog server or for simply customizing the hostname printed in
631 the logs.
632
Kevinm48936af2010-12-22 16:08:21 +0000633log-tag <string>
634 Sets the tag field in the syslog header to this string. It defaults to the
635 program name as launched from the command line, which usually is "haproxy".
636 Sometimes it can be useful to differentiate between multiple processes
Willy Tarreau094af4e2015-01-07 15:03:42 +0100637 running on the same host. See also the per-proxy "log-tag" directive.
Kevinm48936af2010-12-22 16:08:21 +0000638
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100639lua-load <file>
640 This global directive loads and executes a Lua file. This directive can be
641 used multiple times.
642
Willy Tarreau6a06a402007-07-15 20:15:28 +0200643nbproc <number>
644 Creates <number> processes when going daemon. This requires the "daemon"
645 mode. By default, only one process is created, which is the recommended mode
646 of operation. For systems limited to small sets of file descriptors per
647 process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
648 IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
649
650pidfile <pidfile>
651 Writes pids of all daemons into file <pidfile>. This option is equivalent to
652 the "-p" command line argument. The file must be accessible to the user
653 starting the process. See also "daemon".
654
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100655stats bind-process [ all | odd | even | <number 1-64>[-<number 1-64>] ] ...
Willy Tarreau35b7b162012-10-22 23:17:18 +0200656 Limits the stats socket to a certain set of processes numbers. By default the
657 stats socket is bound to all processes, causing a warning to be emitted when
658 nbproc is greater than 1 because there is no way to select the target process
659 when connecting. However, by using this setting, it becomes possible to pin
660 the stats socket to a specific set of processes, typically the first one. The
661 warning will automatically be disabled when this setting is used, whatever
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100662 the number of processes used. The maximum process ID depends on the machine's
Willy Tarreauae302532014-05-07 19:22:24 +0200663 word size (32 or 64). A better option consists in using the "process" setting
664 of the "stats socket" line to force the process on each line.
Willy Tarreau35b7b162012-10-22 23:17:18 +0200665
Willy Tarreau610f04b2014-02-13 11:36:41 +0100666ssl-default-bind-ciphers <ciphers>
667 This setting is only available when support for OpenSSL was built in. It sets
668 the default string describing the list of cipher algorithms ("cipher suite")
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300669 that are negotiated during the SSL/TLS handshake for all "bind" lines which
Willy Tarreau610f04b2014-02-13 11:36:41 +0100670 do not explicitly define theirs. The format of the string is defined in
671 "man 1 ciphers" from OpenSSL man pages, and can be for instance a string such
672 as "AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH" (without quotes). Please check the
673 "bind" keyword for more information.
674
Emeric Brun2c86cbf2014-10-30 15:56:50 +0100675ssl-default-bind-options [<option>]...
676 This setting is only available when support for OpenSSL was built in. It sets
677 default ssl-options to force on all "bind" lines. Please check the "bind"
678 keyword to see available options.
679
680 Example:
681 global
682 ssl-default-bind-options no-sslv3 no-tls-tickets
683
Willy Tarreau610f04b2014-02-13 11:36:41 +0100684ssl-default-server-ciphers <ciphers>
685 This setting is only available when support for OpenSSL was built in. It
686 sets the default string describing the list of cipher algorithms that are
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300687 negotiated during the SSL/TLS handshake with the server, for all "server"
Willy Tarreau610f04b2014-02-13 11:36:41 +0100688 lines which do not explicitly define theirs. The format of the string is
689 defined in "man 1 ciphers". Please check the "server" keyword for more
690 information.
691
Emeric Brun2c86cbf2014-10-30 15:56:50 +0100692ssl-default-server-options [<option>]...
693 This setting is only available when support for OpenSSL was built in. It sets
694 default ssl-options to force on all "server" lines. Please check the "server"
695 keyword to see available options.
696
Emeric Brun850efd52014-01-29 12:24:34 +0100697ssl-server-verify [none|required]
698 The default behavior for SSL verify on servers side. If specified to 'none',
699 servers certificates are not verified. The default is 'required' except if
700 forced using cmdline option '-dV'.
701
Willy Tarreauabb175f2012-09-24 12:43:26 +0200702stats socket [<address:port>|<path>] [param*]
703 Binds a UNIX socket to <path> or a TCPv4/v6 address to <address:port>.
704 Connections to this socket will return various statistics outputs and even
705 allow some commands to be issued to change some runtime settings. Please
706 consult section 9.2 "Unix Socket commands" for more details.
Willy Tarreau6162db22009-10-10 17:13:00 +0200707
Willy Tarreauabb175f2012-09-24 12:43:26 +0200708 All parameters supported by "bind" lines are supported, for instance to
709 restrict access to some users or their access rights. Please consult
710 section 5.1 for more information.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200711
712stats timeout <timeout, in milliseconds>
713 The default timeout on the stats socket is set to 10 seconds. It is possible
714 to change this value with "stats timeout". The value must be passed in
Willy Tarreaubefdff12007-12-02 22:27:38 +0100715 milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200716
717stats maxconn <connections>
718 By default, the stats socket is limited to 10 concurrent connections. It is
719 possible to change this value with "stats maxconn".
720
Willy Tarreau6a06a402007-07-15 20:15:28 +0200721uid <number>
722 Changes the process' user ID to <number>. It is recommended that the user ID
723 is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
724 be started with superuser privileges in order to be able to switch to another
725 one. See also "gid" and "user".
726
727ulimit-n <number>
728 Sets the maximum number of per-process file-descriptors to <number>. By
729 default, it is automatically computed, so it is recommended not to use this
730 option.
731
Willy Tarreauceb24bc2010-11-09 12:46:41 +0100732unix-bind [ prefix <prefix> ] [ mode <mode> ] [ user <user> ] [ uid <uid> ]
733 [ group <group> ] [ gid <gid> ]
734
735 Fixes common settings to UNIX listening sockets declared in "bind" statements.
736 This is mainly used to simplify declaration of those UNIX sockets and reduce
737 the risk of errors, since those settings are most commonly required but are
738 also process-specific. The <prefix> setting can be used to force all socket
739 path to be relative to that directory. This might be needed to access another
740 component's chroot. Note that those paths are resolved before haproxy chroots
741 itself, so they are absolute. The <mode>, <user>, <uid>, <group> and <gid>
742 all have the same meaning as their homonyms used by the "bind" statement. If
743 both are specified, the "bind" statement has priority, meaning that the
744 "unix-bind" settings may be seen as process-wide default settings.
745
Willy Tarreau6a06a402007-07-15 20:15:28 +0200746user <user name>
747 Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
748 See also "uid" and "group".
749
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +0200750node <name>
751 Only letters, digits, hyphen and underscore are allowed, like in DNS names.
752
753 This statement is useful in HA configurations where two or more processes or
754 servers share the same IP address. By setting a different node-name on all
755 nodes, it becomes easy to immediately spot what server is handling the
756 traffic.
757
758description <text>
759 Add a text that describes the instance.
760
761 Please note that it is required to escape certain characters (# for example)
762 and this text is inserted into a html page so you should avoid using
763 "<" and ">" characters.
764
Willy Tarreau6a06a402007-07-15 20:15:28 +0200765
Willy Tarreauc57f0e22009-05-10 13:12:33 +02007663.2. Performance tuning
Willy Tarreau6a06a402007-07-15 20:15:28 +0200767-----------------------
768
Willy Tarreau1746eec2014-04-25 10:46:47 +0200769max-spread-checks <delay in milliseconds>
770 By default, haproxy tries to spread the start of health checks across the
771 smallest health check interval of all the servers in a farm. The principle is
772 to avoid hammering services running on the same server. But when using large
773 check intervals (10 seconds or more), the last servers in the farm take some
774 time before starting to be tested, which can be a problem. This parameter is
775 used to enforce an upper bound on delay between the first and the last check,
776 even if the servers' check intervals are larger. When servers run with
777 shorter intervals, their intervals will be respected though.
778
Willy Tarreau6a06a402007-07-15 20:15:28 +0200779maxconn <number>
780 Sets the maximum per-process number of concurrent connections to <number>. It
781 is equivalent to the command-line argument "-n". Proxies will stop accepting
782 connections when this limit is reached. The "ulimit-n" parameter is
Willy Tarreau8274e102014-06-19 15:31:25 +0200783 automatically adjusted according to this value. See also "ulimit-n". Note:
784 the "select" poller cannot reliably use more than 1024 file descriptors on
785 some platforms. If your platform only supports select and reports "select
786 FAILED" on startup, you need to reduce maxconn until it works (slightly
Willy Tarreaud0256482015-01-15 21:45:22 +0100787 below 500 in general). If this value is not set, it will default to the value
788 set in DEFAULT_MAXCONN at build time (reported in haproxy -vv) if no memory
789 limit is enforced, or will be computed based on the memory limit, the buffer
790 size, memory allocated to compression, SSL cache size, and use or not of SSL
791 and the associated maxsslconn (which can also be automatic).
Willy Tarreau6a06a402007-07-15 20:15:28 +0200792
Willy Tarreau81c25d02011-09-07 15:17:21 +0200793maxconnrate <number>
794 Sets the maximum per-process number of connections per second to <number>.
795 Proxies will stop accepting connections when this limit is reached. It can be
796 used to limit the global capacity regardless of each frontend capacity. It is
797 important to note that this can only be used as a service protection measure,
798 as there will not necessarily be a fair share between frontends when the
799 limit is reached, so it's a good idea to also limit each frontend to some
800 value close to its expected share. Also, lowering tune.maxaccept can improve
801 fairness.
802
William Lallemandd85f9172012-11-09 17:05:39 +0100803maxcomprate <number>
804 Sets the maximum per-process input compression rate to <number> kilobytes
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300805 per second. For each session, if the maximum is reached, the compression
William Lallemandd85f9172012-11-09 17:05:39 +0100806 level will be decreased during the session. If the maximum is reached at the
807 beginning of a session, the session will not compress at all. If the maximum
808 is not reached, the compression level will be increased up to
809 tune.comp.maxlevel. A value of zero means there is no limit, this is the
810 default value.
811
William Lallemand072a2bf2012-11-20 17:01:01 +0100812maxcompcpuusage <number>
813 Sets the maximum CPU usage HAProxy can reach before stopping the compression
814 for new requests or decreasing the compression level of current requests.
815 It works like 'maxcomprate' but measures CPU usage instead of incoming data
816 bandwidth. The value is expressed in percent of the CPU used by haproxy. In
817 case of multiple processes (nbproc > 1), each process manages its individual
818 usage. A value of 100 disable the limit. The default value is 100. Setting
819 a lower value will prevent the compression work from slowing the whole
820 process down and from introducing high latencies.
821
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100822maxpipes <number>
823 Sets the maximum per-process number of pipes to <number>. Currently, pipes
824 are only used by kernel-based tcp splicing. Since a pipe contains two file
825 descriptors, the "ulimit-n" value will be increased accordingly. The default
826 value is maxconn/4, which seems to be more than enough for most heavy usages.
827 The splice code dynamically allocates and releases pipes, and can fall back
828 to standard copy, so setting this value too low may only impact performance.
829
Willy Tarreau93e7c002013-10-07 18:51:07 +0200830maxsessrate <number>
831 Sets the maximum per-process number of sessions per second to <number>.
832 Proxies will stop accepting connections when this limit is reached. It can be
833 used to limit the global capacity regardless of each frontend capacity. It is
834 important to note that this can only be used as a service protection measure,
835 as there will not necessarily be a fair share between frontends when the
836 limit is reached, so it's a good idea to also limit each frontend to some
837 value close to its expected share. Also, lowering tune.maxaccept can improve
838 fairness.
839
Willy Tarreau403edff2012-09-06 11:58:37 +0200840maxsslconn <number>
841 Sets the maximum per-process number of concurrent SSL connections to
842 <number>. By default there is no SSL-specific limit, which means that the
843 global maxconn setting will apply to all connections. Setting this limit
844 avoids having openssl use too much memory and crash when malloc returns NULL
845 (since it unfortunately does not reliably check for such conditions). Note
846 that the limit applies both to incoming and outgoing connections, so one
847 connection which is deciphered then ciphered accounts for 2 SSL connections.
Willy Tarreaud0256482015-01-15 21:45:22 +0100848 If this value is not set, but a memory limit is enforced, this value will be
849 automatically computed based on the memory limit, maxconn, the buffer size,
850 memory allocated to compression, SSL cache size, and use of SSL in either
851 frontends, backends or both. If neither maxconn nor maxsslconn are specified
852 when there is a memory limit, haproxy will automatically adjust these values
853 so that 100% of the connections can be made over SSL with no risk, and will
854 consider the sides where it is enabled (frontend, backend, both).
Willy Tarreau403edff2012-09-06 11:58:37 +0200855
Willy Tarreaue43d5322013-10-07 20:01:52 +0200856maxsslrate <number>
857 Sets the maximum per-process number of SSL sessions per second to <number>.
858 SSL listeners will stop accepting connections when this limit is reached. It
859 can be used to limit the global SSL CPU usage regardless of each frontend
860 capacity. It is important to note that this can only be used as a service
861 protection measure, as there will not necessarily be a fair share between
862 frontends when the limit is reached, so it's a good idea to also limit each
863 frontend to some value close to its expected share. It is also important to
864 note that the sessions are accounted before they enter the SSL stack and not
865 after, which also protects the stack against bad handshakes. Also, lowering
866 tune.maxaccept can improve fairness.
867
William Lallemand9d5f5482012-11-07 16:12:57 +0100868maxzlibmem <number>
869 Sets the maximum amount of RAM in megabytes per process usable by the zlib.
870 When the maximum amount is reached, future sessions will not compress as long
871 as RAM is unavailable. When sets to 0, there is no limit.
William Lallemande3a7d992012-11-20 11:25:20 +0100872 The default value is 0. The value is available in bytes on the UNIX socket
873 with "show info" on the line "MaxZlibMemUsage", the memory used by zlib is
874 "ZlibMemUsage" in bytes.
875
Willy Tarreau6a06a402007-07-15 20:15:28 +0200876noepoll
877 Disables the use of the "epoll" event polling system on Linux. It is
878 equivalent to the command-line argument "-de". The next polling system
Willy Tarreaue9f49e72012-11-11 17:42:00 +0100879 used will generally be "poll". See also "nopoll".
Willy Tarreau6a06a402007-07-15 20:15:28 +0200880
881nokqueue
882 Disables the use of the "kqueue" event polling system on BSD. It is
883 equivalent to the command-line argument "-dk". The next polling system
884 used will generally be "poll". See also "nopoll".
885
886nopoll
887 Disables the use of the "poll" event polling system. It is equivalent to the
888 command-line argument "-dp". The next polling system used will be "select".
Willy Tarreau0ba27502007-12-24 16:55:16 +0100889 It should never be needed to disable "poll" since it's available on all
Willy Tarreaue9f49e72012-11-11 17:42:00 +0100890 platforms supported by HAProxy. See also "nokqueue" and "noepoll".
Willy Tarreau6a06a402007-07-15 20:15:28 +0200891
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100892nosplice
893 Disables the use of kernel tcp splicing between sockets on Linux. It is
894 equivalent to the command line argument "-dS". Data will then be copied
895 using conventional and more portable recv/send calls. Kernel tcp splicing is
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +0100896 limited to some very recent instances of kernel 2.6. Most versions between
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100897 2.6.25 and 2.6.28 are buggy and will forward corrupted data, so they must not
898 be used. This option makes it easier to globally disable kernel splicing in
899 case of doubt. See also "option splice-auto", "option splice-request" and
900 "option splice-response".
901
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300902nogetaddrinfo
903 Disables the use of getaddrinfo(3) for name resolving. It is equivalent to
904 the command line argument "-dG". Deprecated gethostbyname(3) will be used.
905
Willy Tarreaufe255b72007-10-14 23:09:26 +0200906spread-checks <0..50, in percent>
Simon Hormand60d6912013-11-25 10:46:36 +0900907 Sometimes it is desirable to avoid sending agent and health checks to
908 servers at exact intervals, for instance when many logical servers are
909 located on the same physical server. With the help of this parameter, it
910 becomes possible to add some randomness in the check interval between 0
911 and +/- 50%. A value between 2 and 5 seems to show good results. The
912 default value remains at 0.
Willy Tarreaufe255b72007-10-14 23:09:26 +0200913
Willy Tarreau33cb0652014-12-23 22:52:37 +0100914tune.buffers.limit <number>
915 Sets a hard limit on the number of buffers which may be allocated per process.
916 The default value is zero which means unlimited. The minimum non-zero value
917 will always be greater than "tune.buffers.reserve" and should ideally always
918 be about twice as large. Forcing this value can be particularly useful to
919 limit the amount of memory a process may take, while retaining a sane
920 behaviour. When this limit is reached, sessions which need a buffer wait for
921 another one to be released by another session. Since buffers are dynamically
922 allocated and released, the waiting time is very short and not perceptible
923 provided that limits remain reasonable. In fact sometimes reducing the limit
924 may even increase performance by increasing the CPU cache's efficiency. Tests
925 have shown good results on average HTTP traffic with a limit to 1/10 of the
926 expected global maxconn setting, which also significantly reduces memory
927 usage. The memory savings come from the fact that a number of connections
928 will not allocate 2*tune.bufsize. It is best not to touch this value unless
929 advised to do so by an haproxy core developer.
930
Willy Tarreau1058ae72014-12-23 22:40:40 +0100931tune.buffers.reserve <number>
932 Sets the number of buffers which are pre-allocated and reserved for use only
933 during memory shortage conditions resulting in failed memory allocations. The
934 minimum value is 2 and is also the default. There is no reason a user would
935 want to change this value, it's mostly aimed at haproxy core developers.
936
Willy Tarreau27a674e2009-08-17 07:23:33 +0200937tune.bufsize <number>
938 Sets the buffer size to this size (in bytes). Lower values allow more
939 sessions to coexist in the same amount of RAM, and higher values allow some
940 applications with very large cookies to work. The default value is 16384 and
941 can be changed at build time. It is strongly recommended not to change this
942 from the default value, as very low values will break some services such as
943 statistics, and values larger than default size will increase memory usage,
944 possibly causing the system to run out of memory. At least the global maxconn
945 parameter should be decreased by the same factor as this one is increased.
Dmitry Sivachenkof6f4f7b2012-10-21 18:10:25 +0400946 If HTTP request is larger than (tune.bufsize - tune.maxrewrite), haproxy will
947 return HTTP 400 (Bad Request) error. Similarly if an HTTP response is larger
948 than this size, haproxy will return HTTP 502 (Bad Gateway).
Willy Tarreau27a674e2009-08-17 07:23:33 +0200949
Willy Tarreau43961d52010-10-04 20:39:20 +0200950tune.chksize <number>
951 Sets the check buffer size to this size (in bytes). Higher values may help
952 find string or regex patterns in very large pages, though doing so may imply
953 more memory and CPU usage. The default value is 16384 and can be changed at
954 build time. It is not recommended to change this value, but to use better
955 checks whenever possible.
956
William Lallemandf3747832012-11-09 12:33:10 +0100957tune.comp.maxlevel <number>
958 Sets the maximum compression level. The compression level affects CPU
959 usage during compression. This value affects CPU usage during compression.
960 Each session using compression initializes the compression algorithm with
961 this value. The default value is 1.
962
Willy Tarreau193b8c62012-11-22 00:17:38 +0100963tune.http.cookielen <number>
964 Sets the maximum length of captured cookies. This is the maximum value that
965 the "capture cookie xxx len yyy" will be allowed to take, and any upper value
966 will automatically be truncated to this one. It is important not to set too
967 high a value because all cookie captures still allocate this size whatever
968 their configured value (they share a same pool). This value is per request
969 per response, so the memory allocated is twice this value per connection.
970 When not specified, the limit is set to 63 characters. It is recommended not
971 to change this value.
972
Willy Tarreauac1932d2011-10-24 19:14:41 +0200973tune.http.maxhdr <number>
974 Sets the maximum number of headers in a request. When a request comes with a
975 number of headers greater than this value (including the first line), it is
976 rejected with a "400 Bad Request" status code. Similarly, too large responses
977 are blocked with "502 Bad Gateway". The default value is 101, which is enough
978 for all usages, considering that the widely deployed Apache server uses the
979 same limit. It can be useful to push this limit further to temporarily allow
980 a buggy application to work by the time it gets fixed. Keep in mind that each
981 new header consumes 32bits of memory for each session, so don't push this
982 limit too high.
983
Willy Tarreau7e312732014-02-12 16:35:14 +0100984tune.idletimer <timeout>
985 Sets the duration after which haproxy will consider that an empty buffer is
986 probably associated with an idle stream. This is used to optimally adjust
987 some packet sizes while forwarding large and small data alternatively. The
988 decision to use splice() or to send large buffers in SSL is modulated by this
989 parameter. The value is in milliseconds between 0 and 65535. A value of zero
990 means that haproxy will not try to detect idle streams. The default is 1000,
991 which seems to correctly detect end user pauses (eg: read a page before
992 clicking). There should be not reason for changing this value. Please check
993 tune.ssl.maxrecord below.
994
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100995tune.lua.forced-yield <number>
996 This directive forces the Lua engine to execute a yield each <number> of
997 instructions executed. This permits interruptng a long script and allows the
998 HAProxy scheduler to process other tasks like accepting connections or
999 forwarding traffic. The default value is 10000 instructions. If HAProxy often
1000 executes some Lua code but more reactivity is required, this value can be
1001 lowered. If the Lua code is quite long and its result is absolutely required
1002 to process the data, the <number> can be increased.
1003
Willy Tarreau32f61e22015-03-18 17:54:59 +01001004tune.lua.maxmem
1005 Sets the maximum amount of RAM in megabytes per process usable by Lua. By
1006 default it is zero which means unlimited. It is important to set a limit to
1007 ensure that a bug in a script will not result in the system running out of
1008 memory.
1009
Thierry FOURNIER90da1912015-03-05 11:17:06 +01001010tune.lua.session-timeout <timeout>
1011 This is the execution timeout for the Lua sessions. This is useful for
1012 preventing infinite loops or spending too much time in Lua. This timeout has a
1013 priority over other timeouts. For example, if this timeout is set to 4s and
1014 you run a 5s sleep, the code will be interrupted with an error after waiting
1015 4s.
1016
1017tune.lua.task-timeout <timeout>
1018 Purpose is the same as "tune.lua.session-timeout", but this timeout is
1019 dedicated to the tasks. By default, this timeout isn't set because a task may
1020 remain alive during of the lifetime of HAProxy. For example, a task used to
1021 check servers.
1022
Willy Tarreaua0250ba2008-01-06 11:22:57 +01001023tune.maxaccept <number>
Willy Tarreau16a21472012-11-19 12:39:59 +01001024 Sets the maximum number of consecutive connections a process may accept in a
1025 row before switching to other work. In single process mode, higher numbers
1026 give better performance at high connection rates. However in multi-process
1027 modes, keeping a bit of fairness between processes generally is better to
1028 increase performance. This value applies individually to each listener, so
1029 that the number of processes a listener is bound to is taken into account.
1030 This value defaults to 64. In multi-process mode, it is divided by twice
1031 the number of processes the listener is bound to. Setting this value to -1
1032 completely disables the limitation. It should normally not be needed to tweak
1033 this value.
Willy Tarreaua0250ba2008-01-06 11:22:57 +01001034
1035tune.maxpollevents <number>
1036 Sets the maximum amount of events that can be processed at once in a call to
1037 the polling system. The default value is adapted to the operating system. It
1038 has been noticed that reducing it below 200 tends to slightly decrease
1039 latency at the expense of network bandwidth, and increasing it above 200
1040 tends to trade latency for slightly increased bandwidth.
1041
Willy Tarreau27a674e2009-08-17 07:23:33 +02001042tune.maxrewrite <number>
1043 Sets the reserved buffer space to this size in bytes. The reserved space is
1044 used for header rewriting or appending. The first reads on sockets will never
1045 fill more than bufsize-maxrewrite. Historically it has defaulted to half of
1046 bufsize, though that does not make much sense since there are rarely large
1047 numbers of headers to add. Setting it too high prevents processing of large
1048 requests or responses. Setting it too low prevents addition of new headers
1049 to already large requests or to POST requests. It is generally wise to set it
1050 to about 1024. It is automatically readjusted to half of bufsize if it is
1051 larger than that. This means you don't have to worry about it when changing
1052 bufsize.
1053
Willy Tarreauf3045d22015-04-29 16:24:50 +02001054tune.pattern.cache-size <number>
1055 Sets the size of the pattern lookup cache to <number> entries. This is an LRU
1056 cache which reminds previous lookups and their results. It is used by ACLs
1057 and maps on slow pattern lookups, namely the ones using the "sub", "reg",
1058 "dir", "dom", "end", "bin" match methods as well as the case-insensitive
1059 strings. It applies to pattern expressions which means that it will be able
1060 to memorize the result of a lookup among all the patterns specified on a
1061 configuration line (including all those loaded from files). It automatically
1062 invalidates entries which are updated using HTTP actions or on the CLI. The
1063 default cache size is set to 10000 entries, which limits its footprint to
1064 about 5 MB on 32-bit systems and 8 MB on 64-bit systems. There is a very low
1065 risk of collision in this cache, which is in the order of the size of the
1066 cache divided by 2^64. Typically, at 10000 requests per second with the
1067 default cache size of 10000 entries, there's 1% chance that a brute force
1068 attack could cause a single collision after 60 years, or 0.1% after 6 years.
1069 This is considered much lower than the risk of a memory corruption caused by
1070 aging components. If this is not acceptable, the cache can be disabled by
1071 setting this parameter to 0.
1072
Willy Tarreaubd9a0a72011-10-23 21:14:29 +02001073tune.pipesize <number>
1074 Sets the kernel pipe buffer size to this size (in bytes). By default, pipes
1075 are the default size for the system. But sometimes when using TCP splicing,
1076 it can improve performance to increase pipe sizes, especially if it is
1077 suspected that pipes are not filled and that many calls to splice() are
1078 performed. This has an impact on the kernel's memory footprint, so this must
1079 not be changed if impacts are not understood.
1080
Willy Tarreaue803de22010-01-21 17:43:04 +01001081tune.rcvbuf.client <number>
1082tune.rcvbuf.server <number>
1083 Forces the kernel socket receive buffer size on the client or the server side
1084 to the specified value in bytes. This value applies to all TCP/HTTP frontends
1085 and backends. It should normally never be set, and the default size (0) lets
1086 the kernel autotune this value depending on the amount of available memory.
1087 However it can sometimes help to set it to very low values (eg: 4096) in
1088 order to save kernel memory by preventing it from buffering too large amounts
1089 of received data. Lower values will significantly increase CPU usage though.
1090
1091tune.sndbuf.client <number>
1092tune.sndbuf.server <number>
1093 Forces the kernel socket send buffer size on the client or the server side to
1094 the specified value in bytes. This value applies to all TCP/HTTP frontends
1095 and backends. It should normally never be set, and the default size (0) lets
1096 the kernel autotune this value depending on the amount of available memory.
1097 However it can sometimes help to set it to very low values (eg: 4096) in
1098 order to save kernel memory by preventing it from buffering too large amounts
1099 of received data. Lower values will significantly increase CPU usage though.
1100 Another use case is to prevent write timeouts with extremely slow clients due
1101 to the kernel waiting for a large part of the buffer to be read before
1102 notifying haproxy again.
1103
Willy Tarreau6ec58db2012-11-16 16:32:15 +01001104tune.ssl.cachesize <number>
Emeric Brunaf9619d2012-11-28 18:47:52 +01001105 Sets the size of the global SSL session cache, in a number of blocks. A block
1106 is large enough to contain an encoded session without peer certificate.
1107 An encoded session with peer certificate is stored in multiple blocks
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001108 depending on the size of the peer certificate. A block uses approximately
Emeric Brunaf9619d2012-11-28 18:47:52 +01001109 200 bytes of memory. The default value may be forced at build time, otherwise
1110 defaults to 20000. When the cache is full, the most idle entries are purged
1111 and reassigned. Higher values reduce the occurrence of such a purge, hence
1112 the number of CPU-intensive SSL handshakes by ensuring that all users keep
1113 their session as long as possible. All entries are pre-allocated upon startup
Emeric Brun22890a12012-12-28 14:41:32 +01001114 and are shared between all processes if "nbproc" is greater than 1. Setting
1115 this value to 0 disables the SSL session cache.
Willy Tarreau6ec58db2012-11-16 16:32:15 +01001116
Emeric Brun8dc60392014-05-09 13:52:00 +02001117tune.ssl.force-private-cache
1118 This boolean disables SSL session cache sharing between all processes. It
1119 should normally not be used since it will force many renegotiations due to
1120 clients hitting a random process. But it may be required on some operating
1121 systems where none of the SSL cache synchronization method may be used. In
1122 this case, adding a first layer of hash-based load balancing before the SSL
1123 layer might limit the impact of the lack of session sharing.
1124
Emeric Brun4f65bff2012-11-16 15:11:00 +01001125tune.ssl.lifetime <timeout>
1126 Sets how long a cached SSL session may remain valid. This time is expressed
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001127 in seconds and defaults to 300 (5 min). It is important to understand that it
Emeric Brun4f65bff2012-11-16 15:11:00 +01001128 does not guarantee that sessions will last that long, because if the cache is
1129 full, the longest idle sessions will be purged despite their configured
1130 lifetime. The real usefulness of this setting is to prevent sessions from
1131 being used for too long.
1132
Willy Tarreaubfd59462013-02-21 07:46:09 +01001133tune.ssl.maxrecord <number>
1134 Sets the maximum amount of bytes passed to SSL_write() at a time. Default
1135 value 0 means there is no limit. Over SSL/TLS, the client can decipher the
1136 data only once it has received a full record. With large records, it means
1137 that clients might have to download up to 16kB of data before starting to
1138 process them. Limiting the value can improve page load times on browsers
1139 located over high latency or low bandwidth networks. It is suggested to find
1140 optimal values which fit into 1 or 2 TCP segments (generally 1448 bytes over
1141 Ethernet with TCP timestamps enabled, or 1460 when timestamps are disabled),
1142 keeping in mind that SSL/TLS add some overhead. Typical values of 1419 and
1143 2859 gave good results during tests. Use "strace -e trace=write" to find the
Willy Tarreau7e312732014-02-12 16:35:14 +01001144 best value. Haproxy will automatically switch to this setting after an idle
1145 stream has been detected (see tune.idletimer above).
Willy Tarreaubfd59462013-02-21 07:46:09 +01001146
Remi Gacognef46cd6e2014-06-12 14:58:40 +02001147tune.ssl.default-dh-param <number>
1148 Sets the maximum size of the Diffie-Hellman parameters used for generating
1149 the ephemeral/temporary Diffie-Hellman key in case of DHE key exchange. The
1150 final size will try to match the size of the server's RSA (or DSA) key (e.g,
1151 a 2048 bits temporary DH key for a 2048 bits RSA key), but will not exceed
1152 this maximum value. Default value if 1024. Only 1024 or higher values are
1153 allowed. Higher values will increase the CPU load, and values greater than
1154 1024 bits are not supported by Java 7 and earlier clients. This value is not
1155 used if static Diffie-Hellman parameters are supplied via the certificate file.
1156
William Lallemanda509e4c2012-11-07 16:54:34 +01001157tune.zlib.memlevel <number>
1158 Sets the memLevel parameter in zlib initialization for each session. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001159 defines how much memory should be allocated for the internal compression
William Lallemanda509e4c2012-11-07 16:54:34 +01001160 state. A value of 1 uses minimum memory but is slow and reduces compression
1161 ratio, a value of 9 uses maximum memory for optimal speed. Can be a value
1162 between 1 and 9. The default value is 8.
1163
1164tune.zlib.windowsize <number>
1165 Sets the window size (the size of the history buffer) as a parameter of the
1166 zlib initialization for each session. Larger values of this parameter result
1167 in better compression at the expense of memory usage. Can be a value between
1168 8 and 15. The default value is 15.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001169
Willy Tarreauc57f0e22009-05-10 13:12:33 +020011703.3. Debugging
1171--------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02001172
1173debug
1174 Enables debug mode which dumps to stdout all exchanges, and disables forking
1175 into background. It is the equivalent of the command-line argument "-d". It
1176 should never be used in a production configuration since it may prevent full
1177 system startup.
1178
1179quiet
1180 Do not display any message during startup. It is equivalent to the command-
1181 line argument "-q".
1182
Emeric Brunf099e792010-09-27 12:05:28 +02001183
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +010011843.4. Userlists
1185--------------
1186It is possible to control access to frontend/backend/listen sections or to
1187http stats by allowing only authenticated and authorized users. To do this,
1188it is required to create at least one userlist and to define users.
1189
1190userlist <listname>
Cyril Bonté78caf842010-03-10 22:41:43 +01001191 Creates new userlist with name <listname>. Many independent userlists can be
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001192 used to store authentication & authorization data for independent customers.
1193
1194group <groupname> [users <user>,<user>,(...)]
Cyril Bonté78caf842010-03-10 22:41:43 +01001195 Adds group <groupname> to the current userlist. It is also possible to
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001196 attach users to this group by using a comma separated list of names
1197 proceeded by "users" keyword.
1198
Cyril Bontéf0c60612010-02-06 14:44:47 +01001199user <username> [password|insecure-password <password>]
1200 [groups <group>,<group>,(...)]
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001201 Adds user <username> to the current userlist. Both secure (encrypted) and
1202 insecure (unencrypted) passwords can be used. Encrypted passwords are
Cyril Bonté78caf842010-03-10 22:41:43 +01001203 evaluated using the crypt(3) function so depending of the system's
1204 capabilities, different algorithms are supported. For example modern Glibc
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001205 based Linux system supports MD5, SHA-256, SHA-512 and of course classic,
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001206 DES-based method of encrypting passwords.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001207
1208
1209 Example:
Cyril Bontéf0c60612010-02-06 14:44:47 +01001210 userlist L1
1211 group G1 users tiger,scott
1212 group G2 users xdb,scott
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001213
Cyril Bontéf0c60612010-02-06 14:44:47 +01001214 user tiger password $6$k6y3o.eP$JlKBx9za9667qe4(...)xHSwRv6J.C0/D7cV91
1215 user scott insecure-password elgato
1216 user xdb insecure-password hello
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001217
Cyril Bontéf0c60612010-02-06 14:44:47 +01001218 userlist L2
1219 group G1
1220 group G2
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001221
Cyril Bontéf0c60612010-02-06 14:44:47 +01001222 user tiger password $6$k6y3o.eP$JlKBx(...)xHSwRv6J.C0/D7cV91 groups G1
1223 user scott insecure-password elgato groups G1,G2
1224 user xdb insecure-password hello groups G2
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001225
1226 Please note that both lists are functionally identical.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001227
Emeric Brunf099e792010-09-27 12:05:28 +02001228
12293.5. Peers
Cyril Bontédc4d9032012-04-08 21:57:39 +02001230----------
Emeric Brunf099e792010-09-27 12:05:28 +02001231It is possible to synchronize server entries in stick tables between several
1232haproxy instances over TCP connections in a multi-master fashion. Each instance
1233pushes its local updates and insertions to remote peers. Server IDs are used to
1234identify servers remotely, so it is important that configurations look similar
1235or at least that the same IDs are forced on each server on all participants.
1236Interrupted exchanges are automatically detected and recovered from the last
1237known point. In addition, during a soft restart, the old process connects to
1238the new one using such a TCP connection to push all its entries before the new
1239process tries to connect to other peers. That ensures very fast replication
1240during a reload, it typically takes a fraction of a second even for large
1241tables.
1242
1243peers <peersect>
Jamie Gloudon801a0a32012-08-25 00:18:33 -04001244 Creates a new peer list with name <peersect>. It is an independent section,
Emeric Brunf099e792010-09-27 12:05:28 +02001245 which is referenced by one or more stick-tables.
1246
1247peer <peername> <ip>:<port>
1248 Defines a peer inside a peers section.
1249 If <peername> is set to the local peer name (by default hostname, or forced
1250 using "-L" command line option), haproxy will listen for incoming remote peer
1251 connection on <ip>:<port>. Otherwise, <ip>:<port> defines where to connect to
1252 to join the remote peer, and <peername> is used at the protocol level to
1253 identify and validate the remote peer on the server side.
1254
1255 During a soft restart, local peer <ip>:<port> is used by the old instance to
1256 connect the new one and initiate a complete replication (teaching process).
1257
1258 It is strongly recommended to have the exact same peers declaration on all
1259 peers and to only rely on the "-L" command line argument to change the local
1260 peer name. This makes it easier to maintain coherent configuration files
1261 across all peers.
1262
Willy Tarreaudad36a32013-03-11 01:20:04 +01001263 Any part of the address string may reference any number of environment
1264 variables by preceding their name with a dollar sign ('$') and optionally
1265 enclosing them with braces ('{}'), similarly to what is done in Bourne shell.
1266
Cyril Bontédc4d9032012-04-08 21:57:39 +02001267 Example:
Emeric Brunf099e792010-09-27 12:05:28 +02001268 peers mypeers
Willy Tarreauf7b30a92010-12-06 22:59:17 +01001269 peer haproxy1 192.168.0.1:1024
1270 peer haproxy2 192.168.0.2:1024
1271 peer haproxy3 10.2.0.1:1024
Emeric Brunf099e792010-09-27 12:05:28 +02001272
1273 backend mybackend
1274 mode tcp
1275 balance roundrobin
1276 stick-table type ip size 20k peers mypeers
1277 stick on src
1278
Willy Tarreauf7b30a92010-12-06 22:59:17 +01001279 server srv1 192.168.0.30:80
1280 server srv2 192.168.0.31:80
Emeric Brunf099e792010-09-27 12:05:28 +02001281
1282
Simon Horman51a1cf62015-02-03 13:00:44 +090012833.6. Mailers
1284------------
1285It is possible to send email alerts when the state of servers changes.
1286If configured email alerts are sent to each mailer that is configured
1287in a mailers section. Email is sent to mailers using SMTP.
1288
1289mailer <mailersect>
1290 Creates a new mailer list with the name <mailersect>. It is an
1291 independent section which is referenced by one or more proxies.
1292
1293mailer <mailername> <ip>:<port>
1294 Defines a mailer inside a mailers section.
1295
1296 Example:
1297 mailers mymailers
1298 mailer smtp1 192.168.0.1:587
1299 mailer smtp2 192.168.0.2:587
1300
1301 backend mybackend
1302 mode tcp
1303 balance roundrobin
1304
1305 email-alert mailers mymailers
1306 email-alert from test1@horms.org
1307 email-alert to test2@horms.org
1308
1309 server srv1 192.168.0.30:80
1310 server srv2 192.168.0.31:80
1311
1312
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013134. Proxies
Willy Tarreau6a06a402007-07-15 20:15:28 +02001314----------
Willy Tarreau0ba27502007-12-24 16:55:16 +01001315
Willy Tarreau6a06a402007-07-15 20:15:28 +02001316Proxy configuration can be located in a set of sections :
1317 - defaults <name>
1318 - frontend <name>
1319 - backend <name>
1320 - listen <name>
1321
1322A "defaults" section sets default parameters for all other sections following
1323its declaration. Those default parameters are reset by the next "defaults"
1324section. See below for the list of parameters which can be set in a "defaults"
Willy Tarreau0ba27502007-12-24 16:55:16 +01001325section. The name is optional but its use is encouraged for better readability.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001326
1327A "frontend" section describes a set of listening sockets accepting client
1328connections.
1329
1330A "backend" section describes a set of servers to which the proxy will connect
1331to forward incoming connections.
1332
1333A "listen" section defines a complete proxy with its frontend and backend
1334parts combined in one section. It is generally useful for TCP-only traffic.
1335
Willy Tarreau0ba27502007-12-24 16:55:16 +01001336All proxy names must be formed from upper and lower case letters, digits,
1337'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
1338case-sensitive, which means that "www" and "WWW" are two different proxies.
1339
1340Historically, all proxy names could overlap, it just caused troubles in the
1341logs. Since the introduction of content switching, it is mandatory that two
1342proxies with overlapping capabilities (frontend/backend) have different names.
1343However, it is still permitted that a frontend and a backend share the same
1344name, as this configuration seems to be commonly encountered.
1345
1346Right now, two major proxy modes are supported : "tcp", also known as layer 4,
1347and "http", also known as layer 7. In layer 4 mode, HAProxy simply forwards
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001348bidirectional traffic between two sides. In layer 7 mode, HAProxy analyzes the
Willy Tarreau0ba27502007-12-24 16:55:16 +01001349protocol, and can interact with it by allowing, blocking, switching, adding,
1350modifying, or removing arbitrary contents in requests or responses, based on
1351arbitrary criteria.
1352
Willy Tarreau70dffda2014-01-30 03:07:23 +01001353In HTTP mode, the processing applied to requests and responses flowing over
1354a connection depends in the combination of the frontend's HTTP options and
1355the backend's. HAProxy supports 5 connection modes :
1356
1357 - KAL : keep alive ("option http-keep-alive") which is the default mode : all
1358 requests and responses are processed, and connections remain open but idle
1359 between responses and new requests.
1360
1361 - TUN: tunnel ("option http-tunnel") : this was the default mode for versions
1362 1.0 to 1.5-dev21 : only the first request and response are processed, and
1363 everything else is forwarded with no analysis at all. This mode should not
1364 be used as it creates lots of trouble with logging and HTTP processing.
1365
1366 - PCL: passive close ("option httpclose") : exactly the same as tunnel mode,
1367 but with "Connection: close" appended in both directions to try to make
1368 both ends close after the first request/response exchange.
1369
1370 - SCL: server close ("option http-server-close") : the server-facing
1371 connection is closed after the end of the response is received, but the
1372 client-facing connection remains open.
1373
1374 - FCL: forced close ("option forceclose") : the connection is actively closed
1375 after the end of the response.
1376
1377The effective mode that will be applied to a connection passing through a
1378frontend and a backend can be determined by both proxy modes according to the
1379following matrix, but in short, the modes are symmetric, keep-alive is the
1380weakest option and force close is the strongest.
1381
1382 Backend mode
1383
1384 | KAL | TUN | PCL | SCL | FCL
1385 ----+-----+-----+-----+-----+----
1386 KAL | KAL | TUN | PCL | SCL | FCL
1387 ----+-----+-----+-----+-----+----
1388 TUN | TUN | TUN | PCL | SCL | FCL
1389 Frontend ----+-----+-----+-----+-----+----
1390 mode PCL | PCL | PCL | PCL | FCL | FCL
1391 ----+-----+-----+-----+-----+----
1392 SCL | SCL | SCL | FCL | SCL | FCL
1393 ----+-----+-----+-----+-----+----
1394 FCL | FCL | FCL | FCL | FCL | FCL
1395
Willy Tarreau0ba27502007-12-24 16:55:16 +01001396
Willy Tarreau70dffda2014-01-30 03:07:23 +01001397
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013984.1. Proxy keywords matrix
1399--------------------------
Willy Tarreau0ba27502007-12-24 16:55:16 +01001400
Willy Tarreauc57f0e22009-05-10 13:12:33 +02001401The following list of keywords is supported. Most of them may only be used in a
1402limited set of section types. Some of them are marked as "deprecated" because
1403they are inherited from an old syntax which may be confusing or functionally
1404limited, and there are new recommended keywords to replace them. Keywords
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001405marked with "(*)" can be optionally inverted using the "no" prefix, eg. "no
Willy Tarreauc57f0e22009-05-10 13:12:33 +02001406option contstats". This makes sense when the option has been enabled by default
Willy Tarreau3842f002009-06-14 11:39:52 +02001407and must be disabled for a specific instance. Such options may also be prefixed
1408with "default" in order to restore default settings regardless of what has been
1409specified in a previous "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001410
Willy Tarreau6a06a402007-07-15 20:15:28 +02001411
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001412 keyword defaults frontend listen backend
1413------------------------------------+----------+----------+---------+---------
1414acl - X X X
1415appsession - - X X
1416backlog X X X -
1417balance X - X X
1418bind - X X -
1419bind-process X X X X
1420block - X X X
1421capture cookie - X X -
1422capture request header - X X -
1423capture response header - X X -
1424clitimeout (deprecated) X X X -
William Lallemand82fe75c2012-10-23 10:25:10 +02001425compression X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001426contimeout (deprecated) X - X X
1427cookie X - X X
1428default-server X - X X
1429default_backend X X X -
1430description - X X X
1431disabled X X X X
1432dispatch - - X X
Simon Horman51a1cf62015-02-03 13:00:44 +09001433email-alert from X X X X
Simon Horman64e34162015-02-06 11:11:57 +09001434email-alert level X X X X
Simon Horman51a1cf62015-02-03 13:00:44 +09001435email-alert mailers X X X X
1436email-alert myhostname X X X X
1437email-alert to X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001438enabled X X X X
1439errorfile X X X X
1440errorloc X X X X
1441errorloc302 X X X X
1442-- keyword -------------------------- defaults - frontend - listen -- backend -
1443errorloc303 X X X X
Cyril Bonté0d4bf012010-04-25 23:21:46 +02001444force-persist - X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001445fullconn X - X X
1446grace X X X X
1447hash-type X - X X
1448http-check disable-on-404 X - X X
Willy Tarreaubd741542010-03-16 18:46:54 +01001449http-check expect - - X X
Willy Tarreau7ab6aff2010-10-12 06:30:16 +02001450http-check send-state X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001451http-request - X X X
Willy Tarreaue365c0b2013-06-11 16:06:12 +02001452http-response - X X X
Baptiste Assmann2c42ef52013-10-09 21:57:02 +02001453http-send-name-header - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001454id - X X X
Cyril Bonté0d4bf012010-04-25 23:21:46 +02001455ignore-persist - X X X
William Lallemand0f99e342011-10-12 17:50:54 +02001456log (*) X X X X
Willy Tarreaufb4e7ea2015-01-07 14:55:17 +01001457log-format X X X -
Willy Tarreau094af4e2015-01-07 15:03:42 +01001458log-tag X X X X
Willy Tarreauc35362a2014-04-25 13:58:37 +02001459max-keep-alive-queue X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001460maxconn X X X -
1461mode X X X X
1462monitor fail - X X -
1463monitor-net X X X -
1464monitor-uri X X X -
1465option abortonclose (*) X - X X
1466option accept-invalid-http-request (*) X X X -
1467option accept-invalid-http-response (*) X - X X
1468option allbackups (*) X - X X
1469option checkcache (*) X - X X
1470option clitcpka (*) X X X -
1471option contstats (*) X X X -
1472option dontlog-normal (*) X X X -
1473option dontlognull (*) X X X -
1474option forceclose (*) X X X X
1475-- keyword -------------------------- defaults - frontend - listen -- backend -
1476option forwardfor X X X X
Willy Tarreau16bfb022010-01-16 19:48:41 +01001477option http-keep-alive (*) X X X X
Willy Tarreau96e31212011-05-30 18:10:30 +02001478option http-no-delay (*) X X X X
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02001479option http-pretend-keepalive (*) X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001480option http-server-close (*) X X X X
Willy Tarreau02bce8b2014-01-30 00:15:28 +01001481option http-tunnel (*) X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001482option http-use-proxy-header (*) X X X -
1483option httpchk X - X X
1484option httpclose (*) X X X X
1485option httplog X X X X
1486option http_proxy (*) X X X X
Jamie Gloudon801a0a32012-08-25 00:18:33 -04001487option independent-streams (*) X X X X
Gabor Lekenyb4c81e42010-09-29 18:17:05 +02001488option ldap-check X - X X
Simon Horman98637e52014-06-20 12:30:16 +09001489option external-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001490option log-health-checks (*) X - X X
1491option log-separate-errors (*) X X X -
1492option logasap (*) X X X -
1493option mysql-check X - X X
Rauf Kuliyev38b41562011-01-04 15:14:13 +01001494option pgsql-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001495option nolinger (*) X X X X
1496option originalto X X X X
1497option persist (*) X - X X
1498option redispatch (*) X - X X
Hervé COMMOWICKec032d62011-08-05 16:23:48 +02001499option redis-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001500option smtpchk X - X X
1501option socket-stats (*) X X X -
1502option splice-auto (*) X X X X
1503option splice-request (*) X X X X
1504option splice-response (*) X X X X
1505option srvtcpka (*) X - X X
1506option ssl-hello-chk X - X X
1507-- keyword -------------------------- defaults - frontend - listen -- backend -
Willy Tarreaued179852013-12-16 01:07:00 +01001508option tcp-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001509option tcp-smart-accept (*) X X X -
1510option tcp-smart-connect (*) X - X X
1511option tcpka X X X X
1512option tcplog X X X X
1513option transparent (*) X - X X
Simon Horman98637e52014-06-20 12:30:16 +09001514external-check command X - X X
1515external-check path X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001516persist rdp-cookie X - X X
1517rate-limit sessions X X X -
1518redirect - X X X
1519redisp (deprecated) X - X X
1520redispatch (deprecated) X - X X
1521reqadd - X X X
1522reqallow - X X X
1523reqdel - X X X
1524reqdeny - X X X
1525reqiallow - X X X
1526reqidel - X X X
1527reqideny - X X X
1528reqipass - X X X
1529reqirep - X X X
1530reqisetbe - X X X
1531reqitarpit - X X X
1532reqpass - X X X
1533reqrep - X X X
1534-- keyword -------------------------- defaults - frontend - listen -- backend -
1535reqsetbe - X X X
1536reqtarpit - X X X
1537retries X - X X
1538rspadd - X X X
1539rspdel - X X X
1540rspdeny - X X X
1541rspidel - X X X
1542rspideny - X X X
1543rspirep - X X X
1544rsprep - X X X
1545server - - X X
1546source X - X X
1547srvtimeout (deprecated) X - X X
Cyril Bonté66c327d2010-10-12 00:14:37 +02001548stats admin - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001549stats auth X - X X
1550stats enable X - X X
1551stats hide-version X - X X
Cyril Bonté2be1b3f2010-09-30 23:46:30 +02001552stats http-request - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001553stats realm X - X X
1554stats refresh X - X X
1555stats scope X - X X
1556stats show-desc X - X X
1557stats show-legends X - X X
1558stats show-node X - X X
1559stats uri X - X X
1560-- keyword -------------------------- defaults - frontend - listen -- backend -
1561stick match - - X X
1562stick on - - X X
1563stick store-request - - X X
Willy Tarreaud8dc99f2011-07-01 11:33:25 +02001564stick store-response - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001565stick-table - - X X
Willy Tarreau938c7fe2014-04-25 14:21:39 +02001566tcp-check connect - - X X
1567tcp-check expect - - X X
1568tcp-check send - - X X
1569tcp-check send-binary - - X X
Willy Tarreaue9656522010-08-17 15:40:09 +02001570tcp-request connection - X X -
1571tcp-request content - X X X
Willy Tarreaua56235c2010-09-14 11:31:36 +02001572tcp-request inspect-delay - X X X
Emeric Brun0a3b67f2010-09-24 15:34:53 +02001573tcp-response content - - X X
1574tcp-response inspect-delay - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001575timeout check X - X X
1576timeout client X X X -
Willy Tarreau05cdd962014-05-10 14:30:07 +02001577timeout client-fin X X X -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001578timeout clitimeout (deprecated) X X X -
1579timeout connect X - X X
1580timeout contimeout (deprecated) X - X X
1581timeout http-keep-alive X X X X
1582timeout http-request X X X X
1583timeout queue X - X X
1584timeout server X - X X
Willy Tarreau05cdd962014-05-10 14:30:07 +02001585timeout server-fin X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001586timeout srvtimeout (deprecated) X - X X
1587timeout tarpit X X X X
Willy Tarreauce887fd2012-05-12 12:50:00 +02001588timeout tunnel X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001589transparent (deprecated) X - X X
William Lallemanda73203e2012-03-12 12:48:57 +01001590unique-id-format X X X -
1591unique-id-header X X X -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001592use_backend - X X -
Willy Tarreau4a5cade2012-04-05 21:09:48 +02001593use-server - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001594------------------------------------+----------+----------+---------+---------
1595 keyword defaults frontend listen backend
Willy Tarreau6a06a402007-07-15 20:15:28 +02001596
Willy Tarreau0ba27502007-12-24 16:55:16 +01001597
Willy Tarreauc57f0e22009-05-10 13:12:33 +020015984.2. Alphabetically sorted keywords reference
1599---------------------------------------------
Willy Tarreau0ba27502007-12-24 16:55:16 +01001600
1601This section provides a description of each keyword and its usage.
1602
1603
1604acl <aclname> <criterion> [flags] [operator] <value> ...
1605 Declare or complete an access list.
1606 May be used in sections : defaults | frontend | listen | backend
1607 no | yes | yes | yes
1608 Example:
1609 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
1610 acl invalid_src src_port 0:1023
1611 acl local_dst hdr(host) -i localhost
1612
Willy Tarreauc57f0e22009-05-10 13:12:33 +02001613 See section 7 about ACL usage.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001614
1615
Cyril Bontéb21570a2009-11-29 20:04:48 +01001616appsession <cookie> len <length> timeout <holdtime>
1617 [request-learn] [prefix] [mode <path-parameters|query-string>]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001618 Define session stickiness on an existing application cookie.
1619 May be used in sections : defaults | frontend | listen | backend
1620 no | no | yes | yes
1621 Arguments :
1622 <cookie> this is the name of the cookie used by the application and which
1623 HAProxy will have to learn for each new session.
1624
Cyril Bontéb21570a2009-11-29 20:04:48 +01001625 <length> this is the max number of characters that will be memorized and
Willy Tarreau0ba27502007-12-24 16:55:16 +01001626 checked in each cookie value.
1627
1628 <holdtime> this is the time after which the cookie will be removed from
1629 memory if unused. If no unit is specified, this time is in
1630 milliseconds.
1631
Cyril Bontébf47aeb2009-10-15 00:15:40 +02001632 request-learn
1633 If this option is specified, then haproxy will be able to learn
1634 the cookie found in the request in case the server does not
1635 specify any in response. This is typically what happens with
1636 PHPSESSID cookies, or when haproxy's session expires before
1637 the application's session and the correct server is selected.
1638 It is recommended to specify this option to improve reliability.
1639
Cyril Bontéb21570a2009-11-29 20:04:48 +01001640 prefix When this option is specified, haproxy will match on the cookie
1641 prefix (or URL parameter prefix). The appsession value is the
1642 data following this prefix.
1643
1644 Example :
1645 appsession ASPSESSIONID len 64 timeout 3h prefix
1646
1647 This will match the cookie ASPSESSIONIDXXXX=XXXXX,
1648 the appsession value will be XXXX=XXXXX.
1649
1650 mode This option allows to change the URL parser mode.
1651 2 modes are currently supported :
1652 - path-parameters :
1653 The parser looks for the appsession in the path parameters
1654 part (each parameter is separated by a semi-colon), which is
1655 convenient for JSESSIONID for example.
1656 This is the default mode if the option is not set.
1657 - query-string :
1658 In this mode, the parser will look for the appsession in the
1659 query string.
1660
Willy Tarreau0ba27502007-12-24 16:55:16 +01001661 When an application cookie is defined in a backend, HAProxy will check when
1662 the server sets such a cookie, and will store its value in a table, and
1663 associate it with the server's identifier. Up to <length> characters from
1664 the value will be retained. On each connection, haproxy will look for this
Cyril Bontéb21570a2009-11-29 20:04:48 +01001665 cookie both in the "Cookie:" headers, and as a URL parameter (depending on
1666 the mode used). If a known value is found, the client will be directed to the
1667 server associated with this value. Otherwise, the load balancing algorithm is
Willy Tarreau0ba27502007-12-24 16:55:16 +01001668 applied. Cookies are automatically removed from memory when they have been
1669 unused for a duration longer than <holdtime>.
1670
1671 The definition of an application cookie is limited to one per backend.
1672
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01001673 Note : Consider not using this feature in multi-process mode (nbproc > 1)
1674 unless you know what you do : memory is not shared between the
1675 processes, which can result in random behaviours.
1676
Willy Tarreau0ba27502007-12-24 16:55:16 +01001677 Example :
1678 appsession JSESSIONID len 52 timeout 3h
1679
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01001680 See also : "cookie", "capture cookie", "balance", "stick", "stick-table",
1681 "ignore-persist", "nbproc" and "bind-process".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001682
1683
Willy Tarreauc73ce2b2008-01-06 10:55:10 +01001684backlog <conns>
1685 Give hints to the system about the approximate listen backlog desired size
1686 May be used in sections : defaults | frontend | listen | backend
1687 yes | yes | yes | no
1688 Arguments :
1689 <conns> is the number of pending connections. Depending on the operating
1690 system, it may represent the number of already acknowledged
Cyril Bontédc4d9032012-04-08 21:57:39 +02001691 connections, of non-acknowledged ones, or both.
Willy Tarreauc73ce2b2008-01-06 10:55:10 +01001692
1693 In order to protect against SYN flood attacks, one solution is to increase
1694 the system's SYN backlog size. Depending on the system, sometimes it is just
1695 tunable via a system parameter, sometimes it is not adjustable at all, and
1696 sometimes the system relies on hints given by the application at the time of
1697 the listen() syscall. By default, HAProxy passes the frontend's maxconn value
1698 to the listen() syscall. On systems which can make use of this value, it can
1699 sometimes be useful to be able to specify a different value, hence this
1700 backlog parameter.
1701
1702 On Linux 2.4, the parameter is ignored by the system. On Linux 2.6, it is
1703 used as a hint and the system accepts up to the smallest greater power of
1704 two, and never more than some limits (usually 32768).
1705
1706 See also : "maxconn" and the target operating system's tuning guide.
1707
1708
Willy Tarreau0ba27502007-12-24 16:55:16 +01001709balance <algorithm> [ <arguments> ]
Willy Tarreau226071e2014-04-10 11:55:45 +02001710balance url_param <param> [check_post]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001711 Define the load balancing algorithm to be used in a backend.
1712 May be used in sections : defaults | frontend | listen | backend
1713 yes | no | yes | yes
1714 Arguments :
1715 <algorithm> is the algorithm used to select a server when doing load
1716 balancing. This only applies when no persistence information
1717 is available, or when a connection is redispatched to another
1718 server. <algorithm> may be one of the following :
1719
1720 roundrobin Each server is used in turns, according to their weights.
1721 This is the smoothest and fairest algorithm when the server's
1722 processing time remains equally distributed. This algorithm
1723 is dynamic, which means that server weights may be adjusted
Willy Tarreau9757a382009-10-03 12:56:50 +02001724 on the fly for slow starts for instance. It is limited by
Godbacha34bdc02013-07-22 07:44:53 +08001725 design to 4095 active servers per backend. Note that in some
Willy Tarreau9757a382009-10-03 12:56:50 +02001726 large farms, when a server becomes up after having been down
1727 for a very short time, it may sometimes take a few hundreds
1728 requests for it to be re-integrated into the farm and start
1729 receiving traffic. This is normal, though very rare. It is
1730 indicated here in case you would have the chance to observe
1731 it, so that you don't worry.
1732
1733 static-rr Each server is used in turns, according to their weights.
1734 This algorithm is as similar to roundrobin except that it is
1735 static, which means that changing a server's weight on the
1736 fly will have no effect. On the other hand, it has no design
1737 limitation on the number of servers, and when a server goes
1738 up, it is always immediately reintroduced into the farm, once
1739 the full map is recomputed. It also uses slightly less CPU to
1740 run (around -1%).
Willy Tarreau0ba27502007-12-24 16:55:16 +01001741
Willy Tarreau2d2a7f82008-03-17 12:07:56 +01001742 leastconn The server with the lowest number of connections receives the
1743 connection. Round-robin is performed within groups of servers
1744 of the same load to ensure that all servers will be used. Use
1745 of this algorithm is recommended where very long sessions are
1746 expected, such as LDAP, SQL, TSE, etc... but is not very well
1747 suited for protocols using short sessions such as HTTP. This
1748 algorithm is dynamic, which means that server weights may be
1749 adjusted on the fly for slow starts for instance.
1750
Willy Tarreauf09c6602012-02-13 17:12:08 +01001751 first The first server with available connection slots receives the
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001752 connection. The servers are chosen from the lowest numeric
Willy Tarreauf09c6602012-02-13 17:12:08 +01001753 identifier to the highest (see server parameter "id"), which
1754 defaults to the server's position in the farm. Once a server
Willy Tarreau64559c52012-04-07 09:08:45 +02001755 reaches its maxconn value, the next server is used. It does
Willy Tarreauf09c6602012-02-13 17:12:08 +01001756 not make sense to use this algorithm without setting maxconn.
1757 The purpose of this algorithm is to always use the smallest
1758 number of servers so that extra servers can be powered off
1759 during non-intensive hours. This algorithm ignores the server
1760 weight, and brings more benefit to long session such as RDP
Willy Tarreau64559c52012-04-07 09:08:45 +02001761 or IMAP than HTTP, though it can be useful there too. In
1762 order to use this algorithm efficiently, it is recommended
1763 that a cloud controller regularly checks server usage to turn
1764 them off when unused, and regularly checks backend queue to
1765 turn new servers on when the queue inflates. Alternatively,
1766 using "http-check send-state" may inform servers on the load.
Willy Tarreauf09c6602012-02-13 17:12:08 +01001767
Willy Tarreau0ba27502007-12-24 16:55:16 +01001768 source The source IP address is hashed and divided by the total
1769 weight of the running servers to designate which server will
1770 receive the request. This ensures that the same client IP
1771 address will always reach the same server as long as no
1772 server goes down or up. If the hash result changes due to the
1773 number of running servers changing, many clients will be
1774 directed to a different server. This algorithm is generally
1775 used in TCP mode where no cookie may be inserted. It may also
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001776 be used on the Internet to provide a best-effort stickiness
Willy Tarreau0ba27502007-12-24 16:55:16 +01001777 to clients which refuse session cookies. This algorithm is
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001778 static by default, which means that changing a server's
1779 weight on the fly will have no effect, but this can be
1780 changed using "hash-type".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001781
Oskar Stolc8dc41842012-05-19 10:19:54 +01001782 uri This algorithm hashes either the left part of the URI (before
1783 the question mark) or the whole URI (if the "whole" parameter
1784 is present) and divides the hash value by the total weight of
1785 the running servers. The result designates which server will
1786 receive the request. This ensures that the same URI will
1787 always be directed to the same server as long as no server
1788 goes up or down. This is used with proxy caches and
1789 anti-virus proxies in order to maximize the cache hit rate.
1790 Note that this algorithm may only be used in an HTTP backend.
1791 This algorithm is static by default, which means that
1792 changing a server's weight on the fly will have no effect,
1793 but this can be changed using "hash-type".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001794
Oskar Stolc8dc41842012-05-19 10:19:54 +01001795 This algorithm supports two optional parameters "len" and
Marek Majkowski9c30fc12008-04-27 23:25:55 +02001796 "depth", both followed by a positive integer number. These
1797 options may be helpful when it is needed to balance servers
1798 based on the beginning of the URI only. The "len" parameter
1799 indicates that the algorithm should only consider that many
1800 characters at the beginning of the URI to compute the hash.
1801 Note that having "len" set to 1 rarely makes sense since most
1802 URIs start with a leading "/".
1803
1804 The "depth" parameter indicates the maximum directory depth
1805 to be used to compute the hash. One level is counted for each
1806 slash in the request. If both parameters are specified, the
1807 evaluation stops when either is reached.
1808
Willy Tarreau0ba27502007-12-24 16:55:16 +01001809 url_param The URL parameter specified in argument will be looked up in
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001810 the query string of each HTTP GET request.
1811
1812 If the modifier "check_post" is used, then an HTTP POST
Cyril Bontédc4d9032012-04-08 21:57:39 +02001813 request entity will be searched for the parameter argument,
1814 when it is not found in a query string after a question mark
Willy Tarreau226071e2014-04-10 11:55:45 +02001815 ('?') in the URL. The message body will only start to be
1816 analyzed once either the advertised amount of data has been
1817 received or the request buffer is full. In the unlikely event
1818 that chunked encoding is used, only the first chunk is
Cyril Bontédc4d9032012-04-08 21:57:39 +02001819 scanned. Parameter values separated by a chunk boundary, may
Willy Tarreau226071e2014-04-10 11:55:45 +02001820 be randomly balanced if at all. This keyword used to support
1821 an optional <max_wait> parameter which is now ignored.
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001822
1823 If the parameter is found followed by an equal sign ('=') and
1824 a value, then the value is hashed and divided by the total
1825 weight of the running servers. The result designates which
1826 server will receive the request.
1827
1828 This is used to track user identifiers in requests and ensure
1829 that a same user ID will always be sent to the same server as
1830 long as no server goes up or down. If no value is found or if
1831 the parameter is not found, then a round robin algorithm is
1832 applied. Note that this algorithm may only be used in an HTTP
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001833 backend. This algorithm is static by default, which means
1834 that changing a server's weight on the fly will have no
1835 effect, but this can be changed using "hash-type".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001836
Cyril Bontédc4d9032012-04-08 21:57:39 +02001837 hdr(<name>) The HTTP header <name> will be looked up in each HTTP
1838 request. Just as with the equivalent ACL 'hdr()' function,
1839 the header name in parenthesis is not case sensitive. If the
1840 header is absent or if it does not contain any value, the
1841 roundrobin algorithm is applied instead.
Benoitaffb4812009-03-25 13:02:10 +01001842
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001843 An optional 'use_domain_only' parameter is available, for
Benoitaffb4812009-03-25 13:02:10 +01001844 reducing the hash algorithm to the main domain part with some
1845 specific headers such as 'Host'. For instance, in the Host
1846 value "haproxy.1wt.eu", only "1wt" will be considered.
1847
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001848 This algorithm is static by default, which means that
1849 changing a server's weight on the fly will have no effect,
1850 but this can be changed using "hash-type".
1851
Emeric Brun736aa232009-06-30 17:56:00 +02001852 rdp-cookie
Hervé COMMOWICKa3eb39c2011-08-05 18:48:51 +02001853 rdp-cookie(<name>)
Emeric Brun736aa232009-06-30 17:56:00 +02001854 The RDP cookie <name> (or "mstshash" if omitted) will be
1855 looked up and hashed for each incoming TCP request. Just as
1856 with the equivalent ACL 'req_rdp_cookie()' function, the name
1857 is not case-sensitive. This mechanism is useful as a degraded
1858 persistence mode, as it makes it possible to always send the
1859 same user (or the same session ID) to the same server. If the
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001860 cookie is not found, the normal roundrobin algorithm is
Emeric Brun736aa232009-06-30 17:56:00 +02001861 used instead.
1862
1863 Note that for this to work, the frontend must ensure that an
1864 RDP cookie is already present in the request buffer. For this
1865 you must use 'tcp-request content accept' rule combined with
1866 a 'req_rdp_cookie_cnt' ACL.
1867
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001868 This algorithm is static by default, which means that
1869 changing a server's weight on the fly will have no effect,
1870 but this can be changed using "hash-type".
1871
Cyril Bontédc4d9032012-04-08 21:57:39 +02001872 See also the rdp_cookie pattern fetch function.
Simon Hormanab814e02011-06-24 14:50:20 +09001873
Willy Tarreau0ba27502007-12-24 16:55:16 +01001874 <arguments> is an optional list of arguments which may be needed by some
Marek Majkowski9c30fc12008-04-27 23:25:55 +02001875 algorithms. Right now, only "url_param" and "uri" support an
1876 optional argument.
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001877
Willy Tarreau3cd9af22009-03-15 14:06:41 +01001878 The load balancing algorithm of a backend is set to roundrobin when no other
1879 algorithm, mode nor option have been set. The algorithm may only be set once
1880 for each backend.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001881
1882 Examples :
1883 balance roundrobin
1884 balance url_param userid
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001885 balance url_param session_id check_post 64
Benoitaffb4812009-03-25 13:02:10 +01001886 balance hdr(User-Agent)
1887 balance hdr(host)
1888 balance hdr(Host) use_domain_only
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001889
1890 Note: the following caveats and limitations on using the "check_post"
1891 extension with "url_param" must be considered :
1892
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001893 - all POST requests are eligible for consideration, because there is no way
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001894 to determine if the parameters will be found in the body or entity which
1895 may contain binary data. Therefore another method may be required to
1896 restrict consideration of POST requests that have no URL parameters in
1897 the body. (see acl reqideny http_end)
1898
1899 - using a <max_wait> value larger than the request buffer size does not
1900 make sense and is useless. The buffer size is set at build time, and
1901 defaults to 16 kB.
1902
1903 - Content-Encoding is not supported, the parameter search will probably
1904 fail; and load balancing will fall back to Round Robin.
1905
1906 - Expect: 100-continue is not supported, load balancing will fall back to
1907 Round Robin.
1908
1909 - Transfer-Encoding (RFC2616 3.6.1) is only supported in the first chunk.
1910 If the entire parameter value is not present in the first chunk, the
1911 selection of server is undefined (actually, defined by how little
1912 actually appeared in the first chunk).
1913
1914 - This feature does not support generation of a 100, 411 or 501 response.
1915
1916 - In some cases, requesting "check_post" MAY attempt to scan the entire
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001917 contents of a message body. Scanning normally terminates when linear
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001918 white space or control characters are found, indicating the end of what
1919 might be a URL parameter list. This is probably not a concern with SGML
1920 type message bodies.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001921
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001922 See also : "dispatch", "cookie", "appsession", "transparent", "hash-type" and
1923 "http_proxy".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001924
1925
Willy Tarreaub6205fd2012-09-24 12:27:33 +02001926bind [<address>]:<port_range> [, ...] [param*]
1927bind /<path> [, ...] [param*]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001928 Define one or several listening addresses and/or ports in a frontend.
1929 May be used in sections : defaults | frontend | listen | backend
1930 no | yes | yes | no
1931 Arguments :
Willy Tarreaub1e52e82008-01-13 14:49:51 +01001932 <address> is optional and can be a host name, an IPv4 address, an IPv6
1933 address, or '*'. It designates the address the frontend will
1934 listen on. If unset, all IPv4 addresses of the system will be
1935 listened on. The same will apply for '*' or the system's
David du Colombier9c938da2011-03-17 10:40:27 +01001936 special address "0.0.0.0". The IPv6 equivalent is '::'.
Willy Tarreau24709282013-03-10 21:32:12 +01001937 Optionally, an address family prefix may be used before the
1938 address to force the family regardless of the address format,
1939 which can be useful to specify a path to a unix socket with
1940 no slash ('/'). Currently supported prefixes are :
1941 - 'ipv4@' -> address is always IPv4
1942 - 'ipv6@' -> address is always IPv6
1943 - 'unix@' -> address is a path to a local unix socket
Willy Tarreau70f72e02014-07-08 00:37:50 +02001944 - 'abns@' -> address is in abstract namespace (Linux only).
1945 Note: since abstract sockets are not "rebindable", they
1946 do not cope well with multi-process mode during
1947 soft-restart, so it is better to avoid them if
1948 nbproc is greater than 1. The effect is that if the
1949 new process fails to start, only one of the old ones
1950 will be able to rebind to the socket.
Willy Tarreau40aa0702013-03-10 23:51:38 +01001951 - 'fd@<n>' -> use file descriptor <n> inherited from the
1952 parent. The fd must be bound and may or may not already
1953 be listening.
Willy Tarreaudad36a32013-03-11 01:20:04 +01001954 Any part of the address string may reference any number of
1955 environment variables by preceding their name with a dollar
1956 sign ('$') and optionally enclosing them with braces ('{}'),
1957 similarly to what is done in Bourne shell.
Willy Tarreaub1e52e82008-01-13 14:49:51 +01001958
Willy Tarreauc5011ca2010-03-22 11:53:56 +01001959 <port_range> is either a unique TCP port, or a port range for which the
1960 proxy will accept connections for the IP address specified
Willy Tarreauceb24bc2010-11-09 12:46:41 +01001961 above. The port is mandatory for TCP listeners. Note that in
1962 the case of an IPv6 address, the port is always the number
1963 after the last colon (':'). A range can either be :
Willy Tarreauc5011ca2010-03-22 11:53:56 +01001964 - a numerical port (ex: '80')
1965 - a dash-delimited ports range explicitly stating the lower
1966 and upper bounds (ex: '2000-2100') which are included in
1967 the range.
1968
1969 Particular care must be taken against port ranges, because
1970 every <address:port> couple consumes one socket (= a file
1971 descriptor), so it's easy to consume lots of descriptors
1972 with a simple range, and to run out of sockets. Also, each
1973 <address:port> couple must be used only once among all
1974 instances running on a same system. Please note that binding
1975 to ports lower than 1024 generally require particular
Jamie Gloudon801a0a32012-08-25 00:18:33 -04001976 privileges to start the program, which are independent of
Willy Tarreauc5011ca2010-03-22 11:53:56 +01001977 the 'uid' parameter.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001978
Willy Tarreauceb24bc2010-11-09 12:46:41 +01001979 <path> is a UNIX socket path beginning with a slash ('/'). This is
1980 alternative to the TCP listening port. Haproxy will then
1981 receive UNIX connections on the socket located at this place.
1982 The path must begin with a slash and by default is absolute.
1983 It can be relative to the prefix defined by "unix-bind" in
1984 the global section. Note that the total length of the prefix
1985 followed by the socket path cannot exceed some system limits
1986 for UNIX sockets, which commonly are set to 107 characters.
1987
Willy Tarreaub6205fd2012-09-24 12:27:33 +02001988 <param*> is a list of parameters common to all sockets declared on the
1989 same line. These numerous parameters depend on OS and build
1990 options and have a complete section dedicated to them. Please
1991 refer to section 5 to for more details.
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02001992
Willy Tarreau0ba27502007-12-24 16:55:16 +01001993 It is possible to specify a list of address:port combinations delimited by
1994 commas. The frontend will then listen on all of these addresses. There is no
1995 fixed limit to the number of addresses and ports which can be listened on in
1996 a frontend, as well as there is no limit to the number of "bind" statements
1997 in a frontend.
1998
1999 Example :
2000 listen http_proxy
2001 bind :80,:443
2002 bind 10.0.0.1:10080,10.0.0.1:10443
Willy Tarreauceb24bc2010-11-09 12:46:41 +01002003 bind /var/run/ssl-frontend.sock user root mode 600 accept-proxy
Willy Tarreau0ba27502007-12-24 16:55:16 +01002004
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02002005 listen http_https_proxy
2006 bind :80
Cyril Bonté0d44fc62012-10-09 22:45:33 +02002007 bind :443 ssl crt /etc/haproxy/site.pem
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02002008
Willy Tarreau24709282013-03-10 21:32:12 +01002009 listen http_https_proxy_explicit
2010 bind ipv6@:80
2011 bind ipv4@public_ssl:443 ssl crt /etc/haproxy/site.pem
2012 bind unix@ssl-frontend.sock user root mode 600 accept-proxy
2013
Willy Tarreaudad36a32013-03-11 01:20:04 +01002014 listen external_bind_app1
2015 bind fd@${FD_APP1}
2016
Willy Tarreauceb24bc2010-11-09 12:46:41 +01002017 See also : "source", "option forwardfor", "unix-bind" and the PROXY protocol
Willy Tarreaub6205fd2012-09-24 12:27:33 +02002018 documentation, and section 5 about bind options.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002019
2020
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002021bind-process [ all | odd | even | <number 1-64>[-<number 1-64>] ] ...
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002022 Limit visibility of an instance to a certain set of processes numbers.
2023 May be used in sections : defaults | frontend | listen | backend
2024 yes | yes | yes | yes
2025 Arguments :
2026 all All process will see this instance. This is the default. It
2027 may be used to override a default value.
2028
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002029 odd This instance will be enabled on processes 1,3,5,...63. This
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002030 option may be combined with other numbers.
2031
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002032 even This instance will be enabled on processes 2,4,6,...64. This
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002033 option may be combined with other numbers. Do not use it
2034 with less than 2 processes otherwise some instances might be
2035 missing from all processes.
2036
Willy Tarreau110ecc12012-11-15 17:50:01 +01002037 number The instance will be enabled on this process number or range,
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002038 whose values must all be between 1 and 32 or 64 depending on
Willy Tarreau102df612014-05-07 23:56:38 +02002039 the machine's word size. If a proxy is bound to process
2040 numbers greater than the configured global.nbproc, it will
2041 either be forced to process #1 if a single process was
2042 specified, or to all processes otherwise.
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002043
2044 This keyword limits binding of certain instances to certain processes. This
2045 is useful in order not to have too many processes listening to the same
2046 ports. For instance, on a dual-core machine, it might make sense to set
2047 'nbproc 2' in the global section, then distributes the listeners among 'odd'
2048 and 'even' instances.
2049
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002050 At the moment, it is not possible to reference more than 32 or 64 processes
2051 using this keyword, but this should be more than enough for most setups.
2052 Please note that 'all' really means all processes regardless of the machine's
2053 word size, and is not limited to the first 32 or 64.
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002054
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02002055 Each "bind" line may further be limited to a subset of the proxy's processes,
2056 please consult the "process" bind keyword in section 5.1.
2057
Willy Tarreaub369a042014-09-16 13:21:03 +02002058 When a frontend has no explicit "bind-process" line, it tries to bind to all
2059 the processes referenced by its "bind" lines. That means that frontends can
2060 easily adapt to their listeners' processes.
2061
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002062 If some backends are referenced by frontends bound to other processes, the
2063 backend automatically inherits the frontend's processes.
2064
2065 Example :
2066 listen app_ip1
2067 bind 10.0.0.1:80
Willy Tarreaubfcd3112010-10-23 11:22:08 +02002068 bind-process odd
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002069
2070 listen app_ip2
2071 bind 10.0.0.2:80
Willy Tarreaubfcd3112010-10-23 11:22:08 +02002072 bind-process even
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002073
2074 listen management
2075 bind 10.0.0.3:80
Willy Tarreaubfcd3112010-10-23 11:22:08 +02002076 bind-process 1 2 3 4
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002077
Willy Tarreau110ecc12012-11-15 17:50:01 +01002078 listen management
2079 bind 10.0.0.4:80
2080 bind-process 1-4
2081
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02002082 See also : "nbproc" in global section, and "process" in section 5.1.
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002083
2084
Willy Tarreau0ba27502007-12-24 16:55:16 +01002085block { if | unless } <condition>
2086 Block a layer 7 request if/unless a condition is matched
2087 May be used in sections : defaults | frontend | listen | backend
2088 no | yes | yes | yes
2089
2090 The HTTP request will be blocked very early in the layer 7 processing
2091 if/unless <condition> is matched. A 403 error will be returned if the request
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002092 is blocked. The condition has to reference ACLs (see section 7). This is
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02002093 typically used to deny access to certain sensitive resources if some
Willy Tarreau0ba27502007-12-24 16:55:16 +01002094 conditions are met or not met. There is no fixed limit to the number of
2095 "block" statements per instance.
2096
2097 Example:
2098 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
2099 acl invalid_src src_port 0:1023
2100 acl local_dst hdr(host) -i localhost
2101 block if invalid_src || local_dst
2102
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002103 See section 7 about ACL usage.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002104
2105
2106capture cookie <name> len <length>
2107 Capture and log a cookie in the request and in the response.
2108 May be used in sections : defaults | frontend | listen | backend
2109 no | yes | yes | no
2110 Arguments :
2111 <name> is the beginning of the name of the cookie to capture. In order
2112 to match the exact name, simply suffix the name with an equal
2113 sign ('='). The full name will appear in the logs, which is
2114 useful with application servers which adjust both the cookie name
2115 and value (eg: ASPSESSIONXXXXX).
2116
2117 <length> is the maximum number of characters to report in the logs, which
2118 include the cookie name, the equal sign and the value, all in the
2119 standard "name=value" form. The string will be truncated on the
2120 right if it exceeds <length>.
2121
2122 Only the first cookie is captured. Both the "cookie" request headers and the
2123 "set-cookie" response headers are monitored. This is particularly useful to
2124 check for application bugs causing session crossing or stealing between
2125 users, because generally the user's cookies can only change on a login page.
2126
2127 When the cookie was not presented by the client, the associated log column
2128 will report "-". When a request does not cause a cookie to be assigned by the
2129 server, a "-" is reported in the response column.
2130
2131 The capture is performed in the frontend only because it is necessary that
2132 the log format does not change for a given frontend depending on the
2133 backends. This may change in the future. Note that there can be only one
Willy Tarreau193b8c62012-11-22 00:17:38 +01002134 "capture cookie" statement in a frontend. The maximum capture length is set
2135 by the global "tune.http.cookielen" setting and defaults to 63 characters. It
2136 is not possible to specify a capture in a "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002137
2138 Example:
2139 capture cookie ASPSESSION len 32
2140
2141 See also : "capture request header", "capture response header" as well as
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002142 section 8 about logging.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002143
2144
2145capture request header <name> len <length>
Willy Tarreau4460d032012-11-21 23:37:37 +01002146 Capture and log the last occurrence of the specified request header.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002147 May be used in sections : defaults | frontend | listen | backend
2148 no | yes | yes | no
2149 Arguments :
2150 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002151 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +01002152 appear in the requests, with the first letter of each word in
2153 upper case. The header name will not appear in the logs, only the
2154 value is reported, but the position in the logs is respected.
2155
2156 <length> is the maximum number of characters to extract from the value and
2157 report in the logs. The string will be truncated on the right if
2158 it exceeds <length>.
2159
Willy Tarreau4460d032012-11-21 23:37:37 +01002160 The complete value of the last occurrence of the header is captured. The
Willy Tarreau0ba27502007-12-24 16:55:16 +01002161 value will be added to the logs between braces ('{}'). If multiple headers
2162 are captured, they will be delimited by a vertical bar ('|') and will appear
Willy Tarreaucc6c8912009-02-22 10:53:55 +01002163 in the same order they were declared in the configuration. Non-existent
2164 headers will be logged just as an empty string. Common uses for request
2165 header captures include the "Host" field in virtual hosting environments, the
2166 "Content-length" when uploads are supported, "User-agent" to quickly
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002167 differentiate between real users and robots, and "X-Forwarded-For" in proxied
Willy Tarreaucc6c8912009-02-22 10:53:55 +01002168 environments to find where the request came from.
2169
2170 Note that when capturing headers such as "User-agent", some spaces may be
2171 logged, making the log analysis more difficult. Thus be careful about what
2172 you log if you know your log parser is not smart enough to rely on the
2173 braces.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002174
Willy Tarreau0900abb2012-11-22 00:21:46 +01002175 There is no limit to the number of captured request headers nor to their
2176 length, though it is wise to keep them low to limit memory usage per session.
2177 In order to keep log format consistent for a same frontend, header captures
2178 can only be declared in a frontend. It is not possible to specify a capture
2179 in a "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002180
2181 Example:
2182 capture request header Host len 15
2183 capture request header X-Forwarded-For len 15
2184 capture request header Referrer len 15
2185
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002186 See also : "capture cookie", "capture response header" as well as section 8
Willy Tarreau0ba27502007-12-24 16:55:16 +01002187 about logging.
2188
2189
2190capture response header <name> len <length>
Willy Tarreau4460d032012-11-21 23:37:37 +01002191 Capture and log the last occurrence of the specified response header.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002192 May be used in sections : defaults | frontend | listen | backend
2193 no | yes | yes | no
2194 Arguments :
2195 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002196 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +01002197 appear in the response, with the first letter of each word in
2198 upper case. The header name will not appear in the logs, only the
2199 value is reported, but the position in the logs is respected.
2200
2201 <length> is the maximum number of characters to extract from the value and
2202 report in the logs. The string will be truncated on the right if
2203 it exceeds <length>.
2204
Willy Tarreau4460d032012-11-21 23:37:37 +01002205 The complete value of the last occurrence of the header is captured. The
Willy Tarreau0ba27502007-12-24 16:55:16 +01002206 result will be added to the logs between braces ('{}') after the captured
2207 request headers. If multiple headers are captured, they will be delimited by
2208 a vertical bar ('|') and will appear in the same order they were declared in
Willy Tarreaucc6c8912009-02-22 10:53:55 +01002209 the configuration. Non-existent headers will be logged just as an empty
2210 string. Common uses for response header captures include the "Content-length"
2211 header which indicates how many bytes are expected to be returned, the
2212 "Location" header to track redirections.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002213
Willy Tarreau0900abb2012-11-22 00:21:46 +01002214 There is no limit to the number of captured response headers nor to their
2215 length, though it is wise to keep them low to limit memory usage per session.
2216 In order to keep log format consistent for a same frontend, header captures
2217 can only be declared in a frontend. It is not possible to specify a capture
2218 in a "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002219
2220 Example:
2221 capture response header Content-length len 9
2222 capture response header Location len 15
2223
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002224 See also : "capture cookie", "capture request header" as well as section 8
Willy Tarreau0ba27502007-12-24 16:55:16 +01002225 about logging.
2226
2227
Cyril Bontéf0c60612010-02-06 14:44:47 +01002228clitimeout <timeout> (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +01002229 Set the maximum inactivity time on the client side.
2230 May be used in sections : defaults | frontend | listen | backend
2231 yes | yes | yes | no
2232 Arguments :
2233 <timeout> is the timeout value is specified in milliseconds by default, but
2234 can be in any other unit if the number is suffixed by the unit,
2235 as explained at the top of this document.
2236
2237 The inactivity timeout applies when the client is expected to acknowledge or
2238 send data. In HTTP mode, this timeout is particularly important to consider
2239 during the first phase, when the client sends the request, and during the
2240 response while it is reading data sent by the server. The value is specified
2241 in milliseconds by default, but can be in any other unit if the number is
2242 suffixed by the unit, as specified at the top of this document. In TCP mode
2243 (and to a lesser extent, in HTTP mode), it is highly recommended that the
2244 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002245 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01002246 losses by specifying timeouts that are slightly above multiples of 3 seconds
2247 (eg: 4 or 5 seconds).
2248
2249 This parameter is specific to frontends, but can be specified once for all in
2250 "defaults" sections. This is in fact one of the easiest solutions not to
2251 forget about it. An unspecified timeout results in an infinite timeout, which
2252 is not recommended. Such a usage is accepted and works but reports a warning
2253 during startup because it may results in accumulation of expired sessions in
2254 the system if the system's timeouts are not configured either.
2255
2256 This parameter is provided for compatibility but is currently deprecated.
2257 Please use "timeout client" instead.
2258
Willy Tarreau036fae02008-01-06 13:24:40 +01002259 See also : "timeout client", "timeout http-request", "timeout server", and
2260 "srvtimeout".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002261
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002262compression algo <algorithm> ...
2263compression type <mime type> ...
Willy Tarreau70737d12012-10-27 00:34:28 +02002264compression offload
William Lallemand82fe75c2012-10-23 10:25:10 +02002265 Enable HTTP compression.
2266 May be used in sections : defaults | frontend | listen | backend
2267 yes | yes | yes | yes
2268 Arguments :
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002269 algo is followed by the list of supported compression algorithms.
2270 type is followed by the list of MIME types that will be compressed.
2271 offload makes haproxy work as a compression offloader only (see notes).
2272
2273 The currently supported algorithms are :
Willy Tarreauc91840a2015-03-28 17:00:39 +01002274 identity this is mostly for debugging, and it was useful for developing
2275 the compression feature. Identity does not apply any change on
2276 data.
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002277
Willy Tarreauc91840a2015-03-28 17:00:39 +01002278 gzip applies gzip compression. This setting is only available when
2279 support for zlib was built in.
2280
2281 deflate same as "gzip", but with deflate algorithm and zlib format.
2282 Note that this algorithm has ambiguous support on many
2283 browsers and no support at all from recent ones. It is
2284 strongly recommended not to use it for anything else than
2285 experimentation. This setting is only available when support
2286 for zlib was built in.
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002287
Willy Tarreauc91840a2015-03-28 17:00:39 +01002288 raw-deflate same as "deflate" without the zlib wrapper, and used as an
2289 alternative when the browser wants "deflate". All major
2290 browsers understand it and despite violating the standards,
2291 it is known to work better than "deflate", at least on MSIE
2292 and some versions of Safari. Do not use it in conjunction
2293 with "deflate", use either one or the other since both react
2294 to the same Accept-Encoding token. This setting is only
2295 available when support for zlib was built in.
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002296
Dmitry Sivachenko87c208b2012-11-22 20:03:26 +04002297 Compression will be activated depending on the Accept-Encoding request
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002298 header. With identity, it does not take care of that header.
Dmitry Sivachenkoc9f3b452012-11-28 17:47:11 +04002299 If backend servers support HTTP compression, these directives
2300 will be no-op: haproxy will see the compressed response and will not
2301 compress again. If backend servers do not support HTTP compression and
2302 there is Accept-Encoding header in request, haproxy will compress the
2303 matching response.
Willy Tarreau70737d12012-10-27 00:34:28 +02002304
2305 The "offload" setting makes haproxy remove the Accept-Encoding header to
2306 prevent backend servers from compressing responses. It is strongly
2307 recommended not to do this because this means that all the compression work
2308 will be done on the single point where haproxy is located. However in some
2309 deployment scenarios, haproxy may be installed in front of a buggy gateway
Dmitry Sivachenkoc9f3b452012-11-28 17:47:11 +04002310 with broken HTTP compression implementation which can't be turned off.
2311 In that case haproxy can be used to prevent that gateway from emitting
2312 invalid payloads. In this case, simply removing the header in the
2313 configuration does not work because it applies before the header is parsed,
2314 so that prevents haproxy from compressing. The "offload" setting should
Willy Tarreauffea9fd2014-07-12 16:37:02 +02002315 then be used for such scenarios. Note: for now, the "offload" setting is
2316 ignored when set in a defaults section.
William Lallemand82fe75c2012-10-23 10:25:10 +02002317
William Lallemand05097442012-11-20 12:14:28 +01002318 Compression is disabled when:
Baptiste Assmann650d53d2013-01-05 15:44:44 +01002319 * the request does not advertise a supported compression algorithm in the
2320 "Accept-Encoding" header
2321 * the response message is not HTTP/1.1
William Lallemandd3002612012-11-26 14:34:47 +01002322 * HTTP status code is not 200
William Lallemand8bb4e342013-12-10 17:28:48 +01002323 * response header "Transfer-Encoding" contains "chunked" (Temporary
2324 Workaround)
Baptiste Assmann650d53d2013-01-05 15:44:44 +01002325 * response contain neither a "Content-Length" header nor a
2326 "Transfer-Encoding" whose last value is "chunked"
2327 * response contains a "Content-Type" header whose first value starts with
2328 "multipart"
2329 * the response contains the "no-transform" value in the "Cache-control"
2330 header
2331 * User-Agent matches "Mozilla/4" unless it is MSIE 6 with XP SP2, or MSIE 7
2332 and later
2333 * The response contains a "Content-Encoding" header, indicating that the
2334 response is already compressed (see compression offload)
William Lallemand05097442012-11-20 12:14:28 +01002335
Baptiste Assmann650d53d2013-01-05 15:44:44 +01002336 Note: The compression does not rewrite Etag headers, and does not emit the
2337 Warning header.
William Lallemand05097442012-11-20 12:14:28 +01002338
William Lallemand82fe75c2012-10-23 10:25:10 +02002339 Examples :
2340 compression algo gzip
2341 compression type text/html text/plain
Willy Tarreau0ba27502007-12-24 16:55:16 +01002342
Cyril Bontéf0c60612010-02-06 14:44:47 +01002343contimeout <timeout> (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +01002344 Set the maximum time to wait for a connection attempt to a server to succeed.
2345 May be used in sections : defaults | frontend | listen | backend
2346 yes | no | yes | yes
2347 Arguments :
2348 <timeout> is the timeout value is specified in milliseconds by default, but
2349 can be in any other unit if the number is suffixed by the unit,
2350 as explained at the top of this document.
2351
2352 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002353 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreaud72758d2010-01-12 10:42:19 +01002354 cover one or several TCP packet losses by specifying timeouts that are
Willy Tarreau0ba27502007-12-24 16:55:16 +01002355 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
2356 connect timeout also presets the queue timeout to the same value if this one
2357 has not been specified. Historically, the contimeout was also used to set the
2358 tarpit timeout in a listen section, which is not possible in a pure frontend.
2359
2360 This parameter is specific to backends, but can be specified once for all in
2361 "defaults" sections. This is in fact one of the easiest solutions not to
2362 forget about it. An unspecified timeout results in an infinite timeout, which
2363 is not recommended. Such a usage is accepted and works but reports a warning
2364 during startup because it may results in accumulation of failed sessions in
2365 the system if the system's timeouts are not configured either.
2366
2367 This parameter is provided for backwards compatibility but is currently
2368 deprecated. Please use "timeout connect", "timeout queue" or "timeout tarpit"
2369 instead.
2370
2371 See also : "timeout connect", "timeout queue", "timeout tarpit",
2372 "timeout server", "contimeout".
2373
2374
Willy Tarreau55165fe2009-05-10 12:02:55 +02002375cookie <name> [ rewrite | insert | prefix ] [ indirect ] [ nocache ]
Willy Tarreau4992dd22012-05-31 21:02:17 +02002376 [ postonly ] [ preserve ] [ httponly ] [ secure ]
2377 [ domain <domain> ]* [ maxidle <idle> ] [ maxlife <life> ]
Willy Tarreau0ba27502007-12-24 16:55:16 +01002378 Enable cookie-based persistence in a backend.
2379 May be used in sections : defaults | frontend | listen | backend
2380 yes | no | yes | yes
2381 Arguments :
2382 <name> is the name of the cookie which will be monitored, modified or
2383 inserted in order to bring persistence. This cookie is sent to
2384 the client via a "Set-Cookie" header in the response, and is
2385 brought back by the client in a "Cookie" header in all requests.
2386 Special care should be taken to choose a name which does not
2387 conflict with any likely application cookie. Also, if the same
2388 backends are subject to be used by the same clients (eg:
2389 HTTP/HTTPS), care should be taken to use different cookie names
2390 between all backends if persistence between them is not desired.
2391
2392 rewrite This keyword indicates that the cookie will be provided by the
2393 server and that haproxy will have to modify its value to set the
2394 server's identifier in it. This mode is handy when the management
2395 of complex combinations of "Set-cookie" and "Cache-control"
2396 headers is left to the application. The application can then
2397 decide whether or not it is appropriate to emit a persistence
2398 cookie. Since all responses should be monitored, this mode only
2399 works in HTTP close mode. Unless the application behaviour is
2400 very complex and/or broken, it is advised not to start with this
2401 mode for new deployments. This keyword is incompatible with
2402 "insert" and "prefix".
2403
2404 insert This keyword indicates that the persistence cookie will have to
Willy Tarreaua79094d2010-08-31 22:54:15 +02002405 be inserted by haproxy in server responses if the client did not
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002406
Willy Tarreaua79094d2010-08-31 22:54:15 +02002407 already have a cookie that would have permitted it to access this
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002408 server. When used without the "preserve" option, if the server
2409 emits a cookie with the same name, it will be remove before
2410 processing. For this reason, this mode can be used to upgrade
2411 existing configurations running in the "rewrite" mode. The cookie
2412 will only be a session cookie and will not be stored on the
2413 client's disk. By default, unless the "indirect" option is added,
2414 the server will see the cookies emitted by the client. Due to
2415 caching effects, it is generally wise to add the "nocache" or
2416 "postonly" keywords (see below). The "insert" keyword is not
2417 compatible with "rewrite" and "prefix".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002418
2419 prefix This keyword indicates that instead of relying on a dedicated
2420 cookie for the persistence, an existing one will be completed.
2421 This may be needed in some specific environments where the client
2422 does not support more than one single cookie and the application
2423 already needs it. In this case, whenever the server sets a cookie
2424 named <name>, it will be prefixed with the server's identifier
2425 and a delimiter. The prefix will be removed from all client
2426 requests so that the server still finds the cookie it emitted.
2427 Since all requests and responses are subject to being modified,
2428 this mode requires the HTTP close mode. The "prefix" keyword is
Willy Tarreau37229df2011-10-17 12:24:55 +02002429 not compatible with "rewrite" and "insert". Note: it is highly
2430 recommended not to use "indirect" with "prefix", otherwise server
2431 cookie updates would not be sent to clients.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002432
Willy Tarreaua79094d2010-08-31 22:54:15 +02002433 indirect When this option is specified, no cookie will be emitted to a
2434 client which already has a valid one for the server which has
2435 processed the request. If the server sets such a cookie itself,
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002436 it will be removed, unless the "preserve" option is also set. In
2437 "insert" mode, this will additionally remove cookies from the
2438 requests transmitted to the server, making the persistence
2439 mechanism totally transparent from an application point of view.
Willy Tarreau37229df2011-10-17 12:24:55 +02002440 Note: it is highly recommended not to use "indirect" with
2441 "prefix", otherwise server cookie updates would not be sent to
2442 clients.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002443
2444 nocache This option is recommended in conjunction with the insert mode
2445 when there is a cache between the client and HAProxy, as it
2446 ensures that a cacheable response will be tagged non-cacheable if
2447 a cookie needs to be inserted. This is important because if all
2448 persistence cookies are added on a cacheable home page for
2449 instance, then all customers will then fetch the page from an
2450 outer cache and will all share the same persistence cookie,
2451 leading to one server receiving much more traffic than others.
2452 See also the "insert" and "postonly" options.
2453
2454 postonly This option ensures that cookie insertion will only be performed
2455 on responses to POST requests. It is an alternative to the
2456 "nocache" option, because POST responses are not cacheable, so
2457 this ensures that the persistence cookie will never get cached.
2458 Since most sites do not need any sort of persistence before the
2459 first POST which generally is a login request, this is a very
2460 efficient method to optimize caching without risking to find a
2461 persistence cookie in the cache.
2462 See also the "insert" and "nocache" options.
2463
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002464 preserve This option may only be used with "insert" and/or "indirect". It
2465 allows the server to emit the persistence cookie itself. In this
2466 case, if a cookie is found in the response, haproxy will leave it
2467 untouched. This is useful in order to end persistence after a
2468 logout request for instance. For this, the server just has to
2469 emit a cookie with an invalid value (eg: empty) or with a date in
2470 the past. By combining this mechanism with the "disable-on-404"
2471 check option, it is possible to perform a completely graceful
2472 shutdown because users will definitely leave the server after
2473 they logout.
2474
Willy Tarreau4992dd22012-05-31 21:02:17 +02002475 httponly This option tells haproxy to add an "HttpOnly" cookie attribute
2476 when a cookie is inserted. This attribute is used so that a
2477 user agent doesn't share the cookie with non-HTTP components.
2478 Please check RFC6265 for more information on this attribute.
2479
2480 secure This option tells haproxy to add a "Secure" cookie attribute when
2481 a cookie is inserted. This attribute is used so that a user agent
2482 never emits this cookie over non-secure channels, which means
2483 that a cookie learned with this flag will be presented only over
2484 SSL/TLS connections. Please check RFC6265 for more information on
2485 this attribute.
2486
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02002487 domain This option allows to specify the domain at which a cookie is
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002488 inserted. It requires exactly one parameter: a valid domain
Willy Tarreau68a897b2009-12-03 23:28:34 +01002489 name. If the domain begins with a dot, the browser is allowed to
2490 use it for any host ending with that name. It is also possible to
2491 specify several domain names by invoking this option multiple
2492 times. Some browsers might have small limits on the number of
2493 domains, so be careful when doing that. For the record, sending
2494 10 domains to MSIE 6 or Firefox 2 works as expected.
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02002495
Willy Tarreau996a92c2010-10-13 19:30:47 +02002496 maxidle This option allows inserted cookies to be ignored after some idle
2497 time. It only works with insert-mode cookies. When a cookie is
2498 sent to the client, the date this cookie was emitted is sent too.
2499 Upon further presentations of this cookie, if the date is older
2500 than the delay indicated by the parameter (in seconds), it will
2501 be ignored. Otherwise, it will be refreshed if needed when the
2502 response is sent to the client. This is particularly useful to
2503 prevent users who never close their browsers from remaining for
2504 too long on the same server (eg: after a farm size change). When
2505 this option is set and a cookie has no date, it is always
2506 accepted, but gets refreshed in the response. This maintains the
2507 ability for admins to access their sites. Cookies that have a
2508 date in the future further than 24 hours are ignored. Doing so
2509 lets admins fix timezone issues without risking kicking users off
2510 the site.
2511
2512 maxlife This option allows inserted cookies to be ignored after some life
2513 time, whether they're in use or not. It only works with insert
2514 mode cookies. When a cookie is first sent to the client, the date
2515 this cookie was emitted is sent too. Upon further presentations
2516 of this cookie, if the date is older than the delay indicated by
2517 the parameter (in seconds), it will be ignored. If the cookie in
2518 the request has no date, it is accepted and a date will be set.
2519 Cookies that have a date in the future further than 24 hours are
2520 ignored. Doing so lets admins fix timezone issues without risking
2521 kicking users off the site. Contrary to maxidle, this value is
2522 not refreshed, only the first visit date counts. Both maxidle and
2523 maxlife may be used at the time. This is particularly useful to
2524 prevent users who never close their browsers from remaining for
2525 too long on the same server (eg: after a farm size change). This
2526 is stronger than the maxidle method in that it forces a
2527 redispatch after some absolute delay.
2528
Willy Tarreau0ba27502007-12-24 16:55:16 +01002529 There can be only one persistence cookie per HTTP backend, and it can be
2530 declared in a defaults section. The value of the cookie will be the value
2531 indicated after the "cookie" keyword in a "server" statement. If no cookie
2532 is declared for a given server, the cookie is not set.
Willy Tarreau6a06a402007-07-15 20:15:28 +02002533
Willy Tarreau0ba27502007-12-24 16:55:16 +01002534 Examples :
2535 cookie JSESSIONID prefix
2536 cookie SRV insert indirect nocache
2537 cookie SRV insert postonly indirect
Willy Tarreau996a92c2010-10-13 19:30:47 +02002538 cookie SRV insert indirect nocache maxidle 30m maxlife 8h
Willy Tarreau0ba27502007-12-24 16:55:16 +01002539
Cyril Bontéa8e7bbc2010-04-25 22:29:29 +02002540 See also : "appsession", "balance source", "capture cookie", "server"
Cyril Bonté0d4bf012010-04-25 23:21:46 +02002541 and "ignore-persist".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002542
Willy Tarreau983e01e2010-01-11 18:42:06 +01002543
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01002544default-server [param*]
2545 Change default options for a server in a backend
2546 May be used in sections : defaults | frontend | listen | backend
2547 yes | no | yes | yes
2548 Arguments:
Willy Tarreau983e01e2010-01-11 18:42:06 +01002549 <param*> is a list of parameters for this server. The "default-server"
2550 keyword accepts an important number of options and has a complete
2551 section dedicated to it. Please refer to section 5 for more
2552 details.
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01002553
Willy Tarreau983e01e2010-01-11 18:42:06 +01002554 Example :
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01002555 default-server inter 1000 weight 13
2556
2557 See also: "server" and section 5 about server options
Willy Tarreau0ba27502007-12-24 16:55:16 +01002558
Willy Tarreau983e01e2010-01-11 18:42:06 +01002559
Willy Tarreau0ba27502007-12-24 16:55:16 +01002560default_backend <backend>
2561 Specify the backend to use when no "use_backend" rule has been matched.
2562 May be used in sections : defaults | frontend | listen | backend
2563 yes | yes | yes | no
2564 Arguments :
2565 <backend> is the name of the backend to use.
2566
2567 When doing content-switching between frontend and backends using the
2568 "use_backend" keyword, it is often useful to indicate which backend will be
2569 used when no rule has matched. It generally is the dynamic backend which
2570 will catch all undetermined requests.
2571
Willy Tarreau0ba27502007-12-24 16:55:16 +01002572 Example :
2573
2574 use_backend dynamic if url_dyn
2575 use_backend static if url_css url_img extension_img
2576 default_backend dynamic
2577
Willy Tarreau2769aa02007-12-27 18:26:09 +01002578 See also : "use_backend", "reqsetbe", "reqisetbe"
2579
Willy Tarreau0ba27502007-12-24 16:55:16 +01002580
Baptiste Assmann27f51342013-10-09 06:51:49 +02002581description <string>
2582 Describe a listen, frontend or backend.
2583 May be used in sections : defaults | frontend | listen | backend
2584 no | yes | yes | yes
2585 Arguments : string
2586
2587 Allows to add a sentence to describe the related object in the HAProxy HTML
2588 stats page. The description will be printed on the right of the object name
2589 it describes.
2590 No need to backslash spaces in the <string> arguments.
2591
2592
Willy Tarreau0ba27502007-12-24 16:55:16 +01002593disabled
2594 Disable a proxy, frontend or backend.
2595 May be used in sections : defaults | frontend | listen | backend
2596 yes | yes | yes | yes
2597 Arguments : none
2598
2599 The "disabled" keyword is used to disable an instance, mainly in order to
2600 liberate a listening port or to temporarily disable a service. The instance
2601 will still be created and its configuration will be checked, but it will be
2602 created in the "stopped" state and will appear as such in the statistics. It
2603 will not receive any traffic nor will it send any health-checks or logs. It
2604 is possible to disable many instances at once by adding the "disabled"
2605 keyword in a "defaults" section.
2606
2607 See also : "enabled"
2608
2609
Willy Tarreau5ce94572010-06-07 14:35:41 +02002610dispatch <address>:<port>
2611 Set a default server address
2612 May be used in sections : defaults | frontend | listen | backend
2613 no | no | yes | yes
Cyril Bonté108cf6e2012-04-21 23:30:29 +02002614 Arguments :
Willy Tarreau5ce94572010-06-07 14:35:41 +02002615
2616 <address> is the IPv4 address of the default server. Alternatively, a
2617 resolvable hostname is supported, but this name will be resolved
2618 during start-up.
2619
2620 <ports> is a mandatory port specification. All connections will be sent
2621 to this port, and it is not permitted to use port offsets as is
2622 possible with normal servers.
2623
Willy Tarreau787aed52011-04-15 06:45:37 +02002624 The "dispatch" keyword designates a default server for use when no other
Willy Tarreau5ce94572010-06-07 14:35:41 +02002625 server can take the connection. In the past it was used to forward non
2626 persistent connections to an auxiliary load balancer. Due to its simple
2627 syntax, it has also been used for simple TCP relays. It is recommended not to
2628 use it for more clarity, and to use the "server" directive instead.
2629
2630 See also : "server"
2631
2632
Willy Tarreau0ba27502007-12-24 16:55:16 +01002633enabled
2634 Enable a proxy, frontend or backend.
2635 May be used in sections : defaults | frontend | listen | backend
2636 yes | yes | yes | yes
2637 Arguments : none
2638
2639 The "enabled" keyword is used to explicitly enable an instance, when the
2640 defaults has been set to "disabled". This is very rarely used.
2641
2642 See also : "disabled"
2643
2644
2645errorfile <code> <file>
2646 Return a file contents instead of errors generated by HAProxy
2647 May be used in sections : defaults | frontend | listen | backend
2648 yes | yes | yes | yes
2649 Arguments :
2650 <code> is the HTTP status code. Currently, HAProxy is capable of
CJ Ess108b1dd2015-04-07 12:03:37 -04002651 generating codes 200, 400, 403, 405, 408, 429, 500, 502, 503, and
2652 504.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002653
2654 <file> designates a file containing the full HTTP response. It is
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002655 recommended to follow the common practice of appending ".http" to
Willy Tarreau0ba27502007-12-24 16:55:16 +01002656 the filename so that people do not confuse the response with HTML
Willy Tarreau59140a22009-02-22 12:02:30 +01002657 error pages, and to use absolute paths, since files are read
2658 before any chroot is performed.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002659
2660 It is important to understand that this keyword is not meant to rewrite
2661 errors returned by the server, but errors detected and returned by HAProxy.
2662 This is why the list of supported errors is limited to a small set.
2663
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002664 Code 200 is emitted in response to requests matching a "monitor-uri" rule.
2665
Willy Tarreau0ba27502007-12-24 16:55:16 +01002666 The files are returned verbatim on the TCP socket. This allows any trick such
2667 as redirections to another URL or site, as well as tricks to clean cookies,
2668 force enable or disable caching, etc... The package provides default error
2669 files returning the same contents as default errors.
2670
Willy Tarreau59140a22009-02-22 12:02:30 +01002671 The files should not exceed the configured buffer size (BUFSIZE), which
2672 generally is 8 or 16 kB, otherwise they will be truncated. It is also wise
2673 not to put any reference to local contents (eg: images) in order to avoid
2674 loops between the client and HAProxy when all servers are down, causing an
2675 error to be returned instead of an image. For better HTTP compliance, it is
2676 recommended that all header lines end with CR-LF and not LF alone.
2677
Willy Tarreau0ba27502007-12-24 16:55:16 +01002678 The files are read at the same time as the configuration and kept in memory.
2679 For this reason, the errors continue to be returned even when the process is
2680 chrooted, and no file change is considered while the process is running. A
Willy Tarreauc27debf2008-01-06 08:57:02 +01002681 simple method for developing those files consists in associating them to the
Willy Tarreau0ba27502007-12-24 16:55:16 +01002682 403 status code and interrogating a blocked URL.
2683
2684 See also : "errorloc", "errorloc302", "errorloc303"
2685
Willy Tarreau59140a22009-02-22 12:02:30 +01002686 Example :
2687 errorfile 400 /etc/haproxy/errorfiles/400badreq.http
Willy Tarreau2705a612014-05-23 17:38:34 +02002688 errorfile 408 /dev/null # workaround Chrome pre-connect bug
Willy Tarreau59140a22009-02-22 12:02:30 +01002689 errorfile 403 /etc/haproxy/errorfiles/403forbid.http
2690 errorfile 503 /etc/haproxy/errorfiles/503sorry.http
2691
Willy Tarreau2769aa02007-12-27 18:26:09 +01002692
2693errorloc <code> <url>
2694errorloc302 <code> <url>
2695 Return an HTTP redirection to a URL instead of errors generated by HAProxy
2696 May be used in sections : defaults | frontend | listen | backend
2697 yes | yes | yes | yes
2698 Arguments :
2699 <code> is the HTTP status code. Currently, HAProxy is capable of
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002700 generating codes 200, 400, 403, 408, 500, 502, 503, and 504.
Willy Tarreau2769aa02007-12-27 18:26:09 +01002701
2702 <url> it is the exact contents of the "Location" header. It may contain
2703 either a relative URI to an error page hosted on the same site,
2704 or an absolute URI designating an error page on another site.
2705 Special care should be given to relative URIs to avoid redirect
2706 loops if the URI itself may generate the same error (eg: 500).
2707
2708 It is important to understand that this keyword is not meant to rewrite
2709 errors returned by the server, but errors detected and returned by HAProxy.
2710 This is why the list of supported errors is limited to a small set.
2711
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002712 Code 200 is emitted in response to requests matching a "monitor-uri" rule.
2713
Willy Tarreau2769aa02007-12-27 18:26:09 +01002714 Note that both keyword return the HTTP 302 status code, which tells the
2715 client to fetch the designated URL using the same HTTP method. This can be
2716 quite problematic in case of non-GET methods such as POST, because the URL
2717 sent to the client might not be allowed for something other than GET. To
2718 workaround this problem, please use "errorloc303" which send the HTTP 303
2719 status code, indicating to the client that the URL must be fetched with a GET
2720 request.
2721
2722 See also : "errorfile", "errorloc303"
2723
2724
2725errorloc303 <code> <url>
2726 Return an HTTP redirection to a URL instead of errors generated by HAProxy
2727 May be used in sections : defaults | frontend | listen | backend
2728 yes | yes | yes | yes
2729 Arguments :
2730 <code> is the HTTP status code. Currently, HAProxy is capable of
2731 generating codes 400, 403, 408, 500, 502, 503, and 504.
2732
2733 <url> it is the exact contents of the "Location" header. It may contain
2734 either a relative URI to an error page hosted on the same site,
2735 or an absolute URI designating an error page on another site.
2736 Special care should be given to relative URIs to avoid redirect
2737 loops if the URI itself may generate the same error (eg: 500).
2738
2739 It is important to understand that this keyword is not meant to rewrite
2740 errors returned by the server, but errors detected and returned by HAProxy.
2741 This is why the list of supported errors is limited to a small set.
2742
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002743 Code 200 is emitted in response to requests matching a "monitor-uri" rule.
2744
Willy Tarreau2769aa02007-12-27 18:26:09 +01002745 Note that both keyword return the HTTP 303 status code, which tells the
2746 client to fetch the designated URL using the same HTTP GET method. This
2747 solves the usual problems associated with "errorloc" and the 302 code. It is
2748 possible that some very old browsers designed before HTTP/1.1 do not support
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002749 it, but no such problem has been reported till now.
Willy Tarreau2769aa02007-12-27 18:26:09 +01002750
2751 See also : "errorfile", "errorloc", "errorloc302"
2752
2753
Simon Horman51a1cf62015-02-03 13:00:44 +09002754email-alert from <emailaddr>
2755 Declare the from email address to be used in both the envelope and header
2756 of email alerts. This is the address that email alerts are sent from.
2757 May be used in sections: defaults | frontend | listen | backend
2758 yes | yes | yes | yes
2759
2760 Arguments :
2761
2762 <emailaddr> is the from email address to use when sending email alerts
2763
2764 Also requires "email-alert mailers" and "email-alert to" to be set
2765 and if so sending email alerts is enabled for the proxy.
2766
Simon Horman64e34162015-02-06 11:11:57 +09002767 See also : "email-alert level", "email-alert mailers",
2768 "email-alert myhostname", "email-alert to", section 3.6 about mailers.
2769
2770
2771email-alert level <level>
2772 Declare the maximum log level of messages for which email alerts will be
2773 sent. This acts as a filter on the sending of email alerts.
2774 May be used in sections: defaults | frontend | listen | backend
2775 yes | yes | yes | yes
2776
2777 Arguments :
2778
2779 <level> One of the 8 syslog levels:
2780 emerg alert crit err warning notice info debug
2781 The above syslog levels are ordered from lowest to highest.
2782
2783 By default level is alert
2784
2785 Also requires "email-alert from", "email-alert mailers" and
2786 "email-alert to" to be set and if so sending email alerts is enabled
2787 for the proxy.
2788
Simon Horman1421e212015-04-30 13:10:35 +09002789 Alerts are sent when :
2790
2791 * An un-paused server is marked as down and <level> is alert or lower
2792 * A paused server is marked as down and <level> is notice or lower
2793 * A server is marked as up or enters the drain state and <level>
2794 is notice or lower
2795 * "option log-health-checks" is enabled, <level> is info or lower,
2796 and a health check status update occurs
2797
Simon Horman64e34162015-02-06 11:11:57 +09002798 See also : "email-alert from", "email-alert mailers",
2799 "email-alert myhostname", "email-alert to",
Simon Horman51a1cf62015-02-03 13:00:44 +09002800 section 3.6 about mailers.
2801
2802
2803email-alert mailers <mailersect>
2804 Declare the mailers to be used when sending email alerts
2805 May be used in sections: defaults | frontend | listen | backend
2806 yes | yes | yes | yes
2807
2808 Arguments :
2809
2810 <mailersect> is the name of the mailers section to send email alerts.
2811
2812 Also requires "email-alert from" and "email-alert to" to be set
2813 and if so sending email alerts is enabled for the proxy.
2814
Simon Horman64e34162015-02-06 11:11:57 +09002815 See also : "email-alert from", "email-alert level", "email-alert myhostname",
2816 "email-alert to", section 3.6 about mailers.
Simon Horman51a1cf62015-02-03 13:00:44 +09002817
2818
2819email-alert myhostname <hostname>
2820 Declare the to hostname address to be used when communicating with
2821 mailers.
2822 May be used in sections: defaults | frontend | listen | backend
2823 yes | yes | yes | yes
2824
2825 Arguments :
2826
2827 <emailaddr> is the to email address to use when sending email alerts
2828
2829 By default the systems hostname is used.
2830
2831 Also requires "email-alert from", "email-alert mailers" and
2832 "email-alert to" to be set and if so sending email alerts is enabled
2833 for the proxy.
2834
Simon Horman64e34162015-02-06 11:11:57 +09002835 See also : "email-alert from", "email-alert level", "email-alert mailers",
2836 "email-alert to", section 3.6 about mailers.
Simon Horman51a1cf62015-02-03 13:00:44 +09002837
2838
2839email-alert to <emailaddr>
2840 Declare both the recipent address in the envelope and to address in the
2841 header of email alerts. This is the address that email alerts are sent to.
2842 May be used in sections: defaults | frontend | listen | backend
2843 yes | yes | yes | yes
2844
2845 Arguments :
2846
2847 <emailaddr> is the to email address to use when sending email alerts
2848
2849 Also requires "email-alert mailers" and "email-alert to" to be set
2850 and if so sending email alerts is enabled for the proxy.
2851
Simon Horman64e34162015-02-06 11:11:57 +09002852 See also : "email-alert from", "email-alert level", "email-alert mailers",
Simon Horman51a1cf62015-02-03 13:00:44 +09002853 "email-alert myhostname", section 3.6 about mailers.
2854
2855
Willy Tarreau4de91492010-01-22 19:10:05 +01002856force-persist { if | unless } <condition>
2857 Declare a condition to force persistence on down servers
2858 May be used in sections: defaults | frontend | listen | backend
2859 no | yes | yes | yes
2860
2861 By default, requests are not dispatched to down servers. It is possible to
2862 force this using "option persist", but it is unconditional and redispatches
2863 to a valid server if "option redispatch" is set. That leaves with very little
2864 possibilities to force some requests to reach a server which is artificially
2865 marked down for maintenance operations.
2866
2867 The "force-persist" statement allows one to declare various ACL-based
2868 conditions which, when met, will cause a request to ignore the down status of
2869 a server and still try to connect to it. That makes it possible to start a
2870 server, still replying an error to the health checks, and run a specially
2871 configured browser to test the service. Among the handy methods, one could
2872 use a specific source IP address, or a specific cookie. The cookie also has
2873 the advantage that it can easily be added/removed on the browser from a test
2874 page. Once the service is validated, it is then possible to open the service
2875 to the world by returning a valid response to health checks.
2876
2877 The forced persistence is enabled when an "if" condition is met, or unless an
2878 "unless" condition is met. The final redispatch is always disabled when this
2879 is used.
2880
Cyril Bonté0d4bf012010-04-25 23:21:46 +02002881 See also : "option redispatch", "ignore-persist", "persist",
Cyril Bontéa8e7bbc2010-04-25 22:29:29 +02002882 and section 7 about ACL usage.
Willy Tarreau4de91492010-01-22 19:10:05 +01002883
2884
Willy Tarreau2769aa02007-12-27 18:26:09 +01002885fullconn <conns>
2886 Specify at what backend load the servers will reach their maxconn
2887 May be used in sections : defaults | frontend | listen | backend
2888 yes | no | yes | yes
2889 Arguments :
2890 <conns> is the number of connections on the backend which will make the
2891 servers use the maximal number of connections.
2892
Willy Tarreau198a7442008-01-17 12:05:32 +01002893 When a server has a "maxconn" parameter specified, it means that its number
Willy Tarreau2769aa02007-12-27 18:26:09 +01002894 of concurrent connections will never go higher. Additionally, if it has a
Willy Tarreau198a7442008-01-17 12:05:32 +01002895 "minconn" parameter, it indicates a dynamic limit following the backend's
Willy Tarreau2769aa02007-12-27 18:26:09 +01002896 load. The server will then always accept at least <minconn> connections,
2897 never more than <maxconn>, and the limit will be on the ramp between both
2898 values when the backend has less than <conns> concurrent connections. This
2899 makes it possible to limit the load on the servers during normal loads, but
2900 push it further for important loads without overloading the servers during
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002901 exceptional loads.
Willy Tarreau2769aa02007-12-27 18:26:09 +01002902
Willy Tarreaufbb78422011-06-05 15:38:35 +02002903 Since it's hard to get this value right, haproxy automatically sets it to
2904 10% of the sum of the maxconns of all frontends that may branch to this
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01002905 backend (based on "use_backend" and "default_backend" rules). That way it's
2906 safe to leave it unset. However, "use_backend" involving dynamic names are
2907 not counted since there is no way to know if they could match or not.
Willy Tarreaufbb78422011-06-05 15:38:35 +02002908
Willy Tarreau2769aa02007-12-27 18:26:09 +01002909 Example :
2910 # The servers will accept between 100 and 1000 concurrent connections each
2911 # and the maximum of 1000 will be reached when the backend reaches 10000
2912 # connections.
2913 backend dynamic
2914 fullconn 10000
2915 server srv1 dyn1:80 minconn 100 maxconn 1000
2916 server srv2 dyn2:80 minconn 100 maxconn 1000
2917
2918 See also : "maxconn", "server"
2919
2920
2921grace <time>
2922 Maintain a proxy operational for some time after a soft stop
2923 May be used in sections : defaults | frontend | listen | backend
Cyril Bonté99ed3272010-01-24 23:29:44 +01002924 yes | yes | yes | yes
Willy Tarreau2769aa02007-12-27 18:26:09 +01002925 Arguments :
2926 <time> is the time (by default in milliseconds) for which the instance
2927 will remain operational with the frontend sockets still listening
2928 when a soft-stop is received via the SIGUSR1 signal.
2929
2930 This may be used to ensure that the services disappear in a certain order.
2931 This was designed so that frontends which are dedicated to monitoring by an
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002932 external equipment fail immediately while other ones remain up for the time
Willy Tarreau2769aa02007-12-27 18:26:09 +01002933 needed by the equipment to detect the failure.
2934
2935 Note that currently, there is very little benefit in using this parameter,
2936 and it may in fact complicate the soft-reconfiguration process more than
2937 simplify it.
2938
Willy Tarreau0ba27502007-12-24 16:55:16 +01002939
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05002940hash-type <method> <function> <modifier>
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02002941 Specify a method to use for mapping hashes to servers
2942 May be used in sections : defaults | frontend | listen | backend
2943 yes | no | yes | yes
2944 Arguments :
Bhaskar98634f02013-10-29 23:30:51 -04002945 <method> is the method used to select a server from the hash computed by
2946 the <function> :
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02002947
Bhaskar98634f02013-10-29 23:30:51 -04002948 map-based the hash table is a static array containing all alive servers.
2949 The hashes will be very smooth, will consider weights, but
2950 will be static in that weight changes while a server is up
2951 will be ignored. This means that there will be no slow start.
2952 Also, since a server is selected by its position in the array,
2953 most mappings are changed when the server count changes. This
2954 means that when a server goes up or down, or when a server is
2955 added to a farm, most connections will be redistributed to
2956 different servers. This can be inconvenient with caches for
2957 instance.
Willy Tarreau798a39c2010-11-24 15:04:29 +01002958
Bhaskar98634f02013-10-29 23:30:51 -04002959 consistent the hash table is a tree filled with many occurrences of each
2960 server. The hash key is looked up in the tree and the closest
2961 server is chosen. This hash is dynamic, it supports changing
2962 weights while the servers are up, so it is compatible with the
2963 slow start feature. It has the advantage that when a server
2964 goes up or down, only its associations are moved. When a
2965 server is added to the farm, only a few part of the mappings
2966 are redistributed, making it an ideal method for caches.
2967 However, due to its principle, the distribution will never be
2968 very smooth and it may sometimes be necessary to adjust a
2969 server's weight or its ID to get a more balanced distribution.
2970 In order to get the same distribution on multiple load
2971 balancers, it is important that all servers have the exact
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05002972 same IDs. Note: consistent hash uses sdbm and avalanche if no
2973 hash function is specified.
Bhaskar98634f02013-10-29 23:30:51 -04002974
2975 <function> is the hash function to be used :
2976
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03002977 sdbm this function was created initially for sdbm (a public-domain
Bhaskar98634f02013-10-29 23:30:51 -04002978 reimplementation of ndbm) database library. It was found to do
2979 well in scrambling bits, causing better distribution of the keys
2980 and fewer splits. It also happens to be a good general hashing
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05002981 function with good distribution, unless the total server weight
2982 is a multiple of 64, in which case applying the avalanche
2983 modifier may help.
Bhaskar98634f02013-10-29 23:30:51 -04002984
2985 djb2 this function was first proposed by Dan Bernstein many years ago
2986 on comp.lang.c. Studies have shown that for certain workload this
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05002987 function provides a better distribution than sdbm. It generally
2988 works well with text-based inputs though it can perform extremely
2989 poorly with numeric-only input or when the total server weight is
2990 a multiple of 33, unless the avalanche modifier is also used.
2991
Willy Tarreaua0f42712013-11-14 14:30:35 +01002992 wt6 this function was designed for haproxy while testing other
2993 functions in the past. It is not as smooth as the other ones, but
2994 is much less sensible to the input data set or to the number of
2995 servers. It can make sense as an alternative to sdbm+avalanche or
2996 djb2+avalanche for consistent hashing or when hashing on numeric
2997 data such as a source IP address or a visitor identifier in a URL
2998 parameter.
2999
Willy Tarreau324f07f2015-01-20 19:44:50 +01003000 crc32 this is the most common CRC32 implementation as used in Ethernet,
3001 gzip, PNG, etc. It is slower than the other ones but may provide
3002 a better distribution or less predictable results especially when
3003 used on strings.
3004
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05003005 <modifier> indicates an optional method applied after hashing the key :
3006
3007 avalanche This directive indicates that the result from the hash
3008 function above should not be used in its raw form but that
3009 a 4-byte full avalanche hash must be applied first. The
3010 purpose of this step is to mix the resulting bits from the
3011 previous hash in order to avoid any undesired effect when
3012 the input contains some limited values or when the number of
3013 servers is a multiple of one of the hash's components (64
3014 for SDBM, 33 for DJB2). Enabling avalanche tends to make the
3015 result less predictable, but it's also not as smooth as when
3016 using the original function. Some testing might be needed
3017 with some workloads. This hash is one of the many proposed
3018 by Bob Jenkins.
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02003019
Bhaskar98634f02013-10-29 23:30:51 -04003020 The default hash type is "map-based" and is recommended for most usages. The
3021 default function is "sdbm", the selection of a function should be based on
3022 the range of the values being hashed.
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02003023
3024 See also : "balance", "server"
3025
3026
Willy Tarreau0ba27502007-12-24 16:55:16 +01003027http-check disable-on-404
3028 Enable a maintenance mode upon HTTP/404 response to health-checks
3029 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau2769aa02007-12-27 18:26:09 +01003030 yes | no | yes | yes
Willy Tarreau0ba27502007-12-24 16:55:16 +01003031 Arguments : none
3032
3033 When this option is set, a server which returns an HTTP code 404 will be
3034 excluded from further load-balancing, but will still receive persistent
3035 connections. This provides a very convenient method for Web administrators
3036 to perform a graceful shutdown of their servers. It is also important to note
3037 that a server which is detected as failed while it was in this mode will not
3038 generate an alert, just a notice. If the server responds 2xx or 3xx again, it
3039 will immediately be reinserted into the farm. The status on the stats page
3040 reports "NOLB" for a server in this mode. It is important to note that this
Willy Tarreaubd741542010-03-16 18:46:54 +01003041 option only works in conjunction with the "httpchk" option. If this option
3042 is used with "http-check expect", then it has precedence over it so that 404
3043 responses will still be considered as soft-stop.
3044
3045 See also : "option httpchk", "http-check expect"
3046
3047
3048http-check expect [!] <match> <pattern>
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003049 Make HTTP health checks consider response contents or specific status codes
Willy Tarreaubd741542010-03-16 18:46:54 +01003050 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau1ee51a62011-08-19 20:04:17 +02003051 yes | no | yes | yes
Willy Tarreaubd741542010-03-16 18:46:54 +01003052 Arguments :
3053 <match> is a keyword indicating how to look for a specific pattern in the
3054 response. The keyword may be one of "status", "rstatus",
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003055 "string", or "rstring". The keyword may be preceded by an
Willy Tarreaubd741542010-03-16 18:46:54 +01003056 exclamation mark ("!") to negate the match. Spaces are allowed
3057 between the exclamation mark and the keyword. See below for more
3058 details on the supported keywords.
3059
3060 <pattern> is the pattern to look for. It may be a string or a regular
3061 expression. If the pattern contains spaces, they must be escaped
3062 with the usual backslash ('\').
3063
3064 By default, "option httpchk" considers that response statuses 2xx and 3xx
3065 are valid, and that others are invalid. When "http-check expect" is used,
3066 it defines what is considered valid or invalid. Only one "http-check"
3067 statement is supported in a backend. If a server fails to respond or times
3068 out, the check obviously fails. The available matches are :
3069
3070 status <string> : test the exact string match for the HTTP status code.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003071 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003072 response's status code is exactly this string. If the
3073 "status" keyword is prefixed with "!", then the response
3074 will be considered invalid if the status code matches.
3075
3076 rstatus <regex> : test a regular expression for the HTTP status code.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003077 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003078 response's status code matches the expression. If the
3079 "rstatus" keyword is prefixed with "!", then the response
3080 will be considered invalid if the status code matches.
3081 This is mostly used to check for multiple codes.
3082
3083 string <string> : test the exact string match in the HTTP response body.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003084 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003085 response's body contains this exact string. If the
3086 "string" keyword is prefixed with "!", then the response
3087 will be considered invalid if the body contains this
3088 string. This can be used to look for a mandatory word at
3089 the end of a dynamic page, or to detect a failure when a
3090 specific error appears on the check page (eg: a stack
3091 trace).
3092
3093 rstring <regex> : test a regular expression on the HTTP response body.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003094 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003095 response's body matches this expression. If the "rstring"
3096 keyword is prefixed with "!", then the response will be
3097 considered invalid if the body matches the expression.
3098 This can be used to look for a mandatory word at the end
3099 of a dynamic page, or to detect a failure when a specific
3100 error appears on the check page (eg: a stack trace).
3101
3102 It is important to note that the responses will be limited to a certain size
3103 defined by the global "tune.chksize" option, which defaults to 16384 bytes.
3104 Thus, too large responses may not contain the mandatory pattern when using
3105 "string" or "rstring". If a large response is absolutely required, it is
3106 possible to change the default max size by setting the global variable.
3107 However, it is worth keeping in mind that parsing very large responses can
3108 waste some CPU cycles, especially when regular expressions are used, and that
3109 it is always better to focus the checks on smaller resources.
3110
Cyril Bonté32602d22015-01-30 00:07:07 +01003111 Also "http-check expect" doesn't support HTTP keep-alive. Keep in mind that it
3112 will automatically append a "Connection: close" header, meaning that this
3113 header should not be present in the request provided by "option httpchk".
3114
Willy Tarreaubd741542010-03-16 18:46:54 +01003115 Last, if "http-check expect" is combined with "http-check disable-on-404",
3116 then this last one has precedence when the server responds with 404.
3117
3118 Examples :
3119 # only accept status 200 as valid
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003120 http-check expect status 200
Willy Tarreaubd741542010-03-16 18:46:54 +01003121
3122 # consider SQL errors as errors
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003123 http-check expect ! string SQL\ Error
Willy Tarreaubd741542010-03-16 18:46:54 +01003124
3125 # consider status 5xx only as errors
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003126 http-check expect ! rstatus ^5
Willy Tarreaubd741542010-03-16 18:46:54 +01003127
3128 # check that we have a correct hexadecimal tag before /html
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003129 http-check expect rstring <!--tag:[0-9a-f]*</html>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003130
Willy Tarreaubd741542010-03-16 18:46:54 +01003131 See also : "option httpchk", "http-check disable-on-404"
Willy Tarreau2769aa02007-12-27 18:26:09 +01003132
3133
Willy Tarreauef781042010-01-27 11:53:01 +01003134http-check send-state
3135 Enable emission of a state header with HTTP health checks
3136 May be used in sections : defaults | frontend | listen | backend
3137 yes | no | yes | yes
3138 Arguments : none
3139
3140 When this option is set, haproxy will systematically send a special header
3141 "X-Haproxy-Server-State" with a list of parameters indicating to each server
3142 how they are seen by haproxy. This can be used for instance when a server is
3143 manipulated without access to haproxy and the operator needs to know whether
3144 haproxy still sees it up or not, or if the server is the last one in a farm.
3145
3146 The header is composed of fields delimited by semi-colons, the first of which
3147 is a word ("UP", "DOWN", "NOLB"), possibly followed by a number of valid
3148 checks on the total number before transition, just as appears in the stats
3149 interface. Next headers are in the form "<variable>=<value>", indicating in
3150 no specific order some values available in the stats interface :
Joseph Lynch514061c2015-01-15 17:52:59 -08003151 - a variable "address", containing the address of the backend server.
3152 This corresponds to the <address> field in the server declaration. For
3153 unix domain sockets, it will read "unix".
3154
3155 - a variable "port", containing the port of the backend server. This
3156 corresponds to the <port> field in the server declaration. For unix
3157 domain sockets, it will read "unix".
3158
Willy Tarreauef781042010-01-27 11:53:01 +01003159 - a variable "name", containing the name of the backend followed by a slash
3160 ("/") then the name of the server. This can be used when a server is
3161 checked in multiple backends.
3162
3163 - a variable "node" containing the name of the haproxy node, as set in the
3164 global "node" variable, otherwise the system's hostname if unspecified.
3165
3166 - a variable "weight" indicating the weight of the server, a slash ("/")
3167 and the total weight of the farm (just counting usable servers). This
3168 helps to know if other servers are available to handle the load when this
3169 one fails.
3170
3171 - a variable "scur" indicating the current number of concurrent connections
3172 on the server, followed by a slash ("/") then the total number of
3173 connections on all servers of the same backend.
3174
3175 - a variable "qcur" indicating the current number of requests in the
3176 server's queue.
3177
3178 Example of a header received by the application server :
3179 >>> X-Haproxy-Server-State: UP 2/3; name=bck/srv2; node=lb1; weight=1/2; \
3180 scur=13/22; qcur=0
3181
3182 See also : "option httpchk", "http-check disable-on-404"
3183
Willy Tarreauccbcc372012-12-27 12:37:57 +01003184http-request { allow | deny | tarpit | auth [realm <realm>] | redirect <rule> |
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003185 add-header <name> <fmt> | set-header <name> <fmt> |
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003186 del-header <name> | set-nice <nice> | set-log-level <level> |
Sasha Pachev218f0642014-06-16 12:05:59 -06003187 replace-header <name> <match-regex> <replace-fmt> |
3188 replace-value <name> <match-regex> <replace-fmt> |
Willy Tarreaua0dc23f2015-01-22 20:46:11 +01003189 set-method <fmt> | set-path <fmt> | set-query <fmt> |
3190 set-uri <fmt> | set-tos <tos> | set-mark <mark> |
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003191 add-acl(<file name>) <key fmt> |
3192 del-acl(<file name>) <key fmt> |
3193 del-map(<file name>) <key fmt> |
Baptiste Assmannbb7e86a2014-09-03 18:29:47 +02003194 set-map(<file name>) <key fmt> <value fmt> |
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003195 { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>] |
3196 lua <function name>
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003197 }
Cyril Bontéf0c60612010-02-06 14:44:47 +01003198 [ { if | unless } <condition> ]
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003199 Access control for Layer 7 requests
3200
3201 May be used in sections: defaults | frontend | listen | backend
3202 no | yes | yes | yes
3203
Willy Tarreau20b0de52012-12-24 15:45:22 +01003204 The http-request statement defines a set of rules which apply to layer 7
3205 processing. The rules are evaluated in their declaration order when they are
3206 met in a frontend, listen or backend section. Any rule may optionally be
3207 followed by an ACL-based condition, in which case it will only be evaluated
3208 if the condition is true.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003209
Willy Tarreau20b0de52012-12-24 15:45:22 +01003210 The first keyword is the rule's action. Currently supported actions include :
3211 - "allow" : this stops the evaluation of the rules and lets the request
3212 pass the check. No further "http-request" rules are evaluated.
3213
3214 - "deny" : this stops the evaluation of the rules and immediately rejects
3215 the request and emits an HTTP 403 error. No further "http-request" rules
3216 are evaluated.
3217
Willy Tarreauccbcc372012-12-27 12:37:57 +01003218 - "tarpit" : this stops the evaluation of the rules and immediately blocks
3219 the request without responding for a delay specified by "timeout tarpit"
3220 or "timeout connect" if the former is not set. After that delay, if the
3221 client is still connected, an HTTP error 500 is returned so that the
3222 client does not suspect it has been tarpitted. Logs will report the flags
3223 "PT". The goal of the tarpit rule is to slow down robots during an attack
3224 when they're limited on the number of concurrent requests. It can be very
3225 efficient against very dumb robots, and will significantly reduce the
3226 load on firewalls compared to a "deny" rule. But when facing "correctly"
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03003227 developed robots, it can make things worse by forcing haproxy and the
Willy Tarreauccbcc372012-12-27 12:37:57 +01003228 front firewall to support insane number of concurrent connections.
3229
Willy Tarreau20b0de52012-12-24 15:45:22 +01003230 - "auth" : this stops the evaluation of the rules and immediately responds
3231 with an HTTP 401 or 407 error code to invite the user to present a valid
3232 user name and password. No further "http-request" rules are evaluated. An
3233 optional "realm" parameter is supported, it sets the authentication realm
3234 that is returned with the response (typically the application's name).
3235
Willy Tarreau81499eb2012-12-27 12:19:02 +01003236 - "redirect" : this performs an HTTP redirection based on a redirect rule.
3237 This is exactly the same as the "redirect" statement except that it
3238 inserts a redirect rule which can be processed in the middle of other
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01003239 "http-request" rules and that these rules use the "log-format" strings.
3240 See the "redirect" keyword for the rule's syntax.
Willy Tarreau81499eb2012-12-27 12:19:02 +01003241
Willy Tarreau20b0de52012-12-24 15:45:22 +01003242 - "add-header" appends an HTTP header field whose name is specified in
3243 <name> and whose value is defined by <fmt> which follows the log-format
3244 rules (see Custom Log Format in section 8.2.4). This is particularly
3245 useful to pass connection-specific information to the server (eg: the
3246 client's SSL certificate), or to combine several headers into one. This
3247 rule is not final, so it is possible to add other similar rules. Note
3248 that header addition is performed immediately, so one rule might reuse
3249 the resulting header from a previous rule.
3250
3251 - "set-header" does the same as "add-header" except that the header name
3252 is first removed if it existed. This is useful when passing security
3253 information to the server, where the header must not be manipulated by
Willy Tarreau85603282015-01-21 20:39:27 +01003254 external users. Note that the new value is computed before the removal so
3255 it is possible to concatenate a value to an existing header.
Willy Tarreau20b0de52012-12-24 15:45:22 +01003256
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003257 - "del-header" removes all HTTP header fields whose name is specified in
3258 <name>.
3259
Sasha Pachev218f0642014-06-16 12:05:59 -06003260 - "replace-header" matches the regular expression in all occurrences of
3261 header field <name> according to <match-regex>, and replaces them with
3262 the <replace-fmt> argument. Format characters are allowed in replace-fmt
3263 and work like in <fmt> arguments in "add-header". The match is only
3264 case-sensitive. It is important to understand that this action only
3265 considers whole header lines, regardless of the number of values they
3266 may contain. This usage is suited to headers naturally containing commas
3267 in their value, such as If-Modified-Since and so on.
3268
3269 Example:
3270
3271 http-request replace-header Cookie foo=([^;]*);(.*) foo=\1;ip=%bi;\2
3272
3273 applied to:
3274
3275 Cookie: foo=foobar; expires=Tue, 14-Jun-2016 01:40:45 GMT;
3276
3277 outputs:
3278
3279 Cookie: foo=foobar;ip=192.168.1.20; expires=Tue, 14-Jun-2016 01:40:45 GMT;
3280
3281 assuming the backend IP is 192.168.1.20
3282
3283 - "replace-value" works like "replace-header" except that it matches the
3284 regex against every comma-delimited value of the header field <name>
3285 instead of the entire header. This is suited for all headers which are
3286 allowed to carry more than one value. An example could be the Accept
3287 header.
3288
3289 Example:
3290
3291 http-request replace-value X-Forwarded-For ^192\.168\.(.*)$ 172.16.\1
3292
3293 applied to:
3294
3295 X-Forwarded-For: 192.168.10.1, 192.168.13.24, 10.0.0.37
3296
3297 outputs:
3298
3299 X-Forwarded-For: 172.16.10.1, 172.16.13.24, 10.0.0.37
3300
Willy Tarreaua0dc23f2015-01-22 20:46:11 +01003301 - "set-method" rewrites the request method with the result of the
3302 evaluation of format string <fmt>. There should be very few valid reasons
3303 for having to do so as this is more likely to break something than to fix
3304 it.
3305
3306 - "set-path" rewrites the request path with the result of the evaluation of
3307 format string <fmt>. The query string, if any, is left intact. If a
3308 scheme and authority is found before the path, they are left intact as
3309 well. If the request doesn't have a path ("*"), this one is replaced with
3310 the format. This can be used to prepend a directory component in front of
3311 a path for example. See also "set-query" and "set-uri".
3312
3313 Example :
3314 # prepend the host name before the path
3315 http-request set-path /%[hdr(host)]%[path]
3316
3317 - "set-query" rewrites the request's query string which appears after the
3318 first question mark ("?") with the result of the evaluation of format
3319 string <fmt>. The part prior to the question mark is left intact. If the
3320 request doesn't contain a question mark and the new value is not empty,
3321 then one is added at the end of the URI, followed by the new value. If
3322 a question mark was present, it will never be removed even if the value
3323 is empty. This can be used to add or remove parameters from the query
3324 string. See also "set-query" and "set-uri".
3325
3326 Example :
3327 # replace "%3D" with "=" in the query string
3328 http-request set-query %[query,regsub(%3D,=,g)]
3329
3330 - "set-uri" rewrites the request URI with the result of the evaluation of
3331 format string <fmt>. The scheme, authority, path and query string are all
3332 replaced at once. This can be used to rewrite hosts in front of proxies,
3333 or to perform complex modifications to the URI such as moving parts
3334 between the path and the query string. See also "set-path" and
3335 "set-query".
3336
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003337 - "set-nice" sets the "nice" factor of the current request being processed.
3338 It only has effect against the other requests being processed at the same
3339 time. The default value is 0, unless altered by the "nice" setting on the
3340 "bind" line. The accepted range is -1024..1024. The higher the value, the
3341 nicest the request will be. Lower values will make the request more
3342 important than other ones. This can be useful to improve the speed of
3343 some requests, or lower the priority of non-important requests. Using
3344 this setting without prior experimentation can cause some major slowdown.
3345
Willy Tarreau9a355ec2013-06-11 17:45:46 +02003346 - "set-log-level" is used to change the log level of the current request
3347 when a certain condition is met. Valid levels are the 8 syslog levels
3348 (see the "log" keyword) plus the special level "silent" which disables
3349 logging for this request. This rule is not final so the last matching
3350 rule wins. This rule can be useful to disable health checks coming from
3351 another equipment.
3352
Willy Tarreau42cf39e2013-06-11 18:51:32 +02003353 - "set-tos" is used to set the TOS or DSCP field value of packets sent to
3354 the client to the value passed in <tos> on platforms which support this.
3355 This value represents the whole 8 bits of the IP TOS field, and can be
3356 expressed both in decimal or hexadecimal format (prefixed by "0x"). Note
3357 that only the 6 higher bits are used in DSCP or TOS, and the two lower
3358 bits are always 0. This can be used to adjust some routing behaviour on
3359 border routers based on some information from the request. See RFC 2474,
3360 2597, 3260 and 4594 for more information.
3361
Willy Tarreau51347ed2013-06-11 19:34:13 +02003362 - "set-mark" is used to set the Netfilter MARK on all packets sent to the
3363 client to the value passed in <mark> on platforms which support it. This
3364 value is an unsigned 32 bit value which can be matched by netfilter and
3365 by the routing table. It can be expressed both in decimal or hexadecimal
3366 format (prefixed by "0x"). This can be useful to force certain packets to
3367 take a different route (for example a cheaper network path for bulk
3368 downloads). This works on Linux kernels 2.6.32 and above and requires
3369 admin privileges.
3370
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003371 - "add-acl" is used to add a new entry into an ACL. The ACL must be loaded
3372 from a file (even a dummy empty file). The file name of the ACL to be
3373 updated is passed between parentheses. It takes one argument: <key fmt>,
3374 which follows log-format rules, to collect content of the new entry. It
3375 performs a lookup in the ACL before insertion, to avoid duplicated (or
3376 more) values. This lookup is done by a linear search and can be expensive
3377 with large lists! It is the equivalent of the "add acl" command from the
3378 stats socket, but can be triggered by an HTTP request.
3379
3380 - "del-acl" is used to delete an entry from an ACL. The ACL must be loaded
3381 from a file (even a dummy empty file). The file name of the ACL to be
3382 updated is passed between parentheses. It takes one argument: <key fmt>,
3383 which follows log-format rules, to collect content of the entry to delete.
3384 It is the equivalent of the "del acl" command from the stats socket, but
3385 can be triggered by an HTTP request.
3386
3387 - "del-map" is used to delete an entry from a MAP. The MAP must be loaded
3388 from a file (even a dummy empty file). The file name of the MAP to be
3389 updated is passed between parentheses. It takes one argument: <key fmt>,
3390 which follows log-format rules, to collect content of the entry to delete.
3391 It takes one argument: "file name" It is the equivalent of the "del map"
3392 command from the stats socket, but can be triggered by an HTTP request.
3393
3394 - "set-map" is used to add a new entry into a MAP. The MAP must be loaded
3395 from a file (even a dummy empty file). The file name of the MAP to be
3396 updated is passed between parentheses. It takes 2 arguments: <key fmt>,
3397 which follows log-format rules, used to collect MAP key, and <value fmt>,
3398 which follows log-format rules, used to collect content for the new entry.
3399 It performs a lookup in the MAP before insertion, to avoid duplicated (or
3400 more) values. This lookup is done by a linear search and can be expensive
3401 with large lists! It is the equivalent of the "set map" command from the
3402 stats socket, but can be triggered by an HTTP request.
3403
Willy Tarreau09448f72014-06-25 18:12:15 +02003404 - { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>] :
3405 enables tracking of sticky counters from current request. These rules
3406 do not stop evaluation and do not change default action. Three sets of
3407 counters may be simultaneously tracked by the same connection. The first
3408 "track-sc0" rule executed enables tracking of the counters of the
3409 specified table as the first set. The first "track-sc1" rule executed
3410 enables tracking of the counters of the specified table as the second
3411 set. The first "track-sc2" rule executed enables tracking of the
3412 counters of the specified table as the third set. It is a recommended
3413 practice to use the first set of counters for the per-frontend counters
3414 and the second set for the per-backend ones. But this is just a
3415 guideline, all may be used everywhere.
3416
3417 These actions take one or two arguments :
3418 <key> is mandatory, and is a sample expression rule as described
3419 in section 7.3. It describes what elements of the incoming
3420 request or connection will be analysed, extracted, combined,
3421 and used to select which table entry to update the counters.
3422
3423 <table> is an optional table to be used instead of the default one,
3424 which is the stick-table declared in the current proxy. All
3425 the counters for the matches and updates for the key will
3426 then be performed in that table until the session ends.
3427
3428 Once a "track-sc*" rule is executed, the key is looked up in the table
3429 and if it is not found, an entry is allocated for it. Then a pointer to
3430 that entry is kept during all the session's life, and this entry's
3431 counters are updated as often as possible, every time the session's
3432 counters are updated, and also systematically when the session ends.
3433 Counters are only updated for events that happen after the tracking has
3434 been started. As an exception, connection counters and request counters
3435 are systematically updated so that they reflect useful information.
3436
3437 If the entry tracks concurrent connection counters, one connection is
3438 counted for as long as the entry is tracked, and the entry will not
3439 expire during that time. Tracking counters also provides a performance
3440 advantage over just checking the keys, because only one table lookup is
3441 performed for all ACL checks that make use of it.
3442
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003443 - "lua" is used to run a Lua function if the action is executed. The single
3444 parameter is the name of the function to run. The prototype of the
3445 function is documented in the API documentation.
3446
Willy Tarreau20b0de52012-12-24 15:45:22 +01003447 There is no limit to the number of http-request statements per instance.
3448
3449 It is important to know that http-request rules are processed very early in
3450 the HTTP processing, just after "block" rules and before "reqdel" or "reqrep"
3451 rules. That way, headers added by "add-header"/"set-header" are visible by
3452 almost all further ACL rules.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003453
3454 Example:
Cyril Bonté78caf842010-03-10 22:41:43 +01003455 acl nagios src 192.168.129.3
3456 acl local_net src 192.168.0.0/16
3457 acl auth_ok http_auth(L1)
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003458
Cyril Bonté78caf842010-03-10 22:41:43 +01003459 http-request allow if nagios
3460 http-request allow if local_net auth_ok
3461 http-request auth realm Gimme if local_net auth_ok
3462 http-request deny
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003463
Cyril Bonté78caf842010-03-10 22:41:43 +01003464 Example:
3465 acl auth_ok http_auth_group(L1) G1
Cyril Bonté78caf842010-03-10 22:41:43 +01003466 http-request auth unless auth_ok
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003467
Willy Tarreau20b0de52012-12-24 15:45:22 +01003468 Example:
3469 http-request set-header X-Haproxy-Current-Date %T
3470 http-request set-header X-SSL %[ssl_fc]
3471 http-request set-header X-SSL-Session_ID %[ssl_fc_session_id]
3472 http-request set-header X-SSL-Client-Verify %[ssl_c_verify]
3473 http-request set-header X-SSL-Client-DN %{+Q}[ssl_c_s_dn]
3474 http-request set-header X-SSL-Client-CN %{+Q}[ssl_c_s_dn(cn)]
3475 http-request set-header X-SSL-Issuer %{+Q}[ssl_c_i_dn]
3476 http-request set-header X-SSL-Client-NotBefore %{+Q}[ssl_c_notbefore]
3477 http-request set-header X-SSL-Client-NotAfter %{+Q}[ssl_c_notafter]
3478
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003479 Example:
3480 acl key req.hdr(X-Add-Acl-Key) -m found
3481 acl add path /addacl
3482 acl del path /delacl
3483
3484 acl myhost hdr(Host) -f myhost.lst
3485
3486 http-request add-acl(myhost.lst) %[req.hdr(X-Add-Acl-Key)] if key add
3487 http-request del-acl(myhost.lst) %[req.hdr(X-Add-Acl-Key)] if key del
3488
3489 Example:
3490 acl value req.hdr(X-Value) -m found
3491 acl setmap path /setmap
3492 acl delmap path /delmap
3493
3494 use_backend bk_appli if { hdr(Host),map_str(map.lst) -m found }
3495
3496 http-request set-map(map.lst) %[src] %[req.hdr(X-Value)] if setmap value
3497 http-request del-map(map.lst) %[src] if delmap
3498
Cyril Bonté2be1b3f2010-09-30 23:46:30 +02003499 See also : "stats http-request", section 3.4 about userlists and section 7
3500 about ACL usage.
Willy Tarreauef781042010-01-27 11:53:01 +01003501
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003502http-response { allow | deny | add-header <name> <fmt> | set-nice <nice> |
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003503 set-header <name> <fmt> | del-header <name> |
Sasha Pachev218f0642014-06-16 12:05:59 -06003504 replace-header <name> <regex-match> <replace-fmt> |
3505 replace-value <name> <regex-match> <replace-fmt> |
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003506 set-log-level <level> | set-mark <mark> | set-tos <tos> |
3507 add-acl(<file name>) <key fmt> |
3508 del-acl(<file name>) <key fmt> |
3509 del-map(<file name>) <key fmt> |
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003510 set-map(<file name>) <key fmt> <value fmt> |
3511 lua <function name>
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003512 }
Lukas Tribus2dd1d1a2013-06-19 23:34:41 +02003513 [ { if | unless } <condition> ]
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003514 Access control for Layer 7 responses
3515
3516 May be used in sections: defaults | frontend | listen | backend
3517 no | yes | yes | yes
3518
3519 The http-response statement defines a set of rules which apply to layer 7
3520 processing. The rules are evaluated in their declaration order when they are
3521 met in a frontend, listen or backend section. Any rule may optionally be
3522 followed by an ACL-based condition, in which case it will only be evaluated
3523 if the condition is true. Since these rules apply on responses, the backend
3524 rules are applied first, followed by the frontend's rules.
3525
3526 The first keyword is the rule's action. Currently supported actions include :
3527 - "allow" : this stops the evaluation of the rules and lets the response
3528 pass the check. No further "http-response" rules are evaluated for the
3529 current section.
3530
3531 - "deny" : this stops the evaluation of the rules and immediately rejects
3532 the response and emits an HTTP 502 error. No further "http-response"
3533 rules are evaluated.
3534
3535 - "add-header" appends an HTTP header field whose name is specified in
3536 <name> and whose value is defined by <fmt> which follows the log-format
3537 rules (see Custom Log Format in section 8.2.4). This may be used to send
3538 a cookie to a client for example, or to pass some internal information.
3539 This rule is not final, so it is possible to add other similar rules.
3540 Note that header addition is performed immediately, so one rule might
3541 reuse the resulting header from a previous rule.
3542
3543 - "set-header" does the same as "add-header" except that the header name
3544 is first removed if it existed. This is useful when passing security
3545 information to the server, where the header must not be manipulated by
3546 external users.
3547
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003548 - "del-header" removes all HTTP header fields whose name is specified in
3549 <name>.
3550
Sasha Pachev218f0642014-06-16 12:05:59 -06003551 - "replace-header" matches the regular expression in all occurrences of
3552 header field <name> according to <match-regex>, and replaces them with
3553 the <replace-fmt> argument. Format characters are allowed in replace-fmt
3554 and work like in <fmt> arguments in "add-header". The match is only
3555 case-sensitive. It is important to understand that this action only
3556 considers whole header lines, regardless of the number of values they
3557 may contain. This usage is suited to headers naturally containing commas
3558 in their value, such as Set-Cookie, Expires and so on.
3559
3560 Example:
3561
3562 http-response replace-header Set-Cookie (C=[^;]*);(.*) \1;ip=%bi;\2
3563
3564 applied to:
3565
3566 Set-Cookie: C=1; expires=Tue, 14-Jun-2016 01:40:45 GMT
3567
3568 outputs:
3569
3570 Set-Cookie: C=1;ip=192.168.1.20; expires=Tue, 14-Jun-2016 01:40:45 GMT
3571
3572 assuming the backend IP is 192.168.1.20.
3573
3574 - "replace-value" works like "replace-header" except that it matches the
3575 regex against every comma-delimited value of the header field <name>
3576 instead of the entire header. This is suited for all headers which are
3577 allowed to carry more than one value. An example could be the Accept
3578 header.
3579
3580 Example:
3581
3582 http-response replace-value Cache-control ^public$ private
3583
3584 applied to:
3585
3586 Cache-Control: max-age=3600, public
3587
3588 outputs:
3589
3590 Cache-Control: max-age=3600, private
3591
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003592 - "set-nice" sets the "nice" factor of the current request being processed.
3593 It only has effect against the other requests being processed at the same
3594 time. The default value is 0, unless altered by the "nice" setting on the
3595 "bind" line. The accepted range is -1024..1024. The higher the value, the
3596 nicest the request will be. Lower values will make the request more
3597 important than other ones. This can be useful to improve the speed of
3598 some requests, or lower the priority of non-important requests. Using
3599 this setting without prior experimentation can cause some major slowdown.
3600
Willy Tarreau9a355ec2013-06-11 17:45:46 +02003601 - "set-log-level" is used to change the log level of the current request
3602 when a certain condition is met. Valid levels are the 8 syslog levels
3603 (see the "log" keyword) plus the special level "silent" which disables
3604 logging for this request. This rule is not final so the last matching
3605 rule wins. This rule can be useful to disable health checks coming from
3606 another equipment.
3607
Willy Tarreau42cf39e2013-06-11 18:51:32 +02003608 - "set-tos" is used to set the TOS or DSCP field value of packets sent to
3609 the client to the value passed in <tos> on platforms which support this.
3610 This value represents the whole 8 bits of the IP TOS field, and can be
3611 expressed both in decimal or hexadecimal format (prefixed by "0x"). Note
3612 that only the 6 higher bits are used in DSCP or TOS, and the two lower
3613 bits are always 0. This can be used to adjust some routing behaviour on
3614 border routers based on some information from the request. See RFC 2474,
3615 2597, 3260 and 4594 for more information.
3616
Willy Tarreau51347ed2013-06-11 19:34:13 +02003617 - "set-mark" is used to set the Netfilter MARK on all packets sent to the
3618 client to the value passed in <mark> on platforms which support it. This
3619 value is an unsigned 32 bit value which can be matched by netfilter and
3620 by the routing table. It can be expressed both in decimal or hexadecimal
3621 format (prefixed by "0x"). This can be useful to force certain packets to
3622 take a different route (for example a cheaper network path for bulk
3623 downloads). This works on Linux kernels 2.6.32 and above and requires
3624 admin privileges.
3625
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003626 - "add-acl" is used to add a new entry into an ACL. The ACL must be loaded
3627 from a file (even a dummy empty file). The file name of the ACL to be
3628 updated is passed between parentheses. It takes one argument: <key fmt>,
3629 which follows log-format rules, to collect content of the new entry. It
3630 performs a lookup in the ACL before insertion, to avoid duplicated (or
3631 more) values. This lookup is done by a linear search and can be expensive
3632 with large lists! It is the equivalent of the "add acl" command from the
3633 stats socket, but can be triggered by an HTTP response.
3634
3635 - "del-acl" is used to delete an entry from an ACL. The ACL must be loaded
3636 from a file (even a dummy empty file). The file name of the ACL to be
3637 updated is passed between parentheses. It takes one argument: <key fmt>,
3638 which follows log-format rules, to collect content of the entry to delete.
3639 It is the equivalent of the "del acl" command from the stats socket, but
3640 can be triggered by an HTTP response.
3641
3642 - "del-map" is used to delete an entry from a MAP. The MAP must be loaded
3643 from a file (even a dummy empty file). The file name of the MAP to be
3644 updated is passed between parentheses. It takes one argument: <key fmt>,
3645 which follows log-format rules, to collect content of the entry to delete.
3646 It takes one argument: "file name" It is the equivalent of the "del map"
3647 command from the stats socket, but can be triggered by an HTTP response.
3648
3649 - "set-map" is used to add a new entry into a MAP. The MAP must be loaded
3650 from a file (even a dummy empty file). The file name of the MAP to be
3651 updated is passed between parentheses. It takes 2 arguments: <key fmt>,
3652 which follows log-format rules, used to collect MAP key, and <value fmt>,
3653 which follows log-format rules, used to collect content for the new entry.
3654 It performs a lookup in the MAP before insertion, to avoid duplicated (or
3655 more) values. This lookup is done by a linear search and can be expensive
3656 with large lists! It is the equivalent of the "set map" command from the
3657 stats socket, but can be triggered by an HTTP response.
3658
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003659 - "lua" is used to run a Lua function if the action is executed. The single
3660 parameter is the name of the function to run. The prototype of the
3661 function is documented in the API documentation.
3662
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003663 There is no limit to the number of http-response statements per instance.
3664
Godbach09250262013-07-02 01:19:15 +08003665 It is important to know that http-response rules are processed very early in
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003666 the HTTP processing, before "reqdel" or "reqrep" rules. That way, headers
3667 added by "add-header"/"set-header" are visible by almost all further ACL
3668 rules.
3669
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003670 Example:
3671 acl key_acl res.hdr(X-Acl-Key) -m found
3672
3673 acl myhost hdr(Host) -f myhost.lst
3674
3675 http-response add-acl(myhost.lst) %[res.hdr(X-Acl-Key)] if key_acl
3676 http-response del-acl(myhost.lst) %[res.hdr(X-Acl-Key)] if key_acl
3677
3678 Example:
3679 acl value res.hdr(X-Value) -m found
3680
3681 use_backend bk_appli if { hdr(Host),map_str(map.lst) -m found }
3682
3683 http-response set-map(map.lst) %[src] %[res.hdr(X-Value)] if value
3684 http-response del-map(map.lst) %[src] if ! value
3685
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003686 See also : "http-request", section 3.4 about userlists and section 7 about
3687 ACL usage.
3688
Baptiste Assmann5ecb77f2013-10-06 23:24:13 +02003689
Mark Lamourinec2247f02012-01-04 13:02:01 -05003690http-send-name-header [<header>]
3691 Add the server name to a request. Use the header string given by <header>
3692
3693 May be used in sections: defaults | frontend | listen | backend
3694 yes | no | yes | yes
3695
3696 Arguments :
3697
3698 <header> The header string to use to send the server name
3699
3700 The "http-send-name-header" statement causes the name of the target
3701 server to be added to the headers of an HTTP request. The name
3702 is added with the header string proved.
3703
3704 See also : "server"
3705
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01003706id <value>
Willy Tarreau53fb4ae2009-10-04 23:04:08 +02003707 Set a persistent ID to a proxy.
3708 May be used in sections : defaults | frontend | listen | backend
3709 no | yes | yes | yes
3710 Arguments : none
3711
3712 Set a persistent ID for the proxy. This ID must be unique and positive.
3713 An unused ID will automatically be assigned if unset. The first assigned
3714 value will be 1. This ID is currently only returned in statistics.
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01003715
3716
Cyril Bonté0d4bf012010-04-25 23:21:46 +02003717ignore-persist { if | unless } <condition>
3718 Declare a condition to ignore persistence
3719 May be used in sections: defaults | frontend | listen | backend
3720 no | yes | yes | yes
3721
3722 By default, when cookie persistence is enabled, every requests containing
3723 the cookie are unconditionally persistent (assuming the target server is up
3724 and running).
3725
3726 The "ignore-persist" statement allows one to declare various ACL-based
3727 conditions which, when met, will cause a request to ignore persistence.
3728 This is sometimes useful to load balance requests for static files, which
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03003729 often don't require persistence. This can also be used to fully disable
Cyril Bonté0d4bf012010-04-25 23:21:46 +02003730 persistence for a specific User-Agent (for example, some web crawler bots).
3731
3732 Combined with "appsession", it can also help reduce HAProxy memory usage, as
3733 the appsession table won't grow if persistence is ignored.
3734
3735 The persistence is ignored when an "if" condition is met, or unless an
3736 "unless" condition is met.
3737
3738 See also : "force-persist", "cookie", and section 7 about ACL usage.
3739
3740
Willy Tarreau2769aa02007-12-27 18:26:09 +01003741log global
Willy Tarreau18324f52014-06-27 18:10:07 +02003742log <address> [len <length>] <facility> [<level> [<minlevel>]]
William Lallemand0f99e342011-10-12 17:50:54 +02003743no log
Willy Tarreau2769aa02007-12-27 18:26:09 +01003744 Enable per-instance logging of events and traffic.
3745 May be used in sections : defaults | frontend | listen | backend
3746 yes | yes | yes | yes
William Lallemand0f99e342011-10-12 17:50:54 +02003747
3748 Prefix :
3749 no should be used when the logger list must be flushed. For example,
3750 if you don't want to inherit from the default logger list. This
3751 prefix does not allow arguments.
3752
Willy Tarreau2769aa02007-12-27 18:26:09 +01003753 Arguments :
3754 global should be used when the instance's logging parameters are the
3755 same as the global ones. This is the most common usage. "global"
3756 replaces <address>, <facility> and <level> with those of the log
3757 entries found in the "global" section. Only one "log global"
3758 statement may be used per instance, and this form takes no other
3759 parameter.
3760
3761 <address> indicates where to send the logs. It takes the same format as
3762 for the "global" section's logs, and can be one of :
3763
3764 - An IPv4 address optionally followed by a colon (':') and a UDP
3765 port. If no port is specified, 514 is used by default (the
3766 standard syslog port).
3767
David du Colombier24bb5f52011-03-17 10:40:23 +01003768 - An IPv6 address followed by a colon (':') and optionally a UDP
3769 port. If no port is specified, 514 is used by default (the
3770 standard syslog port).
3771
Willy Tarreau2769aa02007-12-27 18:26:09 +01003772 - A filesystem path to a UNIX domain socket, keeping in mind
3773 considerations for chroot (be sure the path is accessible
3774 inside the chroot) and uid/gid (be sure the path is
3775 appropriately writeable).
3776
Willy Tarreaudad36a32013-03-11 01:20:04 +01003777 Any part of the address string may reference any number of
3778 environment variables by preceding their name with a dollar
3779 sign ('$') and optionally enclosing them with braces ('{}'),
3780 similarly to what is done in Bourne shell.
3781
Willy Tarreau18324f52014-06-27 18:10:07 +02003782 <length> is an optional maximum line length. Log lines larger than this
3783 value will be truncated before being sent. The reason is that
3784 syslog servers act differently on log line length. All servers
3785 support the default value of 1024, but some servers simply drop
3786 larger lines while others do log them. If a server supports long
3787 lines, it may make sense to set this value here in order to avoid
3788 truncating long lines. Similarly, if a server drops long lines,
3789 it is preferable to truncate them before sending them. Accepted
3790 values are 80 to 65535 inclusive. The default value of 1024 is
3791 generally fine for all standard usages. Some specific cases of
3792 long captures or JSON-formated logs may require larger values.
3793
Willy Tarreau2769aa02007-12-27 18:26:09 +01003794 <facility> must be one of the 24 standard syslog facilities :
3795
3796 kern user mail daemon auth syslog lpr news
3797 uucp cron auth2 ftp ntp audit alert cron2
3798 local0 local1 local2 local3 local4 local5 local6 local7
3799
3800 <level> is optional and can be specified to filter outgoing messages. By
3801 default, all messages are sent. If a level is specified, only
3802 messages with a severity at least as important as this level
Willy Tarreauf7edefa2009-05-10 17:20:05 +02003803 will be sent. An optional minimum level can be specified. If it
3804 is set, logs emitted with a more severe level than this one will
3805 be capped to this level. This is used to avoid sending "emerg"
3806 messages on all terminals on some default syslog configurations.
3807 Eight levels are known :
Willy Tarreau2769aa02007-12-27 18:26:09 +01003808
3809 emerg alert crit err warning notice info debug
3810
William Lallemand0f99e342011-10-12 17:50:54 +02003811 It is important to keep in mind that it is the frontend which decides what to
3812 log from a connection, and that in case of content switching, the log entries
3813 from the backend will be ignored. Connections are logged at level "info".
Willy Tarreaucc6c8912009-02-22 10:53:55 +01003814
3815 However, backend log declaration define how and where servers status changes
3816 will be logged. Level "notice" will be used to indicate a server going up,
3817 "warning" will be used for termination signals and definitive service
3818 termination, and "alert" will be used for when a server goes down.
3819
3820 Note : According to RFC3164, messages are truncated to 1024 bytes before
3821 being emitted.
Willy Tarreau2769aa02007-12-27 18:26:09 +01003822
3823 Example :
3824 log global
Willy Tarreauf7edefa2009-05-10 17:20:05 +02003825 log 127.0.0.1:514 local0 notice # only send important events
3826 log 127.0.0.1:514 local0 notice notice # same but limit output level
Willy Tarreaudad36a32013-03-11 01:20:04 +01003827 log ${LOCAL_SYSLOG}:514 local0 notice # send to local server
3828
Willy Tarreau2769aa02007-12-27 18:26:09 +01003829
William Lallemand48940402012-01-30 16:47:22 +01003830log-format <string>
Willy Tarreaufb4e7ea2015-01-07 14:55:17 +01003831 Specifies the log format string to use for traffic logs
3832 May be used in sections: defaults | frontend | listen | backend
3833 yes | yes | yes | no
William Lallemand48940402012-01-30 16:47:22 +01003834
Willy Tarreaufb4e7ea2015-01-07 14:55:17 +01003835 This directive specifies the log format string that will be used for all logs
3836 resulting from traffic passing through the frontend using this line. If the
3837 directive is used in a defaults section, all subsequent frontends will use
3838 the same log format. Please see section 8.2.4 which covers the log format
3839 string in depth.
William Lallemand48940402012-01-30 16:47:22 +01003840
Willy Tarreau094af4e2015-01-07 15:03:42 +01003841log-tag <string>
3842 Specifies the log tag to use for all outgoing logs
3843 May be used in sections: defaults | frontend | listen | backend
3844 yes | yes | yes | yes
3845
3846 Sets the tag field in the syslog header to this string. It defaults to the
3847 log-tag set in the global section, otherwise the program name as launched
3848 from the command line, which usually is "haproxy". Sometimes it can be useful
3849 to differentiate between multiple processes running on the same host, or to
3850 differentiate customer instances running in the same process. In the backend,
3851 logs about servers up/down will use this tag. As a hint, it can be convenient
3852 to set a log-tag related to a hosted customer in a defaults section then put
3853 all the frontends and backends for that customer, then start another customer
3854 in a new defaults section. See also the global "log-tag" directive.
Willy Tarreau2769aa02007-12-27 18:26:09 +01003855
Willy Tarreauc35362a2014-04-25 13:58:37 +02003856max-keep-alive-queue <value>
3857 Set the maximum server queue size for maintaining keep-alive connections
3858 May be used in sections: defaults | frontend | listen | backend
3859 yes | no | yes | yes
3860
3861 HTTP keep-alive tries to reuse the same server connection whenever possible,
3862 but sometimes it can be counter-productive, for example if a server has a lot
3863 of connections while other ones are idle. This is especially true for static
3864 servers.
3865
3866 The purpose of this setting is to set a threshold on the number of queued
3867 connections at which haproxy stops trying to reuse the same server and prefers
3868 to find another one. The default value, -1, means there is no limit. A value
3869 of zero means that keep-alive requests will never be queued. For very close
3870 servers which can be reached with a low latency and which are not sensible to
3871 breaking keep-alive, a low value is recommended (eg: local static server can
3872 use a value of 10 or less). For remote servers suffering from a high latency,
3873 higher values might be needed to cover for the latency and/or the cost of
3874 picking a different server.
3875
3876 Note that this has no impact on responses which are maintained to the same
3877 server consecutively to a 401 response. They will still go to the same server
3878 even if they have to be queued.
3879
3880 See also : "option http-server-close", "option prefer-last-server", server
3881 "maxconn" and cookie persistence.
3882
3883
Willy Tarreau2769aa02007-12-27 18:26:09 +01003884maxconn <conns>
3885 Fix the maximum number of concurrent connections on a frontend
3886 May be used in sections : defaults | frontend | listen | backend
3887 yes | yes | yes | no
3888 Arguments :
3889 <conns> is the maximum number of concurrent connections the frontend will
3890 accept to serve. Excess connections will be queued by the system
3891 in the socket's listen queue and will be served once a connection
3892 closes.
3893
3894 If the system supports it, it can be useful on big sites to raise this limit
3895 very high so that haproxy manages connection queues, instead of leaving the
3896 clients with unanswered connection attempts. This value should not exceed the
3897 global maxconn. Also, keep in mind that a connection contains two buffers
3898 of 8kB each, as well as some other data resulting in about 17 kB of RAM being
3899 consumed per established connection. That means that a medium system equipped
3900 with 1GB of RAM can withstand around 40000-50000 concurrent connections if
3901 properly tuned.
3902
3903 Also, when <conns> is set to large values, it is possible that the servers
3904 are not sized to accept such loads, and for this reason it is generally wise
3905 to assign them some reasonable connection limits.
3906
Vincent Bernat6341be52012-06-27 17:18:30 +02003907 By default, this value is set to 2000.
3908
Willy Tarreau2769aa02007-12-27 18:26:09 +01003909 See also : "server", global section's "maxconn", "fullconn"
3910
3911
3912mode { tcp|http|health }
3913 Set the running mode or protocol of the instance
3914 May be used in sections : defaults | frontend | listen | backend
3915 yes | yes | yes | yes
3916 Arguments :
3917 tcp The instance will work in pure TCP mode. A full-duplex connection
3918 will be established between clients and servers, and no layer 7
3919 examination will be performed. This is the default mode. It
3920 should be used for SSL, SSH, SMTP, ...
3921
3922 http The instance will work in HTTP mode. The client request will be
3923 analyzed in depth before connecting to any server. Any request
3924 which is not RFC-compliant will be rejected. Layer 7 filtering,
3925 processing and switching will be possible. This is the mode which
3926 brings HAProxy most of its value.
3927
3928 health The instance will work in "health" mode. It will just reply "OK"
Willy Tarreau82569f92012-09-27 23:48:56 +02003929 to incoming connections and close the connection. Alternatively,
3930 If the "httpchk" option is set, "HTTP/1.0 200 OK" will be sent
3931 instead. Nothing will be logged in either case. This mode is used
3932 to reply to external components health checks. This mode is
3933 deprecated and should not be used anymore as it is possible to do
3934 the same and even better by combining TCP or HTTP modes with the
3935 "monitor" keyword.
Willy Tarreau2769aa02007-12-27 18:26:09 +01003936
Cyril Bonté108cf6e2012-04-21 23:30:29 +02003937 When doing content switching, it is mandatory that the frontend and the
3938 backend are in the same mode (generally HTTP), otherwise the configuration
3939 will be refused.
Willy Tarreau2769aa02007-12-27 18:26:09 +01003940
Cyril Bonté108cf6e2012-04-21 23:30:29 +02003941 Example :
Willy Tarreau2769aa02007-12-27 18:26:09 +01003942 defaults http_instances
3943 mode http
3944
Cyril Bonté108cf6e2012-04-21 23:30:29 +02003945 See also : "monitor", "monitor-net"
Willy Tarreau2769aa02007-12-27 18:26:09 +01003946
Willy Tarreau0ba27502007-12-24 16:55:16 +01003947
Cyril Bontéf0c60612010-02-06 14:44:47 +01003948monitor fail { if | unless } <condition>
Willy Tarreau2769aa02007-12-27 18:26:09 +01003949 Add a condition to report a failure to a monitor HTTP request.
Willy Tarreau0ba27502007-12-24 16:55:16 +01003950 May be used in sections : defaults | frontend | listen | backend
3951 no | yes | yes | no
Willy Tarreau0ba27502007-12-24 16:55:16 +01003952 Arguments :
3953 if <cond> the monitor request will fail if the condition is satisfied,
3954 and will succeed otherwise. The condition should describe a
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01003955 combined test which must induce a failure if all conditions
Willy Tarreau0ba27502007-12-24 16:55:16 +01003956 are met, for instance a low number of servers both in a
3957 backend and its backup.
3958
3959 unless <cond> the monitor request will succeed only if the condition is
3960 satisfied, and will fail otherwise. Such a condition may be
3961 based on a test on the presence of a minimum number of active
3962 servers in a list of backends.
3963
3964 This statement adds a condition which can force the response to a monitor
3965 request to report a failure. By default, when an external component queries
3966 the URI dedicated to monitoring, a 200 response is returned. When one of the
3967 conditions above is met, haproxy will return 503 instead of 200. This is
3968 very useful to report a site failure to an external component which may base
3969 routing advertisements between multiple sites on the availability reported by
3970 haproxy. In this case, one would rely on an ACL involving the "nbsrv"
Willy Tarreauae94d4d2011-05-11 16:28:49 +02003971 criterion. Note that "monitor fail" only works in HTTP mode. Both status
3972 messages may be tweaked using "errorfile" or "errorloc" if needed.
Willy Tarreau0ba27502007-12-24 16:55:16 +01003973
3974 Example:
3975 frontend www
Willy Tarreau2769aa02007-12-27 18:26:09 +01003976 mode http
Willy Tarreau0ba27502007-12-24 16:55:16 +01003977 acl site_dead nbsrv(dynamic) lt 2
3978 acl site_dead nbsrv(static) lt 2
3979 monitor-uri /site_alive
3980 monitor fail if site_dead
3981
Willy Tarreauae94d4d2011-05-11 16:28:49 +02003982 See also : "monitor-net", "monitor-uri", "errorfile", "errorloc"
Willy Tarreau2769aa02007-12-27 18:26:09 +01003983
3984
3985monitor-net <source>
3986 Declare a source network which is limited to monitor requests
3987 May be used in sections : defaults | frontend | listen | backend
3988 yes | yes | yes | no
3989 Arguments :
3990 <source> is the source IPv4 address or network which will only be able to
3991 get monitor responses to any request. It can be either an IPv4
3992 address, a host name, or an address followed by a slash ('/')
3993 followed by a mask.
3994
3995 In TCP mode, any connection coming from a source matching <source> will cause
3996 the connection to be immediately closed without any log. This allows another
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01003997 equipment to probe the port and verify that it is still listening, without
Willy Tarreau2769aa02007-12-27 18:26:09 +01003998 forwarding the connection to a remote server.
3999
4000 In HTTP mode, a connection coming from a source matching <source> will be
4001 accepted, the following response will be sent without waiting for a request,
4002 then the connection will be closed : "HTTP/1.0 200 OK". This is normally
4003 enough for any front-end HTTP probe to detect that the service is UP and
Willy Tarreau82569f92012-09-27 23:48:56 +02004004 running without forwarding the request to a backend server. Note that this
4005 response is sent in raw format, without any transformation. This is important
4006 as it means that it will not be SSL-encrypted on SSL listeners.
Willy Tarreau2769aa02007-12-27 18:26:09 +01004007
Willy Tarreau82569f92012-09-27 23:48:56 +02004008 Monitor requests are processed very early, just after tcp-request connection
4009 ACLs which are the only ones able to block them. These connections are short
4010 lived and never wait for any data from the client. They cannot be logged, and
4011 it is the intended purpose. They are only used to report HAProxy's health to
4012 an upper component, nothing more. Please note that "monitor fail" rules do
4013 not apply to connections intercepted by "monitor-net".
Willy Tarreau2769aa02007-12-27 18:26:09 +01004014
Willy Tarreau95cd2832010-03-04 23:36:33 +01004015 Last, please note that only one "monitor-net" statement can be specified in
4016 a frontend. If more than one is found, only the last one will be considered.
Cyril Bonté108cf6e2012-04-21 23:30:29 +02004017
Willy Tarreau2769aa02007-12-27 18:26:09 +01004018 Example :
4019 # addresses .252 and .253 are just probing us.
4020 frontend www
4021 monitor-net 192.168.0.252/31
4022
4023 See also : "monitor fail", "monitor-uri"
4024
4025
4026monitor-uri <uri>
4027 Intercept a URI used by external components' monitor requests
4028 May be used in sections : defaults | frontend | listen | backend
4029 yes | yes | yes | no
4030 Arguments :
4031 <uri> is the exact URI which we want to intercept to return HAProxy's
4032 health status instead of forwarding the request.
4033
4034 When an HTTP request referencing <uri> will be received on a frontend,
4035 HAProxy will not forward it nor log it, but instead will return either
4036 "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure
4037 conditions defined with "monitor fail". This is normally enough for any
4038 front-end HTTP probe to detect that the service is UP and running without
4039 forwarding the request to a backend server. Note that the HTTP method, the
4040 version and all headers are ignored, but the request must at least be valid
4041 at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
4042
4043 Monitor requests are processed very early. It is not possible to block nor
4044 divert them using ACLs. They cannot be logged either, and it is the intended
4045 purpose. They are only used to report HAProxy's health to an upper component,
4046 nothing more. However, it is possible to add any number of conditions using
4047 "monitor fail" and ACLs so that the result can be adjusted to whatever check
4048 can be imagined (most often the number of available servers in a backend).
4049
4050 Example :
4051 # Use /haproxy_test to report haproxy's status
4052 frontend www
4053 mode http
4054 monitor-uri /haproxy_test
4055
4056 See also : "monitor fail", "monitor-net"
4057
Willy Tarreau0ba27502007-12-24 16:55:16 +01004058
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004059option abortonclose
4060no option abortonclose
4061 Enable or disable early dropping of aborted requests pending in queues.
4062 May be used in sections : defaults | frontend | listen | backend
4063 yes | no | yes | yes
4064 Arguments : none
4065
4066 In presence of very high loads, the servers will take some time to respond.
4067 The per-instance connection queue will inflate, and the response time will
4068 increase respective to the size of the queue times the average per-session
4069 response time. When clients will wait for more than a few seconds, they will
Willy Tarreau198a7442008-01-17 12:05:32 +01004070 often hit the "STOP" button on their browser, leaving a useless request in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004071 the queue, and slowing down other users, and the servers as well, because the
4072 request will eventually be served, then aborted at the first error
4073 encountered while delivering the response.
4074
4075 As there is no way to distinguish between a full STOP and a simple output
4076 close on the client side, HTTP agents should be conservative and consider
4077 that the client might only have closed its output channel while waiting for
4078 the response. However, this introduces risks of congestion when lots of users
4079 do the same, and is completely useless nowadays because probably no client at
4080 all will close the session while waiting for the response. Some HTTP agents
Willy Tarreaud72758d2010-01-12 10:42:19 +01004081 support this behaviour (Squid, Apache, HAProxy), and others do not (TUX, most
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004082 hardware-based load balancers). So the probability for a closed input channel
Willy Tarreau198a7442008-01-17 12:05:32 +01004083 to represent a user hitting the "STOP" button is close to 100%, and the risk
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004084 of being the single component to break rare but valid traffic is extremely
4085 low, which adds to the temptation to be able to abort a session early while
4086 still not served and not pollute the servers.
4087
4088 In HAProxy, the user can choose the desired behaviour using the option
4089 "abortonclose". By default (without the option) the behaviour is HTTP
4090 compliant and aborted requests will be served. But when the option is
4091 specified, a session with an incoming channel closed will be aborted while
4092 it is still possible, either pending in the queue for a connection slot, or
4093 during the connection establishment if the server has not yet acknowledged
4094 the connection request. This considerably reduces the queue size and the load
4095 on saturated servers when users are tempted to click on STOP, which in turn
Willy Tarreaud72758d2010-01-12 10:42:19 +01004096 reduces the response time for other users.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004097
4098 If this option has been enabled in a "defaults" section, it can be disabled
4099 in a specific instance by prepending the "no" keyword before it.
4100
4101 See also : "timeout queue" and server's "maxconn" and "maxqueue" parameters
4102
4103
Willy Tarreau4076a152009-04-02 15:18:36 +02004104option accept-invalid-http-request
4105no option accept-invalid-http-request
4106 Enable or disable relaxing of HTTP request parsing
4107 May be used in sections : defaults | frontend | listen | backend
4108 yes | yes | yes | no
4109 Arguments : none
4110
Willy Tarreau91852eb2015-05-01 13:26:00 +02004111 By default, HAProxy complies with RFC7230 in terms of message parsing. This
Willy Tarreau4076a152009-04-02 15:18:36 +02004112 means that invalid characters in header names are not permitted and cause an
4113 error to be returned to the client. This is the desired behaviour as such
4114 forbidden characters are essentially used to build attacks exploiting server
4115 weaknesses, and bypass security filtering. Sometimes, a buggy browser or
4116 server will emit invalid header names for whatever reason (configuration,
4117 implementation) and the issue will not be immediately fixed. In such a case,
4118 it is possible to relax HAProxy's header name parser to accept any character
Willy Tarreau422246e2012-01-07 23:54:13 +01004119 even if that does not make sense, by specifying this option. Similarly, the
4120 list of characters allowed to appear in a URI is well defined by RFC3986, and
4121 chars 0-31, 32 (space), 34 ('"'), 60 ('<'), 62 ('>'), 92 ('\'), 94 ('^'), 96
4122 ('`'), 123 ('{'), 124 ('|'), 125 ('}'), 127 (delete) and anything above are
4123 not allowed at all. Haproxy always blocks a number of them (0..32, 127). The
Willy Tarreau91852eb2015-05-01 13:26:00 +02004124 remaining ones are blocked by default unless this option is enabled. This
Willy Tarreau13317662015-05-01 13:47:08 +02004125 option also relaxes the test on the HTTP version, it allows HTTP/0.9 requests
4126 to pass through (no version specified) and multiple digits for both the major
4127 and the minor version.
Willy Tarreau4076a152009-04-02 15:18:36 +02004128
4129 This option should never be enabled by default as it hides application bugs
4130 and open security breaches. It should only be deployed after a problem has
4131 been confirmed.
4132
4133 When this option is enabled, erroneous header names will still be accepted in
4134 requests, but the complete request will be captured in order to permit later
Willy Tarreau422246e2012-01-07 23:54:13 +01004135 analysis using the "show errors" request on the UNIX stats socket. Similarly,
4136 requests containing invalid chars in the URI part will be logged. Doing this
Willy Tarreau4076a152009-04-02 15:18:36 +02004137 also helps confirming that the issue has been solved.
4138
4139 If this option has been enabled in a "defaults" section, it can be disabled
4140 in a specific instance by prepending the "no" keyword before it.
4141
4142 See also : "option accept-invalid-http-response" and "show errors" on the
4143 stats socket.
4144
4145
4146option accept-invalid-http-response
4147no option accept-invalid-http-response
4148 Enable or disable relaxing of HTTP response parsing
4149 May be used in sections : defaults | frontend | listen | backend
4150 yes | no | yes | yes
4151 Arguments : none
4152
Willy Tarreau91852eb2015-05-01 13:26:00 +02004153 By default, HAProxy complies with RFC7230 in terms of message parsing. This
Willy Tarreau4076a152009-04-02 15:18:36 +02004154 means that invalid characters in header names are not permitted and cause an
4155 error to be returned to the client. This is the desired behaviour as such
4156 forbidden characters are essentially used to build attacks exploiting server
4157 weaknesses, and bypass security filtering. Sometimes, a buggy browser or
4158 server will emit invalid header names for whatever reason (configuration,
4159 implementation) and the issue will not be immediately fixed. In such a case,
4160 it is possible to relax HAProxy's header name parser to accept any character
Willy Tarreau91852eb2015-05-01 13:26:00 +02004161 even if that does not make sense, by specifying this option. This option also
4162 relaxes the test on the HTTP version format, it allows multiple digits for
4163 both the major and the minor version.
Willy Tarreau4076a152009-04-02 15:18:36 +02004164
4165 This option should never be enabled by default as it hides application bugs
4166 and open security breaches. It should only be deployed after a problem has
4167 been confirmed.
4168
4169 When this option is enabled, erroneous header names will still be accepted in
4170 responses, but the complete response will be captured in order to permit
4171 later analysis using the "show errors" request on the UNIX stats socket.
4172 Doing this also helps confirming that the issue has been solved.
4173
4174 If this option has been enabled in a "defaults" section, it can be disabled
4175 in a specific instance by prepending the "no" keyword before it.
4176
4177 See also : "option accept-invalid-http-request" and "show errors" on the
4178 stats socket.
4179
4180
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004181option allbackups
4182no option allbackups
4183 Use either all backup servers at a time or only the first one
4184 May be used in sections : defaults | frontend | listen | backend
4185 yes | no | yes | yes
4186 Arguments : none
4187
4188 By default, the first operational backup server gets all traffic when normal
4189 servers are all down. Sometimes, it may be preferred to use multiple backups
4190 at once, because one will not be enough. When "option allbackups" is enabled,
4191 the load balancing will be performed among all backup servers when all normal
4192 ones are unavailable. The same load balancing algorithm will be used and the
4193 servers' weights will be respected. Thus, there will not be any priority
4194 order between the backup servers anymore.
4195
4196 This option is mostly used with static server farms dedicated to return a
4197 "sorry" page when an application is completely offline.
4198
4199 If this option has been enabled in a "defaults" section, it can be disabled
4200 in a specific instance by prepending the "no" keyword before it.
4201
4202
4203option checkcache
4204no option checkcache
Godbach7056a352013-12-11 20:01:07 +08004205 Analyze all server responses and block responses with cacheable cookies
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004206 May be used in sections : defaults | frontend | listen | backend
4207 yes | no | yes | yes
4208 Arguments : none
4209
4210 Some high-level frameworks set application cookies everywhere and do not
4211 always let enough control to the developer to manage how the responses should
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004212 be cached. When a session cookie is returned on a cacheable object, there is a
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004213 high risk of session crossing or stealing between users traversing the same
4214 caches. In some situations, it is better to block the response than to let
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02004215 some sensitive session information go in the wild.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004216
4217 The option "checkcache" enables deep inspection of all server responses for
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004218 strict compliance with HTTP specification in terms of cacheability. It
Willy Tarreau198a7442008-01-17 12:05:32 +01004219 carefully checks "Cache-control", "Pragma" and "Set-cookie" headers in server
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004220 response to check if there's a risk of caching a cookie on a client-side
4221 proxy. When this option is enabled, the only responses which can be delivered
Willy Tarreau198a7442008-01-17 12:05:32 +01004222 to the client are :
4223 - all those without "Set-Cookie" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004224 - all those with a return code other than 200, 203, 206, 300, 301, 410,
Willy Tarreau198a7442008-01-17 12:05:32 +01004225 provided that the server has not set a "Cache-control: public" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004226 - all those that come from a POST request, provided that the server has not
4227 set a 'Cache-Control: public' header ;
4228 - those with a 'Pragma: no-cache' header
4229 - those with a 'Cache-control: private' header
4230 - those with a 'Cache-control: no-store' header
4231 - those with a 'Cache-control: max-age=0' header
4232 - those with a 'Cache-control: s-maxage=0' header
4233 - those with a 'Cache-control: no-cache' header
4234 - those with a 'Cache-control: no-cache="set-cookie"' header
4235 - those with a 'Cache-control: no-cache="set-cookie,' header
4236 (allowing other fields after set-cookie)
4237
4238 If a response doesn't respect these requirements, then it will be blocked
Willy Tarreau198a7442008-01-17 12:05:32 +01004239 just as if it was from an "rspdeny" filter, with an "HTTP 502 bad gateway".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004240 The session state shows "PH--" meaning that the proxy blocked the response
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004241 during headers processing. Additionally, an alert will be sent in the logs so
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004242 that admins are informed that there's something to be fixed.
4243
4244 Due to the high impact on the application, the application should be tested
4245 in depth with the option enabled before going to production. It is also a
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01004246 good practice to always activate it during tests, even if it is not used in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004247 production, as it will report potentially dangerous application behaviours.
4248
4249 If this option has been enabled in a "defaults" section, it can be disabled
4250 in a specific instance by prepending the "no" keyword before it.
4251
4252
4253option clitcpka
4254no option clitcpka
4255 Enable or disable the sending of TCP keepalive packets on the client side
4256 May be used in sections : defaults | frontend | listen | backend
4257 yes | yes | yes | no
4258 Arguments : none
4259
4260 When there is a firewall or any session-aware component between a client and
4261 a server, and when the protocol involves very long sessions with long idle
4262 periods (eg: remote desktops), there is a risk that one of the intermediate
4263 components decides to expire a session which has remained idle for too long.
4264
4265 Enabling socket-level TCP keep-alives makes the system regularly send packets
4266 to the other end of the connection, leaving it active. The delay between
4267 keep-alive probes is controlled by the system only and depends both on the
4268 operating system and its tuning parameters.
4269
4270 It is important to understand that keep-alive packets are neither emitted nor
4271 received at the application level. It is only the network stacks which sees
4272 them. For this reason, even if one side of the proxy already uses keep-alives
4273 to maintain its connection alive, those keep-alive packets will not be
4274 forwarded to the other side of the proxy.
4275
4276 Please note that this has nothing to do with HTTP keep-alive.
4277
4278 Using option "clitcpka" enables the emission of TCP keep-alive probes on the
4279 client side of a connection, which should help when session expirations are
4280 noticed between HAProxy and a client.
4281
4282 If this option has been enabled in a "defaults" section, it can be disabled
4283 in a specific instance by prepending the "no" keyword before it.
4284
4285 See also : "option srvtcpka", "option tcpka"
4286
4287
Willy Tarreau0ba27502007-12-24 16:55:16 +01004288option contstats
4289 Enable continuous traffic statistics updates
4290 May be used in sections : defaults | frontend | listen | backend
4291 yes | yes | yes | no
4292 Arguments : none
4293
4294 By default, counters used for statistics calculation are incremented
4295 only when a session finishes. It works quite well when serving small
4296 objects, but with big ones (for example large images or archives) or
4297 with A/V streaming, a graph generated from haproxy counters looks like
4298 a hedgehog. With this option enabled counters get incremented continuously,
4299 during a whole session. Recounting touches a hotpath directly so
4300 it is not enabled by default, as it has small performance impact (~0.5%).
4301
4302
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02004303option dontlog-normal
4304no option dontlog-normal
4305 Enable or disable logging of normal, successful connections
4306 May be used in sections : defaults | frontend | listen | backend
4307 yes | yes | yes | no
4308 Arguments : none
4309
4310 There are large sites dealing with several thousand connections per second
4311 and for which logging is a major pain. Some of them are even forced to turn
4312 logs off and cannot debug production issues. Setting this option ensures that
4313 normal connections, those which experience no error, no timeout, no retry nor
4314 redispatch, will not be logged. This leaves disk space for anomalies. In HTTP
4315 mode, the response status code is checked and return codes 5xx will still be
4316 logged.
4317
4318 It is strongly discouraged to use this option as most of the time, the key to
4319 complex issues is in the normal logs which will not be logged here. If you
4320 need to separate logs, see the "log-separate-errors" option instead.
4321
Willy Tarreauc57f0e22009-05-10 13:12:33 +02004322 See also : "log", "dontlognull", "log-separate-errors" and section 8 about
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02004323 logging.
4324
4325
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004326option dontlognull
4327no option dontlognull
4328 Enable or disable logging of null connections
4329 May be used in sections : defaults | frontend | listen | backend
4330 yes | yes | yes | no
4331 Arguments : none
4332
4333 In certain environments, there are components which will regularly connect to
4334 various systems to ensure that they are still alive. It can be the case from
4335 another load balancer as well as from monitoring systems. By default, even a
4336 simple port probe or scan will produce a log. If those connections pollute
4337 the logs too much, it is possible to enable option "dontlognull" to indicate
4338 that a connection on which no data has been transferred will not be logged,
Willy Tarreau0f228a02015-05-01 15:37:53 +02004339 which typically corresponds to those probes. Note that errors will still be
4340 returned to the client and accounted for in the stats. If this is not what is
4341 desired, option http-ignore-probes can be used instead.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004342
4343 It is generally recommended not to use this option in uncontrolled
4344 environments (eg: internet), otherwise scans and other malicious activities
4345 would not be logged.
4346
4347 If this option has been enabled in a "defaults" section, it can be disabled
4348 in a specific instance by prepending the "no" keyword before it.
4349
Willy Tarreau0f228a02015-05-01 15:37:53 +02004350 See also : "log", "http-ignore-probes", "monitor-net", "monitor-uri", and
4351 section 8 about logging.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004352
4353
4354option forceclose
4355no option forceclose
4356 Enable or disable active connection closing after response is transferred.
4357 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaua31e5df2009-12-30 01:10:35 +01004358 yes | yes | yes | yes
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004359 Arguments : none
4360
4361 Some HTTP servers do not necessarily close the connections when they receive
4362 the "Connection: close" set by "option httpclose", and if the client does not
4363 close either, then the connection remains open till the timeout expires. This
4364 causes high number of simultaneous connections on the servers and shows high
4365 global session times in the logs.
4366
4367 When this happens, it is possible to use "option forceclose". It will
Willy Tarreau82eeaf22009-12-29 12:09:05 +01004368 actively close the outgoing server channel as soon as the server has finished
Cyril Bonté653dcd62014-02-20 00:13:15 +01004369 to respond and release some resources earlier than with "option httpclose".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004370
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004371 This option may also be combined with "option http-pretend-keepalive", which
4372 will disable sending of the "Connection: close" header, but will still cause
4373 the connection to be closed once the whole response is received.
4374
Cyril Bonté653dcd62014-02-20 00:13:15 +01004375 This option disables and replaces any previous "option httpclose", "option
4376 http-server-close", "option http-keep-alive", or "option http-tunnel".
Willy Tarreau02bce8b2014-01-30 00:15:28 +01004377
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004378 If this option has been enabled in a "defaults" section, it can be disabled
4379 in a specific instance by prepending the "no" keyword before it.
4380
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004381 See also : "option httpclose" and "option http-pretend-keepalive"
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004382
4383
Willy Tarreau87cf5142011-08-19 22:57:24 +02004384option forwardfor [ except <network> ] [ header <name> ] [ if-none ]
Willy Tarreauc27debf2008-01-06 08:57:02 +01004385 Enable insertion of the X-Forwarded-For header to requests sent to servers
4386 May be used in sections : defaults | frontend | listen | backend
4387 yes | yes | yes | yes
4388 Arguments :
4389 <network> is an optional argument used to disable this option for sources
4390 matching <network>
Ross Westaf72a1d2008-08-03 10:51:45 +02004391 <name> an optional argument to specify a different "X-Forwarded-For"
Willy Tarreaud72758d2010-01-12 10:42:19 +01004392 header name.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004393
4394 Since HAProxy works in reverse-proxy mode, the servers see its IP address as
4395 their client address. This is sometimes annoying when the client's IP address
4396 is expected in server logs. To solve this problem, the well-known HTTP header
4397 "X-Forwarded-For" may be added by HAProxy to all requests sent to the server.
4398 This header contains a value representing the client's IP address. Since this
4399 header is always appended at the end of the existing header list, the server
4400 must be configured to always use the last occurrence of this header only. See
Ross Westaf72a1d2008-08-03 10:51:45 +02004401 the server's manual to find how to enable use of this standard header. Note
4402 that only the last occurrence of the header must be used, since it is really
4403 possible that the client has already brought one.
4404
Willy Tarreaud72758d2010-01-12 10:42:19 +01004405 The keyword "header" may be used to supply a different header name to replace
Ross Westaf72a1d2008-08-03 10:51:45 +02004406 the default "X-Forwarded-For". This can be useful where you might already
Willy Tarreaud72758d2010-01-12 10:42:19 +01004407 have a "X-Forwarded-For" header from a different application (eg: stunnel),
4408 and you need preserve it. Also if your backend server doesn't use the
Ross Westaf72a1d2008-08-03 10:51:45 +02004409 "X-Forwarded-For" header and requires different one (eg: Zeus Web Servers
4410 require "X-Cluster-Client-IP").
Willy Tarreauc27debf2008-01-06 08:57:02 +01004411
4412 Sometimes, a same HAProxy instance may be shared between a direct client
4413 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
4414 used to decrypt HTTPS traffic). It is possible to disable the addition of the
4415 header for a known source address or network by adding the "except" keyword
4416 followed by the network address. In this case, any source IP matching the
4417 network will not cause an addition of this header. Most common uses are with
4418 private networks or 127.0.0.1.
4419
Willy Tarreau87cf5142011-08-19 22:57:24 +02004420 Alternatively, the keyword "if-none" states that the header will only be
4421 added if it is not present. This should only be used in perfectly trusted
4422 environment, as this might cause a security issue if headers reaching haproxy
4423 are under the control of the end-user.
4424
Willy Tarreauc27debf2008-01-06 08:57:02 +01004425 This option may be specified either in the frontend or in the backend. If at
Ross Westaf72a1d2008-08-03 10:51:45 +02004426 least one of them uses it, the header will be added. Note that the backend's
4427 setting of the header subargument takes precedence over the frontend's if
Willy Tarreau87cf5142011-08-19 22:57:24 +02004428 both are defined. In the case of the "if-none" argument, if at least one of
4429 the frontend or the backend does not specify it, it wants the addition to be
4430 mandatory, so it wins.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004431
Ross Westaf72a1d2008-08-03 10:51:45 +02004432 Examples :
Willy Tarreauc27debf2008-01-06 08:57:02 +01004433 # Public HTTP address also used by stunnel on the same machine
4434 frontend www
4435 mode http
4436 option forwardfor except 127.0.0.1 # stunnel already adds the header
4437
Ross Westaf72a1d2008-08-03 10:51:45 +02004438 # Those servers want the IP Address in X-Client
4439 backend www
4440 mode http
4441 option forwardfor header X-Client
4442
Willy Tarreau87cf5142011-08-19 22:57:24 +02004443 See also : "option httpclose", "option http-server-close",
Willy Tarreau70dffda2014-01-30 03:07:23 +01004444 "option forceclose", "option http-keep-alive"
Willy Tarreauc27debf2008-01-06 08:57:02 +01004445
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004446
Willy Tarreau0f228a02015-05-01 15:37:53 +02004447option http-ignore-probes
4448no option http-ignore-probes
4449 Enable or disable logging of null connections and request timeouts
4450 May be used in sections : defaults | frontend | listen | backend
4451 yes | yes | yes | no
4452 Arguments : none
4453
4454 Recently some browsers started to implement a "pre-connect" feature
4455 consisting in speculatively connecting to some recently visited web sites
4456 just in case the user would like to visit them. This results in many
4457 connections being established to web sites, which end up in 408 Request
4458 Timeout if the timeout strikes first, or 400 Bad Request when the browser
4459 decides to close them first. These ones pollute the log and feed the error
4460 counters. There was already "option dontlognull" but it's insufficient in
4461 this case. Instead, this option does the following things :
4462 - prevent any 400/408 message from being sent to the client if nothing
4463 was received over a connection before it was closed ;
4464 - prevent any log from being emitted in this situation ;
4465 - prevent any error counter from being incremented
4466
4467 That way the empty connection is silently ignored. Note that it is better
4468 not to use this unless it is clear that it is needed, because it will hide
4469 real problems. The most common reason for not receiving a request and seeing
4470 a 408 is due to an MTU inconsistency between the client and an intermediary
4471 element such as a VPN, which blocks too large packets. These issues are
4472 generally seen with POST requests as well as GET with large cookies. The logs
4473 are often the only way to detect them.
4474
4475 If this option has been enabled in a "defaults" section, it can be disabled
4476 in a specific instance by prepending the "no" keyword before it.
4477
4478 See also : "log", "dontlognull", "errorfile", and section 8 about logging.
4479
4480
Willy Tarreau16bfb022010-01-16 19:48:41 +01004481option http-keep-alive
4482no option http-keep-alive
4483 Enable or disable HTTP keep-alive from client to server
4484 May be used in sections : defaults | frontend | listen | backend
4485 yes | yes | yes | yes
4486 Arguments : none
4487
Willy Tarreau70dffda2014-01-30 03:07:23 +01004488 By default HAProxy operates in keep-alive mode with regards to persistent
4489 connections: for each connection it processes each request and response, and
4490 leaves the connection idle on both sides between the end of a response and the
4491 start of a new request. This mode may be changed by several options such as
4492 "option http-server-close", "option forceclose", "option httpclose" or
4493 "option http-tunnel". This option allows to set back the keep-alive mode,
4494 which can be useful when another mode was used in a defaults section.
4495
4496 Setting "option http-keep-alive" enables HTTP keep-alive mode on the client-
4497 and server- sides. This provides the lowest latency on the client side (slow
Willy Tarreau16bfb022010-01-16 19:48:41 +01004498 network) and the fastest session reuse on the server side at the expense
4499 of maintaining idle connections to the servers. In general, it is possible
4500 with this option to achieve approximately twice the request rate that the
4501 "http-server-close" option achieves on small objects. There are mainly two
4502 situations where this option may be useful :
4503
4504 - when the server is non-HTTP compliant and authenticates the connection
4505 instead of requests (eg: NTLM authentication)
4506
4507 - when the cost of establishing the connection to the server is significant
4508 compared to the cost of retrieving the associated object from the server.
4509
4510 This last case can happen when the server is a fast static server of cache.
4511 In this case, the server will need to be properly tuned to support high enough
4512 connection counts because connections will last until the client sends another
4513 request.
4514
4515 If the client request has to go to another backend or another server due to
4516 content switching or the load balancing algorithm, the idle connection will
Willy Tarreau9420b122013-12-15 18:58:25 +01004517 immediately be closed and a new one re-opened. Option "prefer-last-server" is
4518 available to try optimize server selection so that if the server currently
4519 attached to an idle connection is usable, it will be used.
Willy Tarreau16bfb022010-01-16 19:48:41 +01004520
4521 In general it is preferred to use "option http-server-close" with application
4522 servers, and some static servers might benefit from "option http-keep-alive".
4523
4524 At the moment, logs will not indicate whether requests came from the same
4525 session or not. The accept date reported in the logs corresponds to the end
4526 of the previous request, and the request time corresponds to the time spent
4527 waiting for a new request. The keep-alive request time is still bound to the
4528 timeout defined by "timeout http-keep-alive" or "timeout http-request" if
4529 not set.
4530
Cyril Bonté653dcd62014-02-20 00:13:15 +01004531 This option disables and replaces any previous "option httpclose", "option
4532 http-server-close", "option forceclose" or "option http-tunnel". When backend
Willy Tarreau70dffda2014-01-30 03:07:23 +01004533 and frontend options differ, all of these 4 options have precedence over
Cyril Bonté653dcd62014-02-20 00:13:15 +01004534 "option http-keep-alive".
Willy Tarreau16bfb022010-01-16 19:48:41 +01004535
4536 See also : "option forceclose", "option http-server-close",
Willy Tarreau9420b122013-12-15 18:58:25 +01004537 "option prefer-last-server", "option http-pretend-keepalive",
4538 "option httpclose", and "1.1. The HTTP transaction model".
Willy Tarreau16bfb022010-01-16 19:48:41 +01004539
4540
Willy Tarreau96e31212011-05-30 18:10:30 +02004541option http-no-delay
4542no option http-no-delay
4543 Instruct the system to favor low interactive delays over performance in HTTP
4544 May be used in sections : defaults | frontend | listen | backend
4545 yes | yes | yes | yes
4546 Arguments : none
4547
4548 In HTTP, each payload is unidirectional and has no notion of interactivity.
4549 Any agent is expected to queue data somewhat for a reasonably low delay.
4550 There are some very rare server-to-server applications that abuse the HTTP
4551 protocol and expect the payload phase to be highly interactive, with many
4552 interleaved data chunks in both directions within a single request. This is
4553 absolutely not supported by the HTTP specification and will not work across
4554 most proxies or servers. When such applications attempt to do this through
4555 haproxy, it works but they will experience high delays due to the network
4556 optimizations which favor performance by instructing the system to wait for
4557 enough data to be available in order to only send full packets. Typical
4558 delays are around 200 ms per round trip. Note that this only happens with
4559 abnormal uses. Normal uses such as CONNECT requests nor WebSockets are not
4560 affected.
4561
4562 When "option http-no-delay" is present in either the frontend or the backend
4563 used by a connection, all such optimizations will be disabled in order to
4564 make the exchanges as fast as possible. Of course this offers no guarantee on
4565 the functionality, as it may break at any other place. But if it works via
4566 HAProxy, it will work as fast as possible. This option should never be used
4567 by default, and should never be used at all unless such a buggy application
4568 is discovered. The impact of using this option is an increase of bandwidth
4569 usage and CPU usage, which may significantly lower performance in high
4570 latency environments.
4571
4572
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004573option http-pretend-keepalive
4574no option http-pretend-keepalive
4575 Define whether haproxy will announce keepalive to the server or not
4576 May be used in sections : defaults | frontend | listen | backend
4577 yes | yes | yes | yes
4578 Arguments : none
4579
4580 When running with "option http-server-close" or "option forceclose", haproxy
4581 adds a "Connection: close" header to the request forwarded to the server.
4582 Unfortunately, when some servers see this header, they automatically refrain
4583 from using the chunked encoding for responses of unknown length, while this
4584 is totally unrelated. The immediate effect is that this prevents haproxy from
4585 maintaining the client connection alive. A second effect is that a client or
4586 a cache could receive an incomplete response without being aware of it, and
4587 consider the response complete.
4588
4589 By setting "option http-pretend-keepalive", haproxy will make the server
4590 believe it will keep the connection alive. The server will then not fall back
4591 to the abnormal undesired above. When haproxy gets the whole response, it
4592 will close the connection with the server just as it would do with the
4593 "forceclose" option. That way the client gets a normal response and the
4594 connection is correctly closed on the server side.
4595
4596 It is recommended not to enable this option by default, because most servers
4597 will more efficiently close the connection themselves after the last packet,
4598 and release its buffers slightly earlier. Also, the added packet on the
4599 network could slightly reduce the overall peak performance. However it is
4600 worth noting that when this option is enabled, haproxy will have slightly
4601 less work to do. So if haproxy is the bottleneck on the whole architecture,
4602 enabling this option might save a few CPU cycles.
4603
4604 This option may be set both in a frontend and in a backend. It is enabled if
4605 at least one of the frontend or backend holding a connection has it enabled.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04004606 This option may be combined with "option httpclose", which will cause
Willy Tarreau22a95342010-09-29 14:31:41 +02004607 keepalive to be announced to the server and close to be announced to the
4608 client. This practice is discouraged though.
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004609
4610 If this option has been enabled in a "defaults" section, it can be disabled
4611 in a specific instance by prepending the "no" keyword before it.
4612
Willy Tarreau16bfb022010-01-16 19:48:41 +01004613 See also : "option forceclose", "option http-server-close", and
4614 "option http-keep-alive"
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004615
Willy Tarreauc27debf2008-01-06 08:57:02 +01004616
Willy Tarreaub608feb2010-01-02 22:47:18 +01004617option http-server-close
4618no option http-server-close
4619 Enable or disable HTTP connection closing on the server side
4620 May be used in sections : defaults | frontend | listen | backend
4621 yes | yes | yes | yes
4622 Arguments : none
4623
Willy Tarreau70dffda2014-01-30 03:07:23 +01004624 By default HAProxy operates in keep-alive mode with regards to persistent
4625 connections: for each connection it processes each request and response, and
4626 leaves the connection idle on both sides between the end of a response and
4627 the start of a new request. This mode may be changed by several options such
4628 as "option http-server-close", "option forceclose", "option httpclose" or
4629 "option http-tunnel". Setting "option http-server-close" enables HTTP
4630 connection-close mode on the server side while keeping the ability to support
4631 HTTP keep-alive and pipelining on the client side. This provides the lowest
4632 latency on the client side (slow network) and the fastest session reuse on
4633 the server side to save server resources, similarly to "option forceclose".
4634 It also permits non-keepalive capable servers to be served in keep-alive mode
4635 to the clients if they conform to the requirements of RFC2616. Please note
4636 that some servers do not always conform to those requirements when they see
4637 "Connection: close" in the request. The effect will be that keep-alive will
4638 never be used. A workaround consists in enabling "option
4639 http-pretend-keepalive".
Willy Tarreaub608feb2010-01-02 22:47:18 +01004640
4641 At the moment, logs will not indicate whether requests came from the same
4642 session or not. The accept date reported in the logs corresponds to the end
4643 of the previous request, and the request time corresponds to the time spent
4644 waiting for a new request. The keep-alive request time is still bound to the
Willy Tarreaub16a5742010-01-10 14:46:16 +01004645 timeout defined by "timeout http-keep-alive" or "timeout http-request" if
4646 not set.
Willy Tarreaub608feb2010-01-02 22:47:18 +01004647
4648 This option may be set both in a frontend and in a backend. It is enabled if
4649 at least one of the frontend or backend holding a connection has it enabled.
Cyril Bonté653dcd62014-02-20 00:13:15 +01004650 It disables and replaces any previous "option httpclose", "option forceclose",
4651 "option http-tunnel" or "option http-keep-alive". Please check section 4
Willy Tarreau70dffda2014-01-30 03:07:23 +01004652 ("Proxies") to see how this option combines with others when frontend and
4653 backend options differ.
Willy Tarreaub608feb2010-01-02 22:47:18 +01004654
4655 If this option has been enabled in a "defaults" section, it can be disabled
4656 in a specific instance by prepending the "no" keyword before it.
4657
Patrick Mezard9ec2ec42010-06-12 17:02:45 +02004658 See also : "option forceclose", "option http-pretend-keepalive",
Willy Tarreau16bfb022010-01-16 19:48:41 +01004659 "option httpclose", "option http-keep-alive", and
4660 "1.1. The HTTP transaction model".
Willy Tarreaub608feb2010-01-02 22:47:18 +01004661
4662
Willy Tarreau02bce8b2014-01-30 00:15:28 +01004663option http-tunnel
4664no option http-tunnel
4665 Disable or enable HTTP connection processing after first transaction
4666 May be used in sections : defaults | frontend | listen | backend
4667 yes | yes | yes | yes
4668 Arguments : none
4669
Willy Tarreau70dffda2014-01-30 03:07:23 +01004670 By default HAProxy operates in keep-alive mode with regards to persistent
4671 connections: for each connection it processes each request and response, and
4672 leaves the connection idle on both sides between the end of a response and
4673 the start of a new request. This mode may be changed by several options such
4674 as "option http-server-close", "option forceclose", "option httpclose" or
4675 "option http-tunnel".
4676
4677 Option "http-tunnel" disables any HTTP processing past the first request and
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03004678 the first response. This is the mode which was used by default in versions
Willy Tarreau70dffda2014-01-30 03:07:23 +01004679 1.0 to 1.5-dev21. It is the mode with the lowest processing overhead, which
4680 is normally not needed anymore unless in very specific cases such as when
4681 using an in-house protocol that looks like HTTP but is not compatible, or
4682 just to log one request per client in order to reduce log size. Note that
4683 everything which works at the HTTP level, including header parsing/addition,
4684 cookie processing or content switching will only work for the first request
4685 and will be ignored after the first response.
Willy Tarreau02bce8b2014-01-30 00:15:28 +01004686
4687 If this option has been enabled in a "defaults" section, it can be disabled
4688 in a specific instance by prepending the "no" keyword before it.
4689
4690 See also : "option forceclose", "option http-server-close",
4691 "option httpclose", "option http-keep-alive", and
4692 "1.1. The HTTP transaction model".
4693
4694
Willy Tarreau88d349d2010-01-25 12:15:43 +01004695option http-use-proxy-header
Cyril Bontéf0c60612010-02-06 14:44:47 +01004696no option http-use-proxy-header
Willy Tarreau88d349d2010-01-25 12:15:43 +01004697 Make use of non-standard Proxy-Connection header instead of Connection
4698 May be used in sections : defaults | frontend | listen | backend
4699 yes | yes | yes | no
4700 Arguments : none
4701
4702 While RFC2616 explicitly states that HTTP/1.1 agents must use the
4703 Connection header to indicate their wish of persistent or non-persistent
4704 connections, both browsers and proxies ignore this header for proxied
4705 connections and make use of the undocumented, non-standard Proxy-Connection
4706 header instead. The issue begins when trying to put a load balancer between
4707 browsers and such proxies, because there will be a difference between what
4708 haproxy understands and what the client and the proxy agree on.
4709
4710 By setting this option in a frontend, haproxy can automatically switch to use
4711 that non-standard header if it sees proxied requests. A proxied request is
4712 defined here as one where the URI begins with neither a '/' nor a '*'. The
4713 choice of header only affects requests passing through proxies making use of
4714 one of the "httpclose", "forceclose" and "http-server-close" options. Note
4715 that this option can only be specified in a frontend and will affect the
4716 request along its whole life.
4717
Willy Tarreau844a7e72010-01-31 21:46:18 +01004718 Also, when this option is set, a request which requires authentication will
4719 automatically switch to use proxy authentication headers if it is itself a
4720 proxied request. That makes it possible to check or enforce authentication in
4721 front of an existing proxy.
4722
Willy Tarreau88d349d2010-01-25 12:15:43 +01004723 This option should normally never be used, except in front of a proxy.
4724
4725 See also : "option httpclose", "option forceclose" and "option
4726 http-server-close".
4727
4728
Willy Tarreaud63335a2010-02-26 12:56:52 +01004729option httpchk
4730option httpchk <uri>
4731option httpchk <method> <uri>
4732option httpchk <method> <uri> <version>
4733 Enable HTTP protocol to check on the servers health
4734 May be used in sections : defaults | frontend | listen | backend
4735 yes | no | yes | yes
4736 Arguments :
4737 <method> is the optional HTTP method used with the requests. When not set,
4738 the "OPTIONS" method is used, as it generally requires low server
4739 processing and is easy to filter out from the logs. Any method
4740 may be used, though it is not recommended to invent non-standard
4741 ones.
4742
4743 <uri> is the URI referenced in the HTTP requests. It defaults to " / "
4744 which is accessible by default on almost any server, but may be
4745 changed to any other URI. Query strings are permitted.
4746
4747 <version> is the optional HTTP version string. It defaults to "HTTP/1.0"
4748 but some servers might behave incorrectly in HTTP 1.0, so turning
4749 it to HTTP/1.1 may sometimes help. Note that the Host field is
4750 mandatory in HTTP/1.1, and as a trick, it is possible to pass it
4751 after "\r\n" following the version string.
4752
4753 By default, server health checks only consist in trying to establish a TCP
4754 connection. When "option httpchk" is specified, a complete HTTP request is
4755 sent once the TCP connection is established, and responses 2xx and 3xx are
4756 considered valid, while all other ones indicate a server failure, including
4757 the lack of any response.
4758
4759 The port and interval are specified in the server configuration.
4760
4761 This option does not necessarily require an HTTP backend, it also works with
4762 plain TCP backends. This is particularly useful to check simple scripts bound
4763 to some dedicated ports using the inetd daemon.
4764
4765 Examples :
4766 # Relay HTTPS traffic to Apache instance and check service availability
4767 # using HTTP request "OPTIONS * HTTP/1.1" on port 80.
4768 backend https_relay
4769 mode tcp
4770 option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
4771 server apache1 192.168.1.1:443 check port 80
4772
Simon Hormanafc47ee2013-11-25 10:46:35 +09004773 See also : "option ssl-hello-chk", "option smtpchk", "option mysql-check",
4774 "option pgsql-check", "http-check" and the "check", "port" and
4775 "inter" server options.
Willy Tarreaud63335a2010-02-26 12:56:52 +01004776
4777
Willy Tarreauc27debf2008-01-06 08:57:02 +01004778option httpclose
4779no option httpclose
4780 Enable or disable passive HTTP connection closing
4781 May be used in sections : defaults | frontend | listen | backend
4782 yes | yes | yes | yes
4783 Arguments : none
4784
Willy Tarreau70dffda2014-01-30 03:07:23 +01004785 By default HAProxy operates in keep-alive mode with regards to persistent
4786 connections: for each connection it processes each request and response, and
4787 leaves the connection idle on both sides between the end of a response and
4788 the start of a new request. This mode may be changed by several options such
Cyril Bonté653dcd62014-02-20 00:13:15 +01004789 as "option http-server-close", "option forceclose", "option httpclose" or
Willy Tarreau70dffda2014-01-30 03:07:23 +01004790 "option http-tunnel".
4791
4792 If "option httpclose" is set, HAProxy will work in HTTP tunnel mode and check
4793 if a "Connection: close" header is already set in each direction, and will
4794 add one if missing. Each end should react to this by actively closing the TCP
4795 connection after each transfer, thus resulting in a switch to the HTTP close
4796 mode. Any "Connection" header different from "close" will also be removed.
4797 Note that this option is deprecated since what it does is very cheap but not
4798 reliable. Using "option http-server-close" or "option forceclose" is strongly
4799 recommended instead.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004800
4801 It seldom happens that some servers incorrectly ignore this header and do not
Jamie Gloudonaaa21002012-08-25 00:18:33 -04004802 close the connection even though they reply "Connection: close". For this
Willy Tarreau0dfdf192010-01-05 11:33:11 +01004803 reason, they are not compatible with older HTTP 1.0 browsers. If this happens
4804 it is possible to use the "option forceclose" which actively closes the
4805 request connection once the server responds. Option "forceclose" also
4806 releases the server connection earlier because it does not have to wait for
4807 the client to acknowledge it.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004808
4809 This option may be set both in a frontend and in a backend. It is enabled if
4810 at least one of the frontend or backend holding a connection has it enabled.
Cyril Bonté653dcd62014-02-20 00:13:15 +01004811 It disables and replaces any previous "option http-server-close",
4812 "option forceclose", "option http-keep-alive" or "option http-tunnel". Please
Willy Tarreau70dffda2014-01-30 03:07:23 +01004813 check section 4 ("Proxies") to see how this option combines with others when
4814 frontend and backend options differ.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004815
4816 If this option has been enabled in a "defaults" section, it can be disabled
4817 in a specific instance by prepending the "no" keyword before it.
4818
Patrick Mezard9ec2ec42010-06-12 17:02:45 +02004819 See also : "option forceclose", "option http-server-close" and
4820 "1.1. The HTTP transaction model".
Willy Tarreauc27debf2008-01-06 08:57:02 +01004821
4822
Emeric Brun3a058f32009-06-30 18:26:00 +02004823option httplog [ clf ]
Willy Tarreauc27debf2008-01-06 08:57:02 +01004824 Enable logging of HTTP request, session state and timers
4825 May be used in sections : defaults | frontend | listen | backend
4826 yes | yes | yes | yes
Emeric Brun3a058f32009-06-30 18:26:00 +02004827 Arguments :
4828 clf if the "clf" argument is added, then the output format will be
4829 the CLF format instead of HAProxy's default HTTP format. You can
4830 use this when you need to feed HAProxy's logs through a specific
4831 log analyser which only support the CLF format and which is not
4832 extensible.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004833
4834 By default, the log output format is very poor, as it only contains the
4835 source and destination addresses, and the instance name. By specifying
4836 "option httplog", each log line turns into a much richer format including,
4837 but not limited to, the HTTP request, the connection timers, the session
4838 status, the connections numbers, the captured headers and cookies, the
4839 frontend, backend and server name, and of course the source address and
4840 ports.
4841
4842 This option may be set either in the frontend or the backend.
4843
PiBa-NLbd556bf2014-12-11 21:31:54 +01004844 Specifying only "option httplog" will automatically clear the 'clf' mode
4845 if it was set by default.
Emeric Brun3a058f32009-06-30 18:26:00 +02004846
Willy Tarreauc57f0e22009-05-10 13:12:33 +02004847 See also : section 8 about logging.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004848
Willy Tarreau55165fe2009-05-10 12:02:55 +02004849
4850option http_proxy
4851no option http_proxy
4852 Enable or disable plain HTTP proxy mode
4853 May be used in sections : defaults | frontend | listen | backend
4854 yes | yes | yes | yes
4855 Arguments : none
4856
4857 It sometimes happens that people need a pure HTTP proxy which understands
4858 basic proxy requests without caching nor any fancy feature. In this case,
4859 it may be worth setting up an HAProxy instance with the "option http_proxy"
4860 set. In this mode, no server is declared, and the connection is forwarded to
4861 the IP address and port found in the URL after the "http://" scheme.
4862
4863 No host address resolution is performed, so this only works when pure IP
4864 addresses are passed. Since this option's usage perimeter is rather limited,
4865 it will probably be used only by experts who know they need exactly it. Last,
4866 if the clients are susceptible of sending keep-alive requests, it will be
Cyril Bonté2409e682010-12-14 22:47:51 +01004867 needed to add "option httpclose" to ensure that all requests will correctly
Willy Tarreau55165fe2009-05-10 12:02:55 +02004868 be analyzed.
4869
4870 If this option has been enabled in a "defaults" section, it can be disabled
4871 in a specific instance by prepending the "no" keyword before it.
4872
4873 Example :
4874 # this backend understands HTTP proxy requests and forwards them directly.
4875 backend direct_forward
4876 option httpclose
4877 option http_proxy
4878
4879 See also : "option httpclose"
4880
Willy Tarreau211ad242009-10-03 21:45:07 +02004881
Jamie Gloudon801a0a32012-08-25 00:18:33 -04004882option independent-streams
4883no option independent-streams
4884 Enable or disable independent timeout processing for both directions
Willy Tarreauf27b5ea2009-10-03 22:01:18 +02004885 May be used in sections : defaults | frontend | listen | backend
4886 yes | yes | yes | yes
4887 Arguments : none
4888
4889 By default, when data is sent over a socket, both the write timeout and the
4890 read timeout for that socket are refreshed, because we consider that there is
4891 activity on that socket, and we have no other means of guessing if we should
4892 receive data or not.
4893
4894 While this default behaviour is desirable for almost all applications, there
4895 exists a situation where it is desirable to disable it, and only refresh the
4896 read timeout if there are incoming data. This happens on sessions with large
4897 timeouts and low amounts of exchanged data such as telnet session. If the
4898 server suddenly disappears, the output data accumulates in the system's
4899 socket buffers, both timeouts are correctly refreshed, and there is no way
4900 to know the server does not receive them, so we don't timeout. However, when
4901 the underlying protocol always echoes sent data, it would be enough by itself
4902 to detect the issue using the read timeout. Note that this problem does not
4903 happen with more verbose protocols because data won't accumulate long in the
4904 socket buffers.
4905
4906 When this option is set on the frontend, it will disable read timeout updates
4907 on data sent to the client. There probably is little use of this case. When
4908 the option is set on the backend, it will disable read timeout updates on
4909 data sent to the server. Doing so will typically break large HTTP posts from
4910 slow lines, so use it with caution.
4911
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03004912 Note: older versions used to call this setting "option independent-streams"
Jamie Gloudon801a0a32012-08-25 00:18:33 -04004913 with a spelling mistake. This spelling is still supported but
4914 deprecated.
4915
Willy Tarreauce887fd2012-05-12 12:50:00 +02004916 See also : "timeout client", "timeout server" and "timeout tunnel"
Willy Tarreauf27b5ea2009-10-03 22:01:18 +02004917
4918
Gabor Lekenyb4c81e42010-09-29 18:17:05 +02004919option ldap-check
4920 Use LDAPv3 health checks for server testing
4921 May be used in sections : defaults | frontend | listen | backend
4922 yes | no | yes | yes
4923 Arguments : none
4924
4925 It is possible to test that the server correctly talks LDAPv3 instead of just
4926 testing that it accepts the TCP connection. When this option is set, an
4927 LDAPv3 anonymous simple bind message is sent to the server, and the response
4928 is analyzed to find an LDAPv3 bind response message.
4929
4930 The server is considered valid only when the LDAP response contains success
4931 resultCode (http://tools.ietf.org/html/rfc4511#section-4.1.9).
4932
4933 Logging of bind requests is server dependent see your documentation how to
4934 configure it.
4935
4936 Example :
4937 option ldap-check
4938
4939 See also : "option httpchk"
4940
4941
Simon Horman98637e52014-06-20 12:30:16 +09004942option external-check
4943 Use external processes for server health checks
4944 May be used in sections : defaults | frontend | listen | backend
4945 yes | no | yes | yes
4946
4947 It is possible to test the health of a server using an external command.
4948 This is achieved by running the executable set using "external-check
4949 command".
4950
4951 Requires the "external-check" global to be set.
4952
4953 See also : "external-check", "external-check command", "external-check path"
4954
4955
Willy Tarreau211ad242009-10-03 21:45:07 +02004956option log-health-checks
4957no option log-health-checks
Willy Tarreaubef1b322014-05-13 21:01:39 +02004958 Enable or disable logging of health checks status updates
Willy Tarreau211ad242009-10-03 21:45:07 +02004959 May be used in sections : defaults | frontend | listen | backend
4960 yes | no | yes | yes
4961 Arguments : none
4962
Willy Tarreaubef1b322014-05-13 21:01:39 +02004963 By default, failed health check are logged if server is UP and successful
4964 health checks are logged if server is DOWN, so the amount of additional
4965 information is limited.
Willy Tarreau211ad242009-10-03 21:45:07 +02004966
Willy Tarreaubef1b322014-05-13 21:01:39 +02004967 When this option is enabled, any change of the health check status or to
4968 the server's health will be logged, so that it becomes possible to know
4969 that a server was failing occasional checks before crashing, or exactly when
4970 it failed to respond a valid HTTP status, then when the port started to
4971 reject connections, then when the server stopped responding at all.
4972
4973 Note that status changes not caused by health checks (eg: enable/disable on
4974 the CLI) are intentionally not logged by this option.
Willy Tarreau211ad242009-10-03 21:45:07 +02004975
Willy Tarreaubef1b322014-05-13 21:01:39 +02004976 See also: "option httpchk", "option ldap-check", "option mysql-check",
4977 "option pgsql-check", "option redis-check", "option smtpchk",
4978 "option tcp-check", "log" and section 8 about logging.
Willy Tarreau211ad242009-10-03 21:45:07 +02004979
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02004980
4981option log-separate-errors
4982no option log-separate-errors
4983 Change log level for non-completely successful connections
4984 May be used in sections : defaults | frontend | listen | backend
4985 yes | yes | yes | no
4986 Arguments : none
4987
4988 Sometimes looking for errors in logs is not easy. This option makes haproxy
4989 raise the level of logs containing potentially interesting information such
4990 as errors, timeouts, retries, redispatches, or HTTP status codes 5xx. The
4991 level changes from "info" to "err". This makes it possible to log them
4992 separately to a different file with most syslog daemons. Be careful not to
4993 remove them from the original file, otherwise you would lose ordering which
4994 provides very important information.
4995
4996 Using this option, large sites dealing with several thousand connections per
4997 second may log normal traffic to a rotating buffer and only archive smaller
4998 error logs.
4999
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005000 See also : "log", "dontlognull", "dontlog-normal" and section 8 about
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02005001 logging.
5002
Willy Tarreauc27debf2008-01-06 08:57:02 +01005003
5004option logasap
5005no option logasap
5006 Enable or disable early logging of HTTP requests
5007 May be used in sections : defaults | frontend | listen | backend
5008 yes | yes | yes | no
5009 Arguments : none
5010
5011 By default, HTTP requests are logged upon termination so that the total
5012 transfer time and the number of bytes appear in the logs. When large objects
5013 are being transferred, it may take a while before the request appears in the
5014 logs. Using "option logasap", the request gets logged as soon as the server
5015 sends the complete headers. The only missing information in the logs will be
5016 the total number of bytes which will indicate everything except the amount
5017 of data transferred, and the total time which will not take the transfer
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01005018 time into account. In such a situation, it's a good practice to capture the
Willy Tarreauc27debf2008-01-06 08:57:02 +01005019 "Content-Length" response header so that the logs at least indicate how many
5020 bytes are expected to be transferred.
5021
Willy Tarreaucc6c8912009-02-22 10:53:55 +01005022 Examples :
5023 listen http_proxy 0.0.0.0:80
5024 mode http
5025 option httplog
5026 option logasap
5027 log 192.168.2.200 local3
5028
5029 >>> Feb 6 12:14:14 localhost \
5030 haproxy[14389]: 10.0.1.2:33317 [06/Feb/2009:12:14:14.655] http-in \
5031 static/srv1 9/10/7/14/+30 200 +243 - - ---- 3/1/1/1/0 1/0 \
5032 "GET /image.iso HTTP/1.0"
5033
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005034 See also : "option httplog", "capture response header", and section 8 about
Willy Tarreauc27debf2008-01-06 08:57:02 +01005035 logging.
5036
5037
Nenad Merdanovic6639a7c2014-05-30 14:26:32 +02005038option mysql-check [ user <username> [ post-41 ] ]
Hervé COMMOWICK8776f1b2010-10-18 15:58:36 +02005039 Use MySQL health checks for server testing
Hervé COMMOWICK698ae002010-01-12 09:25:13 +01005040 May be used in sections : defaults | frontend | listen | backend
5041 yes | no | yes | yes
Hervé COMMOWICK8776f1b2010-10-18 15:58:36 +02005042 Arguments :
Cyril Bonté108cf6e2012-04-21 23:30:29 +02005043 <username> This is the username which will be used when connecting to MySQL
5044 server.
Nenad Merdanovic6639a7c2014-05-30 14:26:32 +02005045 post-41 Send post v4.1 client compatible checks
Hervé COMMOWICK8776f1b2010-10-18 15:58:36 +02005046
5047 If you specify a username, the check consists of sending two MySQL packet,
5048 one Client Authentication packet, and one QUIT packet, to correctly close
5049 MySQL session. We then parse the MySQL Handshake Initialisation packet and/or
5050 Error packet. It is a basic but useful test which does not produce error nor
5051 aborted connect on the server. However, it requires adding an authorization
5052 in the MySQL table, like this :
5053
5054 USE mysql;
5055 INSERT INTO user (Host,User) values ('<ip_of_haproxy>','<username>');
5056 FLUSH PRIVILEGES;
5057
5058 If you don't specify a username (it is deprecated and not recommended), the
5059 check only consists in parsing the Mysql Handshake Initialisation packet or
5060 Error packet, we don't send anything in this mode. It was reported that it
5061 can generate lockout if check is too frequent and/or if there is not enough
5062 traffic. In fact, you need in this case to check MySQL "max_connect_errors"
5063 value as if a connection is established successfully within fewer than MySQL
5064 "max_connect_errors" attempts after a previous connection was interrupted,
5065 the error count for the host is cleared to zero. If HAProxy's server get
5066 blocked, the "FLUSH HOSTS" statement is the only way to unblock it.
5067
5068 Remember that this does not check database presence nor database consistency.
5069 To do this, you can use an external check with xinetd for example.
Hervé COMMOWICK698ae002010-01-12 09:25:13 +01005070
Hervé COMMOWICK212f7782011-06-10 14:05:59 +02005071 The check requires MySQL >=3.22, for older version, please use TCP check.
Hervé COMMOWICK698ae002010-01-12 09:25:13 +01005072
5073 Most often, an incoming MySQL server needs to see the client's IP address for
5074 various purposes, including IP privilege matching and connection logging.
5075 When possible, it is often wise to masquerade the client's IP address when
5076 connecting to the server using the "usesrc" argument of the "source" keyword,
5077 which requires the cttproxy feature to be compiled in, and the MySQL server
5078 to route the client via the machine hosting haproxy.
5079
5080 See also: "option httpchk"
5081
5082
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005083option nolinger
5084no option nolinger
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01005085 Enable or disable immediate session resource cleaning after close
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005086 May be used in sections: defaults | frontend | listen | backend
5087 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005088 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005089
5090 When clients or servers abort connections in a dirty way (eg: they are
5091 physically disconnected), the session timeouts triggers and the session is
5092 closed. But it will remain in FIN_WAIT1 state for some time in the system,
5093 using some resources and possibly limiting the ability to establish newer
5094 connections.
5095
5096 When this happens, it is possible to activate "option nolinger" which forces
5097 the system to immediately remove any socket's pending data on close. Thus,
5098 the session is instantly purged from the system's tables. This usually has
5099 side effects such as increased number of TCP resets due to old retransmits
5100 getting immediately rejected. Some firewalls may sometimes complain about
5101 this too.
5102
5103 For this reason, it is not recommended to use this option when not absolutely
5104 needed. You know that you need it when you have thousands of FIN_WAIT1
5105 sessions on your system (TIME_WAIT ones do not count).
5106
5107 This option may be used both on frontends and backends, depending on the side
5108 where it is required. Use it on the frontend for clients, and on the backend
5109 for servers.
5110
5111 If this option has been enabled in a "defaults" section, it can be disabled
5112 in a specific instance by prepending the "no" keyword before it.
5113
5114
Willy Tarreau55165fe2009-05-10 12:02:55 +02005115option originalto [ except <network> ] [ header <name> ]
5116 Enable insertion of the X-Original-To header to requests sent to servers
5117 May be used in sections : defaults | frontend | listen | backend
5118 yes | yes | yes | yes
5119 Arguments :
5120 <network> is an optional argument used to disable this option for sources
5121 matching <network>
5122 <name> an optional argument to specify a different "X-Original-To"
5123 header name.
5124
5125 Since HAProxy can work in transparent mode, every request from a client can
5126 be redirected to the proxy and HAProxy itself can proxy every request to a
5127 complex SQUID environment and the destination host from SO_ORIGINAL_DST will
5128 be lost. This is annoying when you want access rules based on destination ip
5129 addresses. To solve this problem, a new HTTP header "X-Original-To" may be
5130 added by HAProxy to all requests sent to the server. This header contains a
5131 value representing the original destination IP address. Since this must be
5132 configured to always use the last occurrence of this header only. Note that
5133 only the last occurrence of the header must be used, since it is really
5134 possible that the client has already brought one.
5135
5136 The keyword "header" may be used to supply a different header name to replace
5137 the default "X-Original-To". This can be useful where you might already
5138 have a "X-Original-To" header from a different application, and you need
5139 preserve it. Also if your backend server doesn't use the "X-Original-To"
5140 header and requires different one.
5141
5142 Sometimes, a same HAProxy instance may be shared between a direct client
5143 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
5144 used to decrypt HTTPS traffic). It is possible to disable the addition of the
5145 header for a known source address or network by adding the "except" keyword
5146 followed by the network address. In this case, any source IP matching the
5147 network will not cause an addition of this header. Most common uses are with
5148 private networks or 127.0.0.1.
5149
5150 This option may be specified either in the frontend or in the backend. If at
5151 least one of them uses it, the header will be added. Note that the backend's
5152 setting of the header subargument takes precedence over the frontend's if
5153 both are defined.
5154
Willy Tarreau55165fe2009-05-10 12:02:55 +02005155 Examples :
5156 # Original Destination address
5157 frontend www
5158 mode http
5159 option originalto except 127.0.0.1
5160
5161 # Those servers want the IP Address in X-Client-Dst
5162 backend www
5163 mode http
5164 option originalto header X-Client-Dst
5165
Willy Tarreau87cf5142011-08-19 22:57:24 +02005166 See also : "option httpclose", "option http-server-close",
5167 "option forceclose"
Willy Tarreau55165fe2009-05-10 12:02:55 +02005168
5169
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005170option persist
5171no option persist
5172 Enable or disable forced persistence on down servers
5173 May be used in sections: defaults | frontend | listen | backend
5174 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005175 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005176
5177 When an HTTP request reaches a backend with a cookie which references a dead
5178 server, by default it is redispatched to another server. It is possible to
5179 force the request to be sent to the dead server first using "option persist"
5180 if absolutely needed. A common use case is when servers are under extreme
5181 load and spend their time flapping. In this case, the users would still be
5182 directed to the server they opened the session on, in the hope they would be
5183 correctly served. It is recommended to use "option redispatch" in conjunction
5184 with this option so that in the event it would not be possible to connect to
5185 the server at all (server definitely dead), the client would finally be
5186 redirected to another valid server.
5187
5188 If this option has been enabled in a "defaults" section, it can be disabled
5189 in a specific instance by prepending the "no" keyword before it.
5190
Willy Tarreau4de91492010-01-22 19:10:05 +01005191 See also : "option redispatch", "retries", "force-persist"
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005192
5193
Willy Tarreau0c122822013-12-15 18:49:01 +01005194option pgsql-check [ user <username> ]
5195 Use PostgreSQL health checks for server testing
5196 May be used in sections : defaults | frontend | listen | backend
5197 yes | no | yes | yes
5198 Arguments :
5199 <username> This is the username which will be used when connecting to
5200 PostgreSQL server.
5201
5202 The check sends a PostgreSQL StartupMessage and waits for either
5203 Authentication request or ErrorResponse message. It is a basic but useful
5204 test which does not produce error nor aborted connect on the server.
5205 This check is identical with the "mysql-check".
5206
5207 See also: "option httpchk"
5208
5209
Willy Tarreau9420b122013-12-15 18:58:25 +01005210option prefer-last-server
5211no option prefer-last-server
5212 Allow multiple load balanced requests to remain on the same server
5213 May be used in sections: defaults | frontend | listen | backend
5214 yes | no | yes | yes
5215 Arguments : none
5216
5217 When the load balancing algorithm in use is not deterministic, and a previous
5218 request was sent to a server to which haproxy still holds a connection, it is
5219 sometimes desirable that subsequent requests on a same session go to the same
5220 server as much as possible. Note that this is different from persistence, as
5221 we only indicate a preference which haproxy tries to apply without any form
5222 of warranty. The real use is for keep-alive connections sent to servers. When
5223 this option is used, haproxy will try to reuse the same connection that is
5224 attached to the server instead of rebalancing to another server, causing a
5225 close of the connection. This can make sense for static file servers. It does
Willy Tarreau068621e2013-12-23 15:11:25 +01005226 not make much sense to use this in combination with hashing algorithms. Note,
5227 haproxy already automatically tries to stick to a server which sends a 401 or
5228 to a proxy which sends a 407 (authentication required). This is mandatory for
5229 use with the broken NTLM authentication challenge, and significantly helps in
5230 troubleshooting some faulty applications. Option prefer-last-server might be
5231 desirable in these environments as well, to avoid redistributing the traffic
5232 after every other response.
Willy Tarreau9420b122013-12-15 18:58:25 +01005233
5234 If this option has been enabled in a "defaults" section, it can be disabled
5235 in a specific instance by prepending the "no" keyword before it.
5236
5237 See also: "option http-keep-alive"
5238
5239
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005240option redispatch
5241no option redispatch
5242 Enable or disable session redistribution in case of connection failure
5243 May be used in sections: defaults | frontend | listen | backend
5244 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005245 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005246
5247 In HTTP mode, if a server designated by a cookie is down, clients may
5248 definitely stick to it because they cannot flush the cookie, so they will not
5249 be able to access the service anymore.
5250
5251 Specifying "option redispatch" will allow the proxy to break their
5252 persistence and redistribute them to a working server.
5253
5254 It also allows to retry last connection to another server in case of multiple
5255 connection failures. Of course, it requires having "retries" set to a nonzero
5256 value.
Willy Tarreaud72758d2010-01-12 10:42:19 +01005257
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005258 This form is the preferred form, which replaces both the "redispatch" and
5259 "redisp" keywords.
5260
5261 If this option has been enabled in a "defaults" section, it can be disabled
5262 in a specific instance by prepending the "no" keyword before it.
5263
Willy Tarreau4de91492010-01-22 19:10:05 +01005264 See also : "redispatch", "retries", "force-persist"
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005265
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005266
Hervé COMMOWICKec032d62011-08-05 16:23:48 +02005267option redis-check
5268 Use redis health checks for server testing
5269 May be used in sections : defaults | frontend | listen | backend
5270 yes | no | yes | yes
5271 Arguments : none
5272
5273 It is possible to test that the server correctly talks REDIS protocol instead
5274 of just testing that it accepts the TCP connection. When this option is set,
5275 a PING redis command is sent to the server, and the response is analyzed to
5276 find the "+PONG" response message.
5277
5278 Example :
5279 option redis-check
5280
5281 See also : "option httpchk"
5282
5283
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005284option smtpchk
5285option smtpchk <hello> <domain>
5286 Use SMTP health checks for server testing
5287 May be used in sections : defaults | frontend | listen | backend
5288 yes | no | yes | yes
Willy Tarreaud72758d2010-01-12 10:42:19 +01005289 Arguments :
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005290 <hello> is an optional argument. It is the "hello" command to use. It can
5291 be either "HELO" (for SMTP) or "EHLO" (for ESTMP). All other
5292 values will be turned into the default command ("HELO").
5293
5294 <domain> is the domain name to present to the server. It may only be
5295 specified (and is mandatory) if the hello command has been
5296 specified. By default, "localhost" is used.
5297
5298 When "option smtpchk" is set, the health checks will consist in TCP
5299 connections followed by an SMTP command. By default, this command is
5300 "HELO localhost". The server's return code is analyzed and only return codes
5301 starting with a "2" will be considered as valid. All other responses,
5302 including a lack of response will constitute an error and will indicate a
5303 dead server.
5304
5305 This test is meant to be used with SMTP servers or relays. Depending on the
5306 request, it is possible that some servers do not log each connection attempt,
5307 so you may want to experiment to improve the behaviour. Using telnet on port
5308 25 is often easier than adjusting the configuration.
5309
5310 Most often, an incoming SMTP server needs to see the client's IP address for
5311 various purposes, including spam filtering, anti-spoofing and logging. When
5312 possible, it is often wise to masquerade the client's IP address when
5313 connecting to the server using the "usesrc" argument of the "source" keyword,
5314 which requires the cttproxy feature to be compiled in.
5315
5316 Example :
5317 option smtpchk HELO mydomain.org
5318
5319 See also : "option httpchk", "source"
5320
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005321
Krzysztof Piotr Oledzkiaeebf9b2009-10-04 15:43:17 +02005322option socket-stats
5323no option socket-stats
5324
5325 Enable or disable collecting & providing separate statistics for each socket.
5326 May be used in sections : defaults | frontend | listen | backend
5327 yes | yes | yes | no
5328
5329 Arguments : none
5330
5331
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005332option splice-auto
5333no option splice-auto
5334 Enable or disable automatic kernel acceleration on sockets in both directions
5335 May be used in sections : defaults | frontend | listen | backend
5336 yes | yes | yes | yes
5337 Arguments : none
5338
5339 When this option is enabled either on a frontend or on a backend, haproxy
5340 will automatically evaluate the opportunity to use kernel tcp splicing to
5341 forward data between the client and the server, in either direction. Haproxy
5342 uses heuristics to estimate if kernel splicing might improve performance or
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01005343 not. Both directions are handled independently. Note that the heuristics used
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005344 are not much aggressive in order to limit excessive use of splicing. This
5345 option requires splicing to be enabled at compile time, and may be globally
5346 disabled with the global option "nosplice". Since splice uses pipes, using it
5347 requires that there are enough spare pipes.
5348
5349 Important note: kernel-based TCP splicing is a Linux-specific feature which
5350 first appeared in kernel 2.6.25. It offers kernel-based acceleration to
5351 transfer data between sockets without copying these data to user-space, thus
5352 providing noticeable performance gains and CPU cycles savings. Since many
5353 early implementations are buggy, corrupt data and/or are inefficient, this
5354 feature is not enabled by default, and it should be used with extreme care.
5355 While it is not possible to detect the correctness of an implementation,
5356 2.6.29 is the first version offering a properly working implementation. In
5357 case of doubt, splicing may be globally disabled using the global "nosplice"
5358 keyword.
5359
5360 Example :
5361 option splice-auto
5362
5363 If this option has been enabled in a "defaults" section, it can be disabled
5364 in a specific instance by prepending the "no" keyword before it.
5365
5366 See also : "option splice-request", "option splice-response", and global
5367 options "nosplice" and "maxpipes"
5368
5369
5370option splice-request
5371no option splice-request
5372 Enable or disable automatic kernel acceleration on sockets for requests
5373 May be used in sections : defaults | frontend | listen | backend
5374 yes | yes | yes | yes
5375 Arguments : none
5376
5377 When this option is enabled either on a frontend or on a backend, haproxy
Jamie Gloudonaaa21002012-08-25 00:18:33 -04005378 will use kernel tcp splicing whenever possible to forward data going from
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005379 the client to the server. It might still use the recv/send scheme if there
5380 are no spare pipes left. This option requires splicing to be enabled at
5381 compile time, and may be globally disabled with the global option "nosplice".
5382 Since splice uses pipes, using it requires that there are enough spare pipes.
5383
5384 Important note: see "option splice-auto" for usage limitations.
5385
5386 Example :
5387 option splice-request
5388
5389 If this option has been enabled in a "defaults" section, it can be disabled
5390 in a specific instance by prepending the "no" keyword before it.
5391
5392 See also : "option splice-auto", "option splice-response", and global options
5393 "nosplice" and "maxpipes"
5394
5395
5396option splice-response
5397no option splice-response
5398 Enable or disable automatic kernel acceleration on sockets for responses
5399 May be used in sections : defaults | frontend | listen | backend
5400 yes | yes | yes | yes
5401 Arguments : none
5402
5403 When this option is enabled either on a frontend or on a backend, haproxy
Jamie Gloudonaaa21002012-08-25 00:18:33 -04005404 will use kernel tcp splicing whenever possible to forward data going from
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005405 the server to the client. It might still use the recv/send scheme if there
5406 are no spare pipes left. This option requires splicing to be enabled at
5407 compile time, and may be globally disabled with the global option "nosplice".
5408 Since splice uses pipes, using it requires that there are enough spare pipes.
5409
5410 Important note: see "option splice-auto" for usage limitations.
5411
5412 Example :
5413 option splice-response
5414
5415 If this option has been enabled in a "defaults" section, it can be disabled
5416 in a specific instance by prepending the "no" keyword before it.
5417
5418 See also : "option splice-auto", "option splice-request", and global options
5419 "nosplice" and "maxpipes"
5420
5421
Willy Tarreaubf1f8162007-12-28 17:42:56 +01005422option srvtcpka
5423no option srvtcpka
5424 Enable or disable the sending of TCP keepalive packets on the server side
5425 May be used in sections : defaults | frontend | listen | backend
5426 yes | no | yes | yes
5427 Arguments : none
5428
5429 When there is a firewall or any session-aware component between a client and
5430 a server, and when the protocol involves very long sessions with long idle
5431 periods (eg: remote desktops), there is a risk that one of the intermediate
5432 components decides to expire a session which has remained idle for too long.
5433
5434 Enabling socket-level TCP keep-alives makes the system regularly send packets
5435 to the other end of the connection, leaving it active. The delay between
5436 keep-alive probes is controlled by the system only and depends both on the
5437 operating system and its tuning parameters.
5438
5439 It is important to understand that keep-alive packets are neither emitted nor
5440 received at the application level. It is only the network stacks which sees
5441 them. For this reason, even if one side of the proxy already uses keep-alives
5442 to maintain its connection alive, those keep-alive packets will not be
5443 forwarded to the other side of the proxy.
5444
5445 Please note that this has nothing to do with HTTP keep-alive.
5446
5447 Using option "srvtcpka" enables the emission of TCP keep-alive probes on the
5448 server side of a connection, which should help when session expirations are
5449 noticed between HAProxy and a server.
5450
5451 If this option has been enabled in a "defaults" section, it can be disabled
5452 in a specific instance by prepending the "no" keyword before it.
5453
5454 See also : "option clitcpka", "option tcpka"
5455
5456
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005457option ssl-hello-chk
5458 Use SSLv3 client hello health checks for server testing
5459 May be used in sections : defaults | frontend | listen | backend
5460 yes | no | yes | yes
5461 Arguments : none
5462
5463 When some SSL-based protocols are relayed in TCP mode through HAProxy, it is
5464 possible to test that the server correctly talks SSL instead of just testing
5465 that it accepts the TCP connection. When "option ssl-hello-chk" is set, pure
5466 SSLv3 client hello messages are sent once the connection is established to
5467 the server, and the response is analyzed to find an SSL server hello message.
5468 The server is considered valid only when the response contains this server
5469 hello message.
5470
5471 All servers tested till there correctly reply to SSLv3 client hello messages,
5472 and most servers tested do not even log the requests containing only hello
5473 messages, which is appreciable.
5474
Willy Tarreau763a95b2012-10-04 23:15:39 +02005475 Note that this check works even when SSL support was not built into haproxy
5476 because it forges the SSL message. When SSL support is available, it is best
5477 to use native SSL health checks instead of this one.
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005478
Willy Tarreau763a95b2012-10-04 23:15:39 +02005479 See also: "option httpchk", "check-ssl"
5480
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005481
Willy Tarreaued179852013-12-16 01:07:00 +01005482option tcp-check
5483 Perform health checks using tcp-check send/expect sequences
5484 May be used in sections: defaults | frontend | listen | backend
5485 yes | no | yes | yes
5486
5487 This health check method is intended to be combined with "tcp-check" command
5488 lists in order to support send/expect types of health check sequences.
5489
5490 TCP checks currently support 4 modes of operations :
5491 - no "tcp-check" directive : the health check only consists in a connection
5492 attempt, which remains the default mode.
5493
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005494 - "tcp-check send" or "tcp-check send-binary" only is mentioned : this is
Willy Tarreaued179852013-12-16 01:07:00 +01005495 used to send a string along with a connection opening. With some
5496 protocols, it helps sending a "QUIT" message for example that prevents
5497 the server from logging a connection error for each health check. The
5498 check result will still be based on the ability to open the connection
5499 only.
5500
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005501 - "tcp-check expect" only is mentioned : this is used to test a banner.
Willy Tarreaued179852013-12-16 01:07:00 +01005502 The connection is opened and haproxy waits for the server to present some
5503 contents which must validate some rules. The check result will be based
5504 on the matching between the contents and the rules. This is suited for
5505 POP, IMAP, SMTP, FTP, SSH, TELNET.
5506
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005507 - both "tcp-check send" and "tcp-check expect" are mentioned : this is
Willy Tarreaued179852013-12-16 01:07:00 +01005508 used to test a hello-type protocol. Haproxy sends a message, the server
5509 responds and its response is analysed. the check result will be based on
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005510 the matching between the response contents and the rules. This is often
Willy Tarreaued179852013-12-16 01:07:00 +01005511 suited for protocols which require a binding or a request/response model.
5512 LDAP, MySQL, Redis and SSL are example of such protocols, though they
5513 already all have their dedicated checks with a deeper understanding of
5514 the respective protocols.
5515 In this mode, many questions may be sent and many answers may be
5516 analysed.
5517
5518 Examples :
5519 # perform a POP check (analyse only server's banner)
5520 option tcp-check
5521 tcp-check expect string +OK\ POP3\ ready
5522
5523 # perform an IMAP check (analyse only server's banner)
5524 option tcp-check
5525 tcp-check expect string *\ OK\ IMAP4\ ready
5526
5527 # look for the redis master server after ensuring it speaks well
5528 # redis protocol, then it exits properly.
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005529 # (send a command then analyse the response 3 times)
Willy Tarreaued179852013-12-16 01:07:00 +01005530 option tcp-check
5531 tcp-check send PING\r\n
5532 tcp-check expect +PONG
5533 tcp-check send info\ replication\r\n
5534 tcp-check expect string role:master
5535 tcp-check send QUIT\r\n
5536 tcp-check expect string +OK
5537
5538 forge a HTTP request, then analyse the response
5539 (send many headers before analyzing)
5540 option tcp-check
5541 tcp-check send HEAD\ /\ HTTP/1.1\r\n
5542 tcp-check send Host:\ www.mydomain.com\r\n
5543 tcp-check send User-Agent:\ HAProxy\ tcpcheck\r\n
5544 tcp-check send \r\n
5545 tcp-check expect rstring HTTP/1\..\ (2..|3..)
5546
5547
5548 See also : "tcp-check expect", "tcp-check send"
5549
5550
Willy Tarreau9ea05a72009-06-14 12:07:01 +02005551option tcp-smart-accept
5552no option tcp-smart-accept
5553 Enable or disable the saving of one ACK packet during the accept sequence
5554 May be used in sections : defaults | frontend | listen | backend
5555 yes | yes | yes | no
5556 Arguments : none
5557
5558 When an HTTP connection request comes in, the system acknowledges it on
5559 behalf of HAProxy, then the client immediately sends its request, and the
5560 system acknowledges it too while it is notifying HAProxy about the new
5561 connection. HAProxy then reads the request and responds. This means that we
5562 have one TCP ACK sent by the system for nothing, because the request could
5563 very well be acknowledged by HAProxy when it sends its response.
5564
5565 For this reason, in HTTP mode, HAProxy automatically asks the system to avoid
5566 sending this useless ACK on platforms which support it (currently at least
5567 Linux). It must not cause any problem, because the system will send it anyway
5568 after 40 ms if the response takes more time than expected to come.
5569
5570 During complex network debugging sessions, it may be desirable to disable
5571 this optimization because delayed ACKs can make troubleshooting more complex
5572 when trying to identify where packets are delayed. It is then possible to
5573 fall back to normal behaviour by specifying "no option tcp-smart-accept".
5574
5575 It is also possible to force it for non-HTTP proxies by simply specifying
5576 "option tcp-smart-accept". For instance, it can make sense with some services
5577 such as SMTP where the server speaks first.
5578
5579 It is recommended to avoid forcing this option in a defaults section. In case
5580 of doubt, consider setting it back to automatic values by prepending the
5581 "default" keyword before it, or disabling it using the "no" keyword.
5582
Willy Tarreaud88edf22009-06-14 15:48:17 +02005583 See also : "option tcp-smart-connect"
5584
5585
5586option tcp-smart-connect
5587no option tcp-smart-connect
5588 Enable or disable the saving of one ACK packet during the connect sequence
5589 May be used in sections : defaults | frontend | listen | backend
5590 yes | no | yes | yes
5591 Arguments : none
5592
5593 On certain systems (at least Linux), HAProxy can ask the kernel not to
5594 immediately send an empty ACK upon a connection request, but to directly
5595 send the buffer request instead. This saves one packet on the network and
5596 thus boosts performance. It can also be useful for some servers, because they
5597 immediately get the request along with the incoming connection.
5598
5599 This feature is enabled when "option tcp-smart-connect" is set in a backend.
5600 It is not enabled by default because it makes network troubleshooting more
5601 complex.
5602
5603 It only makes sense to enable it with protocols where the client speaks first
5604 such as HTTP. In other situations, if there is no data to send in place of
5605 the ACK, a normal ACK is sent.
5606
5607 If this option has been enabled in a "defaults" section, it can be disabled
5608 in a specific instance by prepending the "no" keyword before it.
5609
5610 See also : "option tcp-smart-accept"
5611
Willy Tarreau9ea05a72009-06-14 12:07:01 +02005612
Willy Tarreaubf1f8162007-12-28 17:42:56 +01005613option tcpka
5614 Enable or disable the sending of TCP keepalive packets on both sides
5615 May be used in sections : defaults | frontend | listen | backend
5616 yes | yes | yes | yes
5617 Arguments : none
5618
5619 When there is a firewall or any session-aware component between a client and
5620 a server, and when the protocol involves very long sessions with long idle
5621 periods (eg: remote desktops), there is a risk that one of the intermediate
5622 components decides to expire a session which has remained idle for too long.
5623
5624 Enabling socket-level TCP keep-alives makes the system regularly send packets
5625 to the other end of the connection, leaving it active. The delay between
5626 keep-alive probes is controlled by the system only and depends both on the
5627 operating system and its tuning parameters.
5628
5629 It is important to understand that keep-alive packets are neither emitted nor
5630 received at the application level. It is only the network stacks which sees
5631 them. For this reason, even if one side of the proxy already uses keep-alives
5632 to maintain its connection alive, those keep-alive packets will not be
5633 forwarded to the other side of the proxy.
5634
5635 Please note that this has nothing to do with HTTP keep-alive.
5636
5637 Using option "tcpka" enables the emission of TCP keep-alive probes on both
5638 the client and server sides of a connection. Note that this is meaningful
5639 only in "defaults" or "listen" sections. If this option is used in a
5640 frontend, only the client side will get keep-alives, and if this option is
5641 used in a backend, only the server side will get keep-alives. For this
5642 reason, it is strongly recommended to explicitly use "option clitcpka" and
5643 "option srvtcpka" when the configuration is split between frontends and
5644 backends.
5645
5646 See also : "option clitcpka", "option srvtcpka"
5647
Willy Tarreau844e3c52008-01-11 16:28:18 +01005648
5649option tcplog
5650 Enable advanced logging of TCP connections with session state and timers
5651 May be used in sections : defaults | frontend | listen | backend
5652 yes | yes | yes | yes
5653 Arguments : none
5654
5655 By default, the log output format is very poor, as it only contains the
5656 source and destination addresses, and the instance name. By specifying
5657 "option tcplog", each log line turns into a much richer format including, but
5658 not limited to, the connection timers, the session status, the connections
5659 numbers, the frontend, backend and server name, and of course the source
5660 address and ports. This option is useful for pure TCP proxies in order to
5661 find which of the client or server disconnects or times out. For normal HTTP
5662 proxies, it's better to use "option httplog" which is even more complete.
5663
5664 This option may be set either in the frontend or the backend.
5665
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005666 See also : "option httplog", and section 8 about logging.
Willy Tarreau844e3c52008-01-11 16:28:18 +01005667
5668
Willy Tarreau844e3c52008-01-11 16:28:18 +01005669option transparent
5670no option transparent
5671 Enable client-side transparent proxying
5672 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau4b1f8592008-12-23 23:13:55 +01005673 yes | no | yes | yes
Willy Tarreau844e3c52008-01-11 16:28:18 +01005674 Arguments : none
5675
5676 This option was introduced in order to provide layer 7 persistence to layer 3
5677 load balancers. The idea is to use the OS's ability to redirect an incoming
5678 connection for a remote address to a local process (here HAProxy), and let
5679 this process know what address was initially requested. When this option is
5680 used, sessions without cookies will be forwarded to the original destination
5681 IP address of the incoming request (which should match that of another
5682 equipment), while requests with cookies will still be forwarded to the
5683 appropriate server.
5684
5685 Note that contrary to a common belief, this option does NOT make HAProxy
5686 present the client's IP to the server when establishing the connection.
5687
Willy Tarreaua1146052011-03-01 09:51:54 +01005688 See also: the "usesrc" argument of the "source" keyword, and the
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005689 "transparent" option of the "bind" keyword.
Willy Tarreau844e3c52008-01-11 16:28:18 +01005690
Willy Tarreaubf1f8162007-12-28 17:42:56 +01005691
Simon Horman98637e52014-06-20 12:30:16 +09005692external-check command <command>
5693 Executable to run when performing an external-check
5694 May be used in sections : defaults | frontend | listen | backend
5695 yes | no | yes | yes
5696
5697 Arguments :
5698 <command> is the external command to run
5699
Simon Horman98637e52014-06-20 12:30:16 +09005700 The arguments passed to the to the command are:
5701
Cyril Bonté777be862014-12-02 21:21:35 +01005702 <proxy_address> <proxy_port> <server_address> <server_port>
Simon Horman98637e52014-06-20 12:30:16 +09005703
Cyril Bonté777be862014-12-02 21:21:35 +01005704 The <proxy_address> and <proxy_port> are derived from the first listener
5705 that is either IPv4, IPv6 or a UNIX socket. In the case of a UNIX socket
5706 listener the proxy_address will be the path of the socket and the
5707 <proxy_port> will be the string "NOT_USED". In a backend section, it's not
5708 possible to determine a listener, and both <proxy_address> and <proxy_port>
5709 will have the string value "NOT_USED".
Simon Horman98637e52014-06-20 12:30:16 +09005710
Cyril Bonté72cda2a2014-12-27 22:28:39 +01005711 Some values are also provided through environment variables.
5712
5713 Environment variables :
5714 HAPROXY_PROXY_ADDR The first bind address if available (or empty if not
5715 applicable, for example in a "backend" section).
5716
5717 HAPROXY_PROXY_ID The backend id.
5718
5719 HAPROXY_PROXY_NAME The backend name.
5720
5721 HAPROXY_PROXY_PORT The first bind port if available (or empty if not
5722 applicable, for example in a "backend" section or
5723 for a UNIX socket).
5724
5725 HAPROXY_SERVER_ADDR The server address.
5726
5727 HAPROXY_SERVER_CURCONN The current number of connections on the server.
5728
5729 HAPROXY_SERVER_ID The server id.
5730
5731 HAPROXY_SERVER_MAXCONN The server max connections.
5732
5733 HAPROXY_SERVER_NAME The server name.
5734
5735 HAPROXY_SERVER_PORT The server port if available (or empty for a UNIX
5736 socket).
5737
5738 PATH The PATH environment variable used when executing
5739 the command may be set using "external-check path".
5740
Simon Horman98637e52014-06-20 12:30:16 +09005741 If the command executed and exits with a zero status then the check is
5742 considered to have passed, otherwise the check is considered to have
5743 failed.
5744
5745 Example :
5746 external-check command /bin/true
5747
5748 See also : "external-check", "option external-check", "external-check path"
5749
5750
5751external-check path <path>
5752 The value of the PATH environment variable used when running an external-check
5753 May be used in sections : defaults | frontend | listen | backend
5754 yes | no | yes | yes
5755
5756 Arguments :
5757 <path> is the path used when executing external command to run
5758
5759 The default path is "".
5760
5761 Example :
5762 external-check path "/usr/bin:/bin"
5763
5764 See also : "external-check", "option external-check",
5765 "external-check command"
5766
5767
Emeric Brun647caf12009-06-30 17:57:00 +02005768persist rdp-cookie
Hervé COMMOWICKa3eb39c2011-08-05 18:48:51 +02005769persist rdp-cookie(<name>)
Emeric Brun647caf12009-06-30 17:57:00 +02005770 Enable RDP cookie-based persistence
5771 May be used in sections : defaults | frontend | listen | backend
5772 yes | no | yes | yes
5773 Arguments :
5774 <name> is the optional name of the RDP cookie to check. If omitted, the
Willy Tarreau61e28f22010-05-16 22:31:05 +02005775 default cookie name "msts" will be used. There currently is no
5776 valid reason to change this name.
Emeric Brun647caf12009-06-30 17:57:00 +02005777
5778 This statement enables persistence based on an RDP cookie. The RDP cookie
5779 contains all information required to find the server in the list of known
5780 servers. So when this option is set in the backend, the request is analysed
5781 and if an RDP cookie is found, it is decoded. If it matches a known server
5782 which is still UP (or if "option persist" is set), then the connection is
5783 forwarded to this server.
5784
5785 Note that this only makes sense in a TCP backend, but for this to work, the
5786 frontend must have waited long enough to ensure that an RDP cookie is present
5787 in the request buffer. This is the same requirement as with the "rdp-cookie"
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01005788 load-balancing method. Thus it is highly recommended to put all statements in
Emeric Brun647caf12009-06-30 17:57:00 +02005789 a single "listen" section.
5790
Willy Tarreau61e28f22010-05-16 22:31:05 +02005791 Also, it is important to understand that the terminal server will emit this
5792 RDP cookie only if it is configured for "token redirection mode", which means
5793 that the "IP address redirection" option is disabled.
5794
Emeric Brun647caf12009-06-30 17:57:00 +02005795 Example :
5796 listen tse-farm
5797 bind :3389
5798 # wait up to 5s for an RDP cookie in the request
5799 tcp-request inspect-delay 5s
5800 tcp-request content accept if RDP_COOKIE
5801 # apply RDP cookie persistence
5802 persist rdp-cookie
5803 # if server is unknown, let's balance on the same cookie.
Cyril Bontédc4d9032012-04-08 21:57:39 +02005804 # alternatively, "balance leastconn" may be useful too.
Emeric Brun647caf12009-06-30 17:57:00 +02005805 balance rdp-cookie
5806 server srv1 1.1.1.1:3389
5807 server srv2 1.1.1.2:3389
5808
Simon Hormanab814e02011-06-24 14:50:20 +09005809 See also : "balance rdp-cookie", "tcp-request", the "req_rdp_cookie" ACL and
5810 the rdp_cookie pattern fetch function.
Emeric Brun647caf12009-06-30 17:57:00 +02005811
5812
Willy Tarreau3a7d2072009-03-05 23:48:25 +01005813rate-limit sessions <rate>
5814 Set a limit on the number of new sessions accepted per second on a frontend
5815 May be used in sections : defaults | frontend | listen | backend
5816 yes | yes | yes | no
5817 Arguments :
5818 <rate> The <rate> parameter is an integer designating the maximum number
5819 of new sessions per second to accept on the frontend.
5820
5821 When the frontend reaches the specified number of new sessions per second, it
5822 stops accepting new connections until the rate drops below the limit again.
5823 During this time, the pending sessions will be kept in the socket's backlog
5824 (in system buffers) and haproxy will not even be aware that sessions are
5825 pending. When applying very low limit on a highly loaded service, it may make
5826 sense to increase the socket's backlog using the "backlog" keyword.
5827
5828 This feature is particularly efficient at blocking connection-based attacks
5829 or service abuse on fragile servers. Since the session rate is measured every
5830 millisecond, it is extremely accurate. Also, the limit applies immediately,
5831 no delay is needed at all to detect the threshold.
5832
5833 Example : limit the connection rate on SMTP to 10 per second max
5834 listen smtp
5835 mode tcp
5836 bind :25
5837 rate-limit sessions 10
5838 server 127.0.0.1:1025
5839
Willy Tarreaua17c2d92011-07-25 08:16:20 +02005840 Note : when the maximum rate is reached, the frontend's status is not changed
5841 but its sockets appear as "WAITING" in the statistics if the
5842 "socket-stats" option is enabled.
Willy Tarreau3a7d2072009-03-05 23:48:25 +01005843
5844 See also : the "backlog" keyword and the "fe_sess_rate" ACL criterion.
5845
5846
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005847redirect location <loc> [code <code>] <option> [{if | unless} <condition>]
5848redirect prefix <pfx> [code <code>] <option> [{if | unless} <condition>]
5849redirect scheme <sch> [code <code>] <option> [{if | unless} <condition>]
Willy Tarreaub463dfb2008-06-07 23:08:56 +02005850 Return an HTTP redirection if/unless a condition is matched
5851 May be used in sections : defaults | frontend | listen | backend
5852 no | yes | yes | yes
5853
5854 If/unless the condition is matched, the HTTP request will lead to a redirect
Willy Tarreauf285f542010-01-03 20:03:03 +01005855 response. If no condition is specified, the redirect applies unconditionally.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02005856
Willy Tarreau0140f252008-11-19 21:07:09 +01005857 Arguments :
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005858 <loc> With "redirect location", the exact value in <loc> is placed into
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01005859 the HTTP "Location" header. When used in an "http-request" rule,
5860 <loc> value follows the log-format rules and can include some
5861 dynamic values (see Custom Log Format in section 8.2.4).
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005862
5863 <pfx> With "redirect prefix", the "Location" header is built from the
5864 concatenation of <pfx> and the complete URI path, including the
5865 query string, unless the "drop-query" option is specified (see
5866 below). As a special case, if <pfx> equals exactly "/", then
5867 nothing is inserted before the original URI. It allows one to
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01005868 redirect to the same URL (for instance, to insert a cookie). When
5869 used in an "http-request" rule, <pfx> value follows the log-format
5870 rules and can include some dynamic values (see Custom Log Format
5871 in section 8.2.4).
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005872
5873 <sch> With "redirect scheme", then the "Location" header is built by
5874 concatenating <sch> with "://" then the first occurrence of the
5875 "Host" header, and then the URI path, including the query string
5876 unless the "drop-query" option is specified (see below). If no
5877 path is found or if the path is "*", then "/" is used instead. If
5878 no "Host" header is found, then an empty host component will be
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005879 returned, which most recent browsers interpret as redirecting to
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005880 the same host. This directive is mostly used to redirect HTTP to
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01005881 HTTPS. When used in an "http-request" rule, <sch> value follows
5882 the log-format rules and can include some dynamic values (see
5883 Custom Log Format in section 8.2.4).
Willy Tarreau0140f252008-11-19 21:07:09 +01005884
5885 <code> The code is optional. It indicates which type of HTTP redirection
Willy Tarreaub67fdc42013-03-29 19:28:11 +01005886 is desired. Only codes 301, 302, 303, 307 and 308 are supported,
5887 with 302 used by default if no code is specified. 301 means
5888 "Moved permanently", and a browser may cache the Location. 302
5889 means "Moved permanently" and means that the browser should not
5890 cache the redirection. 303 is equivalent to 302 except that the
5891 browser will fetch the location with a GET method. 307 is just
5892 like 302 but makes it clear that the same method must be reused.
5893 Likewise, 308 replaces 301 if the same method must be used.
Willy Tarreau0140f252008-11-19 21:07:09 +01005894
5895 <option> There are several options which can be specified to adjust the
5896 expected behaviour of a redirection :
5897
5898 - "drop-query"
5899 When this keyword is used in a prefix-based redirection, then the
5900 location will be set without any possible query-string, which is useful
5901 for directing users to a non-secure page for instance. It has no effect
5902 with a location-type redirect.
5903
Willy Tarreau81e3b4f2010-01-10 00:42:19 +01005904 - "append-slash"
5905 This keyword may be used in conjunction with "drop-query" to redirect
5906 users who use a URL not ending with a '/' to the same one with the '/'.
5907 It can be useful to ensure that search engines will only see one URL.
5908 For this, a return code 301 is preferred.
5909
Willy Tarreau0140f252008-11-19 21:07:09 +01005910 - "set-cookie NAME[=value]"
5911 A "Set-Cookie" header will be added with NAME (and optionally "=value")
5912 to the response. This is sometimes used to indicate that a user has
5913 been seen, for instance to protect against some types of DoS. No other
5914 cookie option is added, so the cookie will be a session cookie. Note
5915 that for a browser, a sole cookie name without an equal sign is
5916 different from a cookie with an equal sign.
5917
5918 - "clear-cookie NAME[=]"
5919 A "Set-Cookie" header will be added with NAME (and optionally "="), but
5920 with the "Max-Age" attribute set to zero. This will tell the browser to
5921 delete this cookie. It is useful for instance on logout pages. It is
5922 important to note that clearing the cookie "NAME" will not remove a
5923 cookie set with "NAME=value". You have to clear the cookie "NAME=" for
5924 that, because the browser makes the difference.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02005925
5926 Example: move the login URL only to HTTPS.
5927 acl clear dst_port 80
5928 acl secure dst_port 8080
5929 acl login_page url_beg /login
Willy Tarreau0140f252008-11-19 21:07:09 +01005930 acl logout url_beg /logout
Willy Tarreau79da4692008-11-19 20:03:04 +01005931 acl uid_given url_reg /login?userid=[^&]+
Willy Tarreau0140f252008-11-19 21:07:09 +01005932 acl cookie_set hdr_sub(cookie) SEEN=1
5933
5934 redirect prefix https://mysite.com set-cookie SEEN=1 if !cookie_set
Willy Tarreau79da4692008-11-19 20:03:04 +01005935 redirect prefix https://mysite.com if login_page !secure
5936 redirect prefix http://mysite.com drop-query if login_page !uid_given
5937 redirect location http://mysite.com/ if !login_page secure
Willy Tarreau0140f252008-11-19 21:07:09 +01005938 redirect location / clear-cookie USERID= if logout
Willy Tarreaub463dfb2008-06-07 23:08:56 +02005939
Willy Tarreau81e3b4f2010-01-10 00:42:19 +01005940 Example: send redirects for request for articles without a '/'.
5941 acl missing_slash path_reg ^/article/[^/]*$
5942 redirect code 301 prefix / drop-query append-slash if missing_slash
5943
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005944 Example: redirect all HTTP traffic to HTTPS when SSL is handled by haproxy.
David BERARDe7153042012-11-03 00:11:31 +01005945 redirect scheme https if !{ ssl_fc }
Willy Tarreau2e1dca82012-09-12 08:43:15 +02005946
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01005947 Example: append 'www.' prefix in front of all hosts not having it
5948 http-request redirect code 301 location www.%[hdr(host)]%[req.uri] \
5949 unless { hdr_beg(host) -i www }
5950
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005951 See section 7 about ACL usage.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02005952
5953
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005954redisp (deprecated)
5955redispatch (deprecated)
5956 Enable or disable session redistribution in case of connection failure
5957 May be used in sections: defaults | frontend | listen | backend
5958 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005959 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005960
5961 In HTTP mode, if a server designated by a cookie is down, clients may
5962 definitely stick to it because they cannot flush the cookie, so they will not
5963 be able to access the service anymore.
5964
5965 Specifying "redispatch" will allow the proxy to break their persistence and
5966 redistribute them to a working server.
5967
5968 It also allows to retry last connection to another server in case of multiple
5969 connection failures. Of course, it requires having "retries" set to a nonzero
5970 value.
Willy Tarreaud72758d2010-01-12 10:42:19 +01005971
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005972 This form is deprecated, do not use it in any new configuration, use the new
5973 "option redispatch" instead.
5974
5975 See also : "option redispatch"
5976
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005977
Willy Tarreau8abd4cd2010-01-31 14:30:44 +01005978reqadd <string> [{if | unless} <cond>]
Willy Tarreau303c0352008-01-17 19:01:39 +01005979 Add a header at the end of the HTTP request
5980 May be used in sections : defaults | frontend | listen | backend
5981 no | yes | yes | yes
5982 Arguments :
5983 <string> is the complete line to be added. Any space or known delimiter
5984 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005985 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01005986
Willy Tarreau8abd4cd2010-01-31 14:30:44 +01005987 <cond> is an optional matching condition built from ACLs. It makes it
5988 possible to ignore this rule when other conditions are not met.
5989
Willy Tarreau303c0352008-01-17 19:01:39 +01005990 A new line consisting in <string> followed by a line feed will be added after
5991 the last header of an HTTP request.
5992
5993 Header transformations only apply to traffic which passes through HAProxy,
5994 and not to traffic generated by HAProxy, such as health-checks or error
5995 responses.
5996
Willy Tarreau8abd4cd2010-01-31 14:30:44 +01005997 Example : add "X-Proto: SSL" to requests coming via port 81
5998 acl is-ssl dst_port 81
5999 reqadd X-Proto:\ SSL if is-ssl
6000
6001 See also: "rspadd", section 6 about HTTP header manipulation, and section 7
6002 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006003
6004
Willy Tarreau5321c422010-01-28 20:35:13 +01006005reqallow <search> [{if | unless} <cond>]
6006reqiallow <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006007 Definitely allow an HTTP request if a line matches a regular expression
6008 May be used in sections : defaults | frontend | listen | backend
6009 no | yes | yes | yes
6010 Arguments :
6011 <search> is the regular expression applied to HTTP headers and to the
6012 request line. This is an extended regular expression. Parenthesis
6013 grouping is supported and no preliminary backslash is required.
6014 Any space or known delimiter must be escaped using a backslash
6015 ('\'). The pattern applies to a full line at a time. The
6016 "reqallow" keyword strictly matches case while "reqiallow"
6017 ignores case.
6018
Willy Tarreau5321c422010-01-28 20:35:13 +01006019 <cond> is an optional matching condition built from ACLs. It makes it
6020 possible to ignore this rule when other conditions are not met.
6021
Willy Tarreau303c0352008-01-17 19:01:39 +01006022 A request containing any line which matches extended regular expression
6023 <search> will mark the request as allowed, even if any later test would
6024 result in a deny. The test applies both to the request line and to request
6025 headers. Keep in mind that URLs in request line are case-sensitive while
Willy Tarreaud72758d2010-01-12 10:42:19 +01006026 header names are not.
Willy Tarreau303c0352008-01-17 19:01:39 +01006027
6028 It is easier, faster and more powerful to use ACLs to write access policies.
6029 Reqdeny, reqallow and reqpass should be avoided in new designs.
6030
6031 Example :
6032 # allow www.* but refuse *.local
6033 reqiallow ^Host:\ www\.
6034 reqideny ^Host:\ .*\.local
6035
Willy Tarreau5321c422010-01-28 20:35:13 +01006036 See also: "reqdeny", "block", section 6 about HTTP header manipulation, and
6037 section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006038
6039
Willy Tarreau5321c422010-01-28 20:35:13 +01006040reqdel <search> [{if | unless} <cond>]
6041reqidel <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006042 Delete all headers matching a regular expression in an HTTP request
6043 May be used in sections : defaults | frontend | listen | backend
6044 no | yes | yes | yes
6045 Arguments :
6046 <search> is the regular expression applied to HTTP headers and to the
6047 request line. This is an extended regular expression. Parenthesis
6048 grouping is supported and no preliminary backslash is required.
6049 Any space or known delimiter must be escaped using a backslash
6050 ('\'). The pattern applies to a full line at a time. The "reqdel"
6051 keyword strictly matches case while "reqidel" ignores case.
6052
Willy Tarreau5321c422010-01-28 20:35:13 +01006053 <cond> is an optional matching condition built from ACLs. It makes it
6054 possible to ignore this rule when other conditions are not met.
6055
Willy Tarreau303c0352008-01-17 19:01:39 +01006056 Any header line matching extended regular expression <search> in the request
6057 will be completely deleted. Most common use of this is to remove unwanted
6058 and/or dangerous headers or cookies from a request before passing it to the
6059 next servers.
6060
6061 Header transformations only apply to traffic which passes through HAProxy,
6062 and not to traffic generated by HAProxy, such as health-checks or error
6063 responses. Keep in mind that header names are not case-sensitive.
6064
6065 Example :
6066 # remove X-Forwarded-For header and SERVER cookie
6067 reqidel ^X-Forwarded-For:.*
6068 reqidel ^Cookie:.*SERVER=
6069
Willy Tarreau5321c422010-01-28 20:35:13 +01006070 See also: "reqadd", "reqrep", "rspdel", section 6 about HTTP header
6071 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006072
6073
Willy Tarreau5321c422010-01-28 20:35:13 +01006074reqdeny <search> [{if | unless} <cond>]
6075reqideny <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006076 Deny an HTTP request if a line matches a regular expression
6077 May be used in sections : defaults | frontend | listen | backend
6078 no | yes | yes | yes
6079 Arguments :
6080 <search> is the regular expression applied to HTTP headers and to the
6081 request line. This is an extended regular expression. Parenthesis
6082 grouping is supported and no preliminary backslash is required.
6083 Any space or known delimiter must be escaped using a backslash
6084 ('\'). The pattern applies to a full line at a time. The
6085 "reqdeny" keyword strictly matches case while "reqideny" ignores
6086 case.
6087
Willy Tarreau5321c422010-01-28 20:35:13 +01006088 <cond> is an optional matching condition built from ACLs. It makes it
6089 possible to ignore this rule when other conditions are not met.
6090
Willy Tarreau303c0352008-01-17 19:01:39 +01006091 A request containing any line which matches extended regular expression
6092 <search> will mark the request as denied, even if any later test would
6093 result in an allow. The test applies both to the request line and to request
6094 headers. Keep in mind that URLs in request line are case-sensitive while
Willy Tarreaud72758d2010-01-12 10:42:19 +01006095 header names are not.
Willy Tarreau303c0352008-01-17 19:01:39 +01006096
Willy Tarreauced27012008-01-17 20:35:34 +01006097 A denied request will generate an "HTTP 403 forbidden" response once the
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01006098 complete request has been parsed. This is consistent with what is practiced
Willy Tarreaud72758d2010-01-12 10:42:19 +01006099 using ACLs.
Willy Tarreauced27012008-01-17 20:35:34 +01006100
Willy Tarreau303c0352008-01-17 19:01:39 +01006101 It is easier, faster and more powerful to use ACLs to write access policies.
6102 Reqdeny, reqallow and reqpass should be avoided in new designs.
6103
6104 Example :
6105 # refuse *.local, then allow www.*
6106 reqideny ^Host:\ .*\.local
6107 reqiallow ^Host:\ www\.
6108
Willy Tarreau5321c422010-01-28 20:35:13 +01006109 See also: "reqallow", "rspdeny", "block", section 6 about HTTP header
6110 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006111
6112
Willy Tarreau5321c422010-01-28 20:35:13 +01006113reqpass <search> [{if | unless} <cond>]
6114reqipass <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006115 Ignore any HTTP request line matching a regular expression in next rules
6116 May be used in sections : defaults | frontend | listen | backend
6117 no | yes | yes | yes
6118 Arguments :
6119 <search> is the regular expression applied to HTTP headers and to the
6120 request line. This is an extended regular expression. Parenthesis
6121 grouping is supported and no preliminary backslash is required.
6122 Any space or known delimiter must be escaped using a backslash
6123 ('\'). The pattern applies to a full line at a time. The
6124 "reqpass" keyword strictly matches case while "reqipass" ignores
6125 case.
6126
Willy Tarreau5321c422010-01-28 20:35:13 +01006127 <cond> is an optional matching condition built from ACLs. It makes it
6128 possible to ignore this rule when other conditions are not met.
6129
Willy Tarreau303c0352008-01-17 19:01:39 +01006130 A request containing any line which matches extended regular expression
6131 <search> will skip next rules, without assigning any deny or allow verdict.
6132 The test applies both to the request line and to request headers. Keep in
6133 mind that URLs in request line are case-sensitive while header names are not.
6134
6135 It is easier, faster and more powerful to use ACLs to write access policies.
6136 Reqdeny, reqallow and reqpass should be avoided in new designs.
6137
6138 Example :
6139 # refuse *.local, then allow www.*, but ignore "www.private.local"
6140 reqipass ^Host:\ www.private\.local
6141 reqideny ^Host:\ .*\.local
6142 reqiallow ^Host:\ www\.
6143
Willy Tarreau5321c422010-01-28 20:35:13 +01006144 See also: "reqallow", "reqdeny", "block", section 6 about HTTP header
6145 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006146
6147
Willy Tarreau5321c422010-01-28 20:35:13 +01006148reqrep <search> <string> [{if | unless} <cond>]
6149reqirep <search> <string> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006150 Replace a regular expression with a string in an HTTP request line
6151 May be used in sections : defaults | frontend | listen | backend
6152 no | yes | yes | yes
6153 Arguments :
6154 <search> is the regular expression applied to HTTP headers and to the
6155 request line. This is an extended regular expression. Parenthesis
6156 grouping is supported and no preliminary backslash is required.
6157 Any space or known delimiter must be escaped using a backslash
6158 ('\'). The pattern applies to a full line at a time. The "reqrep"
6159 keyword strictly matches case while "reqirep" ignores case.
6160
6161 <string> is the complete line to be added. Any space or known delimiter
6162 must be escaped using a backslash ('\'). References to matched
6163 pattern groups are possible using the common \N form, with N
6164 being a single digit between 0 and 9. Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006165 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006166
Willy Tarreau5321c422010-01-28 20:35:13 +01006167 <cond> is an optional matching condition built from ACLs. It makes it
6168 possible to ignore this rule when other conditions are not met.
6169
Willy Tarreau303c0352008-01-17 19:01:39 +01006170 Any line matching extended regular expression <search> in the request (both
6171 the request line and header lines) will be completely replaced with <string>.
6172 Most common use of this is to rewrite URLs or domain names in "Host" headers.
6173
6174 Header transformations only apply to traffic which passes through HAProxy,
6175 and not to traffic generated by HAProxy, such as health-checks or error
6176 responses. Note that for increased readability, it is suggested to add enough
6177 spaces between the request and the response. Keep in mind that URLs in
6178 request line are case-sensitive while header names are not.
6179
6180 Example :
6181 # replace "/static/" with "/" at the beginning of any request path.
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04006182 reqrep ^([^\ :]*)\ /static/(.*) \1\ /\2
Willy Tarreau303c0352008-01-17 19:01:39 +01006183 # replace "www.mydomain.com" with "www" in the host name.
6184 reqirep ^Host:\ www.mydomain.com Host:\ www
6185
Dmitry Sivachenkof6f4f7b2012-10-21 18:10:25 +04006186 See also: "reqadd", "reqdel", "rsprep", "tune.bufsize", section 6 about
6187 HTTP header manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006188
6189
Willy Tarreau5321c422010-01-28 20:35:13 +01006190reqtarpit <search> [{if | unless} <cond>]
6191reqitarpit <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006192 Tarpit an HTTP request containing a line matching a regular expression
6193 May be used in sections : defaults | frontend | listen | backend
6194 no | yes | yes | yes
6195 Arguments :
6196 <search> is the regular expression applied to HTTP headers and to the
6197 request line. This is an extended regular expression. Parenthesis
6198 grouping is supported and no preliminary backslash is required.
6199 Any space or known delimiter must be escaped using a backslash
6200 ('\'). The pattern applies to a full line at a time. The
6201 "reqtarpit" keyword strictly matches case while "reqitarpit"
6202 ignores case.
6203
Willy Tarreau5321c422010-01-28 20:35:13 +01006204 <cond> is an optional matching condition built from ACLs. It makes it
6205 possible to ignore this rule when other conditions are not met.
6206
Willy Tarreau303c0352008-01-17 19:01:39 +01006207 A request containing any line which matches extended regular expression
6208 <search> will be tarpitted, which means that it will connect to nowhere, will
Willy Tarreauced27012008-01-17 20:35:34 +01006209 be kept open for a pre-defined time, then will return an HTTP error 500 so
6210 that the attacker does not suspect it has been tarpitted. The status 500 will
6211 be reported in the logs, but the completion flags will indicate "PT". The
Willy Tarreau303c0352008-01-17 19:01:39 +01006212 delay is defined by "timeout tarpit", or "timeout connect" if the former is
6213 not set.
6214
6215 The goal of the tarpit is to slow down robots attacking servers with
6216 identifiable requests. Many robots limit their outgoing number of connections
6217 and stay connected waiting for a reply which can take several minutes to
6218 come. Depending on the environment and attack, it may be particularly
6219 efficient at reducing the load on the network and firewalls.
6220
Willy Tarreau5321c422010-01-28 20:35:13 +01006221 Examples :
Willy Tarreau303c0352008-01-17 19:01:39 +01006222 # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but
6223 # block all others.
6224 reqipass ^User-Agent:\.*(Mozilla|MSIE)
6225 reqitarpit ^User-Agent:
6226
Willy Tarreau5321c422010-01-28 20:35:13 +01006227 # block bad guys
6228 acl badguys src 10.1.0.3 172.16.13.20/28
6229 reqitarpit . if badguys
6230
6231 See also: "reqallow", "reqdeny", "reqpass", section 6 about HTTP header
6232 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006233
6234
Willy Tarreaue5c5ce92008-06-20 17:27:19 +02006235retries <value>
6236 Set the number of retries to perform on a server after a connection failure
6237 May be used in sections: defaults | frontend | listen | backend
6238 yes | no | yes | yes
6239 Arguments :
6240 <value> is the number of times a connection attempt should be retried on
6241 a server when a connection either is refused or times out. The
6242 default value is 3.
6243
6244 It is important to understand that this value applies to the number of
6245 connection attempts, not full requests. When a connection has effectively
6246 been established to a server, there will be no more retry.
6247
6248 In order to avoid immediate reconnections to a server which is restarting,
6249 a turn-around timer of 1 second is applied before a retry occurs.
6250
6251 When "option redispatch" is set, the last retry may be performed on another
6252 server even if a cookie references a different server.
6253
6254 See also : "option redispatch"
6255
6256
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006257rspadd <string> [{if | unless} <cond>]
Willy Tarreau303c0352008-01-17 19:01:39 +01006258 Add a header at the end of the HTTP response
6259 May be used in sections : defaults | frontend | listen | backend
6260 no | yes | yes | yes
6261 Arguments :
6262 <string> is the complete line to be added. Any space or known delimiter
6263 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006264 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006265
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006266 <cond> is an optional matching condition built from ACLs. It makes it
6267 possible to ignore this rule when other conditions are not met.
6268
Willy Tarreau303c0352008-01-17 19:01:39 +01006269 A new line consisting in <string> followed by a line feed will be added after
6270 the last header of an HTTP response.
6271
6272 Header transformations only apply to traffic which passes through HAProxy,
6273 and not to traffic generated by HAProxy, such as health-checks or error
6274 responses.
6275
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006276 See also: "reqadd", section 6 about HTTP header manipulation, and section 7
6277 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006278
6279
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006280rspdel <search> [{if | unless} <cond>]
6281rspidel <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006282 Delete all headers matching a regular expression in an HTTP response
6283 May be used in sections : defaults | frontend | listen | backend
6284 no | yes | yes | yes
6285 Arguments :
6286 <search> is the regular expression applied to HTTP headers and to the
6287 response line. This is an extended regular expression, so
6288 parenthesis grouping is supported and no preliminary backslash
6289 is required. Any space or known delimiter must be escaped using
6290 a backslash ('\'). The pattern applies to a full line at a time.
6291 The "rspdel" keyword strictly matches case while "rspidel"
6292 ignores case.
6293
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006294 <cond> is an optional matching condition built from ACLs. It makes it
6295 possible to ignore this rule when other conditions are not met.
6296
Willy Tarreau303c0352008-01-17 19:01:39 +01006297 Any header line matching extended regular expression <search> in the response
6298 will be completely deleted. Most common use of this is to remove unwanted
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02006299 and/or sensitive headers or cookies from a response before passing it to the
Willy Tarreau303c0352008-01-17 19:01:39 +01006300 client.
6301
6302 Header transformations only apply to traffic which passes through HAProxy,
6303 and not to traffic generated by HAProxy, such as health-checks or error
6304 responses. Keep in mind that header names are not case-sensitive.
6305
6306 Example :
6307 # remove the Server header from responses
Willy Tarreau5e80e022013-05-25 08:31:25 +02006308 rspidel ^Server:.*
Willy Tarreau303c0352008-01-17 19:01:39 +01006309
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006310 See also: "rspadd", "rsprep", "reqdel", section 6 about HTTP header
6311 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006312
6313
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006314rspdeny <search> [{if | unless} <cond>]
6315rspideny <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006316 Block an HTTP response if a line matches a regular expression
6317 May be used in sections : defaults | frontend | listen | backend
6318 no | yes | yes | yes
6319 Arguments :
6320 <search> is the regular expression applied to HTTP headers and to the
6321 response line. This is an extended regular expression, so
6322 parenthesis grouping is supported and no preliminary backslash
6323 is required. Any space or known delimiter must be escaped using
6324 a backslash ('\'). The pattern applies to a full line at a time.
6325 The "rspdeny" keyword strictly matches case while "rspideny"
6326 ignores case.
6327
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006328 <cond> is an optional matching condition built from ACLs. It makes it
6329 possible to ignore this rule when other conditions are not met.
6330
Willy Tarreau303c0352008-01-17 19:01:39 +01006331 A response containing any line which matches extended regular expression
6332 <search> will mark the request as denied. The test applies both to the
6333 response line and to response headers. Keep in mind that header names are not
6334 case-sensitive.
6335
6336 Main use of this keyword is to prevent sensitive information leak and to
Willy Tarreauced27012008-01-17 20:35:34 +01006337 block the response before it reaches the client. If a response is denied, it
6338 will be replaced with an HTTP 502 error so that the client never retrieves
6339 any sensitive data.
Willy Tarreau303c0352008-01-17 19:01:39 +01006340
6341 It is easier, faster and more powerful to use ACLs to write access policies.
6342 Rspdeny should be avoided in new designs.
6343
6344 Example :
6345 # Ensure that no content type matching ms-word will leak
6346 rspideny ^Content-type:\.*/ms-word
6347
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006348 See also: "reqdeny", "acl", "block", section 6 about HTTP header manipulation
6349 and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006350
6351
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006352rsprep <search> <string> [{if | unless} <cond>]
6353rspirep <search> <string> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006354 Replace a regular expression with a string in an HTTP response line
6355 May be used in sections : defaults | frontend | listen | backend
6356 no | yes | yes | yes
6357 Arguments :
6358 <search> is the regular expression applied to HTTP headers and to the
6359 response line. This is an extended regular expression, so
6360 parenthesis grouping is supported and no preliminary backslash
6361 is required. Any space or known delimiter must be escaped using
6362 a backslash ('\'). The pattern applies to a full line at a time.
6363 The "rsprep" keyword strictly matches case while "rspirep"
6364 ignores case.
6365
6366 <string> is the complete line to be added. Any space or known delimiter
6367 must be escaped using a backslash ('\'). References to matched
6368 pattern groups are possible using the common \N form, with N
6369 being a single digit between 0 and 9. Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006370 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006371
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006372 <cond> is an optional matching condition built from ACLs. It makes it
6373 possible to ignore this rule when other conditions are not met.
6374
Willy Tarreau303c0352008-01-17 19:01:39 +01006375 Any line matching extended regular expression <search> in the response (both
6376 the response line and header lines) will be completely replaced with
6377 <string>. Most common use of this is to rewrite Location headers.
6378
6379 Header transformations only apply to traffic which passes through HAProxy,
6380 and not to traffic generated by HAProxy, such as health-checks or error
6381 responses. Note that for increased readability, it is suggested to add enough
6382 spaces between the request and the response. Keep in mind that header names
6383 are not case-sensitive.
6384
6385 Example :
6386 # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com"
6387 rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com
6388
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006389 See also: "rspadd", "rspdel", "reqrep", section 6 about HTTP header
6390 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006391
6392
David du Colombier486df472011-03-17 10:40:26 +01006393server <name> <address>[:[port]] [param*]
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006394 Declare a server in a backend
6395 May be used in sections : defaults | frontend | listen | backend
6396 no | no | yes | yes
6397 Arguments :
6398 <name> is the internal name assigned to this server. This name will
Cyril Bonté941a0c62012-10-15 19:44:24 +02006399 appear in logs and alerts. If "http-send-name-header" is
Mark Lamourinec2247f02012-01-04 13:02:01 -05006400 set, it will be added to the request header sent to the server.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006401
David du Colombier486df472011-03-17 10:40:26 +01006402 <address> is the IPv4 or IPv6 address of the server. Alternatively, a
6403 resolvable hostname is supported, but this name will be resolved
6404 during start-up. Address "0.0.0.0" or "*" has a special meaning.
6405 It indicates that the connection will be forwarded to the same IP
Willy Tarreaud669a4f2010-07-13 14:49:50 +02006406 address as the one from the client connection. This is useful in
6407 transparent proxy architectures where the client's connection is
6408 intercepted and haproxy must forward to the original destination
6409 address. This is more or less what the "transparent" keyword does
6410 except that with a server it's possible to limit concurrency and
Willy Tarreau24709282013-03-10 21:32:12 +01006411 to report statistics. Optionally, an address family prefix may be
6412 used before the address to force the family regardless of the
6413 address format, which can be useful to specify a path to a unix
6414 socket with no slash ('/'). Currently supported prefixes are :
6415 - 'ipv4@' -> address is always IPv4
6416 - 'ipv6@' -> address is always IPv6
6417 - 'unix@' -> address is a path to a local unix socket
Willy Tarreauccfccef2014-05-10 01:49:15 +02006418 - 'abns@' -> address is in abstract namespace (Linux only)
Willy Tarreaudad36a32013-03-11 01:20:04 +01006419 Any part of the address string may reference any number of
6420 environment variables by preceding their name with a dollar
6421 sign ('$') and optionally enclosing them with braces ('{}'),
6422 similarly to what is done in Bourne shell.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006423
Willy Tarreaub6205fd2012-09-24 12:27:33 +02006424 <port> is an optional port specification. If set, all connections will
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006425 be sent to this port. If unset, the same port the client
6426 connected to will be used. The port may also be prefixed by a "+"
6427 or a "-". In this case, the server's port will be determined by
6428 adding this value to the client's port.
6429
6430 <param*> is a list of parameters for this server. The "server" keywords
6431 accepts an important number of options and has a complete section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006432 dedicated to it. Please refer to section 5 for more details.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006433
6434 Examples :
6435 server first 10.1.1.1:1080 cookie first check inter 1000
6436 server second 10.1.1.2:1080 cookie second check inter 1000
Willy Tarreau24709282013-03-10 21:32:12 +01006437 server transp ipv4@
Willy Tarreaudad36a32013-03-11 01:20:04 +01006438 server backup ${SRV_BACKUP}:1080 backup
6439 server www1_dc1 ${LAN_DC1}.101:80
6440 server www1_dc2 ${LAN_DC2}.101:80
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006441
Mark Lamourinec2247f02012-01-04 13:02:01 -05006442 See also: "default-server", "http-send-name-header" and section 5 about
6443 server options
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006444
6445
6446source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
Willy Tarreaubce70882009-09-07 11:51:47 +02006447source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | hdr_ip(<hdr>[,<occ>]) } ]
Willy Tarreaud53f96b2009-02-04 18:46:54 +01006448source <addr>[:<port>] [interface <name>]
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006449 Set the source address for outgoing connections
6450 May be used in sections : defaults | frontend | listen | backend
6451 yes | no | yes | yes
6452 Arguments :
6453 <addr> is the IPv4 address HAProxy will bind to before connecting to a
6454 server. This address is also used as a source for health checks.
Willy Tarreau24709282013-03-10 21:32:12 +01006455
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006456 The default value of 0.0.0.0 means that the system will select
Willy Tarreau24709282013-03-10 21:32:12 +01006457 the most appropriate address to reach its destination. Optionally
6458 an address family prefix may be used before the address to force
6459 the family regardless of the address format, which can be useful
6460 to specify a path to a unix socket with no slash ('/'). Currently
6461 supported prefixes are :
6462 - 'ipv4@' -> address is always IPv4
6463 - 'ipv6@' -> address is always IPv6
6464 - 'unix@' -> address is a path to a local unix socket
Willy Tarreauccfccef2014-05-10 01:49:15 +02006465 - 'abns@' -> address is in abstract namespace (Linux only)
Willy Tarreaudad36a32013-03-11 01:20:04 +01006466 Any part of the address string may reference any number of
6467 environment variables by preceding their name with a dollar
6468 sign ('$') and optionally enclosing them with braces ('{}'),
6469 similarly to what is done in Bourne shell.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006470
6471 <port> is an optional port. It is normally not needed but may be useful
6472 in some very specific contexts. The default value of zero means
Willy Tarreauc6f4ce82009-06-10 11:09:37 +02006473 the system will select a free port. Note that port ranges are not
6474 supported in the backend. If you want to force port ranges, you
6475 have to specify them on each "server" line.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006476
6477 <addr2> is the IP address to present to the server when connections are
6478 forwarded in full transparent proxy mode. This is currently only
6479 supported on some patched Linux kernels. When this address is
6480 specified, clients connecting to the server will be presented
6481 with this address, while health checks will still use the address
6482 <addr>.
6483
6484 <port2> is the optional port to present to the server when connections
6485 are forwarded in full transparent proxy mode (see <addr2> above).
6486 The default value of zero means the system will select a free
6487 port.
6488
Willy Tarreaubce70882009-09-07 11:51:47 +02006489 <hdr> is the name of a HTTP header in which to fetch the IP to bind to.
6490 This is the name of a comma-separated header list which can
6491 contain multiple IP addresses. By default, the last occurrence is
6492 used. This is designed to work with the X-Forwarded-For header
Baptiste Assmannea3e73b2013-02-02 23:47:49 +01006493 and to automatically bind to the client's IP address as seen
Willy Tarreaubce70882009-09-07 11:51:47 +02006494 by previous proxy, typically Stunnel. In order to use another
6495 occurrence from the last one, please see the <occ> parameter
6496 below. When the header (or occurrence) is not found, no binding
6497 is performed so that the proxy's default IP address is used. Also
6498 keep in mind that the header name is case insensitive, as for any
6499 HTTP header.
6500
6501 <occ> is the occurrence number of a value to be used in a multi-value
6502 header. This is to be used in conjunction with "hdr_ip(<hdr>)",
Jamie Gloudonaaa21002012-08-25 00:18:33 -04006503 in order to specify which occurrence to use for the source IP
Willy Tarreaubce70882009-09-07 11:51:47 +02006504 address. Positive values indicate a position from the first
6505 occurrence, 1 being the first one. Negative values indicate
6506 positions relative to the last one, -1 being the last one. This
6507 is helpful for situations where an X-Forwarded-For header is set
6508 at the entry point of an infrastructure and must be used several
6509 proxy layers away. When this value is not specified, -1 is
6510 assumed. Passing a zero here disables the feature.
6511
Willy Tarreaud53f96b2009-02-04 18:46:54 +01006512 <name> is an optional interface name to which to bind to for outgoing
6513 traffic. On systems supporting this features (currently, only
6514 Linux), this allows one to bind all traffic to the server to
6515 this interface even if it is not the one the system would select
6516 based on routing tables. This should be used with extreme care.
6517 Note that using this option requires root privileges.
6518
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006519 The "source" keyword is useful in complex environments where a specific
6520 address only is allowed to connect to the servers. It may be needed when a
6521 private address must be used through a public gateway for instance, and it is
6522 known that the system cannot determine the adequate source address by itself.
6523
6524 An extension which is available on certain patched Linux kernels may be used
6525 through the "usesrc" optional keyword. It makes it possible to connect to the
6526 servers with an IP address which does not belong to the system itself. This
6527 is called "full transparent proxy mode". For this to work, the destination
6528 servers have to route their traffic back to this address through the machine
6529 running HAProxy, and IP forwarding must generally be enabled on this machine.
6530
6531 In this "full transparent proxy" mode, it is possible to force a specific IP
6532 address to be presented to the servers. This is not much used in fact. A more
6533 common use is to tell HAProxy to present the client's IP address. For this,
6534 there are two methods :
6535
6536 - present the client's IP and port addresses. This is the most transparent
6537 mode, but it can cause problems when IP connection tracking is enabled on
6538 the machine, because a same connection may be seen twice with different
6539 states. However, this solution presents the huge advantage of not
6540 limiting the system to the 64k outgoing address+port couples, because all
6541 of the client ranges may be used.
6542
6543 - present only the client's IP address and select a spare port. This
6544 solution is still quite elegant but slightly less transparent (downstream
6545 firewalls logs will not match upstream's). It also presents the downside
6546 of limiting the number of concurrent connections to the usual 64k ports.
6547 However, since the upstream and downstream ports are different, local IP
6548 connection tracking on the machine will not be upset by the reuse of the
6549 same session.
6550
6551 Note that depending on the transparent proxy technology used, it may be
6552 required to force the source address. In fact, cttproxy version 2 requires an
6553 IP address in <addr> above, and does not support setting of "0.0.0.0" as the
6554 IP address because it creates NAT entries which much match the exact outgoing
6555 address. Tproxy version 4 and some other kernel patches which work in pure
6556 forwarding mode generally will not have this limitation.
6557
6558 This option sets the default source for all servers in the backend. It may
6559 also be specified in a "defaults" section. Finer source address specification
6560 is possible at the server level using the "source" server option. Refer to
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006561 section 5 for more information.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006562
6563 Examples :
6564 backend private
6565 # Connect to the servers using our 192.168.1.200 source address
6566 source 192.168.1.200
6567
6568 backend transparent_ssl1
6569 # Connect to the SSL farm from the client's source address
6570 source 192.168.1.200 usesrc clientip
6571
6572 backend transparent_ssl2
6573 # Connect to the SSL farm from the client's source address and port
6574 # not recommended if IP conntrack is present on the local machine.
6575 source 192.168.1.200 usesrc client
6576
6577 backend transparent_ssl3
6578 # Connect to the SSL farm from the client's source address. It
6579 # is more conntrack-friendly.
6580 source 192.168.1.200 usesrc clientip
6581
6582 backend transparent_smtp
6583 # Connect to the SMTP farm from the client's source address/port
6584 # with Tproxy version 4.
6585 source 0.0.0.0 usesrc clientip
6586
Willy Tarreaubce70882009-09-07 11:51:47 +02006587 backend transparent_http
6588 # Connect to the servers using the client's IP as seen by previous
6589 # proxy.
6590 source 0.0.0.0 usesrc hdr_ip(x-forwarded-for,-1)
6591
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006592 See also : the "source" server option in section 5, the Tproxy patches for
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006593 the Linux kernel on www.balabit.com, the "bind" keyword.
6594
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01006595
Willy Tarreau844e3c52008-01-11 16:28:18 +01006596srvtimeout <timeout> (deprecated)
6597 Set the maximum inactivity time on the server side.
6598 May be used in sections : defaults | frontend | listen | backend
6599 yes | no | yes | yes
6600 Arguments :
6601 <timeout> is the timeout value specified in milliseconds by default, but
6602 can be in any other unit if the number is suffixed by the unit,
6603 as explained at the top of this document.
6604
6605 The inactivity timeout applies when the server is expected to acknowledge or
6606 send data. In HTTP mode, this timeout is particularly important to consider
6607 during the first phase of the server's response, when it has to send the
6608 headers, as it directly represents the server's processing time for the
6609 request. To find out what value to put there, it's often good to start with
6610 what would be considered as unacceptable response times, then check the logs
6611 to observe the response time distribution, and adjust the value accordingly.
6612
6613 The value is specified in milliseconds by default, but can be in any other
6614 unit if the number is suffixed by the unit, as specified at the top of this
6615 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
6616 recommended that the client timeout remains equal to the server timeout in
6617 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01006618 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01006619 packet losses by specifying timeouts that are slightly above multiples of 3
Willy Tarreaud72758d2010-01-12 10:42:19 +01006620 seconds (eg: 4 or 5 seconds minimum).
Willy Tarreau844e3c52008-01-11 16:28:18 +01006621
6622 This parameter is specific to backends, but can be specified once for all in
6623 "defaults" sections. This is in fact one of the easiest solutions not to
6624 forget about it. An unspecified timeout results in an infinite timeout, which
6625 is not recommended. Such a usage is accepted and works but reports a warning
6626 during startup because it may results in accumulation of expired sessions in
6627 the system if the system's timeouts are not configured either.
6628
6629 This parameter is provided for compatibility but is currently deprecated.
6630 Please use "timeout server" instead.
6631
Willy Tarreauce887fd2012-05-12 12:50:00 +02006632 See also : "timeout server", "timeout tunnel", "timeout client" and
6633 "clitimeout".
Willy Tarreau844e3c52008-01-11 16:28:18 +01006634
6635
Cyril Bonté66c327d2010-10-12 00:14:37 +02006636stats admin { if | unless } <cond>
6637 Enable statistics admin level if/unless a condition is matched
6638 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006639 no | yes | yes | yes
Cyril Bonté66c327d2010-10-12 00:14:37 +02006640
6641 This statement enables the statistics admin level if/unless a condition is
6642 matched.
6643
6644 The admin level allows to enable/disable servers from the web interface. By
6645 default, statistics page is read-only for security reasons.
6646
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01006647 Note : Consider not using this feature in multi-process mode (nbproc > 1)
6648 unless you know what you do : memory is not shared between the
6649 processes, which can result in random behaviours.
6650
Cyril Bonté23b39d92011-02-10 22:54:44 +01006651 Currently, the POST request is limited to the buffer size minus the reserved
6652 buffer space, which means that if the list of servers is too long, the
6653 request won't be processed. It is recommended to alter few servers at a
6654 time.
Cyril Bonté66c327d2010-10-12 00:14:37 +02006655
6656 Example :
6657 # statistics admin level only for localhost
6658 backend stats_localhost
6659 stats enable
6660 stats admin if LOCALHOST
6661
6662 Example :
6663 # statistics admin level always enabled because of the authentication
6664 backend stats_auth
6665 stats enable
6666 stats auth admin:AdMiN123
6667 stats admin if TRUE
6668
6669 Example :
6670 # statistics admin level depends on the authenticated user
6671 userlist stats-auth
6672 group admin users admin
6673 user admin insecure-password AdMiN123
6674 group readonly users haproxy
6675 user haproxy insecure-password haproxy
6676
6677 backend stats_auth
6678 stats enable
6679 acl AUTH http_auth(stats-auth)
6680 acl AUTH_ADMIN http_auth_group(stats-auth) admin
6681 stats http-request auth unless AUTH
6682 stats admin if AUTH_ADMIN
6683
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01006684 See also : "stats enable", "stats auth", "stats http-request", "nbproc",
6685 "bind-process", section 3.4 about userlists and section 7 about
6686 ACL usage.
Cyril Bonté66c327d2010-10-12 00:14:37 +02006687
6688
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006689stats auth <user>:<passwd>
6690 Enable statistics with authentication and grant access to an account
6691 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006692 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006693 Arguments :
6694 <user> is a user name to grant access to
6695
6696 <passwd> is the cleartext password associated to this user
6697
6698 This statement enables statistics with default settings, and restricts access
6699 to declared users only. It may be repeated as many times as necessary to
6700 allow as many users as desired. When a user tries to access the statistics
6701 without a valid account, a "401 Forbidden" response will be returned so that
6702 the browser asks the user to provide a valid user and password. The real
6703 which will be returned to the browser is configurable using "stats realm".
6704
6705 Since the authentication method is HTTP Basic Authentication, the passwords
6706 circulate in cleartext on the network. Thus, it was decided that the
6707 configuration file would also use cleartext passwords to remind the users
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02006708 that those ones should not be sensitive and not shared with any other account.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006709
6710 It is also possible to reduce the scope of the proxies which appear in the
6711 report using "stats scope".
6712
6713 Though this statement alone is enough to enable statistics reporting, it is
6714 recommended to set all other settings in order to avoid relying on default
6715 unobvious parameters.
6716
6717 Example :
6718 # public access (limited to this backend only)
6719 backend public_www
6720 server srv1 192.168.0.1:80
6721 stats enable
6722 stats hide-version
6723 stats scope .
6724 stats uri /admin?stats
6725 stats realm Haproxy\ Statistics
6726 stats auth admin1:AdMiN123
6727 stats auth admin2:AdMiN321
6728
6729 # internal monitoring access (unlimited)
6730 backend private_monitoring
6731 stats enable
6732 stats uri /admin?stats
6733 stats refresh 5s
6734
6735 See also : "stats enable", "stats realm", "stats scope", "stats uri"
6736
6737
6738stats enable
6739 Enable statistics reporting with default settings
6740 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006741 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006742 Arguments : none
6743
6744 This statement enables statistics reporting with default settings defined
6745 at build time. Unless stated otherwise, these settings are used :
6746 - stats uri : /haproxy?stats
6747 - stats realm : "HAProxy Statistics"
6748 - stats auth : no authentication
6749 - stats scope : no restriction
6750
6751 Though this statement alone is enough to enable statistics reporting, it is
6752 recommended to set all other settings in order to avoid relying on default
6753 unobvious parameters.
6754
6755 Example :
6756 # public access (limited to this backend only)
6757 backend public_www
6758 server srv1 192.168.0.1:80
6759 stats enable
6760 stats hide-version
6761 stats scope .
6762 stats uri /admin?stats
6763 stats realm Haproxy\ Statistics
6764 stats auth admin1:AdMiN123
6765 stats auth admin2:AdMiN321
6766
6767 # internal monitoring access (unlimited)
6768 backend private_monitoring
6769 stats enable
6770 stats uri /admin?stats
6771 stats refresh 5s
6772
6773 See also : "stats auth", "stats realm", "stats uri"
6774
6775
Willy Tarreaud63335a2010-02-26 12:56:52 +01006776stats hide-version
6777 Enable statistics and hide HAProxy version reporting
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02006778 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006779 yes | yes | yes | yes
Willy Tarreaud63335a2010-02-26 12:56:52 +01006780 Arguments : none
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02006781
Willy Tarreaud63335a2010-02-26 12:56:52 +01006782 By default, the stats page reports some useful status information along with
6783 the statistics. Among them is HAProxy's version. However, it is generally
6784 considered dangerous to report precise version to anyone, as it can help them
6785 target known weaknesses with specific attacks. The "stats hide-version"
6786 statement removes the version from the statistics report. This is recommended
6787 for public sites or any site with a weak login/password.
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02006788
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +02006789 Though this statement alone is enough to enable statistics reporting, it is
6790 recommended to set all other settings in order to avoid relying on default
6791 unobvious parameters.
6792
Willy Tarreaud63335a2010-02-26 12:56:52 +01006793 Example :
6794 # public access (limited to this backend only)
6795 backend public_www
6796 server srv1 192.168.0.1:80
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +02006797 stats enable
Willy Tarreaud63335a2010-02-26 12:56:52 +01006798 stats hide-version
6799 stats scope .
6800 stats uri /admin?stats
6801 stats realm Haproxy\ Statistics
6802 stats auth admin1:AdMiN123
6803 stats auth admin2:AdMiN321
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02006804
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02006805 # internal monitoring access (unlimited)
6806 backend private_monitoring
6807 stats enable
Willy Tarreaud63335a2010-02-26 12:56:52 +01006808 stats uri /admin?stats
6809 stats refresh 5s
Krzysztof Piotr Oledzki15514c22010-01-04 16:03:09 +01006810
Willy Tarreaud63335a2010-02-26 12:56:52 +01006811 See also : "stats auth", "stats enable", "stats realm", "stats uri"
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02006812
Willy Tarreau983e01e2010-01-11 18:42:06 +01006813
Cyril Bonté2be1b3f2010-09-30 23:46:30 +02006814stats http-request { allow | deny | auth [realm <realm>] }
6815 [ { if | unless } <condition> ]
6816 Access control for statistics
6817
6818 May be used in sections: defaults | frontend | listen | backend
6819 no | no | yes | yes
6820
6821 As "http-request", these set of options allow to fine control access to
6822 statistics. Each option may be followed by if/unless and acl.
6823 First option with matched condition (or option without condition) is final.
6824 For "deny" a 403 error will be returned, for "allow" normal processing is
6825 performed, for "auth" a 401/407 error code is returned so the client
6826 should be asked to enter a username and password.
6827
6828 There is no fixed limit to the number of http-request statements per
6829 instance.
6830
6831 See also : "http-request", section 3.4 about userlists and section 7
6832 about ACL usage.
6833
6834
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006835stats realm <realm>
6836 Enable statistics and set authentication realm
6837 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006838 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006839 Arguments :
6840 <realm> is the name of the HTTP Basic Authentication realm reported to
6841 the browser. The browser uses it to display it in the pop-up
6842 inviting the user to enter a valid username and password.
6843
6844 The realm is read as a single word, so any spaces in it should be escaped
6845 using a backslash ('\').
6846
6847 This statement is useful only in conjunction with "stats auth" since it is
6848 only related to authentication.
6849
6850 Though this statement alone is enough to enable statistics reporting, it is
6851 recommended to set all other settings in order to avoid relying on default
6852 unobvious parameters.
6853
6854 Example :
6855 # public access (limited to this backend only)
6856 backend public_www
6857 server srv1 192.168.0.1:80
6858 stats enable
6859 stats hide-version
6860 stats scope .
6861 stats uri /admin?stats
6862 stats realm Haproxy\ Statistics
6863 stats auth admin1:AdMiN123
6864 stats auth admin2:AdMiN321
6865
6866 # internal monitoring access (unlimited)
6867 backend private_monitoring
6868 stats enable
6869 stats uri /admin?stats
6870 stats refresh 5s
6871
6872 See also : "stats auth", "stats enable", "stats uri"
6873
6874
6875stats refresh <delay>
6876 Enable statistics with automatic refresh
6877 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006878 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006879 Arguments :
6880 <delay> is the suggested refresh delay, specified in seconds, which will
6881 be returned to the browser consulting the report page. While the
6882 browser is free to apply any delay, it will generally respect it
6883 and refresh the page this every seconds. The refresh interval may
6884 be specified in any other non-default time unit, by suffixing the
6885 unit after the value, as explained at the top of this document.
6886
6887 This statement is useful on monitoring displays with a permanent page
6888 reporting the load balancer's activity. When set, the HTML report page will
6889 include a link "refresh"/"stop refresh" so that the user can select whether
6890 he wants automatic refresh of the page or not.
6891
6892 Though this statement alone is enough to enable statistics reporting, it is
6893 recommended to set all other settings in order to avoid relying on default
6894 unobvious parameters.
6895
6896 Example :
6897 # public access (limited to this backend only)
6898 backend public_www
6899 server srv1 192.168.0.1:80
6900 stats enable
6901 stats hide-version
6902 stats scope .
6903 stats uri /admin?stats
6904 stats realm Haproxy\ Statistics
6905 stats auth admin1:AdMiN123
6906 stats auth admin2:AdMiN321
6907
6908 # internal monitoring access (unlimited)
6909 backend private_monitoring
6910 stats enable
6911 stats uri /admin?stats
6912 stats refresh 5s
6913
6914 See also : "stats auth", "stats enable", "stats realm", "stats uri"
6915
6916
6917stats scope { <name> | "." }
6918 Enable statistics and limit access scope
6919 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006920 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006921 Arguments :
6922 <name> is the name of a listen, frontend or backend section to be
6923 reported. The special name "." (a single dot) designates the
6924 section in which the statement appears.
6925
6926 When this statement is specified, only the sections enumerated with this
6927 statement will appear in the report. All other ones will be hidden. This
6928 statement may appear as many times as needed if multiple sections need to be
6929 reported. Please note that the name checking is performed as simple string
6930 comparisons, and that it is never checked that a give section name really
6931 exists.
6932
6933 Though this statement alone is enough to enable statistics reporting, it is
6934 recommended to set all other settings in order to avoid relying on default
6935 unobvious parameters.
6936
6937 Example :
6938 # public access (limited to this backend only)
6939 backend public_www
6940 server srv1 192.168.0.1:80
6941 stats enable
6942 stats hide-version
6943 stats scope .
6944 stats uri /admin?stats
6945 stats realm Haproxy\ Statistics
6946 stats auth admin1:AdMiN123
6947 stats auth admin2:AdMiN321
6948
6949 # internal monitoring access (unlimited)
6950 backend private_monitoring
6951 stats enable
6952 stats uri /admin?stats
6953 stats refresh 5s
6954
6955 See also : "stats auth", "stats enable", "stats realm", "stats uri"
6956
Willy Tarreaud63335a2010-02-26 12:56:52 +01006957
Willy Tarreauc9705a12010-07-27 20:05:50 +02006958stats show-desc [ <desc> ]
Willy Tarreaud63335a2010-02-26 12:56:52 +01006959 Enable reporting of a description on the statistics page.
6960 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02006961 yes | yes | yes | yes
Willy Tarreaud63335a2010-02-26 12:56:52 +01006962
Willy Tarreauc9705a12010-07-27 20:05:50 +02006963 <desc> is an optional description to be reported. If unspecified, the
Willy Tarreaud63335a2010-02-26 12:56:52 +01006964 description from global section is automatically used instead.
6965
6966 This statement is useful for users that offer shared services to their
6967 customers, where node or description should be different for each customer.
6968
6969 Though this statement alone is enough to enable statistics reporting, it is
6970 recommended to set all other settings in order to avoid relying on default
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04006971 unobvious parameters. By default description is not shown.
Willy Tarreaud63335a2010-02-26 12:56:52 +01006972
6973 Example :
6974 # internal monitoring access (unlimited)
6975 backend private_monitoring
6976 stats enable
6977 stats show-desc Master node for Europe, Asia, Africa
6978 stats uri /admin?stats
6979 stats refresh 5s
6980
6981 See also: "show-node", "stats enable", "stats uri" and "description" in
6982 global section.
6983
6984
6985stats show-legends
Willy Tarreaued2119c2014-04-24 22:10:39 +02006986 Enable reporting additional information on the statistics page
6987 May be used in sections : defaults | frontend | listen | backend
6988 yes | yes | yes | yes
6989 Arguments : none
6990
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03006991 Enable reporting additional information on the statistics page :
Willy Tarreaud63335a2010-02-26 12:56:52 +01006992 - cap: capabilities (proxy)
6993 - mode: one of tcp, http or health (proxy)
6994 - id: SNMP ID (proxy, socket, server)
6995 - IP (socket, server)
6996 - cookie (backend, server)
6997
6998 Though this statement alone is enough to enable statistics reporting, it is
6999 recommended to set all other settings in order to avoid relying on default
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04007000 unobvious parameters. Default behaviour is not to show this information.
Willy Tarreaud63335a2010-02-26 12:56:52 +01007001
7002 See also: "stats enable", "stats uri".
7003
7004
7005stats show-node [ <name> ]
7006 Enable reporting of a host name on the statistics page.
7007 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007008 yes | yes | yes | yes
Willy Tarreaud63335a2010-02-26 12:56:52 +01007009 Arguments:
7010 <name> is an optional name to be reported. If unspecified, the
7011 node name from global section is automatically used instead.
7012
7013 This statement is useful for users that offer shared services to their
7014 customers, where node or description might be different on a stats page
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04007015 provided for each customer. Default behaviour is not to show host name.
Willy Tarreaud63335a2010-02-26 12:56:52 +01007016
7017 Though this statement alone is enough to enable statistics reporting, it is
7018 recommended to set all other settings in order to avoid relying on default
7019 unobvious parameters.
7020
7021 Example:
7022 # internal monitoring access (unlimited)
7023 backend private_monitoring
7024 stats enable
7025 stats show-node Europe-1
7026 stats uri /admin?stats
7027 stats refresh 5s
7028
7029 See also: "show-desc", "stats enable", "stats uri", and "node" in global
7030 section.
7031
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007032
7033stats uri <prefix>
7034 Enable statistics and define the URI prefix to access them
7035 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007036 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007037 Arguments :
7038 <prefix> is the prefix of any URI which will be redirected to stats. This
7039 prefix may contain a question mark ('?') to indicate part of a
7040 query string.
7041
7042 The statistics URI is intercepted on the relayed traffic, so it appears as a
7043 page within the normal application. It is strongly advised to ensure that the
7044 selected URI will never appear in the application, otherwise it will never be
7045 possible to reach it in the application.
7046
7047 The default URI compiled in haproxy is "/haproxy?stats", but this may be
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01007048 changed at build time, so it's better to always explicitly specify it here.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007049 It is generally a good idea to include a question mark in the URI so that
7050 intermediate proxies refrain from caching the results. Also, since any string
7051 beginning with the prefix will be accepted as a stats request, the question
7052 mark helps ensuring that no valid URI will begin with the same words.
7053
7054 It is sometimes very convenient to use "/" as the URI prefix, and put that
7055 statement in a "listen" instance of its own. That makes it easy to dedicate
7056 an address or a port to statistics only.
7057
7058 Though this statement alone is enough to enable statistics reporting, it is
7059 recommended to set all other settings in order to avoid relying on default
7060 unobvious parameters.
7061
7062 Example :
7063 # public access (limited to this backend only)
7064 backend public_www
7065 server srv1 192.168.0.1:80
7066 stats enable
7067 stats hide-version
7068 stats scope .
7069 stats uri /admin?stats
7070 stats realm Haproxy\ Statistics
7071 stats auth admin1:AdMiN123
7072 stats auth admin2:AdMiN321
7073
7074 # internal monitoring access (unlimited)
7075 backend private_monitoring
7076 stats enable
7077 stats uri /admin?stats
7078 stats refresh 5s
7079
7080 See also : "stats auth", "stats enable", "stats realm"
7081
7082
Willy Tarreaud63335a2010-02-26 12:56:52 +01007083stick match <pattern> [table <table>] [{if | unless} <cond>]
7084 Define a request pattern matching condition to stick a user to a server
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007085 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaud63335a2010-02-26 12:56:52 +01007086 no | no | yes | yes
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007087
7088 Arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007089 <pattern> is a sample expression rule as described in section 7.3. It
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007090 describes what elements of the incoming request or connection
7091 will be analysed in the hope to find a matching entry in a
7092 stickiness table. This rule is mandatory.
7093
7094 <table> is an optional stickiness table name. If unspecified, the same
7095 backend's table is used. A stickiness table is declared using
7096 the "stick-table" statement.
7097
7098 <cond> is an optional matching condition. It makes it possible to match
7099 on a certain criterion only when other conditions are met (or
7100 not met). For instance, it could be used to match on a source IP
7101 address except when a request passes through a known proxy, in
7102 which case we'd match on a header containing that IP address.
7103
7104 Some protocols or applications require complex stickiness rules and cannot
7105 always simply rely on cookies nor hashing. The "stick match" statement
7106 describes a rule to extract the stickiness criterion from an incoming request
7107 or connection. See section 7 for a complete list of possible patterns and
7108 transformation rules.
7109
7110 The table has to be declared using the "stick-table" statement. It must be of
7111 a type compatible with the pattern. By default it is the one which is present
7112 in the same backend. It is possible to share a table with other backends by
7113 referencing it using the "table" keyword. If another table is referenced,
7114 the server's ID inside the backends are used. By default, all server IDs
7115 start at 1 in each backend, so the server ordering is enough. But in case of
7116 doubt, it is highly recommended to force server IDs using their "id" setting.
7117
7118 It is possible to restrict the conditions where a "stick match" statement
7119 will apply, using "if" or "unless" followed by a condition. See section 7 for
7120 ACL based conditions.
7121
7122 There is no limit on the number of "stick match" statements. The first that
7123 applies and matches will cause the request to be directed to the same server
7124 as was used for the request which created the entry. That way, multiple
7125 matches can be used as fallbacks.
7126
7127 The stick rules are checked after the persistence cookies, so they will not
7128 affect stickiness if a cookie has already been used to select a server. That
7129 way, it becomes very easy to insert cookies and match on IP addresses in
7130 order to maintain stickiness between HTTP and HTTPS.
7131
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007132 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7133 unless you know what you do : memory is not shared between the
7134 processes, which can result in random behaviours.
7135
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007136 Example :
7137 # forward SMTP users to the same server they just used for POP in the
7138 # last 30 minutes
7139 backend pop
7140 mode tcp
7141 balance roundrobin
7142 stick store-request src
7143 stick-table type ip size 200k expire 30m
7144 server s1 192.168.1.1:110
7145 server s2 192.168.1.1:110
7146
7147 backend smtp
7148 mode tcp
7149 balance roundrobin
7150 stick match src table pop
7151 server s1 192.168.1.1:25
7152 server s2 192.168.1.1:25
7153
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007154 See also : "stick-table", "stick on", "nbproc", "bind-process" and section 7
Willy Tarreaube722a22014-06-13 16:31:59 +02007155 about ACLs and samples fetching.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007156
7157
7158stick on <pattern> [table <table>] [{if | unless} <condition>]
7159 Define a request pattern to associate a user to a server
7160 May be used in sections : defaults | frontend | listen | backend
7161 no | no | yes | yes
7162
7163 Note : This form is exactly equivalent to "stick match" followed by
7164 "stick store-request", all with the same arguments. Please refer
7165 to both keywords for details. It is only provided as a convenience
7166 for writing more maintainable configurations.
7167
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007168 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7169 unless you know what you do : memory is not shared between the
7170 processes, which can result in random behaviours.
7171
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007172 Examples :
7173 # The following form ...
Willy Tarreauec579d82010-02-26 19:15:04 +01007174 stick on src table pop if !localhost
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007175
7176 # ...is strictly equivalent to this one :
7177 stick match src table pop if !localhost
7178 stick store-request src table pop if !localhost
7179
7180
7181 # Use cookie persistence for HTTP, and stick on source address for HTTPS as
7182 # well as HTTP without cookie. Share the same table between both accesses.
7183 backend http
7184 mode http
7185 balance roundrobin
7186 stick on src table https
7187 cookie SRV insert indirect nocache
7188 server s1 192.168.1.1:80 cookie s1
7189 server s2 192.168.1.1:80 cookie s2
7190
7191 backend https
7192 mode tcp
7193 balance roundrobin
7194 stick-table type ip size 200k expire 30m
7195 stick on src
7196 server s1 192.168.1.1:443
7197 server s2 192.168.1.1:443
7198
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007199 See also : "stick match", "stick store-request", "nbproc" and "bind-process".
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007200
7201
7202stick store-request <pattern> [table <table>] [{if | unless} <condition>]
7203 Define a request pattern used to create an entry in a stickiness table
7204 May be used in sections : defaults | frontend | listen | backend
7205 no | no | yes | yes
7206
7207 Arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007208 <pattern> is a sample expression rule as described in section 7.3. It
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007209 describes what elements of the incoming request or connection
7210 will be analysed, extracted and stored in the table once a
7211 server is selected.
7212
7213 <table> is an optional stickiness table name. If unspecified, the same
7214 backend's table is used. A stickiness table is declared using
7215 the "stick-table" statement.
7216
7217 <cond> is an optional storage condition. It makes it possible to store
7218 certain criteria only when some conditions are met (or not met).
7219 For instance, it could be used to store the source IP address
7220 except when the request passes through a known proxy, in which
7221 case we'd store a converted form of a header containing that IP
7222 address.
7223
7224 Some protocols or applications require complex stickiness rules and cannot
7225 always simply rely on cookies nor hashing. The "stick store-request" statement
7226 describes a rule to decide what to extract from the request and when to do
7227 it, in order to store it into a stickiness table for further requests to
7228 match it using the "stick match" statement. Obviously the extracted part must
7229 make sense and have a chance to be matched in a further request. Storing a
7230 client's IP address for instance often makes sense. Storing an ID found in a
7231 URL parameter also makes sense. Storing a source port will almost never make
7232 any sense because it will be randomly matched. See section 7 for a complete
7233 list of possible patterns and transformation rules.
7234
7235 The table has to be declared using the "stick-table" statement. It must be of
7236 a type compatible with the pattern. By default it is the one which is present
7237 in the same backend. It is possible to share a table with other backends by
7238 referencing it using the "table" keyword. If another table is referenced,
7239 the server's ID inside the backends are used. By default, all server IDs
7240 start at 1 in each backend, so the server ordering is enough. But in case of
7241 doubt, it is highly recommended to force server IDs using their "id" setting.
7242
7243 It is possible to restrict the conditions where a "stick store-request"
7244 statement will apply, using "if" or "unless" followed by a condition. This
7245 condition will be evaluated while parsing the request, so any criteria can be
7246 used. See section 7 for ACL based conditions.
7247
7248 There is no limit on the number of "stick store-request" statements, but
7249 there is a limit of 8 simultaneous stores per request or response. This
7250 makes it possible to store up to 8 criteria, all extracted from either the
7251 request or the response, regardless of the number of rules. Only the 8 first
7252 ones which match will be kept. Using this, it is possible to feed multiple
7253 tables at once in the hope to increase the chance to recognize a user on
Willy Tarreau9667a802013-12-09 12:52:13 +01007254 another protocol or access method. Using multiple store-request rules with
7255 the same table is possible and may be used to find the best criterion to rely
7256 on, by arranging the rules by decreasing preference order. Only the first
7257 extracted criterion for a given table will be stored. All subsequent store-
7258 request rules referencing the same table will be skipped and their ACLs will
7259 not be evaluated.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007260
7261 The "store-request" rules are evaluated once the server connection has been
7262 established, so that the table will contain the real server that processed
7263 the request.
7264
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007265 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7266 unless you know what you do : memory is not shared between the
7267 processes, which can result in random behaviours.
7268
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007269 Example :
7270 # forward SMTP users to the same server they just used for POP in the
7271 # last 30 minutes
7272 backend pop
7273 mode tcp
7274 balance roundrobin
7275 stick store-request src
7276 stick-table type ip size 200k expire 30m
7277 server s1 192.168.1.1:110
7278 server s2 192.168.1.1:110
7279
7280 backend smtp
7281 mode tcp
7282 balance roundrobin
7283 stick match src table pop
7284 server s1 192.168.1.1:25
7285 server s2 192.168.1.1:25
7286
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007287 See also : "stick-table", "stick on", "nbproc", "bind-process" and section 7
Willy Tarreaube722a22014-06-13 16:31:59 +02007288 about ACLs and sample fetching.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007289
7290
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007291stick-table type {ip | integer | string [len <length>] | binary [len <length>]}
Emeric Brunf099e792010-09-27 12:05:28 +02007292 size <size> [expire <expire>] [nopurge] [peers <peersect>]
7293 [store <data_type>]*
Godbach64cef792013-12-04 16:08:22 +08007294 Configure the stickiness table for the current section
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007295 May be used in sections : defaults | frontend | listen | backend
Willy Tarreauc00cdc22010-06-06 16:48:26 +02007296 no | yes | yes | yes
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007297
7298 Arguments :
7299 ip a table declared with "type ip" will only store IPv4 addresses.
7300 This form is very compact (about 50 bytes per entry) and allows
7301 very fast entry lookup and stores with almost no overhead. This
7302 is mainly used to store client source IP addresses.
7303
David du Colombier9a6d3c92011-03-17 10:40:24 +01007304 ipv6 a table declared with "type ipv6" will only store IPv6 addresses.
7305 This form is very compact (about 60 bytes per entry) and allows
7306 very fast entry lookup and stores with almost no overhead. This
7307 is mainly used to store client source IP addresses.
7308
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007309 integer a table declared with "type integer" will store 32bit integers
7310 which can represent a client identifier found in a request for
7311 instance.
7312
7313 string a table declared with "type string" will store substrings of up
7314 to <len> characters. If the string provided by the pattern
7315 extractor is larger than <len>, it will be truncated before
7316 being stored. During matching, at most <len> characters will be
7317 compared between the string in the table and the extracted
7318 pattern. When not specified, the string is automatically limited
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007319 to 32 characters.
7320
7321 binary a table declared with "type binary" will store binary blocks
7322 of <len> bytes. If the block provided by the pattern
7323 extractor is larger than <len>, it will be truncated before
Willy Tarreaube722a22014-06-13 16:31:59 +02007324 being stored. If the block provided by the sample expression
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007325 is shorter than <len>, it will be padded by 0. When not
7326 specified, the block is automatically limited to 32 bytes.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007327
7328 <length> is the maximum number of characters that will be stored in a
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007329 "string" type table (See type "string" above). Or the number
7330 of bytes of the block in "binary" type table. Be careful when
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007331 changing this parameter as memory usage will proportionally
7332 increase.
7333
7334 <size> is the maximum number of entries that can fit in the table. This
Cyril Bonté78caf842010-03-10 22:41:43 +01007335 value directly impacts memory usage. Count approximately
7336 50 bytes per entry, plus the size of a string if any. The size
7337 supports suffixes "k", "m", "g" for 2^10, 2^20 and 2^30 factors.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007338
7339 [nopurge] indicates that we refuse to purge older entries when the table
7340 is full. When not specified and the table is full when haproxy
7341 wants to store an entry in it, it will flush a few of the oldest
7342 entries in order to release some space for the new ones. This is
7343 most often the desired behaviour. In some specific cases, it
7344 be desirable to refuse new entries instead of purging the older
7345 ones. That may be the case when the amount of data to store is
7346 far above the hardware limits and we prefer not to offer access
7347 to new clients than to reject the ones already connected. When
7348 using this parameter, be sure to properly set the "expire"
7349 parameter (see below).
7350
Emeric Brunf099e792010-09-27 12:05:28 +02007351 <peersect> is the name of the peers section to use for replication. Entries
7352 which associate keys to server IDs are kept synchronized with
7353 the remote peers declared in this section. All entries are also
7354 automatically learned from the local peer (old process) during a
7355 soft restart.
7356
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007357 NOTE : peers can't be used in multi-process mode.
7358
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007359 <expire> defines the maximum duration of an entry in the table since it
7360 was last created, refreshed or matched. The expiration delay is
7361 defined using the standard time format, similarly as the various
7362 timeouts. The maximum duration is slightly above 24 days. See
7363 section 2.2 for more information. If this delay is not specified,
Cyril Bontédc4d9032012-04-08 21:57:39 +02007364 the session won't automatically expire, but older entries will
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007365 be removed once full. Be sure not to use the "nopurge" parameter
7366 if not expiration delay is specified.
7367
Willy Tarreau08d5f982010-06-06 13:34:54 +02007368 <data_type> is used to store additional information in the stick-table. This
7369 may be used by ACLs in order to control various criteria related
7370 to the activity of the client matching the stick-table. For each
7371 item specified here, the size of each entry will be inflated so
Willy Tarreauc9705a12010-07-27 20:05:50 +02007372 that the additional data can fit. Several data types may be
7373 stored with an entry. Multiple data types may be specified after
7374 the "store" keyword, as a comma-separated list. Alternatively,
7375 it is possible to repeat the "store" keyword followed by one or
7376 several data types. Except for the "server_id" type which is
7377 automatically detected and enabled, all data types must be
7378 explicitly declared to be stored. If an ACL references a data
7379 type which is not stored, the ACL will simply not match. Some
7380 data types require an argument which must be passed just after
7381 the type between parenthesis. See below for the supported data
7382 types and their arguments.
7383
7384 The data types that can be stored with an entry are the following :
7385 - server_id : this is an integer which holds the numeric ID of the server a
7386 request was assigned to. It is used by the "stick match", "stick store",
7387 and "stick on" rules. It is automatically enabled when referenced.
7388
7389 - gpc0 : first General Purpose Counter. It is a positive 32-bit integer
7390 integer which may be used for anything. Most of the time it will be used
7391 to put a special tag on some entries, for instance to note that a
7392 specific behaviour was detected and must be known for future matches.
7393
Willy Tarreauba2ffd12013-05-29 15:54:14 +02007394 - gpc0_rate(<period>) : increment rate of the first General Purpose Counter
7395 over a period. It is a positive 32-bit integer integer which may be used
7396 for anything. Just like <gpc0>, it counts events, but instead of keeping
7397 a cumulative count, it maintains the rate at which the counter is
7398 incremented. Most of the time it will be used to measure the frequency of
7399 occurrence of certain events (eg: requests to a specific URL).
7400
Willy Tarreauc9705a12010-07-27 20:05:50 +02007401 - conn_cnt : Connection Count. It is a positive 32-bit integer which counts
7402 the absolute number of connections received from clients which matched
7403 this entry. It does not mean the connections were accepted, just that
7404 they were received.
7405
7406 - conn_cur : Current Connections. It is a positive 32-bit integer which
7407 stores the concurrent connection counts for the entry. It is incremented
7408 once an incoming connection matches the entry, and decremented once the
7409 connection leaves. That way it is possible to know at any time the exact
7410 number of concurrent connections for an entry.
7411
7412 - conn_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7413 integer parameter <period> which indicates in milliseconds the length
7414 of the period over which the average is measured. It reports the average
7415 incoming connection rate over that period, in connections per period. The
7416 result is an integer which can be matched using ACLs.
7417
7418 - sess_cnt : Session Count. It is a positive 32-bit integer which counts
7419 the absolute number of sessions received from clients which matched this
7420 entry. A session is a connection that was accepted by the layer 4 rules.
7421
7422 - sess_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7423 integer parameter <period> which indicates in milliseconds the length
7424 of the period over which the average is measured. It reports the average
7425 incoming session rate over that period, in sessions per period. The
7426 result is an integer which can be matched using ACLs.
7427
7428 - http_req_cnt : HTTP request Count. It is a positive 32-bit integer which
7429 counts the absolute number of HTTP requests received from clients which
7430 matched this entry. It does not matter whether they are valid requests or
7431 not. Note that this is different from sessions when keep-alive is used on
7432 the client side.
7433
7434 - http_req_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7435 integer parameter <period> which indicates in milliseconds the length
7436 of the period over which the average is measured. It reports the average
7437 HTTP request rate over that period, in requests per period. The result is
7438 an integer which can be matched using ACLs. It does not matter whether
7439 they are valid requests or not. Note that this is different from sessions
7440 when keep-alive is used on the client side.
7441
7442 - http_err_cnt : HTTP Error Count. It is a positive 32-bit integer which
7443 counts the absolute number of HTTP requests errors induced by clients
7444 which matched this entry. Errors are counted on invalid and truncated
7445 requests, as well as on denied or tarpitted requests, and on failed
7446 authentications. If the server responds with 4xx, then the request is
7447 also counted as an error since it's an error triggered by the client
7448 (eg: vulnerability scan).
7449
7450 - http_err_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7451 integer parameter <period> which indicates in milliseconds the length
7452 of the period over which the average is measured. It reports the average
7453 HTTP request error rate over that period, in requests per period (see
7454 http_err_cnt above for what is accounted as an error). The result is an
7455 integer which can be matched using ACLs.
7456
7457 - bytes_in_cnt : client to server byte count. It is a positive 64-bit
7458 integer which counts the cumulated amount of bytes received from clients
7459 which matched this entry. Headers are included in the count. This may be
7460 used to limit abuse of upload features on photo or video servers.
7461
7462 - bytes_in_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7463 integer parameter <period> which indicates in milliseconds the length
7464 of the period over which the average is measured. It reports the average
7465 incoming bytes rate over that period, in bytes per period. It may be used
7466 to detect users which upload too much and too fast. Warning: with large
7467 uploads, it is possible that the amount of uploaded data will be counted
7468 once upon termination, thus causing spikes in the average transfer speed
7469 instead of having a smooth one. This may partially be smoothed with
7470 "option contstats" though this is not perfect yet. Use of byte_in_cnt is
7471 recommended for better fairness.
7472
7473 - bytes_out_cnt : server to client byte count. It is a positive 64-bit
7474 integer which counts the cumulated amount of bytes sent to clients which
7475 matched this entry. Headers are included in the count. This may be used
7476 to limit abuse of bots sucking the whole site.
7477
7478 - bytes_out_rate(<period>) : frequency counter (takes 12 bytes). It takes
7479 an integer parameter <period> which indicates in milliseconds the length
7480 of the period over which the average is measured. It reports the average
7481 outgoing bytes rate over that period, in bytes per period. It may be used
7482 to detect users which download too much and too fast. Warning: with large
7483 transfers, it is possible that the amount of transferred data will be
7484 counted once upon termination, thus causing spikes in the average
7485 transfer speed instead of having a smooth one. This may partially be
7486 smoothed with "option contstats" though this is not perfect yet. Use of
7487 byte_out_cnt is recommended for better fairness.
Willy Tarreau08d5f982010-06-06 13:34:54 +02007488
Willy Tarreauc00cdc22010-06-06 16:48:26 +02007489 There is only one stick-table per proxy. At the moment of writing this doc,
7490 it does not seem useful to have multiple tables per proxy. If this happens
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007491 to be required, simply create a dummy backend with a stick-table in it and
7492 reference it.
7493
7494 It is important to understand that stickiness based on learning information
7495 has some limitations, including the fact that all learned associations are
7496 lost upon restart. In general it can be good as a complement but not always
7497 as an exclusive stickiness.
7498
Willy Tarreauc9705a12010-07-27 20:05:50 +02007499 Last, memory requirements may be important when storing many data types.
7500 Indeed, storing all indicators above at once in each entry requires 116 bytes
7501 per entry, or 116 MB for a 1-million entries table. This is definitely not
7502 something that can be ignored.
7503
7504 Example:
7505 # Keep track of counters of up to 1 million IP addresses over 5 minutes
7506 # and store a general purpose counter and the average connection rate
7507 # computed over a sliding window of 30 seconds.
7508 stick-table type ip size 1m expire 5m store gpc0,conn_rate(30s)
7509
7510 See also : "stick match", "stick on", "stick store-request", section 2.2
David du Colombiera13d1b92011-03-17 10:40:22 +01007511 about time format and section 7 about ACLs.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007512
7513
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007514stick store-response <pattern> [table <table>] [{if | unless} <condition>]
7515 Define a request pattern used to create an entry in a stickiness table
7516 May be used in sections : defaults | frontend | listen | backend
7517 no | no | yes | yes
7518
7519 Arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007520 <pattern> is a sample expression rule as described in section 7.3. It
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007521 describes what elements of the response or connection will
7522 be analysed, extracted and stored in the table once a
7523 server is selected.
7524
7525 <table> is an optional stickiness table name. If unspecified, the same
7526 backend's table is used. A stickiness table is declared using
7527 the "stick-table" statement.
7528
7529 <cond> is an optional storage condition. It makes it possible to store
7530 certain criteria only when some conditions are met (or not met).
7531 For instance, it could be used to store the SSL session ID only
7532 when the response is a SSL server hello.
7533
7534 Some protocols or applications require complex stickiness rules and cannot
7535 always simply rely on cookies nor hashing. The "stick store-response"
7536 statement describes a rule to decide what to extract from the response and
7537 when to do it, in order to store it into a stickiness table for further
7538 requests to match it using the "stick match" statement. Obviously the
7539 extracted part must make sense and have a chance to be matched in a further
Cyril Bonté108cf6e2012-04-21 23:30:29 +02007540 request. Storing an ID found in a header of a response makes sense.
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007541 See section 7 for a complete list of possible patterns and transformation
7542 rules.
7543
7544 The table has to be declared using the "stick-table" statement. It must be of
7545 a type compatible with the pattern. By default it is the one which is present
7546 in the same backend. It is possible to share a table with other backends by
7547 referencing it using the "table" keyword. If another table is referenced,
7548 the server's ID inside the backends are used. By default, all server IDs
7549 start at 1 in each backend, so the server ordering is enough. But in case of
7550 doubt, it is highly recommended to force server IDs using their "id" setting.
7551
7552 It is possible to restrict the conditions where a "stick store-response"
7553 statement will apply, using "if" or "unless" followed by a condition. This
7554 condition will be evaluated while parsing the response, so any criteria can
7555 be used. See section 7 for ACL based conditions.
7556
7557 There is no limit on the number of "stick store-response" statements, but
7558 there is a limit of 8 simultaneous stores per request or response. This
7559 makes it possible to store up to 8 criteria, all extracted from either the
7560 request or the response, regardless of the number of rules. Only the 8 first
7561 ones which match will be kept. Using this, it is possible to feed multiple
7562 tables at once in the hope to increase the chance to recognize a user on
Willy Tarreau9667a802013-12-09 12:52:13 +01007563 another protocol or access method. Using multiple store-response rules with
7564 the same table is possible and may be used to find the best criterion to rely
7565 on, by arranging the rules by decreasing preference order. Only the first
7566 extracted criterion for a given table will be stored. All subsequent store-
7567 response rules referencing the same table will be skipped and their ACLs will
7568 not be evaluated. However, even if a store-request rule references a table, a
7569 store-response rule may also use the same table. This means that each table
7570 may learn exactly one element from the request and one element from the
7571 response at once.
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007572
7573 The table will contain the real server that processed the request.
7574
7575 Example :
7576 # Learn SSL session ID from both request and response and create affinity.
7577 backend https
7578 mode tcp
7579 balance roundrobin
Cyril Bontédc4d9032012-04-08 21:57:39 +02007580 # maximum SSL session ID length is 32 bytes.
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007581 stick-table type binary len 32 size 30k expire 30m
Cyril Bonté108cf6e2012-04-21 23:30:29 +02007582
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007583 acl clienthello req_ssl_hello_type 1
7584 acl serverhello rep_ssl_hello_type 2
7585
7586 # use tcp content accepts to detects ssl client and server hello.
7587 tcp-request inspect-delay 5s
7588 tcp-request content accept if clienthello
7589
7590 # no timeout on response inspect delay by default.
7591 tcp-response content accept if serverhello
Cyril Bonté108cf6e2012-04-21 23:30:29 +02007592
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007593 # SSL session ID (SSLID) may be present on a client or server hello.
7594 # Its length is coded on 1 byte at offset 43 and its value starts
7595 # at offset 44.
7596
7597 # Match and learn on request if client hello.
7598 stick on payload_lv(43,1) if clienthello
7599
7600 # Learn on response if server hello.
7601 stick store-response payload_lv(43,1) if serverhello
Cyril Bontédc4d9032012-04-08 21:57:39 +02007602
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007603 server s1 192.168.1.1:443
7604 server s2 192.168.1.1:443
7605
7606 See also : "stick-table", "stick on", and section 7 about ACLs and pattern
7607 extraction.
7608
7609
Willy Tarreau938c7fe2014-04-25 14:21:39 +02007610tcp-check connect [params*]
7611 Opens a new connection
7612 May be used in sections: defaults | frontend | listen | backend
7613 no | no | yes | yes
7614
7615 When an application lies on more than a single TCP port or when HAProxy
7616 load-balance many services in a single backend, it makes sense to probe all
7617 the services individually before considering a server as operational.
7618
7619 When there are no TCP port configured on the server line neither server port
7620 directive, then the 'tcp-check connect port <port>' must be the first step
7621 of the sequence.
7622
7623 In a tcp-check ruleset a 'connect' is required, it is also mandatory to start
7624 the ruleset with a 'connect' rule. Purpose is to ensure admin know what they
7625 do.
7626
7627 Parameters :
7628 They are optional and can be used to describe how HAProxy should open and
7629 use the TCP connection.
7630
7631 port if not set, check port or server port is used.
7632 It tells HAProxy where to open the connection to.
7633 <port> must be a valid TCP port source integer, from 1 to 65535.
7634
7635 send-proxy send a PROXY protocol string
7636
7637 ssl opens a ciphered connection
7638
7639 Examples:
7640 # check HTTP and HTTPs services on a server.
7641 # first open port 80 thanks to server line port directive, then
7642 # tcp-check opens port 443, ciphered and run a request on it:
7643 option tcp-check
7644 tcp-check connect
7645 tcp-check send GET\ /\ HTTP/1.0\r\n
7646 tcp-check send Host:\ haproxy.1wt.eu\r\n
7647 tcp-check send \r\n
7648 tcp-check expect rstring (2..|3..)
7649 tcp-check connect port 443 ssl
7650 tcp-check send GET\ /\ HTTP/1.0\r\n
7651 tcp-check send Host:\ haproxy.1wt.eu\r\n
7652 tcp-check send \r\n
7653 tcp-check expect rstring (2..|3..)
7654 server www 10.0.0.1 check port 80
7655
7656 # check both POP and IMAP from a single server:
7657 option tcp-check
7658 tcp-check connect port 110
7659 tcp-check expect string +OK\ POP3\ ready
7660 tcp-check connect port 143
7661 tcp-check expect string *\ OK\ IMAP4\ ready
7662 server mail 10.0.0.1 check
7663
7664 See also : "option tcp-check", "tcp-check send", "tcp-check expect"
7665
7666
7667tcp-check expect [!] <match> <pattern>
7668 Specify data to be collected and analysed during a generic health check
7669 May be used in sections: defaults | frontend | listen | backend
7670 no | no | yes | yes
7671
7672 Arguments :
7673 <match> is a keyword indicating how to look for a specific pattern in the
7674 response. The keyword may be one of "string", "rstring" or
7675 binary.
7676 The keyword may be preceded by an exclamation mark ("!") to negate
7677 the match. Spaces are allowed between the exclamation mark and the
7678 keyword. See below for more details on the supported keywords.
7679
7680 <pattern> is the pattern to look for. It may be a string or a regular
7681 expression. If the pattern contains spaces, they must be escaped
7682 with the usual backslash ('\').
7683 If the match is set to binary, then the pattern must be passed as
7684 a serie of hexadecimal digits in an even number. Each sequence of
7685 two digits will represent a byte. The hexadecimal digits may be
7686 used upper or lower case.
7687
7688
7689 The available matches are intentionally similar to their http-check cousins :
7690
7691 string <string> : test the exact string matches in the response buffer.
7692 A health check response will be considered valid if the
7693 response's buffer contains this exact string. If the
7694 "string" keyword is prefixed with "!", then the response
7695 will be considered invalid if the body contains this
7696 string. This can be used to look for a mandatory pattern
7697 in a protocol response, or to detect a failure when a
7698 specific error appears in a protocol banner.
7699
7700 rstring <regex> : test a regular expression on the response buffer.
7701 A health check response will be considered valid if the
7702 response's buffer matches this expression. If the
7703 "rstring" keyword is prefixed with "!", then the response
7704 will be considered invalid if the body matches the
7705 expression.
7706
7707 binary <hexstring> : test the exact string in its hexadecimal form matches
7708 in the response buffer. A health check response will
7709 be considered valid if the response's buffer contains
7710 this exact hexadecimal string.
7711 Purpose is to match data on binary protocols.
7712
7713 It is important to note that the responses will be limited to a certain size
7714 defined by the global "tune.chksize" option, which defaults to 16384 bytes.
7715 Thus, too large responses may not contain the mandatory pattern when using
7716 "string", "rstring" or binary. If a large response is absolutely required, it
7717 is possible to change the default max size by setting the global variable.
7718 However, it is worth keeping in mind that parsing very large responses can
7719 waste some CPU cycles, especially when regular expressions are used, and that
7720 it is always better to focus the checks on smaller resources. Also, in its
7721 current state, the check will not find any string nor regex past a null
7722 character in the response. Similarly it is not possible to request matching
7723 the null character.
7724
7725 Examples :
7726 # perform a POP check
7727 option tcp-check
7728 tcp-check expect string +OK\ POP3\ ready
7729
7730 # perform an IMAP check
7731 option tcp-check
7732 tcp-check expect string *\ OK\ IMAP4\ ready
7733
7734 # look for the redis master server
7735 option tcp-check
7736 tcp-check send PING\r\n
7737 tcp-check expect +PONG
7738 tcp-check send info\ replication\r\n
7739 tcp-check expect string role:master
7740 tcp-check send QUIT\r\n
7741 tcp-check expect string +OK
7742
7743
7744 See also : "option tcp-check", "tcp-check connect", "tcp-check send",
7745 "tcp-check send-binary", "http-check expect", tune.chksize
7746
7747
7748tcp-check send <data>
7749 Specify a string to be sent as a question during a generic health check
7750 May be used in sections: defaults | frontend | listen | backend
7751 no | no | yes | yes
7752
7753 <data> : the data to be sent as a question during a generic health check
7754 session. For now, <data> must be a string.
7755
7756 Examples :
7757 # look for the redis master server
7758 option tcp-check
7759 tcp-check send info\ replication\r\n
7760 tcp-check expect string role:master
7761
7762 See also : "option tcp-check", "tcp-check connect", "tcp-check expect",
7763 "tcp-check send-binary", tune.chksize
7764
7765
7766tcp-check send-binary <hexastring>
7767 Specify an hexa digits string to be sent as a binary question during a raw
7768 tcp health check
7769 May be used in sections: defaults | frontend | listen | backend
7770 no | no | yes | yes
7771
7772 <data> : the data to be sent as a question during a generic health check
7773 session. For now, <data> must be a string.
7774 <hexastring> : test the exact string in its hexadecimal form matches in the
7775 response buffer. A health check response will be considered
7776 valid if the response's buffer contains this exact
7777 hexadecimal string.
7778 Purpose is to send binary data to ask on binary protocols.
7779
7780 Examples :
7781 # redis check in binary
7782 option tcp-check
7783 tcp-check send-binary 50494e470d0a # PING\r\n
7784 tcp-check expect binary 2b504F4e47 # +PONG
7785
7786
7787 See also : "option tcp-check", "tcp-check connect", "tcp-check expect",
7788 "tcp-check send", tune.chksize
7789
7790
Willy Tarreaue9656522010-08-17 15:40:09 +02007791tcp-request connection <action> [{if | unless} <condition>]
7792 Perform an action on an incoming connection depending on a layer 4 condition
Willy Tarreau1a687942010-05-23 22:40:30 +02007793 May be used in sections : defaults | frontend | listen | backend
7794 no | yes | yes | no
Willy Tarreaue9656522010-08-17 15:40:09 +02007795 Arguments :
7796 <action> defines the action to perform if the condition applies. Valid
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007797 actions include : "accept", "reject", "track-sc0", "track-sc1",
7798 "track-sc2", and "expect-proxy". See below for more details.
Willy Tarreau1a687942010-05-23 22:40:30 +02007799
Willy Tarreaue9656522010-08-17 15:40:09 +02007800 <condition> is a standard layer4-only ACL-based condition (see section 7).
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007801
7802 Immediately after acceptance of a new incoming connection, it is possible to
7803 evaluate some conditions to decide whether this connection must be accepted
Willy Tarreaue9656522010-08-17 15:40:09 +02007804 or dropped or have its counters tracked. Those conditions cannot make use of
7805 any data contents because the connection has not been read from yet, and the
7806 buffers are not yet allocated. This is used to selectively and very quickly
7807 accept or drop connections from various sources with a very low overhead. If
7808 some contents need to be inspected in order to take the decision, the
7809 "tcp-request content" statements must be used instead.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007810
Willy Tarreaue9656522010-08-17 15:40:09 +02007811 The "tcp-request connection" rules are evaluated in their exact declaration
7812 order. If no rule matches or if there is no rule, the default action is to
7813 accept the incoming connection. There is no specific limit to the number of
7814 rules which may be inserted.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007815
Willy Tarreau18bf01e2014-06-13 16:18:52 +02007816 Five types of actions are supported :
Willy Tarreaue9656522010-08-17 15:40:09 +02007817 - accept :
7818 accepts the connection if the condition is true (when used with "if")
7819 or false (when used with "unless"). The first such rule executed ends
7820 the rules evaluation.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007821
Willy Tarreaue9656522010-08-17 15:40:09 +02007822 - reject :
7823 rejects the connection if the condition is true (when used with "if")
7824 or false (when used with "unless"). The first such rule executed ends
7825 the rules evaluation. Rejected connections do not even become a
7826 session, which is why they are accounted separately for in the stats,
7827 as "denied connections". They are not considered for the session
7828 rate-limit and are not logged either. The reason is that these rules
7829 should only be used to filter extremely high connection rates such as
7830 the ones encountered during a massive DDoS attack. Under these extreme
7831 conditions, the simple action of logging each event would make the
7832 system collapse and would considerably lower the filtering capacity. If
7833 logging is absolutely desired, then "tcp-request content" rules should
7834 be used instead.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007835
Willy Tarreau4f0d9192013-06-11 20:40:55 +02007836 - expect-proxy layer4 :
7837 configures the client-facing connection to receive a PROXY protocol
7838 header before any byte is read from the socket. This is equivalent to
7839 having the "accept-proxy" keyword on the "bind" line, except that using
7840 the TCP rule allows the PROXY protocol to be accepted only for certain
7841 IP address ranges using an ACL. This is convenient when multiple layers
7842 of load balancers are passed through by traffic coming from public
7843 hosts.
7844
Willy Tarreau18bf01e2014-06-13 16:18:52 +02007845 - capture <sample> len <length> :
7846 This only applies to "tcp-request content" rules. It captures sample
7847 expression <sample> from the request buffer, and converts it to a
7848 string of at most <len> characters. The resulting string is stored into
7849 the next request "capture" slot, so it will possibly appear next to
7850 some captured HTTP headers. It will then automatically appear in the
7851 logs, and it will be possible to extract it using sample fetch rules to
7852 feed it into headers or anything. The length should be limited given
7853 that this size will be allocated for each capture during the whole
7854 session life. Since it applies to Please check section 7.3 (Fetching
7855 samples) and "capture request header" for more information.
7856
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007857 - { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>] :
Willy Tarreaue9656522010-08-17 15:40:09 +02007858 enables tracking of sticky counters from current connection. These
Willy Tarreau09448f72014-06-25 18:12:15 +02007859 rules do not stop evaluation and do not change default action. 3 sets
Willy Tarreaue9656522010-08-17 15:40:09 +02007860 of counters may be simultaneously tracked by the same connection. The
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007861 first "track-sc0" rule executed enables tracking of the counters of the
7862 specified table as the first set. The first "track-sc1" rule executed
Willy Tarreaue9656522010-08-17 15:40:09 +02007863 enables tracking of the counters of the specified table as the second
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007864 set. The first "track-sc2" rule executed enables tracking of the
7865 counters of the specified table as the third set. It is a recommended
7866 practice to use the first set of counters for the per-frontend counters
7867 and the second set for the per-backend ones. But this is just a
7868 guideline, all may be used everywhere.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007869
Willy Tarreaue9656522010-08-17 15:40:09 +02007870 These actions take one or two arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007871 <key> is mandatory, and is a sample expression rule as described
Willy Tarreau74ca5042013-06-11 23:12:07 +02007872 in section 7.3. It describes what elements of the incoming
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01007873 request or connection will be analysed, extracted, combined,
7874 and used to select which table entry to update the counters.
7875 Note that "tcp-request connection" cannot use content-based
7876 fetches.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007877
Willy Tarreaue9656522010-08-17 15:40:09 +02007878 <table> is an optional table to be used instead of the default one,
7879 which is the stick-table declared in the current proxy. All
7880 the counters for the matches and updates for the key will
7881 then be performed in that table until the session ends.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007882
Willy Tarreaue9656522010-08-17 15:40:09 +02007883 Once a "track-sc*" rule is executed, the key is looked up in the table
7884 and if it is not found, an entry is allocated for it. Then a pointer to
7885 that entry is kept during all the session's life, and this entry's
7886 counters are updated as often as possible, every time the session's
7887 counters are updated, and also systematically when the session ends.
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01007888 Counters are only updated for events that happen after the tracking has
7889 been started. For example, connection counters will not be updated when
7890 tracking layer 7 information, since the connection event happens before
7891 layer7 information is extracted.
7892
Willy Tarreaue9656522010-08-17 15:40:09 +02007893 If the entry tracks concurrent connection counters, one connection is
7894 counted for as long as the entry is tracked, and the entry will not
7895 expire during that time. Tracking counters also provides a performance
7896 advantage over just checking the keys, because only one table lookup is
7897 performed for all ACL checks that make use of it.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007898
Willy Tarreaue9656522010-08-17 15:40:09 +02007899 Note that the "if/unless" condition is optional. If no condition is set on
7900 the action, it is simply performed unconditionally. That can be useful for
7901 "track-sc*" actions as well as for changing the default action to a reject.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007902
Willy Tarreaue9656522010-08-17 15:40:09 +02007903 Example: accept all connections from white-listed hosts, reject too fast
7904 connection without counting them, and track accepted connections.
7905 This results in connection rate being capped from abusive sources.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007906
Willy Tarreaue9656522010-08-17 15:40:09 +02007907 tcp-request connection accept if { src -f /etc/haproxy/whitelist.lst }
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007908 tcp-request connection reject if { src_conn_rate gt 10 }
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007909 tcp-request connection track-sc0 src
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007910
Willy Tarreaue9656522010-08-17 15:40:09 +02007911 Example: accept all connections from white-listed hosts, count all other
7912 connections and reject too fast ones. This results in abusive ones
7913 being blocked as long as they don't slow down.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007914
Willy Tarreaue9656522010-08-17 15:40:09 +02007915 tcp-request connection accept if { src -f /etc/haproxy/whitelist.lst }
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007916 tcp-request connection track-sc0 src
7917 tcp-request connection reject if { sc0_conn_rate gt 10 }
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007918
Willy Tarreau4f0d9192013-06-11 20:40:55 +02007919 Example: enable the PROXY protocol for traffic coming from all known proxies.
7920
7921 tcp-request connection expect-proxy layer4 if { src -f proxies.lst }
7922
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007923 See section 7 about ACL usage.
7924
Willy Tarreaue9656522010-08-17 15:40:09 +02007925 See also : "tcp-request content", "stick-table"
Willy Tarreau68c03ab2010-08-06 15:08:45 +02007926
7927
Willy Tarreaue9656522010-08-17 15:40:09 +02007928tcp-request content <action> [{if | unless} <condition>]
7929 Perform an action on a new session depending on a layer 4-7 condition
Willy Tarreau62644772008-07-16 18:36:06 +02007930 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaufb356202010-08-03 14:02:05 +02007931 no | yes | yes | yes
Willy Tarreaue9656522010-08-17 15:40:09 +02007932 Arguments :
7933 <action> defines the action to perform if the condition applies. Valid
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007934 actions include : "accept", "reject", "track-sc0", "track-sc1",
Thierry FOURNIER90da1912015-03-05 11:17:06 +01007935 "track-sc2", "capture" and "lua". See "tcp-request connection"
7936 above for their signification.
Willy Tarreau62644772008-07-16 18:36:06 +02007937
Willy Tarreaue9656522010-08-17 15:40:09 +02007938 <condition> is a standard layer 4-7 ACL-based condition (see section 7).
Willy Tarreau62644772008-07-16 18:36:06 +02007939
Willy Tarreaue9656522010-08-17 15:40:09 +02007940 A request's contents can be analysed at an early stage of request processing
7941 called "TCP content inspection". During this stage, ACL-based rules are
7942 evaluated every time the request contents are updated, until either an
7943 "accept" or a "reject" rule matches, or the TCP request inspection delay
7944 expires with no matching rule.
Willy Tarreau62644772008-07-16 18:36:06 +02007945
Willy Tarreaue9656522010-08-17 15:40:09 +02007946 The first difference between these rules and "tcp-request connection" rules
7947 is that "tcp-request content" rules can make use of contents to take a
7948 decision. Most often, these decisions will consider a protocol recognition or
7949 validity. The second difference is that content-based rules can be used in
Willy Tarreauf3338342014-01-28 21:40:28 +01007950 both frontends and backends. In case of HTTP keep-alive with the client, all
7951 tcp-request content rules are evaluated again, so haproxy keeps a record of
7952 what sticky counters were assigned by a "tcp-request connection" versus a
7953 "tcp-request content" rule, and flushes all the content-related ones after
7954 processing an HTTP request, so that they may be evaluated again by the rules
7955 being evaluated again for the next request. This is of particular importance
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03007956 when the rule tracks some L7 information or when it is conditioned by an
Willy Tarreauf3338342014-01-28 21:40:28 +01007957 L7-based ACL, since tracking may change between requests.
Willy Tarreau62644772008-07-16 18:36:06 +02007958
Willy Tarreaue9656522010-08-17 15:40:09 +02007959 Content-based rules are evaluated in their exact declaration order. If no
7960 rule matches or if there is no rule, the default action is to accept the
7961 contents. There is no specific limit to the number of rules which may be
7962 inserted.
Willy Tarreau62644772008-07-16 18:36:06 +02007963
Willy Tarreau18bf01e2014-06-13 16:18:52 +02007964 Four types of actions are supported :
7965 - accept : the request is accepted
7966 - reject : the request is rejected and the connection is closed
7967 - capture : the specified sample expression is captured
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02007968 - { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>]
Willy Tarreau62644772008-07-16 18:36:06 +02007969
Willy Tarreaue9656522010-08-17 15:40:09 +02007970 They have the same meaning as their counter-parts in "tcp-request connection"
7971 so please refer to that section for a complete description.
Willy Tarreau62644772008-07-16 18:36:06 +02007972
Willy Tarreauf3338342014-01-28 21:40:28 +01007973 While there is nothing mandatory about it, it is recommended to use the
7974 track-sc0 in "tcp-request connection" rules, track-sc1 for "tcp-request
7975 content" rules in the frontend, and track-sc2 for "tcp-request content"
7976 rules in the backend, because that makes the configuration more readable
7977 and easier to troubleshoot, but this is just a guideline and all counters
7978 may be used everywhere.
Willy Tarreau62644772008-07-16 18:36:06 +02007979
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01007980 Note that the "if/unless" condition is optional. If no condition is set on
Willy Tarreaue9656522010-08-17 15:40:09 +02007981 the action, it is simply performed unconditionally. That can be useful for
7982 "track-sc*" actions as well as for changing the default action to a reject.
Willy Tarreau62644772008-07-16 18:36:06 +02007983
Willy Tarreaue9656522010-08-17 15:40:09 +02007984 It is perfectly possible to match layer 7 contents with "tcp-request content"
Willy Tarreauc0239e02012-04-16 14:42:55 +02007985 rules, since HTTP-specific ACL matches are able to preliminarily parse the
7986 contents of a buffer before extracting the required data. If the buffered
7987 contents do not parse as a valid HTTP message, then the ACL does not match.
7988 The parser which is involved there is exactly the same as for all other HTTP
Willy Tarreauf3338342014-01-28 21:40:28 +01007989 processing, so there is no risk of parsing something differently. In an HTTP
7990 backend connected to from an HTTP frontend, it is guaranteed that HTTP
7991 contents will always be immediately present when the rule is evaluated first.
Willy Tarreau62644772008-07-16 18:36:06 +02007992
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01007993 Tracking layer7 information is also possible provided that the information
Willy Tarreau4d54c7c2014-09-16 15:48:15 +02007994 are present when the rule is processed. The rule processing engine is able to
7995 wait until the inspect delay expires when the data to be tracked is not yet
7996 available.
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01007997
Thierry FOURNIER90da1912015-03-05 11:17:06 +01007998 The "lua" keyword is followed by a Lua function name. It is used to run a Lua
7999 function if the action is executed. The single parameter is the name of the
8000 function to run. The prototype of the function is documented in the API
8001 documentation.
8002
Willy Tarreau62644772008-07-16 18:36:06 +02008003 Example:
Willy Tarreaue9656522010-08-17 15:40:09 +02008004 # Accept HTTP requests containing a Host header saying "example.com"
8005 # and reject everything else.
8006 acl is_host_com hdr(Host) -i example.com
8007 tcp-request inspect-delay 30s
Willy Tarreauc0239e02012-04-16 14:42:55 +02008008 tcp-request content accept if is_host_com
Willy Tarreaue9656522010-08-17 15:40:09 +02008009 tcp-request content reject
8010
8011 Example:
Willy Tarreau62644772008-07-16 18:36:06 +02008012 # reject SMTP connection if client speaks first
8013 tcp-request inspect-delay 30s
8014 acl content_present req_len gt 0
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008015 tcp-request content reject if content_present
Willy Tarreau62644772008-07-16 18:36:06 +02008016
8017 # Forward HTTPS connection only if client speaks
8018 tcp-request inspect-delay 30s
8019 acl content_present req_len gt 0
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008020 tcp-request content accept if content_present
Willy Tarreaue9656522010-08-17 15:40:09 +02008021 tcp-request content reject
8022
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008023 Example:
8024 # Track the last IP from X-Forwarded-For
8025 tcp-request inspect-delay 10s
Willy Tarreau4d54c7c2014-09-16 15:48:15 +02008026 tcp-request content track-sc0 hdr(x-forwarded-for,-1)
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008027
8028 Example:
8029 # track request counts per "base" (concatenation of Host+URL)
8030 tcp-request inspect-delay 10s
Willy Tarreau4d54c7c2014-09-16 15:48:15 +02008031 tcp-request content track-sc0 base table req-rate
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008032
Willy Tarreaue9656522010-08-17 15:40:09 +02008033 Example: track per-frontend and per-backend counters, block abusers at the
8034 frontend when the backend detects abuse.
8035
8036 frontend http
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008037 # Use General Purpose Couter 0 in SC0 as a global abuse counter
Willy Tarreaue9656522010-08-17 15:40:09 +02008038 # protecting all our sites
8039 stick-table type ip size 1m expire 5m store gpc0
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008040 tcp-request connection track-sc0 src
8041 tcp-request connection reject if { sc0_get_gpc0 gt 0 }
Willy Tarreaue9656522010-08-17 15:40:09 +02008042 ...
8043 use_backend http_dynamic if { path_end .php }
8044
8045 backend http_dynamic
8046 # if a source makes too fast requests to this dynamic site (tracked
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008047 # by SC1), block it globally in the frontend.
Willy Tarreaue9656522010-08-17 15:40:09 +02008048 stick-table type ip size 1m expire 5m store http_req_rate(10s)
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008049 acl click_too_fast sc1_http_req_rate gt 10
8050 acl mark_as_abuser sc0_inc_gpc0 gt 0
8051 tcp-request content track-sc1 src
Willy Tarreaue9656522010-08-17 15:40:09 +02008052 tcp-request content reject if click_too_fast mark_as_abuser
Willy Tarreau62644772008-07-16 18:36:06 +02008053
Willy Tarreauc57f0e22009-05-10 13:12:33 +02008054 See section 7 about ACL usage.
Willy Tarreau62644772008-07-16 18:36:06 +02008055
Willy Tarreaue9656522010-08-17 15:40:09 +02008056 See also : "tcp-request connection", "tcp-request inspect-delay"
Willy Tarreau62644772008-07-16 18:36:06 +02008057
8058
8059tcp-request inspect-delay <timeout>
8060 Set the maximum allowed time to wait for data during content inspection
8061 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaufb356202010-08-03 14:02:05 +02008062 no | yes | yes | yes
Willy Tarreau62644772008-07-16 18:36:06 +02008063 Arguments :
8064 <timeout> is the timeout value specified in milliseconds by default, but
8065 can be in any other unit if the number is suffixed by the unit,
8066 as explained at the top of this document.
8067
8068 People using haproxy primarily as a TCP relay are often worried about the
8069 risk of passing any type of protocol to a server without any analysis. In
8070 order to be able to analyze the request contents, we must first withhold
8071 the data then analyze them. This statement simply enables withholding of
8072 data for at most the specified amount of time.
8073
Willy Tarreaufb356202010-08-03 14:02:05 +02008074 TCP content inspection applies very early when a connection reaches a
8075 frontend, then very early when the connection is forwarded to a backend. This
8076 means that a connection may experience a first delay in the frontend and a
8077 second delay in the backend if both have tcp-request rules.
8078
Willy Tarreau62644772008-07-16 18:36:06 +02008079 Note that when performing content inspection, haproxy will evaluate the whole
8080 rules for every new chunk which gets in, taking into account the fact that
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01008081 those data are partial. If no rule matches before the aforementioned delay,
Willy Tarreau62644772008-07-16 18:36:06 +02008082 a last check is performed upon expiration, this time considering that the
Willy Tarreaud869b242009-03-15 14:43:58 +01008083 contents are definitive. If no delay is set, haproxy will not wait at all
8084 and will immediately apply a verdict based on the available information.
8085 Obviously this is unlikely to be very useful and might even be racy, so such
8086 setups are not recommended.
Willy Tarreau62644772008-07-16 18:36:06 +02008087
8088 As soon as a rule matches, the request is released and continues as usual. If
8089 the timeout is reached and no rule matches, the default policy will be to let
8090 it pass through unaffected.
8091
8092 For most protocols, it is enough to set it to a few seconds, as most clients
8093 send the full request immediately upon connection. Add 3 or more seconds to
8094 cover TCP retransmits but that's all. For some protocols, it may make sense
Willy Tarreaud72758d2010-01-12 10:42:19 +01008095 to use large values, for instance to ensure that the client never talks
Willy Tarreau62644772008-07-16 18:36:06 +02008096 before the server (eg: SMTP), or to wait for a client to talk before passing
8097 data to the server (eg: SSL). Note that the client timeout must cover at
Willy Tarreaub824b002010-09-29 16:36:16 +02008098 least the inspection delay, otherwise it will expire first. If the client
8099 closes the connection or if the buffer is full, the delay immediately expires
8100 since the contents will not be able to change anymore.
Willy Tarreau62644772008-07-16 18:36:06 +02008101
Willy Tarreau55165fe2009-05-10 12:02:55 +02008102 See also : "tcp-request content accept", "tcp-request content reject",
Willy Tarreau62644772008-07-16 18:36:06 +02008103 "timeout client".
8104
8105
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008106tcp-response content <action> [{if | unless} <condition>]
8107 Perform an action on a session response depending on a layer 4-7 condition
8108 May be used in sections : defaults | frontend | listen | backend
8109 no | no | yes | yes
8110 Arguments :
8111 <action> defines the action to perform if the condition applies. Valid
Thierry FOURNIER90da1912015-03-05 11:17:06 +01008112 actions include : "accept", "close", "reject", "lua".
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008113
8114 <condition> is a standard layer 4-7 ACL-based condition (see section 7).
8115
8116 Response contents can be analysed at an early stage of response processing
8117 called "TCP content inspection". During this stage, ACL-based rules are
8118 evaluated every time the response contents are updated, until either an
Willy Tarreaucc1e04b2013-09-11 23:20:29 +02008119 "accept", "close" or a "reject" rule matches, or a TCP response inspection
8120 delay is set and expires with no matching rule.
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008121
8122 Most often, these decisions will consider a protocol recognition or validity.
8123
8124 Content-based rules are evaluated in their exact declaration order. If no
8125 rule matches or if there is no rule, the default action is to accept the
8126 contents. There is no specific limit to the number of rules which may be
8127 inserted.
8128
8129 Two types of actions are supported :
8130 - accept :
8131 accepts the response if the condition is true (when used with "if")
8132 or false (when used with "unless"). The first such rule executed ends
8133 the rules evaluation.
8134
Willy Tarreaucc1e04b2013-09-11 23:20:29 +02008135 - close :
8136 immediately closes the connection with the server if the condition is
8137 true (when used with "if"), or false (when used with "unless"). The
8138 first such rule executed ends the rules evaluation. The main purpose of
8139 this action is to force a connection to be finished between a client
8140 and a server after an exchange when the application protocol expects
8141 some long time outs to elapse first. The goal is to eliminate idle
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008142 connections which take significant resources on servers with certain
Willy Tarreaucc1e04b2013-09-11 23:20:29 +02008143 protocols.
8144
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008145 - reject :
8146 rejects the response if the condition is true (when used with "if")
8147 or false (when used with "unless"). The first such rule executed ends
Jamie Gloudonaaa21002012-08-25 00:18:33 -04008148 the rules evaluation. Rejected session are immediately closed.
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008149
8150 Note that the "if/unless" condition is optional. If no condition is set on
8151 the action, it is simply performed unconditionally. That can be useful for
8152 for changing the default action to a reject.
8153
Jamie Gloudonaaa21002012-08-25 00:18:33 -04008154 It is perfectly possible to match layer 7 contents with "tcp-response
8155 content" rules, but then it is important to ensure that a full response has
8156 been buffered, otherwise no contents will match. In order to achieve this,
8157 the best solution involves detecting the HTTP protocol during the inspection
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008158 period.
8159
Thierry FOURNIER90da1912015-03-05 11:17:06 +01008160 The "lua" keyword is followed by a Lua function name. It is used to run a Lua
8161 function if the action is executed. The single parameter is the name of the
8162 function to run. The prototype of the function is documented in the API
8163 documentation.
8164
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008165 See section 7 about ACL usage.
8166
8167 See also : "tcp-request content", "tcp-response inspect-delay"
8168
8169
8170tcp-response inspect-delay <timeout>
8171 Set the maximum allowed time to wait for a response during content inspection
8172 May be used in sections : defaults | frontend | listen | backend
8173 no | no | yes | yes
8174 Arguments :
8175 <timeout> is the timeout value specified in milliseconds by default, but
8176 can be in any other unit if the number is suffixed by the unit,
8177 as explained at the top of this document.
8178
8179 See also : "tcp-response content", "tcp-request inspect-delay".
8180
8181
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008182timeout check <timeout>
8183 Set additional check timeout, but only after a connection has been already
8184 established.
8185
8186 May be used in sections: defaults | frontend | listen | backend
8187 yes | no | yes | yes
8188 Arguments:
8189 <timeout> is the timeout value specified in milliseconds by default, but
8190 can be in any other unit if the number is suffixed by the unit,
8191 as explained at the top of this document.
8192
8193 If set, haproxy uses min("timeout connect", "inter") as a connect timeout
8194 for check and "timeout check" as an additional read timeout. The "min" is
8195 used so that people running with *very* long "timeout connect" (eg. those
8196 who needed this due to the queue or tarpit) do not slow down their checks.
Willy Tarreaud7550a22010-02-10 05:10:19 +01008197 (Please also note that there is no valid reason to have such long connect
8198 timeouts, because "timeout queue" and "timeout tarpit" can always be used to
8199 avoid that).
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008200
8201 If "timeout check" is not set haproxy uses "inter" for complete check
8202 timeout (connect + read) exactly like all <1.3.15 version.
8203
8204 In most cases check request is much simpler and faster to handle than normal
8205 requests and people may want to kick out laggy servers so this timeout should
Willy Tarreau41a340d2008-01-22 12:25:31 +01008206 be smaller than "timeout server".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008207
8208 This parameter is specific to backends, but can be specified once for all in
8209 "defaults" sections. This is in fact one of the easiest solutions not to
8210 forget about it.
8211
Willy Tarreau41a340d2008-01-22 12:25:31 +01008212 See also: "timeout connect", "timeout queue", "timeout server",
8213 "timeout tarpit".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008214
8215
Willy Tarreau0ba27502007-12-24 16:55:16 +01008216timeout client <timeout>
8217timeout clitimeout <timeout> (deprecated)
8218 Set the maximum inactivity time on the client side.
8219 May be used in sections : defaults | frontend | listen | backend
8220 yes | yes | yes | no
8221 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01008222 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01008223 can be in any other unit if the number is suffixed by the unit,
8224 as explained at the top of this document.
8225
8226 The inactivity timeout applies when the client is expected to acknowledge or
8227 send data. In HTTP mode, this timeout is particularly important to consider
8228 during the first phase, when the client sends the request, and during the
8229 response while it is reading data sent by the server. The value is specified
8230 in milliseconds by default, but can be in any other unit if the number is
8231 suffixed by the unit, as specified at the top of this document. In TCP mode
8232 (and to a lesser extent, in HTTP mode), it is highly recommended that the
8233 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01008234 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01008235 losses by specifying timeouts that are slightly above multiples of 3 seconds
Willy Tarreauce887fd2012-05-12 12:50:00 +02008236 (eg: 4 or 5 seconds). If some long-lived sessions are mixed with short-lived
8237 sessions (eg: WebSocket and HTTP), it's worth considering "timeout tunnel",
Willy Tarreau05cdd962014-05-10 14:30:07 +02008238 which overrides "timeout client" and "timeout server" for tunnels, as well as
8239 "timeout client-fin" for half-closed connections.
Willy Tarreau0ba27502007-12-24 16:55:16 +01008240
8241 This parameter is specific to frontends, but can be specified once for all in
8242 "defaults" sections. This is in fact one of the easiest solutions not to
8243 forget about it. An unspecified timeout results in an infinite timeout, which
8244 is not recommended. Such a usage is accepted and works but reports a warning
8245 during startup because it may results in accumulation of expired sessions in
8246 the system if the system's timeouts are not configured either.
8247
8248 This parameter replaces the old, deprecated "clitimeout". It is recommended
8249 to use it to write new configurations. The form "timeout clitimeout" is
8250 provided only by backwards compatibility but its use is strongly discouraged.
8251
Willy Tarreauce887fd2012-05-12 12:50:00 +02008252 See also : "clitimeout", "timeout server", "timeout tunnel".
Willy Tarreau0ba27502007-12-24 16:55:16 +01008253
8254
Willy Tarreau05cdd962014-05-10 14:30:07 +02008255timeout client-fin <timeout>
8256 Set the inactivity timeout on the client side for half-closed connections.
8257 May be used in sections : defaults | frontend | listen | backend
8258 yes | yes | yes | no
8259 Arguments :
8260 <timeout> is the timeout value specified in milliseconds by default, but
8261 can be in any other unit if the number is suffixed by the unit,
8262 as explained at the top of this document.
8263
8264 The inactivity timeout applies when the client is expected to acknowledge or
8265 send data while one direction is already shut down. This timeout is different
8266 from "timeout client" in that it only applies to connections which are closed
8267 in one direction. This is particularly useful to avoid keeping connections in
8268 FIN_WAIT state for too long when clients do not disconnect cleanly. This
8269 problem is particularly common long connections such as RDP or WebSocket.
8270 Note that this timeout can override "timeout tunnel" when a connection shuts
8271 down in one direction.
8272
8273 This parameter is specific to frontends, but can be specified once for all in
8274 "defaults" sections. By default it is not set, so half-closed connections
8275 will use the other timeouts (timeout.client or timeout.tunnel).
8276
8277 See also : "timeout client", "timeout server-fin", and "timeout tunnel".
8278
8279
Willy Tarreau0ba27502007-12-24 16:55:16 +01008280timeout connect <timeout>
8281timeout contimeout <timeout> (deprecated)
8282 Set the maximum time to wait for a connection attempt to a server to succeed.
8283 May be used in sections : defaults | frontend | listen | backend
8284 yes | no | yes | yes
8285 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01008286 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01008287 can be in any other unit if the number is suffixed by the unit,
8288 as explained at the top of this document.
8289
8290 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01008291 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreaud72758d2010-01-12 10:42:19 +01008292 cover one or several TCP packet losses by specifying timeouts that are
Willy Tarreau0ba27502007-12-24 16:55:16 +01008293 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008294 connect timeout also presets both queue and tarpit timeouts to the same value
8295 if these have not been specified.
Willy Tarreau0ba27502007-12-24 16:55:16 +01008296
8297 This parameter is specific to backends, but can be specified once for all in
8298 "defaults" sections. This is in fact one of the easiest solutions not to
8299 forget about it. An unspecified timeout results in an infinite timeout, which
8300 is not recommended. Such a usage is accepted and works but reports a warning
8301 during startup because it may results in accumulation of failed sessions in
8302 the system if the system's timeouts are not configured either.
8303
8304 This parameter replaces the old, deprecated "contimeout". It is recommended
8305 to use it to write new configurations. The form "timeout contimeout" is
8306 provided only by backwards compatibility but its use is strongly discouraged.
8307
Willy Tarreau41a340d2008-01-22 12:25:31 +01008308 See also: "timeout check", "timeout queue", "timeout server", "contimeout",
8309 "timeout tarpit".
Willy Tarreau0ba27502007-12-24 16:55:16 +01008310
8311
Willy Tarreaub16a5742010-01-10 14:46:16 +01008312timeout http-keep-alive <timeout>
8313 Set the maximum allowed time to wait for a new HTTP request to appear
8314 May be used in sections : defaults | frontend | listen | backend
8315 yes | yes | yes | yes
8316 Arguments :
8317 <timeout> is the timeout value specified in milliseconds by default, but
8318 can be in any other unit if the number is suffixed by the unit,
8319 as explained at the top of this document.
8320
8321 By default, the time to wait for a new request in case of keep-alive is set
8322 by "timeout http-request". However this is not always convenient because some
8323 people want very short keep-alive timeouts in order to release connections
8324 faster, and others prefer to have larger ones but still have short timeouts
8325 once the request has started to present itself.
8326
8327 The "http-keep-alive" timeout covers these needs. It will define how long to
8328 wait for a new HTTP request to start coming after a response was sent. Once
8329 the first byte of request has been seen, the "http-request" timeout is used
8330 to wait for the complete request to come. Note that empty lines prior to a
8331 new request do not refresh the timeout and are not counted as a new request.
8332
8333 There is also another difference between the two timeouts : when a connection
8334 expires during timeout http-keep-alive, no error is returned, the connection
8335 just closes. If the connection expires in "http-request" while waiting for a
8336 connection to complete, a HTTP 408 error is returned.
8337
8338 In general it is optimal to set this value to a few tens to hundreds of
8339 milliseconds, to allow users to fetch all objects of a page at once but
8340 without waiting for further clicks. Also, if set to a very small value (eg:
8341 1 millisecond) it will probably only accept pipelined requests but not the
8342 non-pipelined ones. It may be a nice trade-off for very large sites running
Patrick Mézard2382ad62010-05-09 10:43:32 +02008343 with tens to hundreds of thousands of clients.
Willy Tarreaub16a5742010-01-10 14:46:16 +01008344
8345 If this parameter is not set, the "http-request" timeout applies, and if both
8346 are not set, "timeout client" still applies at the lower level. It should be
8347 set in the frontend to take effect, unless the frontend is in TCP mode, in
8348 which case the HTTP backend's timeout will be used.
8349
8350 See also : "timeout http-request", "timeout client".
8351
8352
Willy Tarreau036fae02008-01-06 13:24:40 +01008353timeout http-request <timeout>
8354 Set the maximum allowed time to wait for a complete HTTP request
8355 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaucd7afc02009-07-12 10:03:17 +02008356 yes | yes | yes | yes
Willy Tarreau036fae02008-01-06 13:24:40 +01008357 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01008358 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau036fae02008-01-06 13:24:40 +01008359 can be in any other unit if the number is suffixed by the unit,
8360 as explained at the top of this document.
8361
8362 In order to offer DoS protection, it may be required to lower the maximum
8363 accepted time to receive a complete HTTP request without affecting the client
8364 timeout. This helps protecting against established connections on which
8365 nothing is sent. The client timeout cannot offer a good protection against
8366 this abuse because it is an inactivity timeout, which means that if the
8367 attacker sends one character every now and then, the timeout will not
8368 trigger. With the HTTP request timeout, no matter what speed the client
Willy Tarreau2705a612014-05-23 17:38:34 +02008369 types, the request will be aborted if it does not complete in time. When the
8370 timeout expires, an HTTP 408 response is sent to the client to inform it
8371 about the problem, and the connection is closed. The logs will report
8372 termination codes "cR". Some recent browsers are having problems with this
8373 standard, well-documented behaviour, so it might be needed to hide the 408
Willy Tarreau0f228a02015-05-01 15:37:53 +02008374 code using "option http-ignore-probes" or "errorfile 408 /dev/null". See
8375 more details in the explanations of the "cR" termination code in section 8.5.
Willy Tarreau036fae02008-01-06 13:24:40 +01008376
8377 Note that this timeout only applies to the header part of the request, and
8378 not to any data. As soon as the empty line is received, this timeout is not
Willy Tarreaub16a5742010-01-10 14:46:16 +01008379 used anymore. It is used again on keep-alive connections to wait for a second
8380 request if "timeout http-keep-alive" is not set.
Willy Tarreau036fae02008-01-06 13:24:40 +01008381
8382 Generally it is enough to set it to a few seconds, as most clients send the
8383 full request immediately upon connection. Add 3 or more seconds to cover TCP
8384 retransmits but that's all. Setting it to very low values (eg: 50 ms) will
8385 generally work on local networks as long as there are no packet losses. This
8386 will prevent people from sending bare HTTP requests using telnet.
8387
8388 If this parameter is not set, the client timeout still applies between each
Willy Tarreaucd7afc02009-07-12 10:03:17 +02008389 chunk of the incoming request. It should be set in the frontend to take
8390 effect, unless the frontend is in TCP mode, in which case the HTTP backend's
8391 timeout will be used.
Willy Tarreau036fae02008-01-06 13:24:40 +01008392
Willy Tarreau0f228a02015-05-01 15:37:53 +02008393 See also : "errorfile", "http-ignore-probes", "timeout http-keep-alive", and
8394 "timeout client".
Willy Tarreau036fae02008-01-06 13:24:40 +01008395
Willy Tarreau844e3c52008-01-11 16:28:18 +01008396
8397timeout queue <timeout>
8398 Set the maximum time to wait in the queue for a connection slot to be free
8399 May be used in sections : defaults | frontend | listen | backend
8400 yes | no | yes | yes
8401 Arguments :
8402 <timeout> is the timeout value specified in milliseconds by default, but
8403 can be in any other unit if the number is suffixed by the unit,
8404 as explained at the top of this document.
8405
8406 When a server's maxconn is reached, connections are left pending in a queue
8407 which may be server-specific or global to the backend. In order not to wait
8408 indefinitely, a timeout is applied to requests pending in the queue. If the
8409 timeout is reached, it is considered that the request will almost never be
8410 served, so it is dropped and a 503 error is returned to the client.
8411
8412 The "timeout queue" statement allows to fix the maximum time for a request to
8413 be left pending in a queue. If unspecified, the same value as the backend's
8414 connection timeout ("timeout connect") is used, for backwards compatibility
8415 with older versions with no "timeout queue" parameter.
8416
8417 See also : "timeout connect", "contimeout".
8418
8419
8420timeout server <timeout>
8421timeout srvtimeout <timeout> (deprecated)
8422 Set the maximum inactivity time on the server side.
8423 May be used in sections : defaults | frontend | listen | backend
8424 yes | no | yes | yes
8425 Arguments :
8426 <timeout> is the timeout value specified in milliseconds by default, but
8427 can be in any other unit if the number is suffixed by the unit,
8428 as explained at the top of this document.
8429
8430 The inactivity timeout applies when the server is expected to acknowledge or
8431 send data. In HTTP mode, this timeout is particularly important to consider
8432 during the first phase of the server's response, when it has to send the
8433 headers, as it directly represents the server's processing time for the
8434 request. To find out what value to put there, it's often good to start with
8435 what would be considered as unacceptable response times, then check the logs
8436 to observe the response time distribution, and adjust the value accordingly.
8437
8438 The value is specified in milliseconds by default, but can be in any other
8439 unit if the number is suffixed by the unit, as specified at the top of this
8440 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
8441 recommended that the client timeout remains equal to the server timeout in
8442 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01008443 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01008444 packet losses by specifying timeouts that are slightly above multiples of 3
Willy Tarreauce887fd2012-05-12 12:50:00 +02008445 seconds (eg: 4 or 5 seconds minimum). If some long-lived sessions are mixed
8446 with short-lived sessions (eg: WebSocket and HTTP), it's worth considering
8447 "timeout tunnel", which overrides "timeout client" and "timeout server" for
8448 tunnels.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008449
8450 This parameter is specific to backends, but can be specified once for all in
8451 "defaults" sections. This is in fact one of the easiest solutions not to
8452 forget about it. An unspecified timeout results in an infinite timeout, which
8453 is not recommended. Such a usage is accepted and works but reports a warning
8454 during startup because it may results in accumulation of expired sessions in
8455 the system if the system's timeouts are not configured either.
8456
8457 This parameter replaces the old, deprecated "srvtimeout". It is recommended
8458 to use it to write new configurations. The form "timeout srvtimeout" is
8459 provided only by backwards compatibility but its use is strongly discouraged.
8460
Willy Tarreauce887fd2012-05-12 12:50:00 +02008461 See also : "srvtimeout", "timeout client" and "timeout tunnel".
Willy Tarreau844e3c52008-01-11 16:28:18 +01008462
Willy Tarreau05cdd962014-05-10 14:30:07 +02008463
8464timeout server-fin <timeout>
8465 Set the inactivity timeout on the server side for half-closed connections.
8466 May be used in sections : defaults | frontend | listen | backend
8467 yes | no | yes | yes
8468 Arguments :
8469 <timeout> is the timeout value specified in milliseconds by default, but
8470 can be in any other unit if the number is suffixed by the unit,
8471 as explained at the top of this document.
8472
8473 The inactivity timeout applies when the server is expected to acknowledge or
8474 send data while one direction is already shut down. This timeout is different
8475 from "timeout server" in that it only applies to connections which are closed
8476 in one direction. This is particularly useful to avoid keeping connections in
8477 FIN_WAIT state for too long when a remote server does not disconnect cleanly.
8478 This problem is particularly common long connections such as RDP or WebSocket.
8479 Note that this timeout can override "timeout tunnel" when a connection shuts
8480 down in one direction. This setting was provided for completeness, but in most
8481 situations, it should not be needed.
8482
8483 This parameter is specific to backends, but can be specified once for all in
8484 "defaults" sections. By default it is not set, so half-closed connections
8485 will use the other timeouts (timeout.server or timeout.tunnel).
8486
8487 See also : "timeout client-fin", "timeout server", and "timeout tunnel".
8488
Willy Tarreau844e3c52008-01-11 16:28:18 +01008489
8490timeout tarpit <timeout>
Cyril Bonté78caf842010-03-10 22:41:43 +01008491 Set the duration for which tarpitted connections will be maintained
Willy Tarreau844e3c52008-01-11 16:28:18 +01008492 May be used in sections : defaults | frontend | listen | backend
8493 yes | yes | yes | yes
8494 Arguments :
8495 <timeout> is the tarpit duration specified in milliseconds by default, but
8496 can be in any other unit if the number is suffixed by the unit,
8497 as explained at the top of this document.
8498
8499 When a connection is tarpitted using "reqtarpit", it is maintained open with
8500 no activity for a certain amount of time, then closed. "timeout tarpit"
8501 defines how long it will be maintained open.
8502
8503 The value is specified in milliseconds by default, but can be in any other
8504 unit if the number is suffixed by the unit, as specified at the top of this
8505 document. If unspecified, the same value as the backend's connection timeout
8506 ("timeout connect") is used, for backwards compatibility with older versions
Cyril Bonté78caf842010-03-10 22:41:43 +01008507 with no "timeout tarpit" parameter.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008508
8509 See also : "timeout connect", "contimeout".
8510
8511
Willy Tarreauce887fd2012-05-12 12:50:00 +02008512timeout tunnel <timeout>
8513 Set the maximum inactivity time on the client and server side for tunnels.
8514 May be used in sections : defaults | frontend | listen | backend
8515 yes | no | yes | yes
8516 Arguments :
8517 <timeout> is the timeout value specified in milliseconds by default, but
8518 can be in any other unit if the number is suffixed by the unit,
8519 as explained at the top of this document.
8520
Jamie Gloudonaaa21002012-08-25 00:18:33 -04008521 The tunnel timeout applies when a bidirectional connection is established
Willy Tarreauce887fd2012-05-12 12:50:00 +02008522 between a client and a server, and the connection remains inactive in both
8523 directions. This timeout supersedes both the client and server timeouts once
8524 the connection becomes a tunnel. In TCP, this timeout is used as soon as no
8525 analyser remains attached to either connection (eg: tcp content rules are
8526 accepted). In HTTP, this timeout is used when a connection is upgraded (eg:
8527 when switching to the WebSocket protocol, or forwarding a CONNECT request
8528 to a proxy), or after the first response when no keepalive/close option is
8529 specified.
8530
Willy Tarreau05cdd962014-05-10 14:30:07 +02008531 Since this timeout is usually used in conjunction with long-lived connections,
8532 it usually is a good idea to also set "timeout client-fin" to handle the
8533 situation where a client suddenly disappears from the net and does not
8534 acknowledge a close, or sends a shutdown and does not acknowledge pending
8535 data anymore. This can happen in lossy networks where firewalls are present,
8536 and is detected by the presence of large amounts of sessions in a FIN_WAIT
8537 state.
8538
Willy Tarreauce887fd2012-05-12 12:50:00 +02008539 The value is specified in milliseconds by default, but can be in any other
8540 unit if the number is suffixed by the unit, as specified at the top of this
8541 document. Whatever the expected normal idle time, it is a good practice to
8542 cover at least one or several TCP packet losses by specifying timeouts that
8543 are slightly above multiples of 3 seconds (eg: 4 or 5 seconds minimum).
8544
8545 This parameter is specific to backends, but can be specified once for all in
8546 "defaults" sections. This is in fact one of the easiest solutions not to
8547 forget about it.
8548
8549 Example :
8550 defaults http
8551 option http-server-close
8552 timeout connect 5s
8553 timeout client 30s
Willy Tarreau05cdd962014-05-10 14:30:07 +02008554 timeout client-fin 30s
Willy Tarreauce887fd2012-05-12 12:50:00 +02008555 timeout server 30s
8556 timeout tunnel 1h # timeout to use with WebSocket and CONNECT
8557
Willy Tarreau05cdd962014-05-10 14:30:07 +02008558 See also : "timeout client", "timeout client-fin", "timeout server".
Willy Tarreauce887fd2012-05-12 12:50:00 +02008559
8560
Willy Tarreau844e3c52008-01-11 16:28:18 +01008561transparent (deprecated)
8562 Enable client-side transparent proxying
8563 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau4b1f8592008-12-23 23:13:55 +01008564 yes | no | yes | yes
Willy Tarreau844e3c52008-01-11 16:28:18 +01008565 Arguments : none
8566
8567 This keyword was introduced in order to provide layer 7 persistence to layer
8568 3 load balancers. The idea is to use the OS's ability to redirect an incoming
8569 connection for a remote address to a local process (here HAProxy), and let
8570 this process know what address was initially requested. When this option is
8571 used, sessions without cookies will be forwarded to the original destination
8572 IP address of the incoming request (which should match that of another
8573 equipment), while requests with cookies will still be forwarded to the
8574 appropriate server.
8575
8576 The "transparent" keyword is deprecated, use "option transparent" instead.
8577
8578 Note that contrary to a common belief, this option does NOT make HAProxy
8579 present the client's IP to the server when establishing the connection.
8580
Willy Tarreau844e3c52008-01-11 16:28:18 +01008581 See also: "option transparent"
8582
William Lallemanda73203e2012-03-12 12:48:57 +01008583unique-id-format <string>
8584 Generate a unique ID for each request.
8585 May be used in sections : defaults | frontend | listen | backend
8586 yes | yes | yes | no
8587 Arguments :
8588 <string> is a log-format string.
8589
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008590 This keyword creates a ID for each request using the custom log format. A
8591 unique ID is useful to trace a request passing through many components of
8592 a complex infrastructure. The newly created ID may also be logged using the
8593 %ID tag the log-format string.
William Lallemanda73203e2012-03-12 12:48:57 +01008594
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008595 The format should be composed from elements that are guaranteed to be
8596 unique when combined together. For instance, if multiple haproxy instances
8597 are involved, it might be important to include the node name. It is often
8598 needed to log the incoming connection's source and destination addresses
8599 and ports. Note that since multiple requests may be performed over the same
8600 connection, including a request counter may help differentiate them.
8601 Similarly, a timestamp may protect against a rollover of the counter.
8602 Logging the process ID will avoid collisions after a service restart.
William Lallemanda73203e2012-03-12 12:48:57 +01008603
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008604 It is recommended to use hexadecimal notation for many fields since it
8605 makes them more compact and saves space in logs.
William Lallemanda73203e2012-03-12 12:48:57 +01008606
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008607 Example:
William Lallemanda73203e2012-03-12 12:48:57 +01008608
Julien Vehentf21be322014-03-07 08:27:34 -05008609 unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
William Lallemanda73203e2012-03-12 12:48:57 +01008610
8611 will generate:
8612
8613 7F000001:8296_7F00001E:1F90_4F7B0A69_0003:790A
8614
8615 See also: "unique-id-header"
8616
8617unique-id-header <name>
8618 Add a unique ID header in the HTTP request.
8619 May be used in sections : defaults | frontend | listen | backend
8620 yes | yes | yes | no
8621 Arguments :
8622 <name> is the name of the header.
8623
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008624 Add a unique-id header in the HTTP request sent to the server, using the
8625 unique-id-format. It can't work if the unique-id-format doesn't exist.
William Lallemanda73203e2012-03-12 12:48:57 +01008626
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008627 Example:
William Lallemanda73203e2012-03-12 12:48:57 +01008628
Julien Vehentf21be322014-03-07 08:27:34 -05008629 unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
William Lallemanda73203e2012-03-12 12:48:57 +01008630 unique-id-header X-Unique-ID
8631
8632 will generate:
8633
8634 X-Unique-ID: 7F000001:8296_7F00001E:1F90_4F7B0A69_0003:790A
8635
8636 See also: "unique-id-format"
Willy Tarreau844e3c52008-01-11 16:28:18 +01008637
Willy Tarreauf51658d2014-04-23 01:21:56 +02008638use_backend <backend> [{if | unless} <condition>]
Willy Tarreau1d0dfb12009-07-07 15:10:31 +02008639 Switch to a specific backend if/unless an ACL-based condition is matched.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008640 May be used in sections : defaults | frontend | listen | backend
8641 no | yes | yes | no
8642 Arguments :
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01008643 <backend> is the name of a valid backend or "listen" section, or a
8644 "log-format" string resolving to a backend name.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008645
Willy Tarreauf51658d2014-04-23 01:21:56 +02008646 <condition> is a condition composed of ACLs, as described in section 7. If
8647 it is omitted, the rule is unconditionally applied.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008648
8649 When doing content-switching, connections arrive on a frontend and are then
8650 dispatched to various backends depending on a number of conditions. The
8651 relation between the conditions and the backends is described with the
Willy Tarreau1d0dfb12009-07-07 15:10:31 +02008652 "use_backend" keyword. While it is normally used with HTTP processing, it can
8653 also be used in pure TCP, either without content using stateless ACLs (eg:
8654 source address validation) or combined with a "tcp-request" rule to wait for
8655 some payload.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008656
8657 There may be as many "use_backend" rules as desired. All of these rules are
8658 evaluated in their declaration order, and the first one which matches will
8659 assign the backend.
8660
8661 In the first form, the backend will be used if the condition is met. In the
8662 second form, the backend will be used if the condition is not met. If no
8663 condition is valid, the backend defined with "default_backend" will be used.
8664 If no default backend is defined, either the servers in the same section are
8665 used (in case of a "listen" section) or, in case of a frontend, no server is
8666 used and a 503 service unavailable response is returned.
8667
Willy Tarreau51aecc72009-07-12 09:47:04 +02008668 Note that it is possible to switch from a TCP frontend to an HTTP backend. In
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01008669 this case, either the frontend has already checked that the protocol is HTTP,
Willy Tarreau51aecc72009-07-12 09:47:04 +02008670 and backend processing will immediately follow, or the backend will wait for
8671 a complete HTTP request to get in. This feature is useful when a frontend
8672 must decode several protocols on a unique port, one of them being HTTP.
8673
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01008674 When <backend> is a simple name, it is resolved at configuration time, and an
8675 error is reported if the specified backend does not exist. If <backend> is
8676 a log-format string instead, no check may be done at configuration time, so
8677 the backend name is resolved dynamically at run time. If the resulting
8678 backend name does not correspond to any valid backend, no other rule is
8679 evaluated, and the default_backend directive is applied instead. Note that
8680 when using dynamic backend names, it is highly recommended to use a prefix
8681 that no other backend uses in order to ensure that an unauthorized backend
8682 cannot be forced from the request.
8683
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008684 It is worth mentioning that "use_backend" rules with an explicit name are
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01008685 used to detect the association between frontends and backends to compute the
8686 backend's "fullconn" setting. This cannot be done for dynamic names.
8687
8688 See also: "default_backend", "tcp-request", "fullconn", "log-format", and
8689 section 7 about ACLs.
Willy Tarreaud72758d2010-01-12 10:42:19 +01008690
Willy Tarreau036fae02008-01-06 13:24:40 +01008691
Willy Tarreau4a5cade2012-04-05 21:09:48 +02008692use-server <server> if <condition>
8693use-server <server> unless <condition>
8694 Only use a specific server if/unless an ACL-based condition is matched.
8695 May be used in sections : defaults | frontend | listen | backend
8696 no | no | yes | yes
8697 Arguments :
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008698 <server> is the name of a valid server in the same backend section.
Willy Tarreau4a5cade2012-04-05 21:09:48 +02008699
8700 <condition> is a condition composed of ACLs, as described in section 7.
8701
8702 By default, connections which arrive to a backend are load-balanced across
8703 the available servers according to the configured algorithm, unless a
8704 persistence mechanism such as a cookie is used and found in the request.
8705
8706 Sometimes it is desirable to forward a particular request to a specific
8707 server without having to declare a dedicated backend for this server. This
8708 can be achieved using the "use-server" rules. These rules are evaluated after
8709 the "redirect" rules and before evaluating cookies, and they have precedence
8710 on them. There may be as many "use-server" rules as desired. All of these
8711 rules are evaluated in their declaration order, and the first one which
8712 matches will assign the server.
8713
8714 If a rule designates a server which is down, and "option persist" is not used
8715 and no force-persist rule was validated, it is ignored and evaluation goes on
8716 with the next rules until one matches.
8717
8718 In the first form, the server will be used if the condition is met. In the
8719 second form, the server will be used if the condition is not met. If no
8720 condition is valid, the processing continues and the server will be assigned
8721 according to other persistence mechanisms.
8722
8723 Note that even if a rule is matched, cookie processing is still performed but
8724 does not assign the server. This allows prefixed cookies to have their prefix
8725 stripped.
8726
8727 The "use-server" statement works both in HTTP and TCP mode. This makes it
8728 suitable for use with content-based inspection. For instance, a server could
8729 be selected in a farm according to the TLS SNI field. And if these servers
8730 have their weight set to zero, they will not be used for other traffic.
8731
8732 Example :
8733 # intercept incoming TLS requests based on the SNI field
8734 use-server www if { req_ssl_sni -i www.example.com }
8735 server www 192.168.0.1:443 weight 0
8736 use-server mail if { req_ssl_sni -i mail.example.com }
8737 server mail 192.168.0.1:587 weight 0
8738 use-server imap if { req_ssl_sni -i imap.example.com }
8739 server mail 192.168.0.1:993 weight 0
8740 # all the rest is forwarded to this server
8741 server default 192.168.0.2:443 check
8742
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008743 See also: "use_backend", section 5 about server and section 7 about ACLs.
Willy Tarreau4a5cade2012-04-05 21:09:48 +02008744
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008745
87465. Bind and Server options
8747--------------------------
8748
8749The "bind", "server" and "default-server" keywords support a number of settings
8750depending on some build options and on the system HAProxy was built on. These
8751settings generally each consist in one word sometimes followed by a value,
8752written on the same line as the "bind" or "server" line. All these options are
8753described in this section.
8754
8755
87565.1. Bind options
8757-----------------
8758
8759The "bind" keyword supports a certain number of settings which are all passed
8760as arguments on the same line. The order in which those arguments appear makes
8761no importance, provided that they appear after the bind address. All of these
8762parameters are optional. Some of them consist in a single words (booleans),
8763while other ones expect a value after them. In this case, the value must be
8764provided immediately after the setting name.
8765
8766The currently supported settings are the following ones.
8767
8768accept-proxy
8769 Enforces the use of the PROXY protocol over any connection accepted by any of
Willy Tarreau77992672014-06-14 11:06:17 +02008770 the sockets declared on the same line. Versions 1 and 2 of the PROXY protocol
8771 are supported and correctly detected. The PROXY protocol dictates the layer
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008772 3/4 addresses of the incoming connection to be used everywhere an address is
8773 used, with the only exception of "tcp-request connection" rules which will
8774 only see the real connection address. Logs will reflect the addresses
8775 indicated in the protocol, unless it is violated, in which case the real
8776 address will still be used. This keyword combined with support from external
8777 components can be used as an efficient and reliable alternative to the
8778 X-Forwarded-For mechanism which is not always reliable and not even always
Willy Tarreau4f0d9192013-06-11 20:40:55 +02008779 usable. See also "tcp-request connection expect-proxy" for a finer-grained
8780 setting of which client is allowed to use the protocol.
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008781
Willy Tarreauab861d32013-04-02 02:30:41 +02008782alpn <protocols>
8783 This enables the TLS ALPN extension and advertises the specified protocol
8784 list as supported on top of ALPN. The protocol list consists in a comma-
8785 delimited list of protocol names, for instance: "http/1.1,http/1.0" (without
8786 quotes). This requires that the SSL library is build with support for TLS
8787 extensions enabled (check with haproxy -vv). The ALPN extension replaces the
8788 initial NPN extension.
8789
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008790backlog <backlog>
8791 Sets the socket's backlog to this value. If unspecified, the frontend's
8792 backlog is used instead, which generally defaults to the maxconn value.
8793
Emeric Brun7fb34422012-09-28 15:26:15 +02008794ecdhe <named curve>
8795 This setting is only available when support for OpenSSL was built in. It sets
Emeric Brun6924ef82013-03-06 14:08:53 +01008796 the named curve (RFC 4492) used to generate ECDH ephemeral keys. By default,
8797 used named curve is prime256v1.
Emeric Brun7fb34422012-09-28 15:26:15 +02008798
Emeric Brunfd33a262012-10-11 16:28:27 +02008799ca-file <cafile>
Emeric Brun1a073b42012-09-28 17:07:34 +02008800 This setting is only available when support for OpenSSL was built in. It
8801 designates a PEM file from which to load CA certificates used to verify
8802 client's certificate.
8803
Emeric Brunb6dc9342012-09-28 17:55:37 +02008804ca-ignore-err [all|<errorID>,...]
8805 This setting is only available when support for OpenSSL was built in.
8806 Sets a comma separated list of errorIDs to ignore during verify at depth > 0.
8807 If set to 'all', all errors are ignored. SSL handshake is not aborted if an
8808 error is ignored.
8809
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008810ciphers <ciphers>
8811 This setting is only available when support for OpenSSL was built in. It sets
8812 the string describing the list of cipher algorithms ("cipher suite") that are
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008813 negotiated during the SSL/TLS handshake. The format of the string is defined
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008814 in "man 1 ciphers" from OpenSSL man pages, and can be for instance a string
8815 such as "AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH" (without quotes).
8816
Emeric Brunfd33a262012-10-11 16:28:27 +02008817crl-file <crlfile>
Emeric Brun1a073b42012-09-28 17:07:34 +02008818 This setting is only available when support for OpenSSL was built in. It
8819 designates a PEM file from which to load certificate revocation list used
8820 to verify client's certificate.
8821
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008822crt <cert>
Alex Davies0fbf0162013-03-02 16:04:50 +00008823 This setting is only available when support for OpenSSL was built in. It
8824 designates a PEM file containing both the required certificates and any
8825 associated private keys. This file can be built by concatenating multiple
8826 PEM files into one (e.g. cat cert.pem key.pem > combined.pem). If your CA
8827 requires an intermediate certificate, this can also be concatenated into this
8828 file.
8829
8830 If the OpenSSL used supports Diffie-Hellman, parameters present in this file
8831 are loaded.
8832
8833 If a directory name is used instead of a PEM file, then all files found in
Cyril Bonté3180f7b2015-01-25 00:16:08 +01008834 that directory will be loaded in alphabetic order unless their name ends with
Janusz Dziemidowicz2c701b52015-03-07 23:03:59 +01008835 '.issuer', '.ocsp' or '.sctl' (reserved extensions). This directive may be
8836 specified multiple times in order to load certificates from multiple files or
8837 directories. The certificates will be presented to clients who provide a
8838 valid TLS Server Name Indication field matching one of their CN or alt
8839 subjects. Wildcards are supported, where a wildcard character '*' is used
8840 instead of the first hostname component (eg: *.example.org matches
8841 www.example.org but not www.sub.example.org).
Alex Davies0fbf0162013-03-02 16:04:50 +00008842
8843 If no SNI is provided by the client or if the SSL library does not support
8844 TLS extensions, or if the client provides an SNI hostname which does not
8845 match any certificate, then the first loaded certificate will be presented.
8846 This means that when loading certificates from a directory, it is highly
Cyril Bonté3180f7b2015-01-25 00:16:08 +01008847 recommended to load the default one first as a file or to ensure that it will
8848 always be the first one in the directory.
Alex Davies0fbf0162013-03-02 16:04:50 +00008849
Emeric Brune032bfa2012-09-28 13:01:45 +02008850 Note that the same cert may be loaded multiple times without side effects.
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008851
Alex Davies0fbf0162013-03-02 16:04:50 +00008852 Some CAs (such as Godaddy) offer a drop down list of server types that do not
8853 include HAProxy when obtaining a certificate. If this happens be sure to
Godbach8bf60a12014-04-21 21:42:41 +08008854 choose a webserver that the CA believes requires an intermediate CA (for
Alex Davies0fbf0162013-03-02 16:04:50 +00008855 Godaddy, selection Apache Tomcat will get the correct bundle, but many
8856 others, e.g. nginx, result in a wrong bundle that will not work for some
8857 clients).
8858
Emeric Brun4147b2e2014-06-16 18:36:30 +02008859 For each PEM file, haproxy checks for the presence of file at the same path
8860 suffixed by ".ocsp". If such file is found, support for the TLS Certificate
8861 Status Request extension (also known as "OCSP stapling") is automatically
8862 enabled. The content of this file is optional. If not empty, it must contain
8863 a valid OCSP Response in DER format. In order to be valid an OCSP Response
8864 must comply with the following rules: it has to indicate a good status,
8865 it has to be a single response for the certificate of the PEM file, and it
8866 has to be valid at the moment of addition. If these rules are not respected
8867 the OCSP Response is ignored and a warning is emitted. In order to identify
8868 which certificate an OCSP Response applies to, the issuer's certificate is
8869 necessary. If the issuer's certificate is not found in the PEM file, it will
8870 be loaded from a file at the same path as the PEM file suffixed by ".issuer"
8871 if it exists otherwise it will fail with an error.
8872
Janusz Dziemidowicz2c701b52015-03-07 23:03:59 +01008873 For each PEM file, haproxy also checks for the presence of file at the same
8874 path suffixed by ".sctl". If such file is found, support for Certificate
8875 Transparency (RFC6962) TLS extension is enabled. The file must contain a
8876 valid Signed Certificate Timestamp List, as described in RFC. File is parsed
8877 to check basic syntax, but no signatures are verified.
8878
Emeric Brunb6dc9342012-09-28 17:55:37 +02008879crt-ignore-err <errors>
Alex Davies0fbf0162013-03-02 16:04:50 +00008880 This setting is only available when support for OpenSSL was built in. Sets a
8881 comma separated list of errorIDs to ignore during verify at depth == 0. If
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008882 set to 'all', all errors are ignored. SSL handshake is not aborted if an error
Alex Davies0fbf0162013-03-02 16:04:50 +00008883 is ignored.
Emeric Brunb6dc9342012-09-28 17:55:37 +02008884
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01008885crt-list <file>
8886 This setting is only available when support for OpenSSL was built in. It
Emmanuel Hocdet7c41a1b2013-05-07 20:20:06 +02008887 designates a list of PEM file with an optional list of SNI filter per
8888 certificate, with the following format for each line :
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01008889
Emmanuel Hocdet7c41a1b2013-05-07 20:20:06 +02008890 <crtfile> [[!]<snifilter> ...]
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01008891
Emmanuel Hocdet7c41a1b2013-05-07 20:20:06 +02008892 Wildcards are supported in the SNI filter. Negative filter are also supported,
8893 only useful in combination with a wildcard filter to exclude a particular SNI.
8894 The certificates will be presented to clients who provide a valid TLS Server
8895 Name Indication field matching one of the SNI filters. If no SNI filter is
8896 specified, the CN and alt subjects are used. This directive may be specified
8897 multiple times. See the "crt" option for more information. The default
8898 certificate is still needed to meet OpenSSL expectations. If it is not used,
8899 the 'strict-sni' option may be used.
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01008900
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008901defer-accept
8902 Is an optional keyword which is supported only on certain Linux kernels. It
8903 states that a connection will only be accepted once some data arrive on it,
8904 or at worst after the first retransmit. This should be used only on protocols
8905 for which the client talks first (eg: HTTP). It can slightly improve
8906 performance by ensuring that most of the request is already available when
8907 the connection is accepted. On the other hand, it will not be able to detect
8908 connections which don't talk. It is important to note that this option is
8909 broken in all kernels up to 2.6.31, as the connection is never accepted until
8910 the client talks. This can cause issues with front firewalls which would see
8911 an established connection while the proxy will only see it in SYN_RECV. This
8912 option is only supported on TCPv4/TCPv6 sockets and ignored by other ones.
8913
Emeric Brun2cb7ae52012-10-05 14:14:21 +02008914force-sslv3
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008915 This option enforces use of SSLv3 only on SSL connections instantiated from
Emeric Brun2cb7ae52012-10-05 14:14:21 +02008916 this listener. SSLv3 is generally less expensive than the TLS counterparts
Emeric Brun2c86cbf2014-10-30 15:56:50 +01008917 for high connection rates. This option is also available on global statement
8918 "ssl-default-bind-options". See also "no-tlsv*" and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02008919
8920force-tlsv10
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008921 This option enforces use of TLSv1.0 only on SSL connections instantiated from
Emeric Brun2c86cbf2014-10-30 15:56:50 +01008922 this listener. This option is also available on global statement
8923 "ssl-default-bind-options". See also "no-tlsv*" and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02008924
8925force-tlsv11
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008926 This option enforces use of TLSv1.1 only on SSL connections instantiated from
Emeric Brun2c86cbf2014-10-30 15:56:50 +01008927 this listener. This option is also available on global statement
8928 "ssl-default-bind-options". See also "no-tlsv*", and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02008929
8930force-tlsv12
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008931 This option enforces use of TLSv1.2 only on SSL connections instantiated from
Emeric Brun2c86cbf2014-10-30 15:56:50 +01008932 this listener. This option is also available on global statement
8933 "ssl-default-bind-options". See also "no-tlsv*", and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02008934
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008935gid <gid>
8936 Sets the group of the UNIX sockets to the designated system gid. It can also
8937 be set by default in the global section's "unix-bind" statement. Note that
8938 some platforms simply ignore this. This setting is equivalent to the "group"
8939 setting except that the group ID is used instead of its name. This setting is
8940 ignored by non UNIX sockets.
8941
8942group <group>
8943 Sets the group of the UNIX sockets to the designated system group. It can
8944 also be set by default in the global section's "unix-bind" statement. Note
8945 that some platforms simply ignore this. This setting is equivalent to the
8946 "gid" setting except that the group name is used instead of its gid. This
8947 setting is ignored by non UNIX sockets.
8948
8949id <id>
8950 Fixes the socket ID. By default, socket IDs are automatically assigned, but
8951 sometimes it is more convenient to fix them to ease monitoring. This value
8952 must be strictly positive and unique within the listener/frontend. This
8953 option can only be used when defining only a single socket.
8954
8955interface <interface>
Lukas Tribusfce2e962013-02-12 22:13:19 +01008956 Restricts the socket to a specific interface. When specified, only packets
8957 received from that particular interface are processed by the socket. This is
8958 currently only supported on Linux. The interface must be a primary system
8959 interface, not an aliased interface. It is also possible to bind multiple
8960 frontends to the same address if they are bound to different interfaces. Note
8961 that binding to a network interface requires root privileges. This parameter
8962 is only compatible with TCPv4/TCPv6 sockets.
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008963
Willy Tarreauabb175f2012-09-24 12:43:26 +02008964level <level>
8965 This setting is used with the stats sockets only to restrict the nature of
8966 the commands that can be issued on the socket. It is ignored by other
8967 sockets. <level> can be one of :
8968 - "user" is the least privileged level ; only non-sensitive stats can be
8969 read, and no change is allowed. It would make sense on systems where it
8970 is not easy to restrict access to the socket.
8971 - "operator" is the default level and fits most common uses. All data can
8972 be read, and only non-sensitive changes are permitted (eg: clear max
8973 counters).
8974 - "admin" should be used with care, as everything is permitted (eg: clear
8975 all counters).
8976
Willy Tarreaub6205fd2012-09-24 12:27:33 +02008977maxconn <maxconn>
8978 Limits the sockets to this number of concurrent connections. Extraneous
8979 connections will remain in the system's backlog until a connection is
8980 released. If unspecified, the limit will be the same as the frontend's
8981 maxconn. Note that in case of port ranges or multiple addresses, the same
8982 value will be applied to each socket. This setting enables different
8983 limitations on expensive sockets, for instance SSL entries which may easily
8984 eat all memory.
8985
8986mode <mode>
8987 Sets the octal mode used to define access permissions on the UNIX socket. It
8988 can also be set by default in the global section's "unix-bind" statement.
8989 Note that some platforms simply ignore this. This setting is ignored by non
8990 UNIX sockets.
8991
8992mss <maxseg>
8993 Sets the TCP Maximum Segment Size (MSS) value to be advertised on incoming
8994 connections. This can be used to force a lower MSS for certain specific
8995 ports, for instance for connections passing through a VPN. Note that this
8996 relies on a kernel feature which is theoretically supported under Linux but
8997 was buggy in all versions prior to 2.6.28. It may or may not work on other
8998 operating systems. It may also not change the advertised value but change the
8999 effective size of outgoing segments. The commonly advertised value for TCPv4
9000 over Ethernet networks is 1460 = 1500(MTU) - 40(IP+TCP). If this value is
9001 positive, it will be used as the advertised MSS. If it is negative, it will
9002 indicate by how much to reduce the incoming connection's advertised MSS for
9003 outgoing segments. This parameter is only compatible with TCP v4/v6 sockets.
9004
9005name <name>
9006 Sets an optional name for these sockets, which will be reported on the stats
9007 page.
9008
9009nice <nice>
9010 Sets the 'niceness' of connections initiated from the socket. Value must be
9011 in the range -1024..1024 inclusive, and defaults to zero. Positive values
9012 means that such connections are more friendly to others and easily offer
9013 their place in the scheduler. On the opposite, negative values mean that
9014 connections want to run with a higher priority than others. The difference
9015 only happens under high loads when the system is close to saturation.
9016 Negative values are appropriate for low-latency or administration services,
9017 and high values are generally recommended for CPU intensive tasks such as SSL
9018 processing or bulk transfers which are less sensible to latency. For example,
9019 it may make sense to use a positive value for an SMTP socket and a negative
9020 one for an RDP socket.
9021
Emeric Brun9b3009b2012-10-05 11:55:06 +02009022no-sslv3
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009023 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009024 disables support for SSLv3 on any sockets instantiated from the listener when
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009025 SSL is supported. Note that SSLv2 is forced disabled in the code and cannot
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009026 be enabled using any configuration option. This option is also available on
9027 global statement "ssl-default-bind-options". See also "force-tls*",
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009028 and "force-sslv3".
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009029
Emeric Brun90ad8722012-10-02 14:00:59 +02009030no-tls-tickets
9031 This setting is only available when support for OpenSSL was built in. It
9032 disables the stateless session resumption (RFC 5077 TLS Ticket
9033 extension) and force to use stateful session resumption. Stateless
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009034 session resumption is more expensive in CPU usage. This option is also
9035 available on global statement "ssl-default-bind-options".
Emeric Brun90ad8722012-10-02 14:00:59 +02009036
Emeric Brun9b3009b2012-10-05 11:55:06 +02009037no-tlsv10
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009038 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009039 disables support for TLSv1.0 on any sockets instantiated from the listener
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009040 when SSL is supported. Note that SSLv2 is forced disabled in the code and
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009041 cannot be enabled using any configuration option. This option is also
9042 available on global statement "ssl-default-bind-options". See also
9043 "force-tlsv*", and "force-sslv3".
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009044
Emeric Brun9b3009b2012-10-05 11:55:06 +02009045no-tlsv11
Emeric Brunf5da4932012-09-28 19:42:54 +02009046 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009047 disables support for TLSv1.1 on any sockets instantiated from the listener
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009048 when SSL is supported. Note that SSLv2 is forced disabled in the code and
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009049 cannot be enabled using any configuration option. This option is also
9050 available on global statement "ssl-default-bind-options". See also
9051 "force-tlsv*", and "force-sslv3".
Emeric Brunf5da4932012-09-28 19:42:54 +02009052
Emeric Brun9b3009b2012-10-05 11:55:06 +02009053no-tlsv12
Emeric Brunf5da4932012-09-28 19:42:54 +02009054 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009055 disables support for TLSv1.2 on any sockets instantiated from the listener
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009056 when SSL is supported. Note that SSLv2 is forced disabled in the code and
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009057 cannot be enabled using any configuration option. This option is also
9058 available on global statement "ssl-default-bind-options". See also
9059 "force-tlsv*", and "force-sslv3".
Emeric Brunf5da4932012-09-28 19:42:54 +02009060
Willy Tarreau6c9a3d52012-10-18 18:57:14 +02009061npn <protocols>
9062 This enables the NPN TLS extension and advertises the specified protocol list
9063 as supported on top of NPN. The protocol list consists in a comma-delimited
9064 list of protocol names, for instance: "http/1.1,http/1.0" (without quotes).
9065 This requires that the SSL library is build with support for TLS extensions
Willy Tarreauab861d32013-04-02 02:30:41 +02009066 enabled (check with haproxy -vv). Note that the NPN extension has been
9067 replaced with the ALPN extension (see the "alpn" keyword).
Willy Tarreau6c9a3d52012-10-18 18:57:14 +02009068
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02009069process [ all | odd | even | <number 1-64>[-<number 1-64>] ]
9070 This restricts the list of processes on which this listener is allowed to
9071 run. It does not enforce any process but eliminates those which do not match.
9072 If the frontend uses a "bind-process" setting, the intersection between the
9073 two is applied. If in the end the listener is not allowed to run on any
9074 remaining process, a warning is emitted, and the listener will either run on
9075 the first process of the listener if a single process was specified, or on
9076 all of its processes if multiple processes were specified. For the unlikely
Willy Tarreauae302532014-05-07 19:22:24 +02009077 case where several ranges are needed, this directive may be repeated. The
9078 main purpose of this directive is to be used with the stats sockets and have
9079 one different socket per process. The second purpose is to have multiple bind
9080 lines sharing the same IP:port but not the same process in a listener, so
9081 that the system can distribute the incoming connections into multiple queues
9082 and allow a smoother inter-process load balancing. Currently Linux 3.9 and
9083 above is known for supporting this. See also "bind-process" and "nbproc".
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02009084
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009085ssl
9086 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009087 enables SSL deciphering on connections instantiated from this listener. A
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009088 certificate is necessary (see "crt" above). All contents in the buffers will
9089 appear in clear text, so that ACLs and HTTP processing will only have access
9090 to deciphered contents.
9091
Emmanuel Hocdet65623372013-01-24 17:17:15 +01009092strict-sni
9093 This setting is only available when support for OpenSSL was built in. The
9094 SSL/TLS negotiation is allow only if the client provided an SNI which match
9095 a certificate. The default certificate is not used.
9096 See the "crt" option for more information.
9097
Willy Tarreau2af207a2015-02-04 00:45:58 +01009098tcp-ut <delay>
9099 Sets the TCP User Timeout for all incoming connections instanciated from this
9100 listening socket. This option is available on Linux since version 2.6.37. It
9101 allows haproxy to configure a timeout for sockets which contain data not
9102 receiving an acknoledgement for the configured delay. This is especially
9103 useful on long-lived connections experiencing long idle periods such as
9104 remote terminals or database connection pools, where the client and server
9105 timeouts must remain high to allow a long period of idle, but where it is
9106 important to detect that the client has disappeared in order to release all
9107 resources associated with its connection (and the server's session). The
9108 argument is a delay expressed in milliseconds by default. This only works
9109 for regular TCP connections, and is ignored for other protocols.
9110
Willy Tarreau1c862c52012-10-05 16:21:00 +02009111tfo
Lukas Tribus0defb902013-02-13 23:35:39 +01009112 Is an optional keyword which is supported only on Linux kernels >= 3.7. It
Willy Tarreau1c862c52012-10-05 16:21:00 +02009113 enables TCP Fast Open on the listening socket, which means that clients which
9114 support this feature will be able to send a request and receive a response
9115 during the 3-way handshake starting from second connection, thus saving one
9116 round-trip after the first connection. This only makes sense with protocols
9117 that use high connection rates and where each round trip matters. This can
9118 possibly cause issues with many firewalls which do not accept data on SYN
9119 packets, so this option should only be enabled once well tested. This option
Lukas Tribus0999f762013-04-02 16:43:24 +02009120 is only supported on TCPv4/TCPv6 sockets and ignored by other ones. You may
9121 need to build HAProxy with USE_TFO=1 if your libc doesn't define
9122 TCP_FASTOPEN.
Willy Tarreau1c862c52012-10-05 16:21:00 +02009123
Nenad Merdanovic188ad3e2015-02-27 19:56:50 +01009124tls-ticket-keys <keyfile>
9125 Sets the TLS ticket keys file to load the keys from. The keys need to be 48
9126 bytes long, encoded with base64 (ex. openssl rand -base64 48). Number of keys
9127 is specified by the TLS_TICKETS_NO build option (default 3) and at least as
9128 many keys need to be present in the file. Last TLS_TICKETS_NO keys will be
9129 used for decryption and the penultimate one for encryption. This enables easy
9130 key rotation by just appending new key to the file and reloading the process.
9131 Keys must be periodically rotated (ex. every 12h) or Perfect Forward Secrecy
9132 is compromised. It is also a good idea to keep the keys off any permanent
9133 storage such as hard drives (hint: use tmpfs and don't swap those files).
9134 Lifetime hint can be changed using tune.ssl.timeout.
9135
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009136transparent
9137 Is an optional keyword which is supported only on certain Linux kernels. It
9138 indicates that the addresses will be bound even if they do not belong to the
9139 local machine, and that packets targeting any of these addresses will be
9140 intercepted just as if the addresses were locally configured. This normally
9141 requires that IP forwarding is enabled. Caution! do not use this with the
9142 default address '*', as it would redirect any traffic for the specified port.
9143 This keyword is available only when HAProxy is built with USE_LINUX_TPROXY=1.
9144 This parameter is only compatible with TCPv4 and TCPv6 sockets, depending on
9145 kernel version. Some distribution kernels include backports of the feature,
9146 so check for support with your vendor.
9147
Willy Tarreau77e3af92012-11-24 15:07:23 +01009148v4v6
9149 Is an optional keyword which is supported only on most recent systems
9150 including Linux kernels >= 2.4.21. It is used to bind a socket to both IPv4
9151 and IPv6 when it uses the default address. Doing so is sometimes necessary
9152 on systems which bind to IPv6 only by default. It has no effect on non-IPv6
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009153 sockets, and is overridden by the "v6only" option.
Willy Tarreau77e3af92012-11-24 15:07:23 +01009154
Willy Tarreau9b6700f2012-11-24 11:55:28 +01009155v6only
9156 Is an optional keyword which is supported only on most recent systems
9157 including Linux kernels >= 2.4.21. It is used to bind a socket to IPv6 only
9158 when it uses the default address. Doing so is sometimes preferred to doing it
Willy Tarreau77e3af92012-11-24 15:07:23 +01009159 system-wide as it is per-listener. It has no effect on non-IPv6 sockets and
9160 has precedence over the "v4v6" option.
Willy Tarreau9b6700f2012-11-24 11:55:28 +01009161
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009162uid <uid>
9163 Sets the owner of the UNIX sockets to the designated system uid. It can also
9164 be set by default in the global section's "unix-bind" statement. Note that
9165 some platforms simply ignore this. This setting is equivalent to the "user"
9166 setting except that the user numeric ID is used instead of its name. This
9167 setting is ignored by non UNIX sockets.
9168
9169user <user>
9170 Sets the owner of the UNIX sockets to the designated system user. It can also
9171 be set by default in the global section's "unix-bind" statement. Note that
9172 some platforms simply ignore this. This setting is equivalent to the "uid"
9173 setting except that the user name is used instead of its uid. This setting is
9174 ignored by non UNIX sockets.
9175
Emeric Brun1a073b42012-09-28 17:07:34 +02009176verify [none|optional|required]
9177 This setting is only available when support for OpenSSL was built in. If set
9178 to 'none', client certificate is not requested. This is the default. In other
9179 cases, a client certificate is requested. If the client does not provide a
9180 certificate after the request and if 'verify' is set to 'required', then the
9181 handshake is aborted, while it would have succeeded if set to 'optional'. The
Emeric Brunfd33a262012-10-11 16:28:27 +02009182 certificate provided by the client is always verified using CAs from
9183 'ca-file' and optional CRLs from 'crl-file'. On verify failure the handshake
9184 is aborted, regardless of the 'verify' option, unless the error code exactly
9185 matches one of those listed with 'ca-ignore-err' or 'crt-ignore-err'.
Willy Tarreau4a5cade2012-04-05 21:09:48 +02009186
Willy Tarreaub6205fd2012-09-24 12:27:33 +020091875.2. Server and default-server options
Cyril Bontéf0c60612010-02-06 14:44:47 +01009188------------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02009189
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01009190The "server" and "default-server" keywords support a certain number of settings
9191which are all passed as arguments on the server line. The order in which those
9192arguments appear does not count, and they are all optional. Some of those
9193settings are single words (booleans) while others expect one or several values
9194after them. In this case, the values must immediately follow the setting name.
9195Except default-server, all those settings must be specified after the server's
9196address if they are used:
Willy Tarreau6a06a402007-07-15 20:15:28 +02009197
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009198 server <name> <address>[:port] [settings ...]
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01009199 default-server [settings ...]
Willy Tarreau6a06a402007-07-15 20:15:28 +02009200
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009201The currently supported settings are the following ones.
Willy Tarreau0ba27502007-12-24 16:55:16 +01009202
Willy Tarreauceb4ac92012-04-28 00:41:46 +02009203addr <ipv4|ipv6>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009204 Using the "addr" parameter, it becomes possible to use a different IP address
9205 to send health-checks. On some servers, it may be desirable to dedicate an IP
9206 address to specific component able to perform complex tests which are more
9207 suitable to health-checks than the application. This parameter is ignored if
9208 the "check" parameter is not set. See also the "port" parameter.
Willy Tarreau6a06a402007-07-15 20:15:28 +02009209
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009210 Supported in default-server: No
9211
Simon Hormand60d6912013-11-25 10:46:36 +09009212agent-check
9213 Enable an auxiliary agent check which is run independently of a regular
Willy Tarreau81f5d942013-12-09 20:51:51 +01009214 health check. An agent health check is performed by making a TCP connection
9215 to the port set by the "agent-port" parameter and reading an ASCII string.
9216 The string is made of a series of words delimited by spaces, tabs or commas
9217 in any order, optionally terminated by '\r' and/or '\n', each consisting of :
Simon Hormand60d6912013-11-25 10:46:36 +09009218
Willy Tarreau81f5d942013-12-09 20:51:51 +01009219 - An ASCII representation of a positive integer percentage, e.g. "75%".
Simon Hormand60d6912013-11-25 10:46:36 +09009220 Values in this format will set the weight proportional to the initial
Willy Tarreauc5af3a62014-10-07 15:27:33 +02009221 weight of a server as configured when haproxy starts. Note that a zero
9222 weight is reported on the stats page as "DRAIN" since it has the same
9223 effect on the server (it's removed from the LB farm).
Simon Hormand60d6912013-11-25 10:46:36 +09009224
Willy Tarreau81f5d942013-12-09 20:51:51 +01009225 - The word "ready". This will turn the server's administrative state to the
9226 READY mode, thus cancelling any DRAIN or MAINT state
Simon Hormand60d6912013-11-25 10:46:36 +09009227
Willy Tarreau81f5d942013-12-09 20:51:51 +01009228 - The word "drain". This will turn the server's administrative state to the
9229 DRAIN mode, thus it will not accept any new connections other than those
9230 that are accepted via persistence.
Simon Hormand60d6912013-11-25 10:46:36 +09009231
Willy Tarreau81f5d942013-12-09 20:51:51 +01009232 - The word "maint". This will turn the server's administrative state to the
9233 MAINT mode, thus it will not accept any new connections at all, and health
9234 checks will be stopped.
Simon Hormand60d6912013-11-25 10:46:36 +09009235
Willy Tarreau81f5d942013-12-09 20:51:51 +01009236 - The words "down", "failed", or "stopped", optionally followed by a
9237 description string after a sharp ('#'). All of these mark the server's
9238 operating state as DOWN, but since the word itself is reported on the stats
9239 page, the difference allows an administrator to know if the situation was
9240 expected or not : the service may intentionally be stopped, may appear up
9241 but fail some validity tests, or may be seen as down (eg: missing process,
9242 or port not responding).
Simon Hormand60d6912013-11-25 10:46:36 +09009243
Willy Tarreau81f5d942013-12-09 20:51:51 +01009244 - The word "up" sets back the server's operating state as UP if health checks
9245 also report that the service is accessible.
Simon Hormand60d6912013-11-25 10:46:36 +09009246
Willy Tarreau81f5d942013-12-09 20:51:51 +01009247 Parameters which are not advertised by the agent are not changed. For
9248 example, an agent might be designed to monitor CPU usage and only report a
9249 relative weight and never interact with the operating status. Similarly, an
9250 agent could be designed as an end-user interface with 3 radio buttons
9251 allowing an administrator to change only the administrative state. However,
9252 it is important to consider that only the agent may revert its own actions,
9253 so if a server is set to DRAIN mode or to DOWN state using the agent, the
9254 agent must implement the other equivalent actions to bring the service into
9255 operations again.
Simon Hormand60d6912013-11-25 10:46:36 +09009256
Simon Horman2f1f9552013-11-25 10:46:37 +09009257 Failure to connect to the agent is not considered an error as connectivity
9258 is tested by the regular health check which is enabled by the "check"
Willy Tarreau81f5d942013-12-09 20:51:51 +01009259 parameter. Warning though, it is not a good idea to stop an agent after it
9260 reports "down", since only an agent reporting "up" will be able to turn the
9261 server up again. Note that the CLI on the Unix stats socket is also able to
9262 force an agent's result in order to workaround a bogus agent if needed.
Simon Horman2f1f9552013-11-25 10:46:37 +09009263
Willy Tarreau81f5d942013-12-09 20:51:51 +01009264 Requires the "agent-port" parameter to be set. See also the "agent-inter"
9265 parameter.
Simon Hormand60d6912013-11-25 10:46:36 +09009266
9267 Supported in default-server: No
9268
9269agent-inter <delay>
9270 The "agent-inter" parameter sets the interval between two agent checks
9271 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
9272
9273 Just as with every other time-based parameter, it may be entered in any
9274 other explicit unit among { us, ms, s, m, h, d }. The "agent-inter"
9275 parameter also serves as a timeout for agent checks "timeout check" is
9276 not set. In order to reduce "resonance" effects when multiple servers are
9277 hosted on the same hardware, the agent and health checks of all servers
9278 are started with a small time offset between them. It is also possible to
9279 add some random noise in the agent and health checks interval using the
9280 global "spread-checks" keyword. This makes sense for instance when a lot
9281 of backends use the same servers.
9282
9283 See also the "agent-check" and "agent-port" parameters.
9284
9285 Supported in default-server: Yes
9286
9287agent-port <port>
9288 The "agent-port" parameter sets the TCP port used for agent checks.
9289
9290 See also the "agent-check" and "agent-inter" parameters.
9291
9292 Supported in default-server: Yes
9293
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009294backup
9295 When "backup" is present on a server line, the server is only used in load
9296 balancing when all other non-backup servers are unavailable. Requests coming
9297 with a persistence cookie referencing the server will always be served
9298 though. By default, only the first operational backup server is used, unless
9299 the "allbackups" option is set in the backend. See also the "allbackups"
9300 option.
Willy Tarreau6a06a402007-07-15 20:15:28 +02009301
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009302 Supported in default-server: No
9303
Emeric Brunef42d922012-10-11 16:11:36 +02009304ca-file <cafile>
9305 This setting is only available when support for OpenSSL was built in. It
9306 designates a PEM file from which to load CA certificates used to verify
9307 server's certificate.
9308
9309 Supported in default-server: No
9310
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009311check
9312 This option enables health checks on the server. By default, a server is
Patrick Mézardb7aeec62012-01-22 16:01:22 +01009313 always considered available. If "check" is set, the server is available when
9314 accepting periodic TCP connections, to ensure that it is really able to serve
9315 requests. The default address and port to send the tests to are those of the
9316 server, and the default source is the same as the one defined in the
9317 backend. It is possible to change the address using the "addr" parameter, the
9318 port using the "port" parameter, the source address using the "source"
9319 address, and the interval and timers using the "inter", "rise" and "fall"
Simon Hormanafc47ee2013-11-25 10:46:35 +09009320 parameters. The request method is define in the backend using the "httpchk",
9321 "smtpchk", "mysql-check", "pgsql-check" and "ssl-hello-chk" options. Please
9322 refer to those options and parameters for more information.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009323
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009324 Supported in default-server: No
9325
Willy Tarreau6c16adc2012-10-05 00:04:16 +02009326check-send-proxy
9327 This option forces emission of a PROXY protocol line with outgoing health
9328 checks, regardless of whether the server uses send-proxy or not for the
9329 normal traffic. By default, the PROXY protocol is enabled for health checks
9330 if it is already enabled for normal traffic and if no "port" nor "addr"
9331 directive is present. However, if such a directive is present, the
9332 "check-send-proxy" option needs to be used to force the use of the
9333 protocol. See also the "send-proxy" option for more information.
9334
9335 Supported in default-server: No
9336
Willy Tarreau763a95b2012-10-04 23:15:39 +02009337check-ssl
9338 This option forces encryption of all health checks over SSL, regardless of
9339 whether the server uses SSL or not for the normal traffic. This is generally
9340 used when an explicit "port" or "addr" directive is specified and SSL health
9341 checks are not inherited. It is important to understand that this option
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009342 inserts an SSL transport layer below the checks, so that a simple TCP connect
Willy Tarreau763a95b2012-10-04 23:15:39 +02009343 check becomes an SSL connect, which replaces the old ssl-hello-chk. The most
9344 common use is to send HTTPS checks by combining "httpchk" with SSL checks.
9345 All SSL settings are common to health checks and traffic (eg: ciphers).
9346 See the "ssl" option for more information.
9347
9348 Supported in default-server: No
9349
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009350ciphers <ciphers>
9351 This option sets the string describing the list of cipher algorithms that is
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009352 is negotiated during the SSL/TLS handshake with the server. The format of the
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009353 string is defined in "man 1 ciphers". When SSL is used to communicate with
9354 servers on the local network, it is common to see a weaker set of algorithms
9355 than what is used over the internet. Doing so reduces CPU usage on both the
9356 server and haproxy while still keeping it compatible with deployed software.
9357 Some algorithms such as RC4-SHA1 are reasonably cheap. If no security at all
9358 is needed and just connectivity, using DES can be appropriate.
9359
Willy Tarreau763a95b2012-10-04 23:15:39 +02009360 Supported in default-server: No
9361
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009362cookie <value>
9363 The "cookie" parameter sets the cookie value assigned to the server to
9364 <value>. This value will be checked in incoming requests, and the first
9365 operational server possessing the same value will be selected. In return, in
9366 cookie insertion or rewrite modes, this value will be assigned to the cookie
9367 sent to the client. There is nothing wrong in having several servers sharing
9368 the same cookie value, and it is in fact somewhat common between normal and
9369 backup servers. See also the "cookie" keyword in backend section.
9370
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009371 Supported in default-server: No
9372
Emeric Brunef42d922012-10-11 16:11:36 +02009373crl-file <crlfile>
9374 This setting is only available when support for OpenSSL was built in. It
9375 designates a PEM file from which to load certificate revocation list used
9376 to verify server's certificate.
9377
9378 Supported in default-server: No
9379
Emeric Bruna7aa3092012-10-26 12:58:00 +02009380crt <cert>
9381 This setting is only available when support for OpenSSL was built in.
9382 It designates a PEM file from which to load both a certificate and the
9383 associated private key. This file can be built by concatenating both PEM
9384 files into one. This certificate will be sent if the server send a client
9385 certificate request.
9386
9387 Supported in default-server: No
9388
Willy Tarreau96839092010-03-29 10:02:24 +02009389disabled
9390 The "disabled" keyword starts the server in the "disabled" state. That means
9391 that it is marked down in maintenance mode, and no connection other than the
9392 ones allowed by persist mode will reach it. It is very well suited to setup
9393 new servers, because normal traffic will never reach them, while it is still
9394 possible to test the service by making use of the force-persist mechanism.
9395
9396 Supported in default-server: No
9397
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009398error-limit <count>
Willy Tarreau983e01e2010-01-11 18:42:06 +01009399 If health observing is enabled, the "error-limit" parameter specifies the
9400 number of consecutive errors that triggers event selected by the "on-error"
9401 option. By default it is set to 10 consecutive errors.
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009402
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009403 Supported in default-server: Yes
9404
9405 See also the "check", "error-limit" and "on-error".
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009406
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009407fall <count>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009408 The "fall" parameter states that a server will be considered as dead after
9409 <count> consecutive unsuccessful health checks. This value defaults to 3 if
9410 unspecified. See also the "check", "inter" and "rise" parameters.
9411
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009412 Supported in default-server: Yes
9413
Emeric Brun8694b9a2012-10-05 14:39:07 +02009414force-sslv3
9415 This option enforces use of SSLv3 only when SSL is used to communicate with
9416 the server. SSLv3 is generally less expensive than the TLS counterparts for
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009417 high connection rates. This option is also available on global statement
9418 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009419
9420 Supported in default-server: No
9421
9422force-tlsv10
9423 This option enforces use of TLSv1.0 only when SSL is used to communicate with
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009424 the server. This option is also available on global statement
9425 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009426
9427 Supported in default-server: No
9428
9429force-tlsv11
9430 This option enforces use of TLSv1.1 only when SSL is used to communicate with
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009431 the server. This option is also available on global statement
9432 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009433
9434 Supported in default-server: No
9435
9436force-tlsv12
9437 This option enforces use of TLSv1.2 only when SSL is used to communicate with
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009438 the server. This option is also available on global statement
9439 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009440
9441 Supported in default-server: No
9442
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009443id <value>
Willy Tarreau53fb4ae2009-10-04 23:04:08 +02009444 Set a persistent ID for the server. This ID must be positive and unique for
9445 the proxy. An unused ID will automatically be assigned if unset. The first
9446 assigned value will be 1. This ID is currently only returned in statistics.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009447
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009448 Supported in default-server: No
9449
9450inter <delay>
9451fastinter <delay>
9452downinter <delay>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009453 The "inter" parameter sets the interval between two consecutive health checks
9454 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
9455 It is also possible to use "fastinter" and "downinter" to optimize delays
9456 between checks depending on the server state :
9457
9458 Server state | Interval used
9459 ---------------------------------+-----------------------------------------
9460 UP 100% (non-transitional) | "inter"
9461 ---------------------------------+-----------------------------------------
9462 Transitionally UP (going down), |
9463 Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise.
9464 or yet unchecked. |
9465 ---------------------------------+-----------------------------------------
9466 DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise.
9467 ---------------------------------+-----------------------------------------
Willy Tarreaud72758d2010-01-12 10:42:19 +01009468
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009469 Just as with every other time-based parameter, they can be entered in any
9470 other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also
9471 serves as a timeout for health checks sent to servers if "timeout check" is
9472 not set. In order to reduce "resonance" effects when multiple servers are
Simon Hormand60d6912013-11-25 10:46:36 +09009473 hosted on the same hardware, the agent and health checks of all servers
9474 are started with a small time offset between them. It is also possible to
9475 add some random noise in the agent and health checks interval using the
9476 global "spread-checks" keyword. This makes sense for instance when a lot
9477 of backends use the same servers.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009478
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009479 Supported in default-server: Yes
9480
9481maxconn <maxconn>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009482 The "maxconn" parameter specifies the maximal number of concurrent
9483 connections that will be sent to this server. If the number of incoming
9484 concurrent requests goes higher than this value, they will be queued, waiting
9485 for a connection to be released. This parameter is very important as it can
9486 save fragile servers from going down under extreme loads. If a "minconn"
9487 parameter is specified, the limit becomes dynamic. The default value is "0"
9488 which means unlimited. See also the "minconn" and "maxqueue" parameters, and
9489 the backend's "fullconn" keyword.
9490
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009491 Supported in default-server: Yes
9492
9493maxqueue <maxqueue>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009494 The "maxqueue" parameter specifies the maximal number of connections which
9495 will wait in the queue for this server. If this limit is reached, next
9496 requests will be redispatched to other servers instead of indefinitely
9497 waiting to be served. This will break persistence but may allow people to
9498 quickly re-log in when the server they try to connect to is dying. The
9499 default value is "0" which means the queue is unlimited. See also the
9500 "maxconn" and "minconn" parameters.
9501
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009502 Supported in default-server: Yes
9503
9504minconn <minconn>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009505 When the "minconn" parameter is set, the maxconn limit becomes a dynamic
9506 limit following the backend's load. The server will always accept at least
9507 <minconn> connections, never more than <maxconn>, and the limit will be on
9508 the ramp between both values when the backend has less than <fullconn>
9509 concurrent connections. This makes it possible to limit the load on the
9510 server during normal loads, but push it further for important loads without
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01009511 overloading the server during exceptional loads. See also the "maxconn"
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009512 and "maxqueue" parameters, as well as the "fullconn" backend keyword.
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009513
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009514 Supported in default-server: Yes
9515
Willy Tarreau2a3fb1c2015-02-05 16:47:07 +01009516no-ssl-reuse
9517 This option disables SSL session reuse when SSL is used to communicate with
9518 the server. It will force the server to perform a full handshake for every
9519 new connection. It's probably only useful for benchmarking, troubleshooting,
9520 and for paranoid users.
9521
9522 Supported in default-server: No
9523
Emeric Brun9b3009b2012-10-05 11:55:06 +02009524no-sslv3
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009525 This option disables support for SSLv3 when SSL is used to communicate with
9526 the server. Note that SSLv2 is disabled in the code and cannot be enabled
Emeric Brun8694b9a2012-10-05 14:39:07 +02009527 using any configuration option. See also "force-sslv3", "force-tlsv*".
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009528
Willy Tarreau763a95b2012-10-04 23:15:39 +02009529 Supported in default-server: No
9530
Emeric Brunf9c5c472012-10-11 15:28:34 +02009531no-tls-tickets
9532 This setting is only available when support for OpenSSL was built in. It
9533 disables the stateless session resumption (RFC 5077 TLS Ticket
9534 extension) and force to use stateful session resumption. Stateless
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009535 session resumption is more expensive in CPU usage for servers. This option
9536 is also available on global statement "ssl-default-server-options".
Emeric Brunf9c5c472012-10-11 15:28:34 +02009537
9538 Supported in default-server: No
9539
Emeric Brun9b3009b2012-10-05 11:55:06 +02009540no-tlsv10
Emeric Brun8694b9a2012-10-05 14:39:07 +02009541 This option disables support for TLSv1.0 when SSL is used to communicate with
Emeric Brunf5da4932012-09-28 19:42:54 +02009542 the server. Note that SSLv2 is disabled in the code and cannot be enabled
9543 using any configuration option. TLSv1 is more expensive than SSLv3 so it
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009544 often makes sense to disable it when communicating with local servers. This
9545 option is also available on global statement "ssl-default-server-options".
9546 See also "force-sslv3", "force-tlsv*".
Emeric Brunf5da4932012-09-28 19:42:54 +02009547
Willy Tarreau763a95b2012-10-04 23:15:39 +02009548 Supported in default-server: No
9549
Emeric Brun9b3009b2012-10-05 11:55:06 +02009550no-tlsv11
Emeric Brun8694b9a2012-10-05 14:39:07 +02009551 This option disables support for TLSv1.1 when SSL is used to communicate with
Emeric Brunf5da4932012-09-28 19:42:54 +02009552 the server. Note that SSLv2 is disabled in the code and cannot be enabled
9553 using any configuration option. TLSv1 is more expensive than SSLv3 so it
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009554 often makes sense to disable it when communicating with local servers. This
9555 option is also available on global statement "ssl-default-server-options".
9556 See also "force-sslv3", "force-tlsv*".
Emeric Brunf5da4932012-09-28 19:42:54 +02009557
Willy Tarreau763a95b2012-10-04 23:15:39 +02009558 Supported in default-server: No
9559
Emeric Brun9b3009b2012-10-05 11:55:06 +02009560no-tlsv12
Emeric Brun8694b9a2012-10-05 14:39:07 +02009561 This option disables support for TLSv1.2 when SSL is used to communicate with
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009562 the server. Note that SSLv2 is disabled in the code and cannot be enabled
9563 using any configuration option. TLSv1 is more expensive than SSLv3 so it
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009564 often makes sense to disable it when communicating with local servers. This
9565 option is also available on global statement "ssl-default-server-options".
9566 See also "force-sslv3", "force-tlsv*".
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009567
Willy Tarreau763a95b2012-10-04 23:15:39 +02009568 Supported in default-server: No
9569
Simon Hormanfa461682011-06-25 09:39:49 +09009570non-stick
9571 Never add connections allocated to this sever to a stick-table.
9572 This may be used in conjunction with backup to ensure that
9573 stick-table persistence is disabled for backup servers.
9574
Willy Tarreau763a95b2012-10-04 23:15:39 +02009575 Supported in default-server: No
9576
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009577observe <mode>
9578 This option enables health adjusting based on observing communication with
9579 the server. By default this functionality is disabled and enabling it also
9580 requires to enable health checks. There are two supported modes: "layer4" and
9581 "layer7". In layer4 mode, only successful/unsuccessful tcp connections are
9582 significant. In layer7, which is only allowed for http proxies, responses
9583 received from server are verified, like valid/wrong http code, unparsable
Willy Tarreau150d1462012-03-10 08:19:02 +01009584 headers, a timeout, etc. Valid status codes include 100 to 499, 501 and 505.
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009585
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009586 Supported in default-server: No
9587
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009588 See also the "check", "on-error" and "error-limit".
9589
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009590on-error <mode>
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009591 Select what should happen when enough consecutive errors are detected.
9592 Currently, four modes are available:
9593 - fastinter: force fastinter
9594 - fail-check: simulate a failed check, also forces fastinter (default)
9595 - sudden-death: simulate a pre-fatal failed health check, one more failed
9596 check will mark a server down, forces fastinter
9597 - mark-down: mark the server immediately down and force fastinter
9598
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009599 Supported in default-server: Yes
9600
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009601 See also the "check", "observe" and "error-limit".
9602
Simon Hormane0d1bfb2011-06-21 14:34:58 +09009603on-marked-down <action>
9604 Modify what occurs when a server is marked down.
9605 Currently one action is available:
Justin Karnegeseb2c24a2012-05-24 15:28:52 -07009606 - shutdown-sessions: Shutdown peer sessions. When this setting is enabled,
9607 all connections to the server are immediately terminated when the server
9608 goes down. It might be used if the health check detects more complex cases
9609 than a simple connection status, and long timeouts would cause the service
9610 to remain unresponsive for too long a time. For instance, a health check
9611 might detect that a database is stuck and that there's no chance to reuse
9612 existing connections anymore. Connections killed this way are logged with
9613 a 'D' termination code (for "Down").
Simon Hormane0d1bfb2011-06-21 14:34:58 +09009614
9615 Actions are disabled by default
9616
9617 Supported in default-server: Yes
9618
Justin Karnegeseb2c24a2012-05-24 15:28:52 -07009619on-marked-up <action>
9620 Modify what occurs when a server is marked up.
9621 Currently one action is available:
9622 - shutdown-backup-sessions: Shutdown sessions on all backup servers. This is
9623 done only if the server is not in backup state and if it is not disabled
9624 (it must have an effective weight > 0). This can be used sometimes to force
9625 an active server to take all the traffic back after recovery when dealing
9626 with long sessions (eg: LDAP, SQL, ...). Doing this can cause more trouble
9627 than it tries to solve (eg: incomplete transactions), so use this feature
9628 with extreme care. Sessions killed because a server comes up are logged
9629 with an 'U' termination code (for "Up").
9630
9631 Actions are disabled by default
9632
9633 Supported in default-server: Yes
9634
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009635port <port>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009636 Using the "port" parameter, it becomes possible to use a different port to
9637 send health-checks. On some servers, it may be desirable to dedicate a port
9638 to a specific component able to perform complex tests which are more suitable
9639 to health-checks than the application. It is common to run a simple script in
9640 inetd for instance. This parameter is ignored if the "check" parameter is not
9641 set. See also the "addr" parameter.
9642
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009643 Supported in default-server: Yes
9644
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009645redir <prefix>
9646 The "redir" parameter enables the redirection mode for all GET and HEAD
9647 requests addressing this server. This means that instead of having HAProxy
9648 forward the request to the server, it will send an "HTTP 302" response with
9649 the "Location" header composed of this prefix immediately followed by the
9650 requested URI beginning at the leading '/' of the path component. That means
9651 that no trailing slash should be used after <prefix>. All invalid requests
9652 will be rejected, and all non-GET or HEAD requests will be normally served by
9653 the server. Note that since the response is completely forged, no header
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01009654 mangling nor cookie insertion is possible in the response. However, cookies in
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009655 requests are still analysed, making this solution completely usable to direct
9656 users to a remote location in case of local disaster. Main use consists in
9657 increasing bandwidth for static servers by having the clients directly
9658 connect to them. Note: never use a relative location here, it would cause a
9659 loop between the client and HAProxy!
9660
9661 Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check
9662
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009663 Supported in default-server: No
9664
9665rise <count>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009666 The "rise" parameter states that a server will be considered as operational
9667 after <count> consecutive successful health checks. This value defaults to 2
9668 if unspecified. See also the "check", "inter" and "fall" parameters.
9669
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009670 Supported in default-server: Yes
9671
Willy Tarreau5ab04ec2011-03-20 10:32:26 +01009672send-proxy
9673 The "send-proxy" parameter enforces use of the PROXY protocol over any
9674 connection established to this server. The PROXY protocol informs the other
9675 end about the layer 3/4 addresses of the incoming connection, so that it can
9676 know the client's address or the public address it accessed to, whatever the
9677 upper layer protocol. For connections accepted by an "accept-proxy" listener,
9678 the advertised address will be used. Only TCPv4 and TCPv6 address families
9679 are supported. Other families such as Unix sockets, will report an UNKNOWN
9680 family. Servers using this option can fully be chained to another instance of
9681 haproxy listening with an "accept-proxy" setting. This setting must not be
Willy Tarreau6c16adc2012-10-05 00:04:16 +02009682 used if the server isn't aware of the protocol. When health checks are sent
9683 to the server, the PROXY protocol is automatically used when this option is
9684 set, unless there is an explicit "port" or "addr" directive, in which case an
9685 explicit "check-send-proxy" directive would also be needed to use the PROXY
9686 protocol. See also the "accept-proxy" option of the "bind" keyword.
Willy Tarreau5ab04ec2011-03-20 10:32:26 +01009687
9688 Supported in default-server: No
9689
David Safb76832014-05-08 23:42:08 -04009690send-proxy-v2
9691 The "send-proxy-v2" parameter enforces use of the PROXY protocol version 2
9692 over any connection established to this server. The PROXY protocol informs
9693 the other end about the layer 3/4 addresses of the incoming connection, so
9694 that it can know the client's address or the public address it accessed to,
9695 whatever the upper layer protocol. This setting must not be used if the
9696 server isn't aware of this version of the protocol. See also the "send-proxy"
9697 option of the "bind" keyword.
9698
9699 Supported in default-server: No
9700
9701send-proxy-v2-ssl
9702 The "send-proxy-v2-ssl" parameter enforces use of the PROXY protocol version
9703 2 over any connection established to this server. The PROXY protocol informs
9704 the other end about the layer 3/4 addresses of the incoming connection, so
9705 that it can know the client's address or the public address it accessed to,
9706 whatever the upper layer protocol. In addition, the SSL information extension
9707 of the PROXY protocol is added to the PROXY protocol header. This setting
9708 must not be used if the server isn't aware of this version of the protocol.
9709 See also the "send-proxy-v2" option of the "bind" keyword.
9710
9711 Supported in default-server: No
9712
9713send-proxy-v2-ssl-cn
9714 The "send-proxy-v2-ssl" parameter enforces use of the PROXY protocol version
9715 2 over any connection established to this server. The PROXY protocol informs
9716 the other end about the layer 3/4 addresses of the incoming connection, so
9717 that it can know the client's address or the public address it accessed to,
9718 whatever the upper layer protocol. In addition, the SSL information extension
9719 of the PROXY protocol, along along with the Common Name from the subject of
9720 the client certificate (if any), is added to the PROXY protocol header. This
9721 setting must not be used if the server isn't aware of this version of the
9722 protocol. See also the "send-proxy-v2" option of the "bind" keyword.
9723
9724 Supported in default-server: No
9725
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009726slowstart <start_time_in_ms>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009727 The "slowstart" parameter for a server accepts a value in milliseconds which
9728 indicates after how long a server which has just come back up will run at
9729 full speed. Just as with every other time-based parameter, it can be entered
9730 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
9731 linearly from 0 to 100% during this time. The limitation applies to two
9732 parameters :
9733
9734 - maxconn: the number of connections accepted by the server will grow from 1
9735 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
9736
9737 - weight: when the backend uses a dynamic weighted algorithm, the weight
9738 grows linearly from 1 to 100%. In this case, the weight is updated at every
9739 health-check. For this reason, it is important that the "inter" parameter
9740 is smaller than the "slowstart", in order to maximize the number of steps.
9741
9742 The slowstart never applies when haproxy starts, otherwise it would cause
9743 trouble to running servers. It only applies when a server has been previously
9744 seen as failed.
9745
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009746 Supported in default-server: Yes
9747
Willy Tarreauc6f4ce82009-06-10 11:09:37 +02009748source <addr>[:<pl>[-<ph>]] [usesrc { <addr2>[:<port2>] | client | clientip } ]
Willy Tarreaubce70882009-09-07 11:51:47 +02009749source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | hdr_ip(<hdr>[,<occ>]) } ]
Willy Tarreauc6f4ce82009-06-10 11:09:37 +02009750source <addr>[:<pl>[-<ph>]] [interface <name>] ...
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009751 The "source" parameter sets the source address which will be used when
9752 connecting to the server. It follows the exact same parameters and principle
9753 as the backend "source" keyword, except that it only applies to the server
9754 referencing it. Please consult the "source" keyword for details.
9755
Willy Tarreauc6f4ce82009-06-10 11:09:37 +02009756 Additionally, the "source" statement on a server line allows one to specify a
9757 source port range by indicating the lower and higher bounds delimited by a
9758 dash ('-'). Some operating systems might require a valid IP address when a
9759 source port range is specified. It is permitted to have the same IP/range for
9760 several servers. Doing so makes it possible to bypass the maximum of 64k
9761 total concurrent connections. The limit will then reach 64k connections per
9762 server.
9763
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009764 Supported in default-server: No
9765
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009766ssl
Willy Tarreau44f65392013-06-25 07:56:20 +02009767 This option enables SSL ciphering on outgoing connections to the server. It
9768 is critical to verify server certificates using "verify" when using SSL to
9769 connect to servers, otherwise the communication is prone to trivial man in
9770 the-middle attacks rendering SSL useless. When this option is used, health
9771 checks are automatically sent in SSL too unless there is a "port" or an
9772 "addr" directive indicating the check should be sent to a different location.
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009773 See the "check-ssl" option to force SSL health checks.
Willy Tarreau763a95b2012-10-04 23:15:39 +02009774
9775 Supported in default-server: No
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009776
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009777track [<proxy>/]<server>
Willy Tarreau32091232014-05-16 13:52:00 +02009778 This option enables ability to set the current state of the server by tracking
9779 another one. It is possible to track a server which itself tracks another
9780 server, provided that at the end of the chain, a server has health checks
9781 enabled. If <proxy> is omitted the current one is used. If disable-on-404 is
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009782 used, it has to be enabled on both proxies.
9783
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009784 Supported in default-server: No
9785
Emeric Brunef42d922012-10-11 16:11:36 +02009786verify [none|required]
9787 This setting is only available when support for OpenSSL was built in. If set
Emeric Brun850efd52014-01-29 12:24:34 +01009788 to 'none', server certificate is not verified. In the other case, The
9789 certificate provided by the server is verified using CAs from 'ca-file'
9790 and optional CRLs from 'crl-file'. If 'ssl_server_verify' is not specified
9791 in global section, this is the default. On verify failure the handshake
Willy Tarreau44f65392013-06-25 07:56:20 +02009792 is aborted. It is critically important to verify server certificates when
9793 using SSL to connect to servers, otherwise the communication is prone to
9794 trivial man-in-the-middle attacks rendering SSL totally useless.
Emeric Brunef42d922012-10-11 16:11:36 +02009795
9796 Supported in default-server: No
9797
Evan Broderbe554312013-06-27 00:05:25 -07009798verifyhost <hostname>
9799 This setting is only available when support for OpenSSL was built in, and
9800 only takes effect if 'verify required' is also specified. When set, the
9801 hostnames in the subject and subjectAlternateNames of the certificate
9802 provided by the server are checked. If none of the hostnames in the
9803 certificate match the specified hostname, the handshake is aborted. The
9804 hostnames in the server-provided certificate may include wildcards.
9805
9806 Supported in default-server: No
9807
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009808weight <weight>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009809 The "weight" parameter is used to adjust the server's weight relative to
9810 other servers. All servers will receive a load proportional to their weight
9811 relative to the sum of all weights, so the higher the weight, the higher the
Willy Tarreau6704d672009-06-15 10:56:05 +02009812 load. The default weight is 1, and the maximal value is 256. A value of 0
9813 means the server will not participate in load-balancing but will still accept
9814 persistent connections. If this parameter is used to distribute the load
9815 according to server's capacity, it is recommended to start with values which
9816 can both grow and shrink, for instance between 10 and 100 to leave enough
9817 room above and below for later adjustments.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009818
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009819 Supported in default-server: Yes
9820
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009821
98226. HTTP header manipulation
9823---------------------------
9824
9825In HTTP mode, it is possible to rewrite, add or delete some of the request and
9826response headers based on regular expressions. It is also possible to block a
9827request or a response if a particular header matches a regular expression,
9828which is enough to stop most elementary protocol attacks, and to protect
Willy Tarreau70dffda2014-01-30 03:07:23 +01009829against information leak from the internal network.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009830
Willy Tarreau70dffda2014-01-30 03:07:23 +01009831If HAProxy encounters an "Informational Response" (status code 1xx), it is able
9832to process all rsp* rules which can allow, deny, rewrite or delete a header,
9833but it will refuse to add a header to any such messages as this is not
9834HTTP-compliant. The reason for still processing headers in such responses is to
9835stop and/or fix any possible information leak which may happen, for instance
9836because another downstream equipment would unconditionally add a header, or if
9837a server name appears there. When such messages are seen, normal processing
9838still occurs on the next non-informational messages.
Willy Tarreau816b9792009-09-15 21:25:21 +02009839
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009840This section covers common usage of the following keywords, described in detail
9841in section 4.2 :
9842
9843 - reqadd <string>
9844 - reqallow <search>
9845 - reqiallow <search>
9846 - reqdel <search>
9847 - reqidel <search>
9848 - reqdeny <search>
9849 - reqideny <search>
9850 - reqpass <search>
9851 - reqipass <search>
9852 - reqrep <search> <replace>
9853 - reqirep <search> <replace>
9854 - reqtarpit <search>
9855 - reqitarpit <search>
9856 - rspadd <string>
9857 - rspdel <search>
9858 - rspidel <search>
9859 - rspdeny <search>
9860 - rspideny <search>
9861 - rsprep <search> <replace>
9862 - rspirep <search> <replace>
9863
9864With all these keywords, the same conventions are used. The <search> parameter
9865is a POSIX extended regular expression (regex) which supports grouping through
9866parenthesis (without the backslash). Spaces and other delimiters must be
9867prefixed with a backslash ('\') to avoid confusion with a field delimiter.
9868Other characters may be prefixed with a backslash to change their meaning :
9869
9870 \t for a tab
9871 \r for a carriage return (CR)
9872 \n for a new line (LF)
9873 \ to mark a space and differentiate it from a delimiter
9874 \# to mark a sharp and differentiate it from a comment
9875 \\ to use a backslash in a regex
9876 \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy)
9877 \xXX to write the ASCII hex code XX as in the C language
9878
9879The <replace> parameter contains the string to be used to replace the largest
9880portion of text matching the regex. It can make use of the special characters
9881above, and can reference a substring which is delimited by parenthesis in the
9882regex, by writing a backslash ('\') immediately followed by one digit from 0 to
98839 indicating the group position (0 designating the entire line). This practice
9884is very common to users of the "sed" program.
9885
9886The <string> parameter represents the string which will systematically be added
9887after the last header line. It can also use special character sequences above.
9888
9889Notes related to these keywords :
9890---------------------------------
9891 - these keywords are not always convenient to allow/deny based on header
9892 contents. It is strongly recommended to use ACLs with the "block" keyword
9893 instead, resulting in far more flexible and manageable rules.
9894
9895 - lines are always considered as a whole. It is not possible to reference
9896 a header name only or a value only. This is important because of the way
9897 headers are written (notably the number of spaces after the colon).
9898
9899 - the first line is always considered as a header, which makes it possible to
9900 rewrite or filter HTTP requests URIs or response codes, but in turn makes
9901 it harder to distinguish between headers and request line. The regex prefix
9902 ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix
9903 ^[^ \t:]*: matches any header name followed by a colon.
9904
9905 - for performances reasons, the number of characters added to a request or to
9906 a response is limited at build time to values between 1 and 4 kB. This
9907 should normally be far more than enough for most usages. If it is too short
9908 on occasional usages, it is possible to gain some space by removing some
9909 useless headers before adding new ones.
9910
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01009911 - keywords beginning with "reqi" and "rspi" are the same as their counterpart
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009912 without the 'i' letter except that they ignore case when matching patterns.
9913
9914 - when a request passes through a frontend then a backend, all req* rules
9915 from the frontend will be evaluated, then all req* rules from the backend
9916 will be evaluated. The reverse path is applied to responses.
9917
9918 - req* statements are applied after "block" statements, so that "block" is
9919 always the first one, but before "use_backend" in order to permit rewriting
Willy Tarreaud72758d2010-01-12 10:42:19 +01009920 before switching.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009921
9922
Willy Tarreau74ca5042013-06-11 23:12:07 +020099237. Using ACLs and fetching samples
9924----------------------------------
9925
9926Haproxy is capable of extracting data from request or response streams, from
9927client or server information, from tables, environmental information etc...
9928The action of extracting such data is called fetching a sample. Once retrieved,
9929these samples may be used for various purposes such as a key to a stick-table,
9930but most common usages consist in matching them against predefined constant
9931data called patterns.
9932
9933
99347.1. ACL basics
9935---------------
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009936
9937The use of Access Control Lists (ACL) provides a flexible solution to perform
9938content switching and generally to take decisions based on content extracted
9939from the request, the response or any environmental status. The principle is
9940simple :
9941
Willy Tarreau74ca5042013-06-11 23:12:07 +02009942 - extract a data sample from a stream, table or the environment
Willy Tarreaue6b11e42013-11-26 19:02:32 +01009943 - optionally apply some format conversion to the extracted sample
Willy Tarreau74ca5042013-06-11 23:12:07 +02009944 - apply one or multiple pattern matching methods on this sample
9945 - perform actions only when a pattern matches the sample
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009946
Willy Tarreau74ca5042013-06-11 23:12:07 +02009947The actions generally consist in blocking a request, selecting a backend, or
9948adding a header.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009949
9950In order to define a test, the "acl" keyword is used. The syntax is :
9951
Willy Tarreau74ca5042013-06-11 23:12:07 +02009952 acl <aclname> <criterion> [flags] [operator] [<value>] ...
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009953
9954This creates a new ACL <aclname> or completes an existing one with new tests.
9955Those tests apply to the portion of request/response specified in <criterion>
9956and may be adjusted with optional flags [flags]. Some criteria also support
Willy Tarreaue6b11e42013-11-26 19:02:32 +01009957an operator which may be specified before the set of values. Optionally some
9958conversion operators may be applied to the sample, and they will be specified
9959as a comma-delimited list of keywords just after the first keyword. The values
9960are of the type supported by the criterion, and are separated by spaces.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009961
9962ACL names must be formed from upper and lower case letters, digits, '-' (dash),
9963'_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive,
9964which means that "my_acl" and "My_Acl" are two different ACLs.
9965
9966There is no enforced limit to the number of ACLs. The unused ones do not affect
9967performance, they just consume a small amount of memory.
9968
Willy Tarreau74ca5042013-06-11 23:12:07 +02009969The criterion generally is the name of a sample fetch method, or one of its ACL
9970specific declinations. The default test method is implied by the output type of
9971this sample fetch method. The ACL declinations can describe alternate matching
Willy Tarreaue6b11e42013-11-26 19:02:32 +01009972methods of a same sample fetch method. The sample fetch methods are the only
9973ones supporting a conversion.
Willy Tarreau74ca5042013-06-11 23:12:07 +02009974
9975Sample fetch methods return data which can be of the following types :
9976 - boolean
9977 - integer (signed or unsigned)
9978 - IPv4 or IPv6 address
9979 - string
9980 - data block
9981
Willy Tarreaue6b11e42013-11-26 19:02:32 +01009982Converters transform any of these data into any of these. For example, some
9983converters might convert a string to a lower-case string while other ones
9984would turn a string to an IPv4 address, or apply a netmask to an IP address.
9985The resulting sample is of the type of the last converter applied to the list,
9986which defaults to the type of the sample fetch method.
9987
Thierry FOURNIER2a06e392014-05-11 15:49:55 +02009988Each sample or converter returns data of a specific type, specified with its
9989keyword in this documentation. When an ACL is declared using a standard sample
9990fetch method, certain types automatically involved a default matching method
9991which are summarized in the table below :
9992
9993 +---------------------+-----------------+
9994 | Sample or converter | Default |
9995 | output type | matching method |
9996 +---------------------+-----------------+
9997 | boolean | bool |
9998 +---------------------+-----------------+
9999 | integer | int |
10000 +---------------------+-----------------+
10001 | ip | ip |
10002 +---------------------+-----------------+
10003 | string | str |
10004 +---------------------+-----------------+
10005 | binary | none, use "-m" |
10006 +---------------------+-----------------+
10007
10008Note that in order to match a binary samples, it is mandatory to specify a
10009matching method, see below.
10010
Willy Tarreau74ca5042013-06-11 23:12:07 +020010011The ACL engine can match these types against patterns of the following types :
10012 - boolean
10013 - integer or integer range
10014 - IP address / network
10015 - string (exact, substring, suffix, prefix, subdir, domain)
10016 - regular expression
10017 - hex block
10018
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010019The following ACL flags are currently supported :
10020
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010021 -i : ignore case during matching of all subsequent patterns.
10022 -f : load patterns from a file.
Willy Tarreau74ca5042013-06-11 23:12:07 +020010023 -m : use a specific pattern matching method
Thierry FOURNIERb7729c92014-02-11 16:24:41 +010010024 -n : forbid the DNS resolutions
Thierry FOURNIER9860c412014-01-29 14:23:29 +010010025 -M : load the file pointed by -f like a map file.
Thierry FOURNIER3534d882014-01-20 17:01:44 +010010026 -u : force the unique id of the ACL
Willy Tarreau6a06a402007-07-15 20:15:28 +020010027 -- : force end of flags. Useful when a string looks like one of the flags.
10028
Willy Tarreau74ca5042013-06-11 23:12:07 +020010029The "-f" flag is followed by the name of a file from which all lines will be
10030read as individual values. It is even possible to pass multiple "-f" arguments
10031if the patterns are to be loaded from multiple files. Empty lines as well as
10032lines beginning with a sharp ('#') will be ignored. All leading spaces and tabs
10033will be stripped. If it is absolutely necessary to insert a valid pattern
10034beginning with a sharp, just prefix it with a space so that it is not taken for
10035a comment. Depending on the data type and match method, haproxy may load the
10036lines into a binary tree, allowing very fast lookups. This is true for IPv4 and
10037exact string matching. In this case, duplicates will automatically be removed.
10038
Thierry FOURNIER9860c412014-01-29 14:23:29 +010010039The "-M" flag allows an ACL to use a map file. If this flag is set, the file is
10040parsed as two column file. The first column contains the patterns used by the
10041ACL, and the second column contain the samples. The sample can be used later by
10042a map. This can be useful in some rare cases where an ACL would just be used to
10043check for the existence of a pattern in a map before a mapping is applied.
10044
Thierry FOURNIER3534d882014-01-20 17:01:44 +010010045The "-u" flag forces the unique id of the ACL. This unique id is used with the
10046socket interface to identify ACL and dynamically change its values. Note that a
10047file is always identified by its name even if an id is set.
10048
Willy Tarreau74ca5042013-06-11 23:12:07 +020010049Also, note that the "-i" flag applies to subsequent entries and not to entries
10050loaded from files preceding it. For instance :
10051
10052 acl valid-ua hdr(user-agent) -f exact-ua.lst -i -f generic-ua.lst test
10053
10054In this example, each line of "exact-ua.lst" will be exactly matched against
10055the "user-agent" header of the request. Then each line of "generic-ua" will be
10056case-insensitively matched. Then the word "test" will be insensitively matched
10057as well.
10058
10059The "-m" flag is used to select a specific pattern matching method on the input
10060sample. All ACL-specific criteria imply a pattern matching method and generally
10061do not need this flag. However, this flag is useful with generic sample fetch
10062methods to describe how they're going to be matched against the patterns. This
10063is required for sample fetches which return data type for which there is no
10064obvious matching method (eg: string or binary). When "-m" is specified and
10065followed by a pattern matching method name, this method is used instead of the
10066default one for the criterion. This makes it possible to match contents in ways
10067that were not initially planned, or with sample fetch methods which return a
10068string. The matching method also affects the way the patterns are parsed.
10069
Thierry FOURNIERb7729c92014-02-11 16:24:41 +010010070The "-n" flag forbids the dns resolutions. It is used with the load of ip files.
10071By default, if the parser cannot parse ip address it considers that the parsed
10072string is maybe a domain name and try dns resolution. The flag "-n" disable this
10073resolution. It is useful for detecting malformed ip lists. Note that if the DNS
10074server is not reachable, the haproxy configuration parsing may last many minutes
10075waiting fir the timeout. During this time no error messages are displayed. The
10076flag "-n" disable this behavior. Note also that during the runtime, this
10077function is disabled for the dynamic acl modifications.
10078
Willy Tarreau74ca5042013-06-11 23:12:07 +020010079There are some restrictions however. Not all methods can be used with all
10080sample fetch methods. Also, if "-m" is used in conjunction with "-f", it must
10081be placed first. The pattern matching method must be one of the following :
Willy Tarreau5adeda12013-03-31 22:13:34 +020010082
10083 - "found" : only check if the requested sample could be found in the stream,
10084 but do not compare it against any pattern. It is recommended not
Willy Tarreau74ca5042013-06-11 23:12:07 +020010085 to pass any pattern to avoid confusion. This matching method is
10086 particularly useful to detect presence of certain contents such
10087 as headers, cookies, etc... even if they are empty and without
10088 comparing them to anything nor counting them.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010089
10090 - "bool" : check the value as a boolean. It can only be applied to fetches
10091 which return a boolean or integer value, and takes no pattern.
Willy Tarreau74ca5042013-06-11 23:12:07 +020010092 Value zero or false does not match, all other values do match.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010093
10094 - "int" : match the value as an integer. It can be used with integer and
Willy Tarreau74ca5042013-06-11 23:12:07 +020010095 boolean samples. Boolean false is integer 0, true is integer 1.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010096
10097 - "ip" : match the value as an IPv4 or IPv6 address. It is compatible
Willy Tarreau74ca5042013-06-11 23:12:07 +020010098 with IP address samples only, so it is implied and never needed.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010099
10100 - "bin" : match the contents against an hexadecimal string representing a
10101 binary sequence. This may be used with binary or string samples.
10102
10103 - "len" : match the sample's length as an integer. This may be used with
10104 binary or string samples.
10105
Willy Tarreau74ca5042013-06-11 23:12:07 +020010106 - "str" : exact match : match the contents against a string. This may be
10107 used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010108
Willy Tarreau74ca5042013-06-11 23:12:07 +020010109 - "sub" : substring match : check that the contents contain at least one of
10110 the provided string patterns. This may be used with binary or
10111 string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010112
Willy Tarreau74ca5042013-06-11 23:12:07 +020010113 - "reg" : regex match : match the contents against a list of regular
10114 expressions. This may be used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010115
Willy Tarreau74ca5042013-06-11 23:12:07 +020010116 - "beg" : prefix match : check that the contents begin like the provided
10117 string patterns. This may be used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010118
Willy Tarreau74ca5042013-06-11 23:12:07 +020010119 - "end" : suffix match : check that the contents end like the provided
10120 string patterns. This may be used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010121
Willy Tarreau74ca5042013-06-11 23:12:07 +020010122 - "dir" : subdir match : check that a slash-delimited portion of the
10123 contents exactly matches one of the provided string patterns.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010124 This may be used with binary or string samples.
10125
Willy Tarreau74ca5042013-06-11 23:12:07 +020010126 - "dom" : domain match : check that a dot-delimited portion of the contents
10127 exactly match one of the provided string patterns. This may be
10128 used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010129
10130For example, to quickly detect the presence of cookie "JSESSIONID" in an HTTP
10131request, it is possible to do :
10132
10133 acl jsess_present cook(JSESSIONID) -m found
10134
10135In order to apply a regular expression on the 500 first bytes of data in the
10136buffer, one would use the following acl :
10137
10138 acl script_tag payload(0,500) -m reg -i <script>
10139
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010140On systems where the regex library is much slower when using "-i", it is
10141possible to convert the sample to lowercase before matching, like this :
10142
10143 acl script_tag payload(0,500),lower -m reg <script>
10144
Willy Tarreau74ca5042013-06-11 23:12:07 +020010145All ACL-specific criteria imply a default matching method. Most often, these
10146criteria are composed by concatenating the name of the original sample fetch
10147method and the matching method. For example, "hdr_beg" applies the "beg" match
10148to samples retrieved using the "hdr" fetch method. Since all ACL-specific
10149criteria rely on a sample fetch method, it is always possible instead to use
10150the original sample fetch method and the explicit matching method using "-m".
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010151
Willy Tarreau74ca5042013-06-11 23:12:07 +020010152If an alternate match is specified using "-m" on an ACL-specific criterion,
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030010153the matching method is simply applied to the underlying sample fetch method.
10154For example, all ACLs below are exact equivalent :
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010155
Willy Tarreau74ca5042013-06-11 23:12:07 +020010156 acl short_form hdr_beg(host) www.
10157 acl alternate1 hdr_beg(host) -m beg www.
10158 acl alternate2 hdr_dom(host) -m beg www.
10159 acl alternate3 hdr(host) -m beg www.
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010160
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010161
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010162The table below summarizes the compatibility matrix between sample or converter
10163types and the pattern types to fetch against. It indicates for each compatible
10164combination the name of the matching method to be used, surrounded with angle
10165brackets ">" and "<" when the method is the default one and will work by
10166default without "-m".
Willy Tarreau0ba27502007-12-24 16:55:16 +010010167
Willy Tarreau74ca5042013-06-11 23:12:07 +020010168 +-------------------------------------------------+
10169 | Input sample type |
10170 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010171 | pattern type | boolean | integer | ip | string | binary |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010172 +----------------------+---------+---------+---------+---------+---------+
10173 | none (presence only) | found | found | found | found | found |
10174 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010175 | none (boolean value) |> bool <| bool | | bool | |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010176 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010177 | integer (value) | int |> int <| int | int | |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010178 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010179 | integer (length) | len | len | len | len | len |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010180 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010181 | IP address | | |> ip <| ip | ip |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010182 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010183 | exact string | str | str | str |> str <| str |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010184 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010185 | prefix | beg | beg | beg | beg | beg |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010186 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010187 | suffix | end | end | end | end | end |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010188 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010189 | substring | sub | sub | sub | sub | sub |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010190 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010191 | subdir | dir | dir | dir | dir | dir |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010192 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010193 | domain | dom | dom | dom | dom | dom |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010194 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010195 | regex | reg | reg | reg | reg | reg |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010196 +----------------------+---------+---------+---------+---------+---------+
10197 | hex block | | | | bin | bin |
10198 +----------------------+---------+---------+---------+---------+---------+
Willy Tarreau6a06a402007-07-15 20:15:28 +020010199
10200
Willy Tarreau74ca5042013-06-11 23:12:07 +0200102017.1.1. Matching booleans
10202------------------------
10203
10204In order to match a boolean, no value is needed and all values are ignored.
10205Boolean matching is used by default for all fetch methods of type "boolean".
10206When boolean matching is used, the fetched value is returned as-is, which means
10207that a boolean "true" will always match and a boolean "false" will never match.
10208
10209Boolean matching may also be enforced using "-m bool" on fetch methods which
10210return an integer value. Then, integer value 0 is converted to the boolean
10211"false" and all other values are converted to "true".
10212
Willy Tarreau6a06a402007-07-15 20:15:28 +020010213
Willy Tarreau74ca5042013-06-11 23:12:07 +0200102147.1.2. Matching integers
10215------------------------
10216
10217Integer matching applies by default to integer fetch methods. It can also be
10218enforced on boolean fetches using "-m int". In this case, "false" is converted
10219to the integer 0, and "true" is converted to the integer 1.
10220
10221Integer matching also supports integer ranges and operators. Note that integer
10222matching only applies to positive values. A range is a value expressed with a
10223lower and an upper bound separated with a colon, both of which may be omitted.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010224
10225For instance, "1024:65535" is a valid range to represent a range of
10226unprivileged ports, and "1024:" would also work. "0:1023" is a valid
10227representation of privileged ports, and ":1023" would also work.
10228
Willy Tarreau62644772008-07-16 18:36:06 +020010229As a special case, some ACL functions support decimal numbers which are in fact
10230two integers separated by a dot. This is used with some version checks for
10231instance. All integer properties apply to those decimal numbers, including
10232ranges and operators.
10233
Willy Tarreau6a06a402007-07-15 20:15:28 +020010234For an easier usage, comparison operators are also supported. Note that using
Willy Tarreau0ba27502007-12-24 16:55:16 +010010235operators with ranges does not make much sense and is strongly discouraged.
10236Similarly, it does not make much sense to perform order comparisons with a set
10237of values.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010238
Willy Tarreau0ba27502007-12-24 16:55:16 +010010239Available operators for integer matching are :
Willy Tarreau6a06a402007-07-15 20:15:28 +020010240
10241 eq : true if the tested value equals at least one value
10242 ge : true if the tested value is greater than or equal to at least one value
10243 gt : true if the tested value is greater than at least one value
10244 le : true if the tested value is less than or equal to at least one value
10245 lt : true if the tested value is less than at least one value
10246
Willy Tarreau0ba27502007-12-24 16:55:16 +010010247For instance, the following ACL matches any negative Content-Length header :
Willy Tarreau6a06a402007-07-15 20:15:28 +020010248
10249 acl negative-length hdr_val(content-length) lt 0
10250
Willy Tarreau62644772008-07-16 18:36:06 +020010251This one matches SSL versions between 3.0 and 3.1 (inclusive) :
10252
10253 acl sslv3 req_ssl_ver 3:3.1
10254
Willy Tarreau6a06a402007-07-15 20:15:28 +020010255
Willy Tarreau74ca5042013-06-11 23:12:07 +0200102567.1.3. Matching strings
10257-----------------------
10258
10259String matching applies to string or binary fetch methods, and exists in 6
10260different forms :
10261
10262 - exact match (-m str) : the extracted string must exactly match the
10263 patterns ;
10264
10265 - substring match (-m sub) : the patterns are looked up inside the
10266 extracted string, and the ACL matches if any of them is found inside ;
10267
10268 - prefix match (-m beg) : the patterns are compared with the beginning of
10269 the extracted string, and the ACL matches if any of them matches.
10270
10271 - suffix match (-m end) : the patterns are compared with the end of the
10272 extracted string, and the ACL matches if any of them matches.
10273
10274 - subdir match (-m sub) : the patterns are looked up inside the extracted
10275 string, delimited with slashes ("/"), and the ACL matches if any of them
10276 matches.
10277
10278 - domain match (-m dom) : the patterns are looked up inside the extracted
10279 string, delimited with dots ("."), and the ACL matches if any of them
10280 matches.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010281
10282String matching applies to verbatim strings as they are passed, with the
10283exception of the backslash ("\") which makes it possible to escape some
10284characters such as the space. If the "-i" flag is passed before the first
10285string, then the matching will be performed ignoring the case. In order
10286to match the string "-i", either set it second, or pass the "--" flag
Willy Tarreau0ba27502007-12-24 16:55:16 +010010287before the first string. Same applies of course to match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +020010288
10289
Willy Tarreau74ca5042013-06-11 23:12:07 +0200102907.1.4. Matching regular expressions (regexes)
10291---------------------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +020010292
10293Just like with string matching, regex matching applies to verbatim strings as
10294they are passed, with the exception of the backslash ("\") which makes it
10295possible to escape some characters such as the space. If the "-i" flag is
10296passed before the first regex, then the matching will be performed ignoring
10297the case. In order to match the string "-i", either set it second, or pass
Willy Tarreau0ba27502007-12-24 16:55:16 +010010298the "--" flag before the first string. Same principle applies of course to
10299match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +020010300
10301
Willy Tarreau74ca5042013-06-11 23:12:07 +0200103027.1.5. Matching arbitrary data blocks
10303-------------------------------------
10304
10305It is possible to match some extracted samples against a binary block which may
10306not safely be represented as a string. For this, the patterns must be passed as
10307a series of hexadecimal digits in an even number, when the match method is set
10308to binary. Each sequence of two digits will represent a byte. The hexadecimal
10309digits may be used upper or lower case.
10310
10311Example :
10312 # match "Hello\n" in the input stream (\x48 \x65 \x6c \x6c \x6f \x0a)
10313 acl hello payload(0,6) -m bin 48656c6c6f0a
10314
10315
103167.1.6. Matching IPv4 and IPv6 addresses
10317---------------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +020010318
10319IPv4 addresses values can be specified either as plain addresses or with a
10320netmask appended, in which case the IPv4 address matches whenever it is
10321within the network. Plain addresses may also be replaced with a resolvable
Willy Tarreaud2a4aa22008-01-31 15:28:22 +010010322host name, but this practice is generally discouraged as it makes it more
Willy Tarreau0ba27502007-12-24 16:55:16 +010010323difficult to read and debug configurations. If hostnames are used, you should
10324at least ensure that they are present in /etc/hosts so that the configuration
10325does not depend on any random DNS match at the moment the configuration is
10326parsed.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010327
Willy Tarreauceb4ac92012-04-28 00:41:46 +020010328IPv6 may be entered in their usual form, with or without a netmask appended.
10329Only bit counts are accepted for IPv6 netmasks. In order to avoid any risk of
10330trouble with randomly resolved IP addresses, host names are never allowed in
10331IPv6 patterns.
10332
10333HAProxy is also able to match IPv4 addresses with IPv6 addresses in the
10334following situations :
10335 - tested address is IPv4, pattern address is IPv4, the match applies
10336 in IPv4 using the supplied mask if any.
10337 - tested address is IPv6, pattern address is IPv6, the match applies
10338 in IPv6 using the supplied mask if any.
10339 - tested address is IPv6, pattern address is IPv4, the match applies in IPv4
10340 using the pattern's mask if the IPv6 address matches with 2002:IPV4::,
10341 ::IPV4 or ::ffff:IPV4, otherwise it fails.
10342 - tested address is IPv4, pattern address is IPv6, the IPv4 address is first
10343 converted to IPv6 by prefixing ::ffff: in front of it, then the match is
10344 applied in IPv6 using the supplied IPv6 mask.
10345
Willy Tarreau74ca5042013-06-11 23:12:07 +020010346
103477.2. Using ACLs to form conditions
10348----------------------------------
10349
10350Some actions are only performed upon a valid condition. A condition is a
10351combination of ACLs with operators. 3 operators are supported :
10352
10353 - AND (implicit)
10354 - OR (explicit with the "or" keyword or the "||" operator)
10355 - Negation with the exclamation mark ("!")
Willy Tarreau6a06a402007-07-15 20:15:28 +020010356
Willy Tarreau74ca5042013-06-11 23:12:07 +020010357A condition is formed as a disjunctive form:
Willy Tarreau6a06a402007-07-15 20:15:28 +020010358
Willy Tarreau74ca5042013-06-11 23:12:07 +020010359 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
Willy Tarreaubef91e72013-03-31 23:14:46 +020010360
Willy Tarreau74ca5042013-06-11 23:12:07 +020010361Such conditions are generally used after an "if" or "unless" statement,
10362indicating when the condition will trigger the action.
Willy Tarreaubef91e72013-03-31 23:14:46 +020010363
Willy Tarreau74ca5042013-06-11 23:12:07 +020010364For instance, to block HTTP requests to the "*" URL with methods other than
10365"OPTIONS", as well as POST requests without content-length, and GET or HEAD
10366requests with a content-length greater than 0, and finally every request which
10367is not either GET/HEAD/POST/OPTIONS !
10368
10369 acl missing_cl hdr_cnt(Content-length) eq 0
10370 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
10371 block if METH_GET HTTP_CONTENT
10372 block unless METH_GET or METH_POST or METH_OPTIONS
10373
10374To select a different backend for requests to static contents on the "www" site
10375and to every request on the "img", "video", "download" and "ftp" hosts :
10376
10377 acl url_static path_beg /static /images /img /css
10378 acl url_static path_end .gif .png .jpg .css .js
10379 acl host_www hdr_beg(host) -i www
10380 acl host_static hdr_beg(host) -i img. video. download. ftp.
10381
10382 # now use backend "static" for all static-only hosts, and for static urls
10383 # of host "www". Use backend "www" for the rest.
10384 use_backend static if host_static or host_www url_static
10385 use_backend www if host_www
10386
10387It is also possible to form rules using "anonymous ACLs". Those are unnamed ACL
10388expressions that are built on the fly without needing to be declared. They must
10389be enclosed between braces, with a space before and after each brace (because
10390the braces must be seen as independent words). Example :
10391
10392 The following rule :
10393
10394 acl missing_cl hdr_cnt(Content-length) eq 0
10395 block if METH_POST missing_cl
10396
10397 Can also be written that way :
10398
10399 block if METH_POST { hdr_cnt(Content-length) eq 0 }
10400
10401It is generally not recommended to use this construct because it's a lot easier
10402to leave errors in the configuration when written that way. However, for very
10403simple rules matching only one source IP address for instance, it can make more
10404sense to use them than to declare ACLs with random names. Another example of
10405good use is the following :
10406
10407 With named ACLs :
10408
10409 acl site_dead nbsrv(dynamic) lt 2
10410 acl site_dead nbsrv(static) lt 2
10411 monitor fail if site_dead
10412
10413 With anonymous ACLs :
10414
10415 monitor fail if { nbsrv(dynamic) lt 2 } || { nbsrv(static) lt 2 }
10416
10417See section 4.2 for detailed help on the "block" and "use_backend" keywords.
10418
10419
104207.3. Fetching samples
10421---------------------
10422
10423Historically, sample fetch methods were only used to retrieve data to match
10424against patterns using ACLs. With the arrival of stick-tables, a new class of
10425sample fetch methods was created, most often sharing the same syntax as their
10426ACL counterpart. These sample fetch methods are also known as "fetches". As
10427of now, ACLs and fetches have converged. All ACL fetch methods have been made
10428available as fetch methods, and ACLs may use any sample fetch method as well.
10429
10430This section details all available sample fetch methods and their output type.
10431Some sample fetch methods have deprecated aliases that are used to maintain
10432compatibility with existing configurations. They are then explicitly marked as
10433deprecated and should not be used in new setups.
10434
10435The ACL derivatives are also indicated when available, with their respective
10436matching methods. These ones all have a well defined default pattern matching
10437method, so it is never necessary (though allowed) to pass the "-m" option to
10438indicate how the sample will be matched using ACLs.
10439
10440As indicated in the sample type versus matching compatibility matrix above,
10441when using a generic sample fetch method in an ACL, the "-m" option is
10442mandatory unless the sample type is one of boolean, integer, IPv4 or IPv6. When
10443the same keyword exists as an ACL keyword and as a standard fetch method, the
10444ACL engine will automatically pick the ACL-only one by default.
10445
10446Some of these keywords support one or multiple mandatory arguments, and one or
10447multiple optional arguments. These arguments are strongly typed and are checked
10448when the configuration is parsed so that there is no risk of running with an
10449incorrect argument (eg: an unresolved backend name). Fetch function arguments
10450are passed between parenthesis and are delimited by commas. When an argument
10451is optional, it will be indicated below between square brackets ('[ ]'). When
10452all arguments are optional, the parenthesis may be omitted.
10453
10454Thus, the syntax of a standard sample fetch method is one of the following :
10455 - name
10456 - name(arg1)
10457 - name(arg1,arg2)
10458
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010459
104607.3.1. Converters
10461-----------------
10462
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010463Sample fetch methods may be combined with transformations to be applied on top
10464of the fetched sample (also called "converters"). These combinations form what
10465is called "sample expressions" and the result is a "sample". Initially this
10466was only supported by "stick on" and "stick store-request" directives but this
10467has now be extended to all places where samples may be used (acls, log-format,
10468unique-id-format, add-header, ...).
10469
10470These transformations are enumerated as a series of specific keywords after the
10471sample fetch method. These keywords may equally be appended immediately after
10472the fetch keyword's argument, delimited by a comma. These keywords can also
10473support some arguments (eg: a netmask) which must be passed in parenthesis.
Willy Tarreau0ba27502007-12-24 16:55:16 +010010474
Willy Tarreau97707872015-01-27 15:12:13 +010010475A certain category of converters are bitwise and arithmetic operators which
10476support performing basic operations on integers. Some bitwise operations are
10477supported (and, or, xor, cpl) and some arithmetic operations are supported
10478(add, sub, mul, div, mod, neg). Some comparators are provided (odd, even, not,
10479bool) which make it possible to report a match without having to write an ACL.
10480
Willy Tarreau74ca5042013-06-11 23:12:07 +020010481The currently available list of transformation keywords include :
Willy Tarreau0ba27502007-12-24 16:55:16 +010010482
Willy Tarreau97707872015-01-27 15:12:13 +010010483add(<value>)
10484 Adds <value> to the input value of type unsigned integer, and returns the
10485 result as an unsigned integer.
10486
10487and(<value>)
10488 Performs a bitwise "AND" between <value> and the input value of type unsigned
10489 integer, and returns the result as an unsigned integer.
10490
Emeric Brun53d1a982014-04-30 18:21:37 +020010491base64
10492 Converts a binary input sample to a base64 string. It is used to log or
10493 transfer binary content in a way that can be reliably transferred (eg:
10494 an SSL ID can be copied in a header).
10495
Willy Tarreau97707872015-01-27 15:12:13 +010010496bool
10497 Returns a boolean TRUE if the input value of type unsigned integer is
10498 non-null, otherwise returns FALSE. Used in conjunction with and(), it can be
10499 used to report true/false for bit testing on input values (eg: verify the
10500 presence of a flag).
10501
Emeric Brun54c4ac82014-11-03 15:32:43 +010010502bytes(<offset>[,<length>])
10503 Extracts some bytes from an input binary sample. The result is a binary
10504 sample starting at an offset (in bytes) of the original sample and
10505 optionnaly truncated at the given length.
10506
Willy Tarreau97707872015-01-27 15:12:13 +010010507cpl
10508 Takes the input value of type unsigned integer, applies a twos-complement
10509 (flips all bits) and returns the result as an unsigned integer.
10510
Willy Tarreau80599772015-01-20 19:35:24 +010010511crc32([<avalanche>])
10512 Hashes a binary input sample into an unsigned 32-bit quantity using the CRC32
10513 hash function. Optionally, it is possible to apply a full avalanche hash
10514 function to the output if the optional <avalanche> argument equals 1. This
10515 converter uses the same functions as used by the various hash-based load
10516 balancing algorithms, so it will provide exactly the same results. It is
10517 provided for compatibility with other software which want a CRC32 to be
10518 computed on some input keys, so it follows the most common implementation as
10519 found in Ethernet, Gzip, PNG, etc... It is slower than the other algorithms
10520 but may provide a better or at least less predictable distribution. It must
10521 not be used for security purposes as a 32-bit hash is trivial to break. See
10522 also "djb2", "sdbm", "wt6" and the "hash-type" directive.
10523
Willy Tarreau97707872015-01-27 15:12:13 +010010524div(<value>)
10525 Divides the input value of type unsigned integer by <value>, and returns the
10526 result as an unsigned integer. If <value> is null, the largest unsigned
10527 integer is returned (typically 2^32-1).
10528
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020010529djb2([<avalanche>])
10530 Hashes a binary input sample into an unsigned 32-bit quantity using the DJB2
10531 hash function. Optionally, it is possible to apply a full avalanche hash
10532 function to the output if the optional <avalanche> argument equals 1. This
10533 converter uses the same functions as used by the various hash-based load
10534 balancing algorithms, so it will provide exactly the same results. It is
10535 mostly intended for debugging, but can be used as a stick-table entry to
10536 collect rough statistics. It must not be used for security purposes as a
Willy Tarreau80599772015-01-20 19:35:24 +010010537 32-bit hash is trivial to break. See also "crc32", "sdbm", "wt6" and the
10538 "hash-type" directive.
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020010539
Willy Tarreau97707872015-01-27 15:12:13 +010010540even
10541 Returns a boolean TRUE if the input value of type unsigned integer is even
10542 otherwise returns FALSE. It is functionally equivalent to "not,and(1),bool".
10543
Emeric Brunf399b0d2014-11-03 17:07:03 +010010544field(<index>,<delimiters>)
10545 Extracts the substring at the given index considering given delimiters from
10546 an input string. Indexes start at 1 and delimiters are a string formatted
10547 list of chars.
10548
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010549hex
10550 Converts a binary input sample to an hex string containing two hex digits per
10551 input byte. It is used to log or transfer hex dumps of some binary input data
10552 in a way that can be reliably transferred (eg: an SSL ID can be copied in a
10553 header).
Thierry FOURNIER2f49d6d2014-03-12 15:01:52 +010010554
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010555http_date([<offset>])
10556 Converts an integer supposed to contain a date since epoch to a string
10557 representing this date in a format suitable for use in HTTP header fields. If
10558 an offset value is specified, then it is a number of seconds that is added to
10559 the date before the conversion is operated. This is particularly useful to
10560 emit Date header fields, Expires values in responses when combined with a
10561 positive offset, or Last-Modified values when the offset is negative.
Willy Tarreau74ca5042013-06-11 23:12:07 +020010562
Willy Tarreaud9f316a2014-07-10 14:03:38 +020010563in_table(<table>)
10564 Uses the string representation of the input sample to perform a look up in
10565 the specified table. If the key is not found in the table, a boolean false
10566 is returned. Otherwise a boolean true is returned. This can be used to verify
10567 the presence of a certain key in a table tracking some elements (eg: whether
10568 or not a source IP address or an Authorization header was already seen).
10569
Willy Tarreauffcb2e42014-07-10 16:29:08 +020010570ipmask(<mask>)
10571 Apply a mask to an IPv4 address, and use the result for lookups and storage.
10572 This can be used to make all hosts within a certain mask to share the same
10573 table entries and as such use the same server. The mask can be passed in
10574 dotted form (eg: 255.255.255.0) or in CIDR form (eg: 24).
10575
Thierry FOURNIER317e1c42014-08-12 10:20:47 +020010576json([<input-code>])
10577 Escapes the input string and produces an ASCII ouput string ready to use as a
10578 JSON string. The converter tries to decode the input string according to the
10579 <input-code> parameter. It can be "ascii", "utf8", "utf8s", "utf8"" or
10580 "utf8ps". The "ascii" decoder never fails. The "utf8" decoder detects 3 types
10581 of errors:
10582 - bad UTF-8 sequence (lone continuation byte, bad number of continuation
10583 bytes, ...)
10584 - invalid range (the decoded value is within a UTF-8 prohibited range),
10585 - code overlong (the value is encoded with more bytes than necessary).
10586
10587 The UTF-8 JSON encoding can produce a "too long value" error when the UTF-8
10588 character is greater than 0xffff because the JSON string escape specification
10589 only authorizes 4 hex digits for the value encoding. The UTF-8 decoder exists
10590 in 4 variants designated by a combination of two suffix letters : "p" for
10591 "permissive" and "s" for "silently ignore". The behaviors of the decoders
10592 are :
10593 - "ascii" : never fails ;
10594 - "utf8" : fails on any detected errors ;
10595 - "utf8s" : never fails, but removes characters corresponding to errors ;
10596 - "utf8p" : accepts and fixes the overlong errors, but fails on any other
10597 error ;
10598 - "utf8ps" : never fails, accepts and fixes the overlong errors, but removes
10599 characters corresponding to the other errors.
10600
10601 This converter is particularly useful for building properly escaped JSON for
10602 logging to servers which consume JSON-formated traffic logs.
10603
10604 Example:
10605 capture request header user-agent len 150
10606 capture request header Host len 15
10607 log-format {"ip":"%[src]","user-agent":"%[capture.req.hdr(1),json]"}
10608
10609 Input request from client 127.0.0.1:
10610 GET / HTTP/1.0
10611 User-Agent: Very "Ugly" UA 1/2
10612
10613 Output log:
10614 {"ip":"127.0.0.1","user-agent":"Very \"Ugly\" UA 1\/2"}
10615
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010616language(<value>[,<default>])
10617 Returns the value with the highest q-factor from a list as extracted from the
10618 "accept-language" header using "req.fhdr". Values with no q-factor have a
10619 q-factor of 1. Values with a q-factor of 0 are dropped. Only values which
10620 belong to the list of semi-colon delimited <values> will be considered. The
10621 argument <value> syntax is "lang[;lang[;lang[;...]]]". If no value matches the
10622 given list and a default value is provided, it is returned. Note that language
10623 names may have a variant after a dash ('-'). If this variant is present in the
10624 list, it will be matched, but if it is not, only the base language is checked.
10625 The match is case-sensitive, and the output string is always one of those
10626 provided in arguments. The ordering of arguments is meaningless, only the
10627 ordering of the values in the request counts, as the first value among
10628 multiple sharing the same q-factor is used.
Thierry FOURNIERad903512014-04-11 17:51:01 +020010629
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010630 Example :
Thierry FOURNIERad903512014-04-11 17:51:01 +020010631
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010632 # this configuration switches to the backend matching a
10633 # given language based on the request :
Thierry FOURNIERad903512014-04-11 17:51:01 +020010634
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010635 acl es req.fhdr(accept-language),language(es;fr;en) -m str es
10636 acl fr req.fhdr(accept-language),language(es;fr;en) -m str fr
10637 acl en req.fhdr(accept-language),language(es;fr;en) -m str en
10638 use_backend spanish if es
10639 use_backend french if fr
10640 use_backend english if en
10641 default_backend choose_your_language
Thierry FOURNIERad903512014-04-11 17:51:01 +020010642
Willy Tarreauffcb2e42014-07-10 16:29:08 +020010643lower
10644 Convert a string sample to lower case. This can only be placed after a string
10645 sample fetch function or after a transformation keyword returning a string
10646 type. The result is of type string.
10647
Willy Tarreau0dbfdba2014-07-10 16:37:47 +020010648ltime(<format>[,<offset>])
10649 Converts an integer supposed to contain a date since epoch to a string
10650 representing this date in local time using a format defined by the <format>
10651 string using strftime(3). The purpose is to allow any date format to be used
10652 in logs. An optional <offset> in seconds may be applied to the input date
10653 (positive or negative). See the strftime() man page for the format supported
10654 by your operating system. See also the utime converter.
10655
10656 Example :
10657
10658 # Emit two colons, one with the local time and another with ip:port
10659 # Eg: 20140710162350 127.0.0.1:57325
10660 log-format %[date,ltime(%Y%m%d%H%M%S)]\ %ci:%cp
10661
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010662map(<map_file>[,<default_value>])
10663map_<match_type>(<map_file>[,<default_value>])
10664map_<match_type>_<output_type>(<map_file>[,<default_value>])
10665 Search the input value from <map_file> using the <match_type> matching method,
10666 and return the associated value converted to the type <output_type>. If the
10667 input value cannot be found in the <map_file>, the converter returns the
10668 <default_value>. If the <default_value> is not set, the converter fails and
10669 acts as if no input value could be fetched. If the <match_type> is not set, it
10670 defaults to "str". Likewise, if the <output_type> is not set, it defaults to
10671 "str". For convenience, the "map" keyword is an alias for "map_str" and maps a
10672 string to another string.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010010673
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010674 It is important to avoid overlapping between the keys : IP addresses and
10675 strings are stored in trees, so the first of the finest match will be used.
10676 Other keys are stored in lists, so the first matching occurrence will be used.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010010677
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010678 The following array contains the list of all map functions avalaible sorted by
10679 input type, match type and output type.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010010680
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010681 input type | match method | output type str | output type int | output type ip
10682 -----------+--------------+-----------------+-----------------+---------------
10683 str | str | map_str | map_str_int | map_str_ip
10684 -----------+--------------+-----------------+-----------------+---------------
Willy Tarreau787a4c02014-05-10 07:55:30 +020010685 str | beg | map_beg | map_beg_int | map_end_ip
10686 -----------+--------------+-----------------+-----------------+---------------
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010687 str | sub | map_sub | map_sub_int | map_sub_ip
10688 -----------+--------------+-----------------+-----------------+---------------
10689 str | dir | map_dir | map_dir_int | map_dir_ip
10690 -----------+--------------+-----------------+-----------------+---------------
10691 str | dom | map_dom | map_dom_int | map_dom_ip
10692 -----------+--------------+-----------------+-----------------+---------------
10693 str | end | map_end | map_end_int | map_end_ip
10694 -----------+--------------+-----------------+-----------------+---------------
10695 str | reg | map_reg | map_reg_int | map_reg_ip
10696 -----------+--------------+-----------------+-----------------+---------------
10697 int | int | map_int | map_int_int | map_int_ip
10698 -----------+--------------+-----------------+-----------------+---------------
10699 ip | ip | map_ip | map_ip_int | map_ip_ip
10700 -----------+--------------+-----------------+-----------------+---------------
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010010701
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010702 The file contains one key + value per line. Lines which start with '#' are
10703 ignored, just like empty lines. Leading tabs and spaces are stripped. The key
10704 is then the first "word" (series of non-space/tabs characters), and the value
10705 is what follows this series of space/tab till the end of the line excluding
10706 trailing spaces/tabs.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010010707
Thierry FOURNIER060762e2014-04-23 13:29:15 +020010708 Example :
10709
10710 # this is a comment and is ignored
10711 2.22.246.0/23 United Kingdom \n
10712 <-><-----------><--><------------><---->
10713 | | | | `- trailing spaces ignored
10714 | | | `---------- value
10715 | | `-------------------- middle spaces ignored
10716 | `---------------------------- key
10717 `------------------------------------ leading spaces ignored
10718
Willy Tarreau97707872015-01-27 15:12:13 +010010719mod(<value>)
10720 Divides the input value of type unsigned integer by <value>, and returns the
10721 remainder as an unsigned integer. If <value> is null, then zero is returned.
10722
10723mul(<value>)
10724 Multiplies the input value of type unsigned integer by <value>, and returns
10725 the product as an unsigned integer. In case of overflow, the higher bits are
10726 lost, leading to seemingly strange values.
10727
10728neg
10729 Takes the input value of type unsigned integer, computes the opposite value,
10730 and returns the remainder as an unsigned integer. 0 is identity. This
10731 operator is provided for reversed subtracts : in order to subtract the input
10732 from a constant, simply perform a "neg,add(value)".
10733
10734not
10735 Returns a boolean FALSE if the input value of type unsigned integer is
10736 non-null, otherwise returns TRUE. Used in conjunction with and(), it can be
10737 used to report true/false for bit testing on input values (eg: verify the
10738 absence of a flag).
10739
10740odd
10741 Returns a boolean TRUE if the input value of type unsigned integer is odd
10742 otherwise returns FALSE. It is functionally equivalent to "and(1),bool".
10743
10744or(<value>)
10745 Performs a bitwise "OR" between <value> and the input value of type unsigned
10746 integer, and returns the result as an unsigned integer.
10747
Willy Tarreauc4dc3502015-01-23 20:39:28 +010010748regsub(<regex>,<subst>[,<flags>])
Willy Tarreau7eda8492015-01-20 19:47:06 +010010749 Applies a regex-based substitution to the input string. It does the same
10750 operation as the well-known "sed" utility with "s/<regex>/<subst>/". By
10751 default it will replace in the input string the first occurrence of the
10752 largest part matching the regular expression <regex> with the substitution
10753 string <subst>. It is possible to replace all occurrences instead by adding
10754 the flag "g" in the third argument <flags>. It is also possible to make the
10755 regex case insensitive by adding the flag "i" in <flags>. Since <flags> is a
10756 string, it is made up from the concatenation of all desired flags. Thus if
10757 both "i" and "g" are desired, using "gi" or "ig" will have the same effect.
10758 It is important to note that due to the current limitations of the
10759 configuration parser, some characters such as closing parenthesis or comma
10760 are not possible to use in the arguments. The first use of this converter is
10761 to replace certain characters or sequence of characters with other ones.
10762
10763 Example :
10764
10765 # de-duplicate "/" in header "x-path".
10766 # input: x-path: /////a///b/c/xzxyz/
10767 # output: x-path: /a/b/c/xzxyz/
10768 http-request set-header x-path %[hdr(x-path),regsub(/+,/,g)]
10769
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020010770sdbm([<avalanche>])
10771 Hashes a binary input sample into an unsigned 32-bit quantity using the SDBM
10772 hash function. Optionally, it is possible to apply a full avalanche hash
10773 function to the output if the optional <avalanche> argument equals 1. This
10774 converter uses the same functions as used by the various hash-based load
10775 balancing algorithms, so it will provide exactly the same results. It is
10776 mostly intended for debugging, but can be used as a stick-table entry to
10777 collect rough statistics. It must not be used for security purposes as a
Willy Tarreau80599772015-01-20 19:35:24 +010010778 32-bit hash is trivial to break. See also "crc32", "djb2", "wt6" and the
10779 "hash-type" directive.
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020010780
Willy Tarreau97707872015-01-27 15:12:13 +010010781sub(<value>)
10782 Subtracts <value> from the input value of type unsigned integer, and returns
10783 the result as an unsigned integer. Note: in order to subtract the input from
10784 a constant, simply perform a "neg,add(value)".
10785
Willy Tarreaud9f316a2014-07-10 14:03:38 +020010786table_bytes_in_rate(<table>)
10787 Uses the string representation of the input sample to perform a look up in
10788 the specified table. If the key is not found in the table, integer value zero
10789 is returned. Otherwise the converter returns the average client-to-server
10790 bytes rate associated with the input sample in the designated table, measured
10791 in amount of bytes over the period configured in the table. See also the
10792 sc_bytes_in_rate sample fetch keyword.
10793
10794
10795table_bytes_out_rate(<table>)
10796 Uses the string representation of the input sample to perform a look up in
10797 the specified table. If the key is not found in the table, integer value zero
10798 is returned. Otherwise the converter returns the average server-to-client
10799 bytes rate associated with the input sample in the designated table, measured
10800 in amount of bytes over the period configured in the table. See also the
10801 sc_bytes_out_rate sample fetch keyword.
10802
10803table_conn_cnt(<table>)
10804 Uses the string representation of the input sample to perform a look up in
10805 the specified table. If the key is not found in the table, integer value zero
10806 is returned. Otherwise the converter returns the cumulated amount of incoming
10807 connections associated with the input sample in the designated table. See
10808 also the sc_conn_cnt sample fetch keyword.
10809
10810table_conn_cur(<table>)
10811 Uses the string representation of the input sample to perform a look up in
10812 the specified table. If the key is not found in the table, integer value zero
10813 is returned. Otherwise the converter returns the current amount of concurrent
10814 tracked connections associated with the input sample in the designated table.
10815 See also the sc_conn_cur sample fetch keyword.
10816
10817table_conn_rate(<table>)
10818 Uses the string representation of the input sample to perform a look up in
10819 the specified table. If the key is not found in the table, integer value zero
10820 is returned. Otherwise the converter returns the average incoming connection
10821 rate associated with the input sample in the designated table. See also the
10822 sc_conn_rate sample fetch keyword.
10823
10824table_gpc0(<table>)
10825 Uses the string representation of the input sample to perform a look up in
10826 the specified table. If the key is not found in the table, integer value zero
10827 is returned. Otherwise the converter returns the current value of the first
10828 general purpose counter associated with the input sample in the designated
10829 table. See also the sc_get_gpc0 sample fetch keyword.
10830
10831table_gpc0_rate(<table>)
10832 Uses the string representation of the input sample to perform a look up in
10833 the specified table. If the key is not found in the table, integer value zero
10834 is returned. Otherwise the converter returns the frequency which the gpc0
10835 counter was incremented over the configured period in the table, associated
10836 with the input sample in the designated table. See also the sc_get_gpc0_rate
10837 sample fetch keyword.
10838
10839table_http_err_cnt(<table>)
10840 Uses the string representation of the input sample to perform a look up in
10841 the specified table. If the key is not found in the table, integer value zero
10842 is returned. Otherwise the converter returns the cumulated amount of HTTP
10843 errors associated with the input sample in the designated table. See also the
10844 sc_http_err_cnt sample fetch keyword.
10845
10846table_http_err_rate(<table>)
10847 Uses the string representation of the input sample to perform a look up in
10848 the specified table. If the key is not found in the table, integer value zero
10849 is returned. Otherwise the average rate of HTTP errors associated with the
10850 input sample in the designated table, measured in amount of errors over the
10851 period configured in the table. See also the sc_http_err_rate sample fetch
10852 keyword.
10853
10854table_http_req_cnt(<table>)
10855 Uses the string representation of the input sample to perform a look up in
10856 the specified table. If the key is not found in the table, integer value zero
10857 is returned. Otherwise the converter returns the cumulated amount of HTTP
10858 requests associated with the input sample in the designated table. See also
10859 the sc_http_req_cnt sample fetch keyword.
10860
10861table_http_req_rate(<table>)
10862 Uses the string representation of the input sample to perform a look up in
10863 the specified table. If the key is not found in the table, integer value zero
10864 is returned. Otherwise the average rate of HTTP requests associated with the
10865 input sample in the designated table, measured in amount of requests over the
10866 period configured in the table. See also the sc_http_req_rate sample fetch
10867 keyword.
10868
10869table_kbytes_in(<table>)
10870 Uses the string representation of the input sample to perform a look up in
10871 the specified table. If the key is not found in the table, integer value zero
10872 is returned. Otherwise the converter returns the cumulated amount of client-
10873 to-server data associated with the input sample in the designated table,
10874 measured in kilobytes. The test is currently performed on 32-bit integers,
10875 which limits values to 4 terabytes. See also the sc_kbytes_in sample fetch
10876 keyword.
10877
10878table_kbytes_out(<table>)
10879 Uses the string representation of the input sample to perform a look up in
10880 the specified table. If the key is not found in the table, integer value zero
10881 is returned. Otherwise the converter returns the cumulated amount of server-
10882 to-client data associated with the input sample in the designated table,
10883 measured in kilobytes. The test is currently performed on 32-bit integers,
10884 which limits values to 4 terabytes. See also the sc_kbytes_out sample fetch
10885 keyword.
10886
10887table_server_id(<table>)
10888 Uses the string representation of the input sample to perform a look up in
10889 the specified table. If the key is not found in the table, integer value zero
10890 is returned. Otherwise the converter returns the server ID associated with
10891 the input sample in the designated table. A server ID is associated to a
10892 sample by a "stick" rule when a connection to a server succeeds. A server ID
10893 zero means that no server is associated with this key.
10894
10895table_sess_cnt(<table>)
10896 Uses the string representation of the input sample to perform a look up in
10897 the specified table. If the key is not found in the table, integer value zero
10898 is returned. Otherwise the converter returns the cumulated amount of incoming
10899 sessions associated with the input sample in the designated table. Note that
10900 a session here refers to an incoming connection being accepted by the
10901 "tcp-request connection" rulesets. See also the sc_sess_cnt sample fetch
10902 keyword.
10903
10904table_sess_rate(<table>)
10905 Uses the string representation of the input sample to perform a look up in
10906 the specified table. If the key is not found in the table, integer value zero
10907 is returned. Otherwise the converter returns the average incoming session
10908 rate associated with the input sample in the designated table. Note that a
10909 session here refers to an incoming connection being accepted by the
10910 "tcp-request connection" rulesets. See also the sc_sess_rate sample fetch
10911 keyword.
10912
10913table_trackers(<table>)
10914 Uses the string representation of the input sample to perform a look up in
10915 the specified table. If the key is not found in the table, integer value zero
10916 is returned. Otherwise the converter returns the current amount of concurrent
10917 connections tracking the same key as the input sample in the designated
10918 table. It differs from table_conn_cur in that it does not rely on any stored
10919 information but on the table's reference count (the "use" value which is
10920 returned by "show table" on the CLI). This may sometimes be more suited for
10921 layer7 tracking. It can be used to tell a server how many concurrent
10922 connections there are from a given address for example. See also the
10923 sc_trackers sample fetch keyword.
10924
Willy Tarreauffcb2e42014-07-10 16:29:08 +020010925upper
10926 Convert a string sample to upper case. This can only be placed after a string
10927 sample fetch function or after a transformation keyword returning a string
10928 type. The result is of type string.
10929
Willy Tarreau0dbfdba2014-07-10 16:37:47 +020010930utime(<format>[,<offset>])
10931 Converts an integer supposed to contain a date since epoch to a string
10932 representing this date in UTC time using a format defined by the <format>
10933 string using strftime(3). The purpose is to allow any date format to be used
10934 in logs. An optional <offset> in seconds may be applied to the input date
10935 (positive or negative). See the strftime() man page for the format supported
10936 by your operating system. See also the ltime converter.
10937
10938 Example :
10939
10940 # Emit two colons, one with the UTC time and another with ip:port
10941 # Eg: 20140710162350 127.0.0.1:57325
10942 log-format %[date,utime(%Y%m%d%H%M%S)]\ %ci:%cp
10943
Emeric Brunc9a0f6d2014-11-25 14:09:01 +010010944word(<index>,<delimiters>)
10945 Extracts the nth word considering given delimiters from an input string.
10946 Indexes start at 1 and delimiters are a string formatted list of chars.
10947
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020010948wt6([<avalanche>])
10949 Hashes a binary input sample into an unsigned 32-bit quantity using the WT6
10950 hash function. Optionally, it is possible to apply a full avalanche hash
10951 function to the output if the optional <avalanche> argument equals 1. This
10952 converter uses the same functions as used by the various hash-based load
10953 balancing algorithms, so it will provide exactly the same results. It is
10954 mostly intended for debugging, but can be used as a stick-table entry to
10955 collect rough statistics. It must not be used for security purposes as a
Willy Tarreau80599772015-01-20 19:35:24 +010010956 32-bit hash is trivial to break. See also "crc32", "djb2", "sdbm", and the
10957 "hash-type" directive.
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020010958
Willy Tarreau97707872015-01-27 15:12:13 +010010959xor(<value>)
10960 Performs a bitwise "XOR" (exclusive OR) between <value> and the input value
10961 of type unsigned integer, and returns the result as an unsigned integer.
10962
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010010963
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200109647.3.2. Fetching samples from internal states
Willy Tarreau74ca5042013-06-11 23:12:07 +020010965--------------------------------------------
10966
10967A first set of sample fetch methods applies to internal information which does
10968not even relate to any client information. These ones are sometimes used with
10969"monitor-fail" directives to report an internal status to external watchers.
10970The sample fetch methods described in this section are usable anywhere.
10971
10972always_false : boolean
10973 Always returns the boolean "false" value. It may be used with ACLs as a
10974 temporary replacement for another one when adjusting configurations.
10975
10976always_true : boolean
10977 Always returns the boolean "true" value. It may be used with ACLs as a
10978 temporary replacement for another one when adjusting configurations.
10979
10980avg_queue([<backend>]) : integer
Willy Tarreaud63335a2010-02-26 12:56:52 +010010981 Returns the total number of queued connections of the designated backend
Willy Tarreau74ca5042013-06-11 23:12:07 +020010982 divided by the number of active servers. The current backend is used if no
10983 backend is specified. This is very similar to "queue" except that the size of
10984 the farm is considered, in order to give a more accurate measurement of the
10985 time it may take for a new connection to be processed. The main usage is with
10986 ACL to return a sorry page to new users when it becomes certain they will get
10987 a degraded service, or to pass to the backend servers in a header so that
10988 they decide to work in degraded mode or to disable some functions to speed up
10989 the processing a bit. Note that in the event there would not be any active
10990 server anymore, twice the number of queued connections would be considered as
10991 the measured value. This is a fair estimate, as we expect one server to get
10992 back soon anyway, but we still prefer to send new traffic to another backend
10993 if in better shape. See also the "queue", "be_conn", and "be_sess_rate"
10994 sample fetches.
Krzysztof Piotr Oledzki346f76d2010-01-12 21:59:30 +010010995
Willy Tarreau74ca5042013-06-11 23:12:07 +020010996be_conn([<backend>]) : integer
Willy Tarreaua36af912009-10-10 12:02:45 +020010997 Applies to the number of currently established connections on the backend,
10998 possibly including the connection being evaluated. If no backend name is
10999 specified, the current one is used. But it is also possible to check another
11000 backend. It can be used to use a specific farm when the nominal one is full.
11001 See also the "fe_conn", "queue" and "be_sess_rate" criteria.
Willy Tarreau6a06a402007-07-15 20:15:28 +020011002
Willy Tarreau74ca5042013-06-11 23:12:07 +020011003be_sess_rate([<backend>]) : integer
11004 Returns an integer value corresponding to the sessions creation rate on the
11005 backend, in number of new sessions per second. This is used with ACLs to
11006 switch to an alternate backend when an expensive or fragile one reaches too
11007 high a session rate, or to limit abuse of service (eg. prevent sucking of an
11008 online dictionary). It can also be useful to add this element to logs using a
11009 log-format directive.
Willy Tarreaud63335a2010-02-26 12:56:52 +010011010
11011 Example :
11012 # Redirect to an error page if the dictionary is requested too often
11013 backend dynamic
11014 mode http
11015 acl being_scanned be_sess_rate gt 100
11016 redirect location /denied.html if being_scanned
Willy Tarreau0ba27502007-12-24 16:55:16 +010011017
Willy Tarreau74ca5042013-06-11 23:12:07 +020011018connslots([<backend>]) : integer
11019 Returns an integer value corresponding to the number of connection slots
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011020 still available in the backend, by totaling the maximum amount of
Willy Tarreau74ca5042013-06-11 23:12:07 +020011021 connections on all servers and the maximum queue size. This is probably only
11022 used with ACLs.
Tait Clarridge7896d522012-12-05 21:39:31 -050011023
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011024 The basic idea here is to be able to measure the number of connection "slots"
Willy Tarreau55165fe2009-05-10 12:02:55 +020011025 still available (connection + queue), so that anything beyond that (intended
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011026 usage; see "use_backend" keyword) can be redirected to a different backend.
11027
Willy Tarreau55165fe2009-05-10 12:02:55 +020011028 'connslots' = number of available server connection slots, + number of
11029 available server queue slots.
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011030
Willy Tarreaua36af912009-10-10 12:02:45 +020011031 Note that while "fe_conn" may be used, "connslots" comes in especially
Willy Tarreau55165fe2009-05-10 12:02:55 +020011032 useful when you have a case of traffic going to one single ip, splitting into
Willy Tarreau74ca5042013-06-11 23:12:07 +020011033 multiple backends (perhaps using ACLs to do name-based load balancing) and
Willy Tarreau55165fe2009-05-10 12:02:55 +020011034 you want to be able to differentiate between different backends, and their
11035 available "connslots". Also, whereas "nbsrv" only measures servers that are
Willy Tarreau74ca5042013-06-11 23:12:07 +020011036 actually *down*, this fetch is more fine-grained and looks into the number of
Willy Tarreaua36af912009-10-10 12:02:45 +020011037 available connection slots as well. See also "queue" and "avg_queue".
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011038
Willy Tarreau55165fe2009-05-10 12:02:55 +020011039 OTHER CAVEATS AND NOTES: at this point in time, the code does not take care
11040 of dynamic connections. Also, if any of the server maxconn, or maxqueue is 0,
Willy Tarreau74ca5042013-06-11 23:12:07 +020011041 then this fetch clearly does not make sense, in which case the value returned
Willy Tarreau55165fe2009-05-10 12:02:55 +020011042 will be -1.
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011043
Willy Tarreau6236d3a2013-07-25 14:28:25 +020011044date([<offset>]) : integer
11045 Returns the current date as the epoch (number of seconds since 01/01/1970).
11046 If an offset value is specified, then it is a number of seconds that is added
11047 to the current date before returning the value. This is particularly useful
11048 to compute relative dates, as both positive and negative offsets are allowed.
Willy Tarreau276fae92013-07-25 14:36:01 +020011049 It is useful combined with the http_date converter.
11050
11051 Example :
11052
11053 # set an expires header to now+1 hour in every response
11054 http-response set-header Expires %[date(3600),http_date]
Willy Tarreau6236d3a2013-07-25 14:28:25 +020011055
Willy Tarreau595ec542013-06-12 21:34:28 +020011056env(<name>) : string
11057 Returns a string containing the value of environment variable <name>. As a
11058 reminder, environment variables are per-process and are sampled when the
11059 process starts. This can be useful to pass some information to a next hop
11060 server, or with ACLs to take specific action when the process is started a
11061 certain way.
11062
11063 Examples :
11064 # Pass the Via header to next hop with the local hostname in it
11065 http-request add-header Via 1.1\ %[env(HOSTNAME)]
11066
11067 # reject cookie-less requests when the STOP environment variable is set
11068 http-request deny if !{ cook(SESSIONID) -m found } { env(STOP) -m found }
11069
Willy Tarreau74ca5042013-06-11 23:12:07 +020011070fe_conn([<frontend>]) : integer
11071 Returns the number of currently established connections on the frontend,
Willy Tarreaud63335a2010-02-26 12:56:52 +010011072 possibly including the connection being evaluated. If no frontend name is
11073 specified, the current one is used. But it is also possible to check another
Willy Tarreau74ca5042013-06-11 23:12:07 +020011074 frontend. It can be used to return a sorry page before hard-blocking, or to
11075 use a specific backend to drain new requests when the farm is considered
11076 full. This is mostly used with ACLs but can also be used to pass some
11077 statistics to servers in HTTP headers. See also the "dst_conn", "be_conn",
11078 "fe_sess_rate" fetches.
Willy Tarreaua36af912009-10-10 12:02:45 +020011079
Willy Tarreau74ca5042013-06-11 23:12:07 +020011080fe_sess_rate([<frontend>]) : integer
11081 Returns an integer value corresponding to the sessions creation rate on the
11082 frontend, in number of new sessions per second. This is used with ACLs to
11083 limit the incoming session rate to an acceptable range in order to prevent
11084 abuse of service at the earliest moment, for example when combined with other
11085 layer 4 ACLs in order to force the clients to wait a bit for the rate to go
11086 down below the limit. It can also be useful to add this element to logs using
11087 a log-format directive. See also the "rate-limit sessions" directive for use
11088 in frontends.
Willy Tarreau079ff0a2009-03-05 21:34:28 +010011089
11090 Example :
11091 # This frontend limits incoming mails to 10/s with a max of 100
11092 # concurrent connections. We accept any connection below 10/s, and
11093 # force excess clients to wait for 100 ms. Since clients are limited to
11094 # 100 max, there cannot be more than 10 incoming mails per second.
11095 frontend mail
11096 bind :25
11097 mode tcp
11098 maxconn 100
11099 acl too_fast fe_sess_rate ge 10
11100 tcp-request inspect-delay 100ms
11101 tcp-request content accept if ! too_fast
11102 tcp-request content accept if WAIT_END
Willy Tarreaud72758d2010-01-12 10:42:19 +010011103
Willy Tarreau0f30d262014-11-24 16:02:05 +010011104nbproc : integer
11105 Returns an integer value corresponding to the number of processes that were
11106 started (it equals the global "nbproc" setting). This is useful for logging
11107 and debugging purposes.
11108
Willy Tarreau74ca5042013-06-11 23:12:07 +020011109nbsrv([<backend>]) : integer
11110 Returns an integer value corresponding to the number of usable servers of
11111 either the current backend or the named backend. This is mostly used with
11112 ACLs but can also be useful when added to logs. This is normally used to
Willy Tarreaud63335a2010-02-26 12:56:52 +010011113 switch to an alternate backend when the number of servers is too low to
11114 to handle some load. It is useful to report a failure when combined with
11115 "monitor fail".
Willy Tarreau079ff0a2009-03-05 21:34:28 +010011116
Willy Tarreau0f30d262014-11-24 16:02:05 +010011117proc : integer
11118 Returns an integer value corresponding to the position of the process calling
11119 the function, between 1 and global.nbproc. This is useful for logging and
11120 debugging purposes.
11121
Willy Tarreau74ca5042013-06-11 23:12:07 +020011122queue([<backend>]) : integer
Willy Tarreaud63335a2010-02-26 12:56:52 +010011123 Returns the total number of queued connections of the designated backend,
11124 including all the connections in server queues. If no backend name is
11125 specified, the current one is used, but it is also possible to check another
Willy Tarreau74ca5042013-06-11 23:12:07 +020011126 one. This is useful with ACLs or to pass statistics to backend servers. This
11127 can be used to take actions when queuing goes above a known level, generally
11128 indicating a surge of traffic or a massive slowdown on the servers. One
11129 possible action could be to reject new users but still accept old ones. See
11130 also the "avg_queue", "be_conn", and "be_sess_rate" fetches.
11131
Willy Tarreau84310e22014-02-14 11:59:04 +010011132rand([<range>]) : integer
11133 Returns a random integer value within a range of <range> possible values,
11134 starting at zero. If the range is not specified, it defaults to 2^32, which
11135 gives numbers between 0 and 4294967295. It can be useful to pass some values
11136 needed to take some routing decisions for example, or just for debugging
11137 purposes. This random must not be used for security purposes.
11138
Willy Tarreau74ca5042013-06-11 23:12:07 +020011139srv_conn([<backend>/]<server>) : integer
11140 Returns an integer value corresponding to the number of currently established
11141 connections on the designated server, possibly including the connection being
11142 evaluated. If <backend> is omitted, then the server is looked up in the
11143 current backend. It can be used to use a specific farm when one server is
11144 full, or to inform the server about our view of the number of active
11145 connections with it. See also the "fe_conn", "be_conn" and "queue" fetch
11146 methods.
11147
11148srv_is_up([<backend>/]<server>) : boolean
11149 Returns true when the designated server is UP, and false when it is either
11150 DOWN or in maintenance mode. If <backend> is omitted, then the server is
11151 looked up in the current backend. It is mainly used to take action based on
11152 an external status reported via a health check (eg: a geographical site's
11153 availability). Another possible use which is more of a hack consists in
11154 using dummy servers as boolean variables that can be enabled or disabled from
11155 the CLI, so that rules depending on those ACLs can be tweaked in realtime.
11156
11157srv_sess_rate([<backend>/]<server>) : integer
11158 Returns an integer corresponding to the sessions creation rate on the
11159 designated server, in number of new sessions per second. If <backend> is
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011160 omitted, then the server is looked up in the current backend. This is mostly
Willy Tarreau74ca5042013-06-11 23:12:07 +020011161 used with ACLs but can make sense with logs too. This is used to switch to an
11162 alternate backend when an expensive or fragile one reaches too high a session
11163 rate, or to limit abuse of service (eg. prevent latent requests from
11164 overloading servers).
11165
11166 Example :
11167 # Redirect to a separate back
11168 acl srv1_full srv_sess_rate(be1/srv1) gt 50
11169 acl srv2_full srv_sess_rate(be1/srv2) gt 50
11170 use_backend be2 if srv1_full or srv2_full
11171
Willy Tarreau0f30d262014-11-24 16:02:05 +010011172stopping : boolean
11173 Returns TRUE if the process calling the function is currently stopping. This
11174 can be useful for logging, or for relaxing certain checks or helping close
11175 certain connections upon graceful shutdown.
11176
Willy Tarreau74ca5042013-06-11 23:12:07 +020011177table_avl([<table>]) : integer
11178 Returns the total number of available entries in the current proxy's
11179 stick-table or in the designated stick-table. See also table_cnt.
11180
11181table_cnt([<table>]) : integer
11182 Returns the total number of entries currently in use in the current proxy's
11183 stick-table or in the designated stick-table. See also src_conn_cnt and
11184 table_avl for other entry counting methods.
11185
11186
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200111877.3.3. Fetching samples at Layer 4
Willy Tarreau74ca5042013-06-11 23:12:07 +020011188----------------------------------
11189
11190The layer 4 usually describes just the transport layer which in haproxy is
11191closest to the connection, where no content is yet made available. The fetch
11192methods described here are usable as low as the "tcp-request connection" rule
11193sets unless they require some future information. Those generally include
11194TCP/IP addresses and ports, as well as elements from stick-tables related to
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011195the incoming connection. For retrieving a value from a sticky counters, the
11196counter number can be explicitly set as 0, 1, or 2 using the pre-defined
11197"sc0_", "sc1_", or "sc2_" prefix, or it can be specified as the first integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011198argument when using the "sc_" prefix. An optional table may be specified with
11199the "sc*" form, in which case the currently tracked key will be looked up into
11200this alternate table instead of the table currently being tracked.
Willy Tarreau74ca5042013-06-11 23:12:07 +020011201
11202be_id : integer
11203 Returns an integer containing the current backend's id. It can be used in
11204 frontends with responses to check which backend processed the request.
11205
11206dst : ip
11207 This is the destination IPv4 address of the connection on the client side,
11208 which is the address the client connected to. It can be useful when running
11209 in transparent mode. It is of type IP and works on both IPv4 and IPv6 tables.
11210 On IPv6 tables, IPv4 address is mapped to its IPv6 equivalent, according to
11211 RFC 4291.
11212
11213dst_conn : integer
11214 Returns an integer value corresponding to the number of currently established
11215 connections on the same socket including the one being evaluated. It is
11216 normally used with ACLs but can as well be used to pass the information to
11217 servers in an HTTP header or in logs. It can be used to either return a sorry
11218 page before hard-blocking, or to use a specific backend to drain new requests
11219 when the socket is considered saturated. This offers the ability to assign
11220 different limits to different listening ports or addresses. See also the
11221 "fe_conn" and "be_conn" fetches.
Willy Tarreaud63335a2010-02-26 12:56:52 +010011222
Willy Tarreau74ca5042013-06-11 23:12:07 +020011223dst_port : integer
11224 Returns an integer value corresponding to the destination TCP port of the
11225 connection on the client side, which is the port the client connected to.
11226 This might be used when running in transparent mode, when assigning dynamic
11227 ports to some clients for a whole application session, to stick all users to
11228 a same server, or to pass the destination port information to a server using
11229 an HTTP header.
11230
11231fe_id : integer
11232 Returns an integer containing the current frontend's id. It can be used in
11233 backends to check from which backend it was called, or to stick all users
11234 coming via a same frontend to the same server.
11235
Cyril Bonté62ba8702014-04-22 23:52:25 +020011236sc_bytes_in_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011237sc0_bytes_in_rate([<table>]) : integer
11238sc1_bytes_in_rate([<table>]) : integer
11239sc2_bytes_in_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011240 Returns the average client-to-server bytes rate from the currently tracked
11241 counters, measured in amount of bytes over the period configured in the
11242 table. See also src_bytes_in_rate.
11243
Cyril Bonté62ba8702014-04-22 23:52:25 +020011244sc_bytes_out_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011245sc0_bytes_out_rate([<table>]) : integer
11246sc1_bytes_out_rate([<table>]) : integer
11247sc2_bytes_out_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011248 Returns the average server-to-client bytes rate from the currently tracked
11249 counters, measured in amount of bytes over the period configured in the
11250 table. See also src_bytes_out_rate.
11251
Cyril Bonté62ba8702014-04-22 23:52:25 +020011252sc_clr_gpc0(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011253sc0_clr_gpc0([<table>]) : integer
11254sc1_clr_gpc0([<table>]) : integer
11255sc2_clr_gpc0([<table>]) : integer
Willy Tarreauf73cd112011-08-13 01:45:16 +020011256 Clears the first General Purpose Counter associated to the currently tracked
11257 counters, and returns its previous value. Before the first invocation, the
Willy Tarreau869948b2013-01-04 14:14:57 +010011258 stored value is zero, so first invocation will always return zero. This is
11259 typically used as a second ACL in an expression in order to mark a connection
11260 when a first ACL was verified :
Willy Tarreauf73cd112011-08-13 01:45:16 +020011261
11262 # block if 5 consecutive requests continue to come faster than 10 sess
11263 # per second, and reset the counter as soon as the traffic slows down.
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020011264 acl abuse sc0_http_req_rate gt 10
11265 acl kill sc0_inc_gpc0 gt 5
11266 acl save sc0_clr_gpc0 ge 0
Willy Tarreauf73cd112011-08-13 01:45:16 +020011267 tcp-request connection accept if !abuse save
11268 tcp-request connection reject if abuse kill
11269
Cyril Bonté62ba8702014-04-22 23:52:25 +020011270sc_conn_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011271sc0_conn_cnt([<table>]) : integer
11272sc1_conn_cnt([<table>]) : integer
11273sc2_conn_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011274 Returns the cumulated number of incoming connections from currently tracked
11275 counters. See also src_conn_cnt.
11276
Cyril Bonté62ba8702014-04-22 23:52:25 +020011277sc_conn_cur(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011278sc0_conn_cur([<table>]) : integer
11279sc1_conn_cur([<table>]) : integer
11280sc2_conn_cur([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011281 Returns the current amount of concurrent connections tracking the same
11282 tracked counters. This number is automatically incremented when tracking
11283 begins and decremented when tracking stops. See also src_conn_cur.
11284
Cyril Bonté62ba8702014-04-22 23:52:25 +020011285sc_conn_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011286sc0_conn_rate([<table>]) : integer
11287sc1_conn_rate([<table>]) : integer
11288sc2_conn_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011289 Returns the average connection rate from the currently tracked counters,
11290 measured in amount of connections over the period configured in the table.
11291 See also src_conn_rate.
11292
Cyril Bonté62ba8702014-04-22 23:52:25 +020011293sc_get_gpc0(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011294sc0_get_gpc0([<table>]) : integer
11295sc1_get_gpc0([<table>]) : integer
11296sc2_get_gpc0([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011297 Returns the value of the first General Purpose Counter associated to the
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011298 currently tracked counters. See also src_get_gpc0 and sc/sc0/sc1/sc2_inc_gpc0.
Willy Tarreauba2ffd12013-05-29 15:54:14 +020011299
Cyril Bonté62ba8702014-04-22 23:52:25 +020011300sc_gpc0_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011301sc0_gpc0_rate([<table>]) : integer
11302sc1_gpc0_rate([<table>]) : integer
11303sc2_gpc0_rate([<table>]) : integer
Willy Tarreauba2ffd12013-05-29 15:54:14 +020011304 Returns the average increment rate of the first General Purpose Counter
11305 associated to the currently tracked counters. It reports the frequency
11306 which the gpc0 counter was incremented over the configured period. See also
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011307 src_gpc0_rate, sc/sc0/sc1/sc2_get_gpc0, and sc/sc0/sc1/sc2_inc_gpc0. Note
11308 that the "gpc0_rate" counter must be stored in the stick-table for a value to
11309 be returned, as "gpc0" only holds the event count.
Willy Tarreaue9656522010-08-17 15:40:09 +020011310
Cyril Bonté62ba8702014-04-22 23:52:25 +020011311sc_http_err_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011312sc0_http_err_cnt([<table>]) : integer
11313sc1_http_err_cnt([<table>]) : integer
11314sc2_http_err_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011315 Returns the cumulated number of HTTP errors from the currently tracked
11316 counters. This includes the both request errors and 4xx error responses.
11317 See also src_http_err_cnt.
11318
Cyril Bonté62ba8702014-04-22 23:52:25 +020011319sc_http_err_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011320sc0_http_err_rate([<table>]) : integer
11321sc1_http_err_rate([<table>]) : integer
11322sc2_http_err_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011323 Returns the average rate of HTTP errors from the currently tracked counters,
11324 measured in amount of errors over the period configured in the table. This
11325 includes the both request errors and 4xx error responses. See also
11326 src_http_err_rate.
11327
Cyril Bonté62ba8702014-04-22 23:52:25 +020011328sc_http_req_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011329sc0_http_req_cnt([<table>]) : integer
11330sc1_http_req_cnt([<table>]) : integer
11331sc2_http_req_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011332 Returns the cumulated number of HTTP requests from the currently tracked
11333 counters. This includes every started request, valid or not. See also
11334 src_http_req_cnt.
11335
Cyril Bonté62ba8702014-04-22 23:52:25 +020011336sc_http_req_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011337sc0_http_req_rate([<table>]) : integer
11338sc1_http_req_rate([<table>]) : integer
11339sc2_http_req_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011340 Returns the average rate of HTTP requests from the currently tracked
11341 counters, measured in amount of requests over the period configured in
11342 the table. This includes every started request, valid or not. See also
11343 src_http_req_rate.
11344
Cyril Bonté62ba8702014-04-22 23:52:25 +020011345sc_inc_gpc0(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011346sc0_inc_gpc0([<table>]) : integer
11347sc1_inc_gpc0([<table>]) : integer
11348sc2_inc_gpc0([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011349 Increments the first General Purpose Counter associated to the currently
Willy Tarreau869948b2013-01-04 14:14:57 +010011350 tracked counters, and returns its new value. Before the first invocation,
11351 the stored value is zero, so first invocation will increase it to 1 and will
11352 return 1. This is typically used as a second ACL in an expression in order
11353 to mark a connection when a first ACL was verified :
Willy Tarreaue9656522010-08-17 15:40:09 +020011354
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020011355 acl abuse sc0_http_req_rate gt 10
11356 acl kill sc0_inc_gpc0 gt 0
Willy Tarreaue9656522010-08-17 15:40:09 +020011357 tcp-request connection reject if abuse kill
11358
Cyril Bonté62ba8702014-04-22 23:52:25 +020011359sc_kbytes_in(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011360sc0_kbytes_in([<table>]) : integer
11361sc1_kbytes_in([<table>]) : integer
11362sc2_kbytes_in([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020011363 Returns the total amount of client-to-server data from the currently tracked
11364 counters, measured in kilobytes. The test is currently performed on 32-bit
11365 integers, which limits values to 4 terabytes. See also src_kbytes_in.
Willy Tarreaue9656522010-08-17 15:40:09 +020011366
Cyril Bonté62ba8702014-04-22 23:52:25 +020011367sc_kbytes_out(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011368sc0_kbytes_out([<table>]) : integer
11369sc1_kbytes_out([<table>]) : integer
11370sc2_kbytes_out([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020011371 Returns the total amount of server-to-client data from the currently tracked
11372 counters, measured in kilobytes. The test is currently performed on 32-bit
11373 integers, which limits values to 4 terabytes. See also src_kbytes_out.
Willy Tarreaue9656522010-08-17 15:40:09 +020011374
Cyril Bonté62ba8702014-04-22 23:52:25 +020011375sc_sess_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011376sc0_sess_cnt([<table>]) : integer
11377sc1_sess_cnt([<table>]) : integer
11378sc2_sess_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011379 Returns the cumulated number of incoming connections that were transformed
11380 into sessions, which means that they were accepted by a "tcp-request
11381 connection" rule, from the currently tracked counters. A backend may count
11382 more sessions than connections because each connection could result in many
Jamie Gloudonaaa21002012-08-25 00:18:33 -040011383 backend sessions if some HTTP keep-alive is performed over the connection
Willy Tarreaue9656522010-08-17 15:40:09 +020011384 with the client. See also src_sess_cnt.
11385
Cyril Bonté62ba8702014-04-22 23:52:25 +020011386sc_sess_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011387sc0_sess_rate([<table>]) : integer
11388sc1_sess_rate([<table>]) : integer
11389sc2_sess_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020011390 Returns the average session rate from the currently tracked counters,
11391 measured in amount of sessions over the period configured in the table. A
11392 session is a connection that got past the early "tcp-request connection"
11393 rules. A backend may count more sessions than connections because each
11394 connection could result in many backend sessions if some HTTP keep-alive is
Jamie Gloudonaaa21002012-08-25 00:18:33 -040011395 performed over the connection with the client. See also src_sess_rate.
Willy Tarreaue9656522010-08-17 15:40:09 +020011396
Cyril Bonté62ba8702014-04-22 23:52:25 +020011397sc_tracked(<ctr>[,<table>]) : boolean
Willy Tarreau0f791d42013-07-23 19:56:43 +020011398sc0_tracked([<table>]) : boolean
11399sc1_tracked([<table>]) : boolean
11400sc2_tracked([<table>]) : boolean
Willy Tarreau6f1615f2013-06-03 15:15:22 +020011401 Returns true if the designated session counter is currently being tracked by
11402 the current session. This can be useful when deciding whether or not we want
11403 to set some values in a header passed to the server.
11404
Cyril Bonté62ba8702014-04-22 23:52:25 +020011405sc_trackers(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020011406sc0_trackers([<table>]) : integer
11407sc1_trackers([<table>]) : integer
11408sc2_trackers([<table>]) : integer
Willy Tarreau2406db42012-12-09 12:16:43 +010011409 Returns the current amount of concurrent connections tracking the same
11410 tracked counters. This number is automatically incremented when tracking
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020011411 begins and decremented when tracking stops. It differs from sc0_conn_cur in
Willy Tarreau2406db42012-12-09 12:16:43 +010011412 that it does not rely on any stored information but on the table's reference
11413 count (the "use" value which is returned by "show table" on the CLI). This
Willy Tarreau74ca5042013-06-11 23:12:07 +020011414 may sometimes be more suited for layer7 tracking. It can be used to tell a
11415 server how many concurrent connections there are from a given address for
11416 example.
Willy Tarreau2406db42012-12-09 12:16:43 +010011417
Willy Tarreau74ca5042013-06-11 23:12:07 +020011418so_id : integer
11419 Returns an integer containing the current listening socket's id. It is useful
11420 in frontends involving many "bind" lines, or to stick all users coming via a
11421 same socket to the same server.
Willy Tarreaud63335a2010-02-26 12:56:52 +010011422
Willy Tarreau74ca5042013-06-11 23:12:07 +020011423src : ip
11424 This is the source IPv4 address of the client of the session. It is of type
11425 IP and works on both IPv4 and IPv6 tables. On IPv6 tables, IPv4 addresses are
11426 mapped to their IPv6 equivalent, according to RFC 4291. Note that it is the
11427 TCP-level source address which is used, and not the address of a client
11428 behind a proxy. However if the "accept-proxy" bind directive is used, it can
11429 be the address of a client behind another PROXY-protocol compatible component
11430 for all rule sets except "tcp-request connection" which sees the real address.
Willy Tarreaud63335a2010-02-26 12:56:52 +010011431
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011432 Example:
11433 # add an HTTP header in requests with the originating address' country
11434 http-request set-header X-Country %[src,map_ip(geoip.lst)]
11435
Willy Tarreau74ca5042013-06-11 23:12:07 +020011436src_bytes_in_rate([<table>]) : integer
11437 Returns the average bytes rate from the incoming connection's source address
11438 in the current proxy's stick-table or in the designated stick-table, measured
11439 in amount of bytes over the period configured in the table. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011440 not found, zero is returned. See also sc/sc0/sc1/sc2_bytes_in_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011441
Willy Tarreau74ca5042013-06-11 23:12:07 +020011442src_bytes_out_rate([<table>]) : integer
11443 Returns the average bytes rate to the incoming connection's source address in
11444 the current proxy's stick-table or in the designated stick-table, measured in
Willy Tarreauc9705a12010-07-27 20:05:50 +020011445 amount of bytes over the period configured in the table. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011446 not found, zero is returned. See also sc/sc0/sc1/sc2_bytes_out_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011447
Willy Tarreau74ca5042013-06-11 23:12:07 +020011448src_clr_gpc0([<table>]) : integer
11449 Clears the first General Purpose Counter associated to the incoming
11450 connection's source address in the current proxy's stick-table or in the
11451 designated stick-table, and returns its previous value. If the address is not
11452 found, an entry is created and 0 is returned. This is typically used as a
11453 second ACL in an expression in order to mark a connection when a first ACL
11454 was verified :
Willy Tarreauf73cd112011-08-13 01:45:16 +020011455
11456 # block if 5 consecutive requests continue to come faster than 10 sess
11457 # per second, and reset the counter as soon as the traffic slows down.
11458 acl abuse src_http_req_rate gt 10
11459 acl kill src_inc_gpc0 gt 5
Willy Tarreau869948b2013-01-04 14:14:57 +010011460 acl save src_clr_gpc0 ge 0
Willy Tarreauf73cd112011-08-13 01:45:16 +020011461 tcp-request connection accept if !abuse save
11462 tcp-request connection reject if abuse kill
11463
Willy Tarreau74ca5042013-06-11 23:12:07 +020011464src_conn_cnt([<table>]) : integer
Willy Tarreauc9705a12010-07-27 20:05:50 +020011465 Returns the cumulated number of connections initiated from the current
Willy Tarreau74ca5042013-06-11 23:12:07 +020011466 incoming connection's source address in the current proxy's stick-table or in
Willy Tarreauc9705a12010-07-27 20:05:50 +020011467 the designated stick-table. If the address is not found, zero is returned.
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011468 See also sc/sc0/sc1/sc2_conn_cnt.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011469
Willy Tarreau74ca5042013-06-11 23:12:07 +020011470src_conn_cur([<table>]) : integer
Willy Tarreauc9705a12010-07-27 20:05:50 +020011471 Returns the current amount of concurrent connections initiated from the
Willy Tarreau74ca5042013-06-11 23:12:07 +020011472 current incoming connection's source address in the current proxy's
11473 stick-table or in the designated stick-table. If the address is not found,
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011474 zero is returned. See also sc/sc0/sc1/sc2_conn_cur.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011475
Willy Tarreau74ca5042013-06-11 23:12:07 +020011476src_conn_rate([<table>]) : integer
11477 Returns the average connection rate from the incoming connection's source
11478 address in the current proxy's stick-table or in the designated stick-table,
11479 measured in amount of connections over the period configured in the table. If
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011480 the address is not found, zero is returned. See also sc/sc0/sc1/sc2_conn_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011481
Willy Tarreau74ca5042013-06-11 23:12:07 +020011482src_get_gpc0([<table>]) : integer
Willy Tarreauc9705a12010-07-27 20:05:50 +020011483 Returns the value of the first General Purpose Counter associated to the
Willy Tarreau74ca5042013-06-11 23:12:07 +020011484 incoming connection's source address in the current proxy's stick-table or in
Willy Tarreauc9705a12010-07-27 20:05:50 +020011485 the designated stick-table. If the address is not found, zero is returned.
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011486 See also sc/sc0/sc1/sc2_get_gpc0 and src_inc_gpc0.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011487
Willy Tarreau74ca5042013-06-11 23:12:07 +020011488src_gpc0_rate([<table>]) : integer
Willy Tarreauba2ffd12013-05-29 15:54:14 +020011489 Returns the average increment rate of the first General Purpose Counter
Willy Tarreau74ca5042013-06-11 23:12:07 +020011490 associated to the incoming connection's source address in the current proxy's
Willy Tarreauba2ffd12013-05-29 15:54:14 +020011491 stick-table or in the designated stick-table. It reports the frequency
11492 which the gpc0 counter was incremented over the configured period. See also
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011493 sc/sc0/sc1/sc2_gpc0_rate, src_get_gpc0, and sc/sc0/sc1/sc2_inc_gpc0. Note
11494 that the "gpc0_rate" counter must be stored in the stick-table for a value to
11495 be returned, as "gpc0" only holds the event count.
Willy Tarreauba2ffd12013-05-29 15:54:14 +020011496
Willy Tarreau74ca5042013-06-11 23:12:07 +020011497src_http_err_cnt([<table>]) : integer
11498 Returns the cumulated number of HTTP errors from the incoming connection's
11499 source address in the current proxy's stick-table or in the designated
Willy Tarreauc9705a12010-07-27 20:05:50 +020011500 stick-table. This includes the both request errors and 4xx error responses.
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011501 See also sc/sc0/sc1/sc2_http_err_cnt. If the address is not found, zero is
Willy Tarreau74ca5042013-06-11 23:12:07 +020011502 returned.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011503
Willy Tarreau74ca5042013-06-11 23:12:07 +020011504src_http_err_rate([<table>]) : integer
11505 Returns the average rate of HTTP errors from the incoming connection's source
11506 address in the current proxy's stick-table or in the designated stick-table,
11507 measured in amount of errors over the period configured in the table. This
11508 includes the both request errors and 4xx error responses. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011509 not found, zero is returned. See also sc/sc0/sc1/sc2_http_err_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011510
Willy Tarreau74ca5042013-06-11 23:12:07 +020011511src_http_req_cnt([<table>]) : integer
11512 Returns the cumulated number of HTTP requests from the incoming connection's
11513 source address in the current proxy's stick-table or in the designated stick-
11514 table. This includes every started request, valid or not. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011515 not found, zero is returned. See also sc/sc0/sc1/sc2_http_req_cnt.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011516
Willy Tarreau74ca5042013-06-11 23:12:07 +020011517src_http_req_rate([<table>]) : integer
11518 Returns the average rate of HTTP requests from the incoming connection's
11519 source address in the current proxy's stick-table or in the designated stick-
11520 table, measured in amount of requests over the period configured in the
Willy Tarreauc9705a12010-07-27 20:05:50 +020011521 table. This includes every started request, valid or not. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011522 not found, zero is returned. See also sc/sc0/sc1/sc2_http_req_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011523
Willy Tarreau74ca5042013-06-11 23:12:07 +020011524src_inc_gpc0([<table>]) : integer
11525 Increments the first General Purpose Counter associated to the incoming
11526 connection's source address in the current proxy's stick-table or in the
11527 designated stick-table, and returns its new value. If the address is not
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020011528 found, an entry is created and 1 is returned. See also sc0/sc2/sc2_inc_gpc0.
Willy Tarreau74ca5042013-06-11 23:12:07 +020011529 This is typically used as a second ACL in an expression in order to mark a
11530 connection when a first ACL was verified :
Willy Tarreauc9705a12010-07-27 20:05:50 +020011531
11532 acl abuse src_http_req_rate gt 10
Willy Tarreau869948b2013-01-04 14:14:57 +010011533 acl kill src_inc_gpc0 gt 0
Willy Tarreaue9656522010-08-17 15:40:09 +020011534 tcp-request connection reject if abuse kill
Willy Tarreauc9705a12010-07-27 20:05:50 +020011535
Willy Tarreau74ca5042013-06-11 23:12:07 +020011536src_kbytes_in([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020011537 Returns the total amount of data received from the incoming connection's
11538 source address in the current proxy's stick-table or in the designated
11539 stick-table, measured in kilobytes. If the address is not found, zero is
11540 returned. The test is currently performed on 32-bit integers, which limits
11541 values to 4 terabytes. See also sc/sc0/sc1/sc2_kbytes_in.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011542
Willy Tarreau74ca5042013-06-11 23:12:07 +020011543src_kbytes_out([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020011544 Returns the total amount of data sent to the incoming connection's source
11545 address in the current proxy's stick-table or in the designated stick-table,
11546 measured in kilobytes. If the address is not found, zero is returned. The
11547 test is currently performed on 32-bit integers, which limits values to 4
11548 terabytes. See also sc/sc0/sc1/sc2_kbytes_out.
Willy Tarreaua975b8f2010-06-05 19:13:27 +020011549
Willy Tarreau74ca5042013-06-11 23:12:07 +020011550src_port : integer
11551 Returns an integer value corresponding to the TCP source port of the
11552 connection on the client side, which is the port the client connected from.
11553 Usage of this function is very limited as modern protocols do not care much
11554 about source ports nowadays.
Willy Tarreau079ff0a2009-03-05 21:34:28 +010011555
Willy Tarreau74ca5042013-06-11 23:12:07 +020011556src_sess_cnt([<table>]) : integer
11557 Returns the cumulated number of connections initiated from the incoming
Willy Tarreauc9705a12010-07-27 20:05:50 +020011558 connection's source IPv4 address in the current proxy's stick-table or in the
11559 designated stick-table, that were transformed into sessions, which means that
11560 they were accepted by "tcp-request" rules. If the address is not found, zero
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011561 is returned. See also sc/sc0/sc1/sc2_sess_cnt.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011562
Willy Tarreau74ca5042013-06-11 23:12:07 +020011563src_sess_rate([<table>]) : integer
11564 Returns the average session rate from the incoming connection's source
11565 address in the current proxy's stick-table or in the designated stick-table,
11566 measured in amount of sessions over the period configured in the table. A
11567 session is a connection that went past the early "tcp-request" rules. If the
Willy Tarreau4d4149c2013-07-23 19:33:46 +020011568 address is not found, zero is returned. See also sc/sc0/sc1/sc2_sess_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020011569
Willy Tarreau74ca5042013-06-11 23:12:07 +020011570src_updt_conn_cnt([<table>]) : integer
11571 Creates or updates the entry associated to the incoming connection's source
11572 address in the current proxy's stick-table or in the designated stick-table.
11573 This table must be configured to store the "conn_cnt" data type, otherwise
11574 the match will be ignored. The current count is incremented by one, and the
11575 expiration timer refreshed. The updated count is returned, so this match
11576 can't return zero. This was used to reject service abusers based on their
11577 source address. Note: it is recommended to use the more complete "track-sc*"
11578 actions in "tcp-request" rules instead.
Willy Tarreaua975b8f2010-06-05 19:13:27 +020011579
11580 Example :
11581 # This frontend limits incoming SSH connections to 3 per 10 second for
11582 # each source address, and rejects excess connections until a 10 second
11583 # silence is observed. At most 20 addresses are tracked.
11584 listen ssh
11585 bind :22
11586 mode tcp
11587 maxconn 100
Willy Tarreauc9705a12010-07-27 20:05:50 +020011588 stick-table type ip size 20 expire 10s store conn_cnt
Willy Tarreau74ca5042013-06-11 23:12:07 +020011589 tcp-request content reject if { src_updt_conn_cnt gt 3 }
Willy Tarreaua975b8f2010-06-05 19:13:27 +020011590 server local 127.0.0.1:22
11591
Willy Tarreau74ca5042013-06-11 23:12:07 +020011592srv_id : integer
11593 Returns an integer containing the server's id when processing the response.
11594 While it's almost only used with ACLs, it may be used for logging or
11595 debugging.
Hervé COMMOWICKdaa824e2011-08-05 12:09:44 +020011596
Hervé COMMOWICK35ed8012010-12-15 14:04:51 +010011597
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200115987.3.4. Fetching samples at Layer 5
Willy Tarreau74ca5042013-06-11 23:12:07 +020011599----------------------------------
Willy Tarreau0b1cd942010-05-16 22:18:27 +020011600
Willy Tarreau74ca5042013-06-11 23:12:07 +020011601The layer 5 usually describes just the session layer which in haproxy is
11602closest to the session once all the connection handshakes are finished, but
11603when no content is yet made available. The fetch methods described here are
11604usable as low as the "tcp-request content" rule sets unless they require some
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011605future information. Those generally include the results of SSL negotiations.
Willy Tarreauc735a072011-03-29 00:57:02 +020011606
Emeric Brun645ae792014-04-30 14:21:06 +020011607ssl_bc : boolean
11608 Returns true when the back connection was made via an SSL/TLS transport
11609 layer and is locally deciphered. This means the outgoing connection was made
11610 other a server with the "ssl" option.
11611
11612ssl_bc_alg_keysize : integer
11613 Returns the symmetric cipher key size supported in bits when the outgoing
11614 connection was made over an SSL/TLS transport layer.
11615
11616ssl_bc_cipher : string
11617 Returns the name of the used cipher when the outgoing connection was made
11618 over an SSL/TLS transport layer.
11619
11620ssl_bc_protocol : string
11621 Returns the name of the used protocol when the outgoing connection was made
11622 over an SSL/TLS transport layer.
11623
Emeric Brunb73a9b02014-04-30 18:49:19 +020011624ssl_bc_unique_id : binary
Emeric Brun645ae792014-04-30 14:21:06 +020011625 When the outgoing connection was made over an SSL/TLS transport layer,
Emeric Brunb73a9b02014-04-30 18:49:19 +020011626 returns the TLS unique ID as defined in RFC5929 section 3. The unique id
11627 can be encoded to base64 using the converter: "ssl_bc_unique_id,base64".
Emeric Brun645ae792014-04-30 14:21:06 +020011628
11629ssl_bc_session_id : binary
11630 Returns the SSL ID of the back connection when the outgoing connection was
11631 made over an SSL/TLS transport layer. It is useful to log if we want to know
11632 if session was reused or not.
11633
11634ssl_bc_use_keysize : integer
11635 Returns the symmetric cipher key size used in bits when the outgoing
11636 connection was made over an SSL/TLS transport layer.
11637
Willy Tarreau74ca5042013-06-11 23:12:07 +020011638ssl_c_ca_err : integer
11639 When the incoming connection was made over an SSL/TLS transport layer,
11640 returns the ID of the first error detected during verification of the client
11641 certificate at depth > 0, or 0 if no error was encountered during this
11642 verification process. Please refer to your SSL library's documentation to
11643 find the exhaustive list of error codes.
Willy Tarreauc735a072011-03-29 00:57:02 +020011644
Willy Tarreau74ca5042013-06-11 23:12:07 +020011645ssl_c_ca_err_depth : integer
11646 When the incoming connection was made over an SSL/TLS transport layer,
11647 returns the depth in the CA chain of the first error detected during the
11648 verification of the client certificate. If no error is encountered, 0 is
11649 returned.
Willy Tarreau0ba27502007-12-24 16:55:16 +010011650
Emeric Brun43e79582014-10-29 19:03:26 +010011651ssl_c_der : binary
11652 Returns the DER formatted certificate presented by the client when the
11653 incoming connection was made over an SSL/TLS transport layer. When used for
11654 an ACL, the value(s) to match against can be passed in hexadecimal form.
11655
Willy Tarreau74ca5042013-06-11 23:12:07 +020011656ssl_c_err : integer
11657 When the incoming connection was made over an SSL/TLS transport layer,
11658 returns the ID of the first error detected during verification at depth 0, or
11659 0 if no error was encountered during this verification process. Please refer
11660 to your SSL library's documentation to find the exhaustive list of error
11661 codes.
Willy Tarreau62644772008-07-16 18:36:06 +020011662
Willy Tarreau74ca5042013-06-11 23:12:07 +020011663ssl_c_i_dn([<entry>[,<occ>]]) : string
11664 When the incoming connection was made over an SSL/TLS transport layer,
11665 returns the full distinguished name of the issuer of the certificate
11666 presented by the client when no <entry> is specified, or the value of the
11667 first given entry found from the beginning of the DN. If a positive/negative
11668 occurrence number is specified as the optional second argument, it returns
11669 the value of the nth given entry value from the beginning/end of the DN.
11670 For instance, "ssl_c_i_dn(OU,2)" the second organization unit, and
11671 "ssl_c_i_dn(CN)" retrieves the common name.
Willy Tarreau62644772008-07-16 18:36:06 +020011672
Willy Tarreau74ca5042013-06-11 23:12:07 +020011673ssl_c_key_alg : string
11674 Returns the name of the algorithm used to generate the key of the certificate
11675 presented by the client when the incoming connection was made over an SSL/TLS
11676 transport layer.
Willy Tarreau62644772008-07-16 18:36:06 +020011677
Willy Tarreau74ca5042013-06-11 23:12:07 +020011678ssl_c_notafter : string
11679 Returns the end date presented by the client as a formatted string
11680 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
11681 transport layer.
Emeric Brunbede3d02009-06-30 17:54:00 +020011682
Willy Tarreau74ca5042013-06-11 23:12:07 +020011683ssl_c_notbefore : string
11684 Returns the start date presented by the client as a formatted string
11685 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
11686 transport layer.
Willy Tarreaub6672b52011-12-12 17:23:41 +010011687
Willy Tarreau74ca5042013-06-11 23:12:07 +020011688ssl_c_s_dn([<entry>[,<occ>]]) : string
11689 When the incoming connection was made over an SSL/TLS transport layer,
11690 returns the full distinguished name of the subject of the certificate
11691 presented by the client when no <entry> is specified, or the value of the
11692 first given entry found from the beginning of the DN. If a positive/negative
11693 occurrence number is specified as the optional second argument, it returns
11694 the value of the nth given entry value from the beginning/end of the DN.
11695 For instance, "ssl_c_s_dn(OU,2)" the second organization unit, and
11696 "ssl_c_s_dn(CN)" retrieves the common name.
Willy Tarreaub6672b52011-12-12 17:23:41 +010011697
Willy Tarreau74ca5042013-06-11 23:12:07 +020011698ssl_c_serial : binary
11699 Returns the serial of the certificate presented by the client when the
11700 incoming connection was made over an SSL/TLS transport layer. When used for
11701 an ACL, the value(s) to match against can be passed in hexadecimal form.
Emeric Brun2525b6b2012-10-18 15:59:43 +020011702
Willy Tarreau74ca5042013-06-11 23:12:07 +020011703ssl_c_sha1 : binary
11704 Returns the SHA-1 fingerprint of the certificate presented by the client when
11705 the incoming connection was made over an SSL/TLS transport layer. This can be
11706 used to stick a client to a server, or to pass this information to a server.
Willy Tarreau2d0caa32014-07-02 19:01:22 +020011707 Note that the output is binary, so if you want to pass that signature to the
11708 server, you need to encode it in hex or base64, such as in the example below:
11709
11710 http-request set-header X-SSL-Client-SHA1 %[ssl_c_sha1,hex]
Emeric Brun2525b6b2012-10-18 15:59:43 +020011711
Willy Tarreau74ca5042013-06-11 23:12:07 +020011712ssl_c_sig_alg : string
11713 Returns the name of the algorithm used to sign the certificate presented by
11714 the client when the incoming connection was made over an SSL/TLS transport
11715 layer.
Emeric Brun87855892012-10-17 17:39:35 +020011716
Willy Tarreau74ca5042013-06-11 23:12:07 +020011717ssl_c_used : boolean
11718 Returns true if current SSL session uses a client certificate even if current
11719 connection uses SSL session resumption. See also "ssl_fc_has_crt".
Emeric Brun7f56e742012-10-19 18:15:40 +020011720
Willy Tarreau74ca5042013-06-11 23:12:07 +020011721ssl_c_verify : integer
11722 Returns the verify result error ID when the incoming connection was made over
11723 an SSL/TLS transport layer, otherwise zero if no error is encountered. Please
11724 refer to your SSL library's documentation for an exhaustive list of error
11725 codes.
Emeric Brunce5ad802012-10-22 14:11:22 +020011726
Willy Tarreau74ca5042013-06-11 23:12:07 +020011727ssl_c_version : integer
11728 Returns the version of the certificate presented by the client when the
11729 incoming connection was made over an SSL/TLS transport layer.
Emeric Brunce5ad802012-10-22 14:11:22 +020011730
Emeric Brun43e79582014-10-29 19:03:26 +010011731ssl_f_der : binary
11732 Returns the DER formatted certificate presented by the frontend when the
11733 incoming connection was made over an SSL/TLS transport layer. When used for
11734 an ACL, the value(s) to match against can be passed in hexadecimal form.
11735
Willy Tarreau74ca5042013-06-11 23:12:07 +020011736ssl_f_i_dn([<entry>[,<occ>]]) : string
11737 When the incoming connection was made over an SSL/TLS transport layer,
11738 returns the full distinguished name of the issuer of the certificate
11739 presented by the frontend when no <entry> is specified, or the value of the
11740 first given entry found from the beginning of the DN. If a positive/negative
Emeric Brun87855892012-10-17 17:39:35 +020011741 occurrence number is specified as the optional second argument, it returns
Willy Tarreau74ca5042013-06-11 23:12:07 +020011742 the value of the nth given entry value from the beginning/end of the DN.
11743 For instance, "ssl_f_i_dn(OU,2)" the second organization unit, and
11744 "ssl_f_i_dn(CN)" retrieves the common name.
Emeric Brun87855892012-10-17 17:39:35 +020011745
Willy Tarreau74ca5042013-06-11 23:12:07 +020011746ssl_f_key_alg : string
11747 Returns the name of the algorithm used to generate the key of the certificate
11748 presented by the frontend when the incoming connection was made over an
11749 SSL/TLS transport layer.
Emeric Brun7f56e742012-10-19 18:15:40 +020011750
Willy Tarreau74ca5042013-06-11 23:12:07 +020011751ssl_f_notafter : string
11752 Returns the end date presented by the frontend as a formatted string
11753 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
11754 transport layer.
Emeric Brun2525b6b2012-10-18 15:59:43 +020011755
Willy Tarreau74ca5042013-06-11 23:12:07 +020011756ssl_f_notbefore : string
11757 Returns the start date presented by the frontend as a formatted string
11758 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
11759 transport layer.
Emeric Brun87855892012-10-17 17:39:35 +020011760
Willy Tarreau74ca5042013-06-11 23:12:07 +020011761ssl_f_s_dn([<entry>[,<occ>]]) : string
11762 When the incoming connection was made over an SSL/TLS transport layer,
11763 returns the full distinguished name of the subject of the certificate
11764 presented by the frontend when no <entry> is specified, or the value of the
11765 first given entry found from the beginning of the DN. If a positive/negative
11766 occurrence number is specified as the optional second argument, it returns
11767 the value of the nth given entry value from the beginning/end of the DN.
11768 For instance, "ssl_f_s_dn(OU,2)" the second organization unit, and
11769 "ssl_f_s_dn(CN)" retrieves the common name.
Emeric Brunce5ad802012-10-22 14:11:22 +020011770
Willy Tarreau74ca5042013-06-11 23:12:07 +020011771ssl_f_serial : binary
11772 Returns the serial of the certificate presented by the frontend when the
11773 incoming connection was made over an SSL/TLS transport layer. When used for
11774 an ACL, the value(s) to match against can be passed in hexadecimal form.
Emeric Brun87855892012-10-17 17:39:35 +020011775
Emeric Brun55f4fa82014-04-30 17:11:25 +020011776ssl_f_sha1 : binary
11777 Returns the SHA-1 fingerprint of the certificate presented by the frontend
11778 when the incoming connection was made over an SSL/TLS transport layer. This
11779 can be used to know which certificate was chosen using SNI.
11780
Willy Tarreau74ca5042013-06-11 23:12:07 +020011781ssl_f_sig_alg : string
11782 Returns the name of the algorithm used to sign the certificate presented by
11783 the frontend when the incoming connection was made over an SSL/TLS transport
11784 layer.
Emeric Brun7f56e742012-10-19 18:15:40 +020011785
Willy Tarreau74ca5042013-06-11 23:12:07 +020011786ssl_f_version : integer
11787 Returns the version of the certificate presented by the frontend when the
11788 incoming connection was made over an SSL/TLS transport layer.
11789
11790ssl_fc : boolean
Emeric Brun2525b6b2012-10-18 15:59:43 +020011791 Returns true when the front connection was made via an SSL/TLS transport
11792 layer and is locally deciphered. This means it has matched a socket declared
11793 with a "bind" line having the "ssl" option.
11794
Willy Tarreau74ca5042013-06-11 23:12:07 +020011795 Example :
11796 # This passes "X-Proto: https" to servers when client connects over SSL
11797 listen http-https
11798 bind :80
11799 bind :443 ssl crt /etc/haproxy.pem
11800 http-request add-header X-Proto https if { ssl_fc }
11801
11802ssl_fc_alg_keysize : integer
11803 Returns the symmetric cipher key size supported in bits when the incoming
11804 connection was made over an SSL/TLS transport layer.
11805
11806ssl_fc_alpn : string
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011807 This extracts the Application Layer Protocol Negotiation field from an
Willy Tarreau74ca5042013-06-11 23:12:07 +020011808 incoming connection made via a TLS transport layer and locally deciphered by
11809 haproxy. The result is a string containing the protocol name advertised by
11810 the client. The SSL library must have been built with support for TLS
11811 extensions enabled (check haproxy -vv). Note that the TLS ALPN extension is
11812 not advertised unless the "alpn" keyword on the "bind" line specifies a
11813 protocol list. Also, nothing forces the client to pick a protocol from this
11814 list, any other one may be requested. The TLS ALPN extension is meant to
11815 replace the TLS NPN extension. See also "ssl_fc_npn".
11816
Willy Tarreau74ca5042013-06-11 23:12:07 +020011817ssl_fc_cipher : string
11818 Returns the name of the used cipher when the incoming connection was made
11819 over an SSL/TLS transport layer.
Willy Tarreauab861d32013-04-02 02:30:41 +020011820
Willy Tarreau74ca5042013-06-11 23:12:07 +020011821ssl_fc_has_crt : boolean
Emeric Brun2525b6b2012-10-18 15:59:43 +020011822 Returns true if a client certificate is present in an incoming connection over
11823 SSL/TLS transport layer. Useful if 'verify' statement is set to 'optional'.
Emeric Brun9143d372012-12-20 15:44:16 +010011824 Note: on SSL session resumption with Session ID or TLS ticket, client
11825 certificate is not present in the current connection but may be retrieved
11826 from the cache or the ticket. So prefer "ssl_c_used" if you want to check if
11827 current SSL session uses a client certificate.
Emeric Brun2525b6b2012-10-18 15:59:43 +020011828
Willy Tarreau74ca5042013-06-11 23:12:07 +020011829ssl_fc_has_sni : boolean
11830 This checks for the presence of a Server Name Indication TLS extension (SNI)
Willy Tarreauf7bc57c2012-10-03 00:19:48 +020011831 in an incoming connection was made over an SSL/TLS transport layer. Returns
11832 true when the incoming connection presents a TLS SNI field. This requires
11833 that the SSL library is build with support for TLS extensions enabled (check
11834 haproxy -vv).
Willy Tarreau7875d092012-09-10 08:20:03 +020011835
Willy Tarreau74ca5042013-06-11 23:12:07 +020011836ssl_fc_npn : string
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011837 This extracts the Next Protocol Negotiation field from an incoming connection
Willy Tarreau74ca5042013-06-11 23:12:07 +020011838 made via a TLS transport layer and locally deciphered by haproxy. The result
11839 is a string containing the protocol name advertised by the client. The SSL
11840 library must have been built with support for TLS extensions enabled (check
11841 haproxy -vv). Note that the TLS NPN extension is not advertised unless the
11842 "npn" keyword on the "bind" line specifies a protocol list. Also, nothing
11843 forces the client to pick a protocol from this list, any other one may be
11844 requested. Please note that the TLS NPN extension was replaced with ALPN.
Willy Tarreaua33c6542012-10-15 13:19:06 +020011845
Willy Tarreau74ca5042013-06-11 23:12:07 +020011846ssl_fc_protocol : string
11847 Returns the name of the used protocol when the incoming connection was made
11848 over an SSL/TLS transport layer.
Willy Tarreau7875d092012-09-10 08:20:03 +020011849
Emeric Brunb73a9b02014-04-30 18:49:19 +020011850ssl_fc_unique_id : binary
David Sc1ad52e2014-04-08 18:48:47 -040011851 When the incoming connection was made over an SSL/TLS transport layer,
Emeric Brunb73a9b02014-04-30 18:49:19 +020011852 returns the TLS unique ID as defined in RFC5929 section 3. The unique id
11853 can be encoded to base64 using the converter: "ssl_bc_unique_id,base64".
David Sc1ad52e2014-04-08 18:48:47 -040011854
Willy Tarreau74ca5042013-06-11 23:12:07 +020011855ssl_fc_session_id : binary
11856 Returns the SSL ID of the front connection when the incoming connection was
11857 made over an SSL/TLS transport layer. It is useful to stick a given client to
11858 a server. It is important to note that some browsers refresh their session ID
11859 every few minutes.
Willy Tarreau7875d092012-09-10 08:20:03 +020011860
Willy Tarreau74ca5042013-06-11 23:12:07 +020011861ssl_fc_sni : string
11862 This extracts the Server Name Indication TLS extension (SNI) field from an
11863 incoming connection made via an SSL/TLS transport layer and locally
11864 deciphered by haproxy. The result (when present) typically is a string
11865 matching the HTTPS host name (253 chars or less). The SSL library must have
11866 been built with support for TLS extensions enabled (check haproxy -vv).
11867
11868 This fetch is different from "req_ssl_sni" above in that it applies to the
11869 connection being deciphered by haproxy and not to SSL contents being blindly
11870 forwarded. See also "ssl_fc_sni_end" and "ssl_fc_sni_reg" below. This
Cyril Bonté9c1eb1e2012-10-09 22:45:34 +020011871 requires that the SSL library is build with support for TLS extensions
11872 enabled (check haproxy -vv).
Willy Tarreau62644772008-07-16 18:36:06 +020011873
Willy Tarreau74ca5042013-06-11 23:12:07 +020011874 ACL derivatives :
Willy Tarreau74ca5042013-06-11 23:12:07 +020011875 ssl_fc_sni_end : suffix match
11876 ssl_fc_sni_reg : regex match
Emeric Brun589fcad2012-10-16 14:13:26 +020011877
Willy Tarreau74ca5042013-06-11 23:12:07 +020011878ssl_fc_use_keysize : integer
11879 Returns the symmetric cipher key size used in bits when the incoming
11880 connection was made over an SSL/TLS transport layer.
Willy Tarreaub6fb4202008-07-20 11:18:28 +020011881
Willy Tarreaub6fb4202008-07-20 11:18:28 +020011882
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200118837.3.5. Fetching samples from buffer contents (Layer 6)
Willy Tarreau74ca5042013-06-11 23:12:07 +020011884------------------------------------------------------
Willy Tarreaub6fb4202008-07-20 11:18:28 +020011885
Willy Tarreau74ca5042013-06-11 23:12:07 +020011886Fetching samples from buffer contents is a bit different from the previous
11887sample fetches above because the sampled data are ephemeral. These data can
11888only be used when they're available and will be lost when they're forwarded.
11889For this reason, samples fetched from buffer contents during a request cannot
11890be used in a response for example. Even while the data are being fetched, they
11891can change. Sometimes it is necessary to set some delays or combine multiple
11892sample fetch methods to ensure that the expected data are complete and usable,
11893for example through TCP request content inspection. Please see the "tcp-request
11894content" keyword for more detailed information on the subject.
Willy Tarreau62644772008-07-16 18:36:06 +020011895
Willy Tarreau74ca5042013-06-11 23:12:07 +020011896payload(<offset>,<length>) : binary (deprecated)
11897 This is an alias for "req.payload" when used in the context of a request (eg:
11898 "stick on", "stick match"), and for "res.payload" when used in the context of
11899 a response such as in "stick store response".
Willy Tarreau0ba27502007-12-24 16:55:16 +010011900
Willy Tarreau74ca5042013-06-11 23:12:07 +020011901payload_lv(<offset1>,<length>[,<offset2>]) : binary (deprecated)
11902 This is an alias for "req.payload_lv" when used in the context of a request
11903 (eg: "stick on", "stick match"), and for "res.payload_lv" when used in the
11904 context of a response such as in "stick store response".
Willy Tarreau0ba27502007-12-24 16:55:16 +010011905
Willy Tarreau74ca5042013-06-11 23:12:07 +020011906req.len : integer
11907req_len : integer (deprecated)
11908 Returns an integer value corresponding to the number of bytes present in the
11909 request buffer. This is mostly used in ACL. It is important to understand
11910 that this test does not return false as long as the buffer is changing. This
11911 means that a check with equality to zero will almost always immediately match
11912 at the beginning of the session, while a test for more data will wait for
11913 that data to come in and return false only when haproxy is certain that no
11914 more data will come in. This test was designed to be used with TCP request
11915 content inspection.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011916
Willy Tarreau74ca5042013-06-11 23:12:07 +020011917req.payload(<offset>,<length>) : binary
11918 This extracts a binary block of <length> bytes and starting at byte <offset>
Willy Tarreau00f00842013-08-02 11:07:32 +020011919 in the request buffer. As a special case, if the <length> argument is zero,
11920 the the whole buffer from <offset> to the end is extracted. This can be used
11921 with ACLs in order to check for the presence of some content in a buffer at
11922 any location.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011923
Willy Tarreau74ca5042013-06-11 23:12:07 +020011924 ACL alternatives :
11925 payload(<offset>,<length>) : hex binary match
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011926
Willy Tarreau74ca5042013-06-11 23:12:07 +020011927req.payload_lv(<offset1>,<length>[,<offset2>]) : binary
11928 This extracts a binary block whose size is specified at <offset1> for <length>
11929 bytes, and which starts at <offset2> if specified or just after the length in
11930 the request buffer. The <offset2> parameter also supports relative offsets if
11931 prepended with a '+' or '-' sign.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011932
Willy Tarreau74ca5042013-06-11 23:12:07 +020011933 ACL alternatives :
11934 payload_lv(<offset1>,<length>[,<offset2>]) : hex binary match
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011935
Willy Tarreau74ca5042013-06-11 23:12:07 +020011936 Example : please consult the example from the "stick store-response" keyword.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011937
Willy Tarreau74ca5042013-06-11 23:12:07 +020011938req.proto_http : boolean
11939req_proto_http : boolean (deprecated)
11940 Returns true when data in the request buffer look like HTTP and correctly
11941 parses as such. It is the same parser as the common HTTP request parser which
11942 is used so there should be no surprises. The test does not match until the
11943 request is complete, failed or timed out. This test may be used to report the
11944 protocol in TCP logs, but the biggest use is to block TCP request analysis
11945 until a complete HTTP request is present in the buffer, for example to track
11946 a header.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011947
Willy Tarreau74ca5042013-06-11 23:12:07 +020011948 Example:
11949 # track request counts per "base" (concatenation of Host+URL)
11950 tcp-request inspect-delay 10s
11951 tcp-request content reject if !HTTP
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020011952 tcp-request content track-sc0 base table req-rate
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020011953
Willy Tarreau74ca5042013-06-11 23:12:07 +020011954req.rdp_cookie([<name>]) : string
11955rdp_cookie([<name>]) : string (deprecated)
11956 When the request buffer looks like the RDP protocol, extracts the RDP cookie
11957 <name>, or any cookie if unspecified. The parser only checks for the first
11958 cookie, as illustrated in the RDP protocol specification. The cookie name is
11959 case insensitive. Generally the "MSTS" cookie name will be used, as it can
11960 contain the user name of the client connecting to the server if properly
11961 configured on the client. The "MSTSHASH" cookie is often used as well for
11962 session stickiness to servers.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020011963
Willy Tarreau74ca5042013-06-11 23:12:07 +020011964 This differs from "balance rdp-cookie" in that any balancing algorithm may be
11965 used and thus the distribution of clients to backend servers is not linked to
11966 a hash of the RDP cookie. It is envisaged that using a balancing algorithm
11967 such as "balance roundrobin" or "balance leastconn" will lead to a more even
11968 distribution of clients to backend servers than the hash used by "balance
11969 rdp-cookie".
Willy Tarreau04aa6a92012-04-06 18:57:55 +020011970
Willy Tarreau74ca5042013-06-11 23:12:07 +020011971 ACL derivatives :
11972 req_rdp_cookie([<name>]) : exact string match
Willy Tarreau04aa6a92012-04-06 18:57:55 +020011973
Willy Tarreau74ca5042013-06-11 23:12:07 +020011974 Example :
11975 listen tse-farm
11976 bind 0.0.0.0:3389
11977 # wait up to 5s for an RDP cookie in the request
11978 tcp-request inspect-delay 5s
11979 tcp-request content accept if RDP_COOKIE
11980 # apply RDP cookie persistence
11981 persist rdp-cookie
11982 # Persist based on the mstshash cookie
11983 # This is only useful makes sense if
11984 # balance rdp-cookie is not used
11985 stick-table type string size 204800
11986 stick on req.rdp_cookie(mstshash)
11987 server srv1 1.1.1.1:3389
11988 server srv1 1.1.1.2:3389
Willy Tarreau04aa6a92012-04-06 18:57:55 +020011989
Willy Tarreau74ca5042013-06-11 23:12:07 +020011990 See also : "balance rdp-cookie", "persist rdp-cookie", "tcp-request" and the
11991 "req_rdp_cookie" ACL.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020011992
Willy Tarreau74ca5042013-06-11 23:12:07 +020011993req.rdp_cookie_cnt([name]) : integer
11994rdp_cookie_cnt([name]) : integer (deprecated)
11995 Tries to parse the request buffer as RDP protocol, then returns an integer
11996 corresponding to the number of RDP cookies found. If an optional cookie name
11997 is passed, only cookies matching this name are considered. This is mostly
11998 used in ACL.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020011999
Willy Tarreau74ca5042013-06-11 23:12:07 +020012000 ACL derivatives :
12001 req_rdp_cookie_cnt([<name>]) : integer match
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012002
Willy Tarreau74ca5042013-06-11 23:12:07 +020012003req.ssl_hello_type : integer
12004req_ssl_hello_type : integer (deprecated)
12005 Returns an integer value containing the type of the SSL hello message found
12006 in the request buffer if the buffer contains data that parse as a complete
12007 SSL (v3 or superior) client hello message. Note that this only applies to raw
12008 contents found in the request buffer and not to contents deciphered via an
12009 SSL data layer, so this will not work with "bind" lines having the "ssl"
12010 option. This is mostly used in ACL to detect presence of an SSL hello message
12011 that is supposed to contain an SSL session ID usable for stickiness.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012012
Willy Tarreau74ca5042013-06-11 23:12:07 +020012013req.ssl_sni : string
12014req_ssl_sni : string (deprecated)
12015 Returns a string containing the value of the Server Name TLS extension sent
12016 by a client in a TLS stream passing through the request buffer if the buffer
12017 contains data that parse as a complete SSL (v3 or superior) client hello
12018 message. Note that this only applies to raw contents found in the request
12019 buffer and not to contents deciphered via an SSL data layer, so this will not
12020 work with "bind" lines having the "ssl" option. SNI normally contains the
12021 name of the host the client tries to connect to (for recent browsers). SNI is
12022 useful for allowing or denying access to certain hosts when SSL/TLS is used
12023 by the client. This test was designed to be used with TCP request content
12024 inspection. If content switching is needed, it is recommended to first wait
12025 for a complete client hello (type 1), like in the example below. See also
12026 "ssl_fc_sni".
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012027
Willy Tarreau74ca5042013-06-11 23:12:07 +020012028 ACL derivatives :
12029 req_ssl_sni : exact string match
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012030
Willy Tarreau74ca5042013-06-11 23:12:07 +020012031 Examples :
12032 # Wait for a client hello for at most 5 seconds
12033 tcp-request inspect-delay 5s
12034 tcp-request content accept if { req_ssl_hello_type 1 }
12035 use_backend bk_allow if { req_ssl_sni -f allowed_sites }
12036 default_backend bk_sorry_page
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012037
Willy Tarreau74ca5042013-06-11 23:12:07 +020012038res.ssl_hello_type : integer
12039rep_ssl_hello_type : integer (deprecated)
12040 Returns an integer value containing the type of the SSL hello message found
12041 in the response buffer if the buffer contains data that parses as a complete
12042 SSL (v3 or superior) hello message. Note that this only applies to raw
12043 contents found in the response buffer and not to contents deciphered via an
12044 SSL data layer, so this will not work with "server" lines having the "ssl"
12045 option. This is mostly used in ACL to detect presence of an SSL hello message
12046 that is supposed to contain an SSL session ID usable for stickiness.
Willy Tarreau51539362012-05-08 12:46:28 +020012047
Willy Tarreau74ca5042013-06-11 23:12:07 +020012048req.ssl_ver : integer
12049req_ssl_ver : integer (deprecated)
12050 Returns an integer value containing the version of the SSL/TLS protocol of a
12051 stream present in the request buffer. Both SSLv2 hello messages and SSLv3
12052 messages are supported. TLSv1 is announced as SSL version 3.1. The value is
12053 composed of the major version multiplied by 65536, added to the minor
12054 version. Note that this only applies to raw contents found in the request
12055 buffer and not to contents deciphered via an SSL data layer, so this will not
12056 work with "bind" lines having the "ssl" option. The ACL version of the test
12057 matches against a decimal notation in the form MAJOR.MINOR (eg: 3.1). This
12058 fetch is mostly used in ACL.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012059
Willy Tarreau74ca5042013-06-11 23:12:07 +020012060 ACL derivatives :
12061 req_ssl_ver : decimal match
Willy Tarreaud63335a2010-02-26 12:56:52 +010012062
Willy Tarreau47e8eba2013-09-11 23:28:46 +020012063res.len : integer
12064 Returns an integer value corresponding to the number of bytes present in the
12065 response buffer. This is mostly used in ACL. It is important to understand
12066 that this test does not return false as long as the buffer is changing. This
12067 means that a check with equality to zero will almost always immediately match
12068 at the beginning of the session, while a test for more data will wait for
12069 that data to come in and return false only when haproxy is certain that no
12070 more data will come in. This test was designed to be used with TCP response
12071 content inspection.
12072
Willy Tarreau74ca5042013-06-11 23:12:07 +020012073res.payload(<offset>,<length>) : binary
12074 This extracts a binary block of <length> bytes and starting at byte <offset>
Willy Tarreau00f00842013-08-02 11:07:32 +020012075 in the response buffer. As a special case, if the <length> argument is zero,
12076 the the whole buffer from <offset> to the end is extracted. This can be used
12077 with ACLs in order to check for the presence of some content in a buffer at
12078 any location.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012079
Willy Tarreau74ca5042013-06-11 23:12:07 +020012080res.payload_lv(<offset1>,<length>[,<offset2>]) : binary
12081 This extracts a binary block whose size is specified at <offset1> for <length>
12082 bytes, and which starts at <offset2> if specified or just after the length in
12083 the response buffer. The <offset2> parameter also supports relative offsets
12084 if prepended with a '+' or '-' sign.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012085
Willy Tarreau74ca5042013-06-11 23:12:07 +020012086 Example : please consult the example from the "stick store-response" keyword.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012087
Willy Tarreau74ca5042013-06-11 23:12:07 +020012088wait_end : boolean
12089 This fetch either returns true when the inspection period is over, or does
12090 not fetch. It is only used in ACLs, in conjunction with content analysis to
12091 avoid returning a wrong verdict early. It may also be used to delay some
12092 actions, such as a delayed reject for some special addresses. Since it either
12093 stops the rules evaluation or immediately returns true, it is recommended to
12094 use this acl as the last one in a rule. Please note that the default ACL
12095 "WAIT_END" is always usable without prior declaration. This test was designed
12096 to be used with TCP request content inspection.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012097
Willy Tarreau74ca5042013-06-11 23:12:07 +020012098 Examples :
12099 # delay every incoming request by 2 seconds
12100 tcp-request inspect-delay 2s
12101 tcp-request content accept if WAIT_END
Willy Tarreaud63335a2010-02-26 12:56:52 +010012102
Willy Tarreau74ca5042013-06-11 23:12:07 +020012103 # don't immediately tell bad guys they are rejected
12104 tcp-request inspect-delay 10s
12105 acl goodguys src 10.0.0.0/24
12106 acl badguys src 10.0.1.0/24
12107 tcp-request content accept if goodguys
12108 tcp-request content reject if badguys WAIT_END
12109 tcp-request content reject
12110
12111
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200121127.3.6. Fetching HTTP samples (Layer 7)
Willy Tarreau74ca5042013-06-11 23:12:07 +020012113--------------------------------------
12114
12115It is possible to fetch samples from HTTP contents, requests and responses.
12116This application layer is also called layer 7. It is only possible to fetch the
12117data in this section when a full HTTP request or response has been parsed from
12118its respective request or response buffer. This is always the case with all
12119HTTP specific rules and for sections running with "mode http". When using TCP
12120content inspection, it may be necessary to support an inspection delay in order
12121to let the request or response come in first. These fetches may require a bit
12122more CPU resources than the layer 4 ones, but not much since the request and
12123response are indexed.
12124
12125base : string
12126 This returns the concatenation of the first Host header and the path part of
12127 the request, which starts at the first slash and ends before the question
12128 mark. It can be useful in virtual hosted environments to detect URL abuses as
12129 well as to improve shared caches efficiency. Using this with a limited size
12130 stick table also allows one to collect statistics about most commonly
12131 requested objects by host/path. With ACLs it can allow simple content
12132 switching rules involving the host and the path at the same time, such as
12133 "www.example.com/favicon.ico". See also "path" and "uri".
12134
12135 ACL derivatives :
12136 base : exact string match
12137 base_beg : prefix match
12138 base_dir : subdir match
12139 base_dom : domain match
12140 base_end : suffix match
12141 base_len : length match
12142 base_reg : regex match
12143 base_sub : substring match
12144
12145base32 : integer
12146 This returns a 32-bit hash of the value returned by the "base" fetch method
12147 above. This is useful to track per-URL activity on high traffic sites without
12148 having to store all URLs. Instead a shorter hash is stored, saving a lot of
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020012149 memory. The output type is an unsigned integer. The hash function used is
12150 SDBM with full avalanche on the output. Technically, base32 is exactly equal
12151 to "base,sdbm(1)".
Willy Tarreau74ca5042013-06-11 23:12:07 +020012152
12153base32+src : binary
12154 This returns the concatenation of the base32 fetch above and the src fetch
12155 below. The resulting type is of type binary, with a size of 8 or 20 bytes
12156 depending on the source address family. This can be used to track per-IP,
12157 per-URL counters.
12158
William Lallemand65ad6e12014-01-31 15:08:02 +010012159capture.req.hdr(<idx>) : string
12160 This extracts the content of the header captured by the "capture request
12161 header", idx is the position of the capture keyword in the configuration.
12162 The first entry is an index of 0. See also: "capture request header".
12163
12164capture.req.method : string
12165 This extracts the METHOD of an HTTP request. It can be used in both request
12166 and response. Unlike "method", it can be used in both request and response
12167 because it's allocated.
12168
12169capture.req.uri : string
12170 This extracts the request's URI, which starts at the first slash and ends
12171 before the first space in the request (without the host part). Unlike "path"
12172 and "url", it can be used in both request and response because it's
12173 allocated.
12174
Willy Tarreau3c1b5ec2014-04-24 23:41:57 +020012175capture.req.ver : string
12176 This extracts the request's HTTP version and returns either "HTTP/1.0" or
12177 "HTTP/1.1". Unlike "req.ver", it can be used in both request, response, and
12178 logs because it relies on a persistent flag.
12179
William Lallemand65ad6e12014-01-31 15:08:02 +010012180capture.res.hdr(<idx>) : string
12181 This extracts the content of the header captured by the "capture response
12182 header", idx is the position of the capture keyword in the configuration.
12183 The first entry is an index of 0.
12184 See also: "capture response header"
12185
Willy Tarreau3c1b5ec2014-04-24 23:41:57 +020012186capture.res.ver : string
12187 This extracts the response's HTTP version and returns either "HTTP/1.0" or
12188 "HTTP/1.1". Unlike "res.ver", it can be used in logs because it relies on a
12189 persistent flag.
12190
Willy Tarreau74ca5042013-06-11 23:12:07 +020012191req.cook([<name>]) : string
12192cook([<name>]) : string (deprecated)
12193 This extracts the last occurrence of the cookie name <name> on a "Cookie"
12194 header line from the request, and returns its value as string. If no name is
12195 specified, the first cookie value is returned. When used with ACLs, all
12196 matching cookies are evaluated. Spaces around the name and the value are
12197 ignored as requested by the Cookie header specification (RFC6265). The cookie
12198 name is case-sensitive. Empty cookies are valid, so an empty cookie may very
12199 well return an empty value if it is present. Use the "found" match to detect
12200 presence. Use the res.cook() variant for response cookies sent by the server.
12201
12202 ACL derivatives :
12203 cook([<name>]) : exact string match
12204 cook_beg([<name>]) : prefix match
12205 cook_dir([<name>]) : subdir match
12206 cook_dom([<name>]) : domain match
12207 cook_end([<name>]) : suffix match
12208 cook_len([<name>]) : length match
12209 cook_reg([<name>]) : regex match
12210 cook_sub([<name>]) : substring match
Willy Tarreaud63335a2010-02-26 12:56:52 +010012211
Willy Tarreau74ca5042013-06-11 23:12:07 +020012212req.cook_cnt([<name>]) : integer
12213cook_cnt([<name>]) : integer (deprecated)
12214 Returns an integer value representing the number of occurrences of the cookie
12215 <name> in the request, or all cookies if <name> is not specified.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012216
Willy Tarreau74ca5042013-06-11 23:12:07 +020012217req.cook_val([<name>]) : integer
12218cook_val([<name>]) : integer (deprecated)
12219 This extracts the last occurrence of the cookie name <name> on a "Cookie"
12220 header line from the request, and converts its value to an integer which is
12221 returned. If no name is specified, the first cookie value is returned. When
12222 used in ACLs, all matching names are iterated over until a value matches.
Willy Tarreau0e698542011-09-16 08:32:32 +020012223
Willy Tarreau74ca5042013-06-11 23:12:07 +020012224cookie([<name>]) : string (deprecated)
12225 This extracts the last occurrence of the cookie name <name> on a "Cookie"
12226 header line from the request, or a "Set-Cookie" header from the response, and
12227 returns its value as a string. A typical use is to get multiple clients
12228 sharing a same profile use the same server. This can be similar to what
12229 "appsession" does with the "request-learn" statement, but with support for
12230 multi-peer synchronization and state keeping across restarts. If no name is
12231 specified, the first cookie value is returned. This fetch should not be used
12232 anymore and should be replaced by req.cook() or res.cook() instead as it
12233 ambiguously uses the direction based on the context where it is used.
12234 See also : "appsession".
Willy Tarreaud63335a2010-02-26 12:56:52 +010012235
Willy Tarreau74ca5042013-06-11 23:12:07 +020012236hdr([<name>[,<occ>]]) : string
12237 This is equivalent to req.hdr() when used on requests, and to res.hdr() when
12238 used on responses. Please refer to these respective fetches for more details.
12239 In case of doubt about the fetch direction, please use the explicit ones.
12240 Note that contrary to the hdr() sample fetch method, the hdr_* ACL keywords
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030012241 unambiguously apply to the request headers.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012242
Willy Tarreau74ca5042013-06-11 23:12:07 +020012243req.fhdr(<name>[,<occ>]) : string
12244 This extracts the last occurrence of header <name> in an HTTP request. When
12245 used from an ACL, all occurrences are iterated over until a match is found.
12246 Optionally, a specific occurrence might be specified as a position number.
12247 Positive values indicate a position from the first occurrence, with 1 being
12248 the first one. Negative values indicate positions relative to the last one,
12249 with -1 being the last one. It differs from req.hdr() in that any commas
12250 present in the value are returned and are not used as delimiters. This is
12251 sometimes useful with headers such as User-Agent.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012252
Willy Tarreau74ca5042013-06-11 23:12:07 +020012253req.fhdr_cnt([<name>]) : integer
12254 Returns an integer value representing the number of occurrences of request
12255 header field name <name>, or the total number of header fields if <name> is
12256 not specified. Contrary to its req.hdr_cnt() cousin, this function returns
12257 the number of full line headers and does not stop on commas.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012258
Willy Tarreau74ca5042013-06-11 23:12:07 +020012259req.hdr([<name>[,<occ>]]) : string
12260 This extracts the last occurrence of header <name> in an HTTP request. When
12261 used from an ACL, all occurrences are iterated over until a match is found.
12262 Optionally, a specific occurrence might be specified as a position number.
12263 Positive values indicate a position from the first occurrence, with 1 being
12264 the first one. Negative values indicate positions relative to the last one,
12265 with -1 being the last one. A typical use is with the X-Forwarded-For header
12266 once converted to IP, associated with an IP stick-table. The function
12267 considers any comma as a delimiter for distinct values. If full-line headers
12268 are desired instead, use req.fhdr(). Please carefully check RFC2616 to know
12269 how certain headers are supposed to be parsed. Also, some of them are case
12270 insensitive (eg: Connection).
Willy Tarreaud63335a2010-02-26 12:56:52 +010012271
Willy Tarreau74ca5042013-06-11 23:12:07 +020012272 ACL derivatives :
12273 hdr([<name>[,<occ>]]) : exact string match
12274 hdr_beg([<name>[,<occ>]]) : prefix match
12275 hdr_dir([<name>[,<occ>]]) : subdir match
12276 hdr_dom([<name>[,<occ>]]) : domain match
12277 hdr_end([<name>[,<occ>]]) : suffix match
12278 hdr_len([<name>[,<occ>]]) : length match
12279 hdr_reg([<name>[,<occ>]]) : regex match
12280 hdr_sub([<name>[,<occ>]]) : substring match
12281
12282req.hdr_cnt([<name>]) : integer
12283hdr_cnt([<header>]) : integer (deprecated)
12284 Returns an integer value representing the number of occurrences of request
12285 header field name <name>, or the total number of header field values if
12286 <name> is not specified. It is important to remember that one header line may
12287 count as several headers if it has several values. The function considers any
12288 comma as a delimiter for distinct values. If full-line headers are desired
12289 instead, req.fhdr_cnt() should be used instead. With ACLs, it can be used to
12290 detect presence, absence or abuse of a specific header, as well as to block
12291 request smuggling attacks by rejecting requests which contain more than one
12292 of certain headers. See "req.hdr" for more information on header matching.
12293
12294req.hdr_ip([<name>[,<occ>]]) : ip
12295hdr_ip([<name>[,<occ>]]) : ip (deprecated)
12296 This extracts the last occurrence of header <name> in an HTTP request,
12297 converts it to an IPv4 or IPv6 address and returns this address. When used
12298 with ACLs, all occurrences are checked, and if <name> is omitted, every value
12299 of every header is checked. Optionally, a specific occurrence might be
12300 specified as a position number. Positive values indicate a position from the
12301 first occurrence, with 1 being the first one. Negative values indicate
12302 positions relative to the last one, with -1 being the last one. A typical use
12303 is with the X-Forwarded-For and X-Client-IP headers.
12304
12305req.hdr_val([<name>[,<occ>]]) : integer
12306hdr_val([<name>[,<occ>]]) : integer (deprecated)
12307 This extracts the last occurrence of header <name> in an HTTP request, and
12308 converts it to an integer value. When used with ACLs, all occurrences are
12309 checked, and if <name> is omitted, every value of every header is checked.
12310 Optionally, a specific occurrence might be specified as a position number.
12311 Positive values indicate a position from the first occurrence, with 1 being
12312 the first one. Negative values indicate positions relative to the last one,
12313 with -1 being the last one. A typical use is with the X-Forwarded-For header.
12314
12315http_auth(<userlist>) : boolean
12316 Returns a boolean indicating whether the authentication data received from
12317 the client match a username & password stored in the specified userlist. This
12318 fetch function is not really useful outside of ACLs. Currently only http
12319 basic auth is supported.
12320
Thierry FOURNIER9eec0a62014-01-22 18:38:02 +010012321http_auth_group(<userlist>) : string
12322 Returns a string corresponding to the user name found in the authentication
12323 data received from the client if both the user name and password are valid
12324 according to the specified userlist. The main purpose is to use it in ACLs
12325 where it is then checked whether the user belongs to any group within a list.
Willy Tarreau74ca5042013-06-11 23:12:07 +020012326 This fetch function is not really useful outside of ACLs. Currently only http
12327 basic auth is supported.
12328
12329 ACL derivatives :
Thierry FOURNIER9eec0a62014-01-22 18:38:02 +010012330 http_auth_group(<userlist>) : group ...
12331 Returns true when the user extracted from the request and whose password is
12332 valid according to the specified userlist belongs to at least one of the
12333 groups.
Willy Tarreau74ca5042013-06-11 23:12:07 +020012334
12335http_first_req : boolean
Willy Tarreau7f18e522010-10-22 20:04:13 +020012336 Returns true when the request being processed is the first one of the
12337 connection. This can be used to add or remove headers that may be missing
Willy Tarreau74ca5042013-06-11 23:12:07 +020012338 from some requests when a request is not the first one, or to help grouping
12339 requests in the logs.
Willy Tarreau7f18e522010-10-22 20:04:13 +020012340
Willy Tarreau74ca5042013-06-11 23:12:07 +020012341method : integer + string
12342 Returns an integer value corresponding to the method in the HTTP request. For
12343 example, "GET" equals 1 (check sources to establish the matching). Value 9
12344 means "other method" and may be converted to a string extracted from the
12345 stream. This should not be used directly as a sample, this is only meant to
12346 be used from ACLs, which transparently convert methods from patterns to these
12347 integer + string values. Some predefined ACL already check for most common
12348 methods.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012349
Willy Tarreau74ca5042013-06-11 23:12:07 +020012350 ACL derivatives :
12351 method : case insensitive method match
Willy Tarreau6a06a402007-07-15 20:15:28 +020012352
Willy Tarreau74ca5042013-06-11 23:12:07 +020012353 Example :
12354 # only accept GET and HEAD requests
12355 acl valid_method method GET HEAD
12356 http-request deny if ! valid_method
Willy Tarreau6a06a402007-07-15 20:15:28 +020012357
Willy Tarreau74ca5042013-06-11 23:12:07 +020012358path : string
12359 This extracts the request's URL path, which starts at the first slash and
12360 ends before the question mark (without the host part). A typical use is with
12361 prefetch-capable caches, and with portals which need to aggregate multiple
12362 information from databases and keep them in caches. Note that with outgoing
12363 caches, it would be wiser to use "url" instead. With ACLs, it's typically
12364 used to match exact file names (eg: "/login.php"), or directory parts using
12365 the derivative forms. See also the "url" and "base" fetch methods.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012366
Willy Tarreau74ca5042013-06-11 23:12:07 +020012367 ACL derivatives :
12368 path : exact string match
12369 path_beg : prefix match
12370 path_dir : subdir match
12371 path_dom : domain match
12372 path_end : suffix match
12373 path_len : length match
12374 path_reg : regex match
12375 path_sub : substring match
Willy Tarreau6a06a402007-07-15 20:15:28 +020012376
Willy Tarreau49ad95c2015-01-19 15:06:26 +010012377query : string
12378 This extracts the request's query string, which starts after the first
12379 question mark. If no question mark is present, this fetch returns nothing. If
12380 a question mark is present but nothing follows, it returns an empty string.
12381 This means it's possible to easily know whether a query string is present
12382 using the "found" matching method. This fetch is the completemnt of "path"
12383 which stops before the question mark.
12384
Willy Tarreaueb27ec72015-02-20 13:55:29 +010012385req.hdr_names([<delim>]) : string
12386 This builds a string made from the concatenation of all header names as they
12387 appear in the request when the rule is evaluated. The default delimiter is
12388 the comma (',') but it may be overridden as an optional argument <delim>. In
12389 this case, only the first character of <delim> is considered.
12390
Willy Tarreau74ca5042013-06-11 23:12:07 +020012391req.ver : string
12392req_ver : string (deprecated)
12393 Returns the version string from the HTTP request, for example "1.1". This can
12394 be useful for logs, but is mostly there for ACL. Some predefined ACL already
12395 check for versions 1.0 and 1.1.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012396
Willy Tarreau74ca5042013-06-11 23:12:07 +020012397 ACL derivatives :
12398 req_ver : exact string match
Willy Tarreau0e698542011-09-16 08:32:32 +020012399
Willy Tarreau74ca5042013-06-11 23:12:07 +020012400res.comp : boolean
12401 Returns the boolean "true" value if the response has been compressed by
12402 HAProxy, otherwise returns boolean "false". This may be used to add
12403 information in the logs.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012404
Willy Tarreau74ca5042013-06-11 23:12:07 +020012405res.comp_algo : string
12406 Returns a string containing the name of the algorithm used if the response
12407 was compressed by HAProxy, for example : "deflate". This may be used to add
12408 some information in the logs.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012409
Willy Tarreau74ca5042013-06-11 23:12:07 +020012410res.cook([<name>]) : string
12411scook([<name>]) : string (deprecated)
12412 This extracts the last occurrence of the cookie name <name> on a "Set-Cookie"
12413 header line from the response, and returns its value as string. If no name is
12414 specified, the first cookie value is returned.
Willy Tarreau0ce3aa02012-04-25 18:46:33 +020012415
Willy Tarreau74ca5042013-06-11 23:12:07 +020012416 ACL derivatives :
12417 scook([<name>] : exact string match
Willy Tarreau0ce3aa02012-04-25 18:46:33 +020012418
Willy Tarreau74ca5042013-06-11 23:12:07 +020012419res.cook_cnt([<name>]) : integer
12420scook_cnt([<name>]) : integer (deprecated)
12421 Returns an integer value representing the number of occurrences of the cookie
12422 <name> in the response, or all cookies if <name> is not specified. This is
12423 mostly useful when combined with ACLs to detect suspicious responses.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012424
Willy Tarreau74ca5042013-06-11 23:12:07 +020012425res.cook_val([<name>]) : integer
12426scook_val([<name>]) : integer (deprecated)
12427 This extracts the last occurrence of the cookie name <name> on a "Set-Cookie"
12428 header line from the response, and converts its value to an integer which is
12429 returned. If no name is specified, the first cookie value is returned.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012430
Willy Tarreau74ca5042013-06-11 23:12:07 +020012431res.fhdr([<name>[,<occ>]]) : string
12432 This extracts the last occurrence of header <name> in an HTTP response, or of
12433 the last header if no <name> is specified. Optionally, a specific occurrence
12434 might be specified as a position number. Positive values indicate a position
12435 from the first occurrence, with 1 being the first one. Negative values
12436 indicate positions relative to the last one, with -1 being the last one. It
12437 differs from res.hdr() in that any commas present in the value are returned
12438 and are not used as delimiters. If this is not desired, the res.hdr() fetch
12439 should be used instead. This is sometimes useful with headers such as Date or
12440 Expires.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012441
Willy Tarreau74ca5042013-06-11 23:12:07 +020012442res.fhdr_cnt([<name>]) : integer
12443 Returns an integer value representing the number of occurrences of response
12444 header field name <name>, or the total number of header fields if <name> is
12445 not specified. Contrary to its res.hdr_cnt() cousin, this function returns
12446 the number of full line headers and does not stop on commas. If this is not
12447 desired, the res.hdr_cnt() fetch should be used instead.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012448
Willy Tarreau74ca5042013-06-11 23:12:07 +020012449res.hdr([<name>[,<occ>]]) : string
12450shdr([<name>[,<occ>]]) : string (deprecated)
12451 This extracts the last occurrence of header <name> in an HTTP response, or of
12452 the last header if no <name> is specified. Optionally, a specific occurrence
12453 might be specified as a position number. Positive values indicate a position
12454 from the first occurrence, with 1 being the first one. Negative values
12455 indicate positions relative to the last one, with -1 being the last one. This
12456 can be useful to learn some data into a stick-table. The function considers
12457 any comma as a delimiter for distinct values. If this is not desired, the
12458 res.fhdr() fetch should be used instead.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012459
Willy Tarreau74ca5042013-06-11 23:12:07 +020012460 ACL derivatives :
12461 shdr([<name>[,<occ>]]) : exact string match
12462 shdr_beg([<name>[,<occ>]]) : prefix match
12463 shdr_dir([<name>[,<occ>]]) : subdir match
12464 shdr_dom([<name>[,<occ>]]) : domain match
12465 shdr_end([<name>[,<occ>]]) : suffix match
12466 shdr_len([<name>[,<occ>]]) : length match
12467 shdr_reg([<name>[,<occ>]]) : regex match
12468 shdr_sub([<name>[,<occ>]]) : substring match
12469
12470res.hdr_cnt([<name>]) : integer
12471shdr_cnt([<name>]) : integer (deprecated)
12472 Returns an integer value representing the number of occurrences of response
12473 header field name <name>, or the total number of header fields if <name> is
12474 not specified. The function considers any comma as a delimiter for distinct
12475 values. If this is not desired, the res.fhdr_cnt() fetch should be used
12476 instead.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012477
Willy Tarreau74ca5042013-06-11 23:12:07 +020012478res.hdr_ip([<name>[,<occ>]]) : ip
12479shdr_ip([<name>[,<occ>]]) : ip (deprecated)
12480 This extracts the last occurrence of header <name> in an HTTP response,
12481 convert it to an IPv4 or IPv6 address and returns this address. Optionally, a
12482 specific occurrence might be specified as a position number. Positive values
12483 indicate a position from the first occurrence, with 1 being the first one.
12484 Negative values indicate positions relative to the last one, with -1 being
12485 the last one. This can be useful to learn some data into a stick table.
Willy Tarreau6a06a402007-07-15 20:15:28 +020012486
Willy Tarreaueb27ec72015-02-20 13:55:29 +010012487res.hdr_names([<delim>]) : string
12488 This builds a string made from the concatenation of all header names as they
12489 appear in the response when the rule is evaluated. The default delimiter is
12490 the comma (',') but it may be overridden as an optional argument <delim>. In
12491 this case, only the first character of <delim> is considered.
12492
Willy Tarreau74ca5042013-06-11 23:12:07 +020012493res.hdr_val([<name>[,<occ>]]) : integer
12494shdr_val([<name>[,<occ>]]) : integer (deprecated)
12495 This extracts the last occurrence of header <name> in an HTTP response, and
12496 converts it to an integer value. Optionally, a specific occurrence might be
12497 specified as a position number. Positive values indicate a position from the
12498 first occurrence, with 1 being the first one. Negative values indicate
12499 positions relative to the last one, with -1 being the last one. This can be
12500 useful to learn some data into a stick table.
Alexandre Cassen5eb1a902007-11-29 15:43:32 +010012501
Willy Tarreau74ca5042013-06-11 23:12:07 +020012502res.ver : string
12503resp_ver : string (deprecated)
12504 Returns the version string from the HTTP response, for example "1.1". This
12505 can be useful for logs, but is mostly there for ACL.
Willy Tarreau0e698542011-09-16 08:32:32 +020012506
Willy Tarreau74ca5042013-06-11 23:12:07 +020012507 ACL derivatives :
12508 resp_ver : exact string match
Alexandre Cassen5eb1a902007-11-29 15:43:32 +010012509
Willy Tarreau74ca5042013-06-11 23:12:07 +020012510set-cookie([<name>]) : string (deprecated)
12511 This extracts the last occurrence of the cookie name <name> on a "Set-Cookie"
12512 header line from the response and uses the corresponding value to match. This
12513 can be comparable to what "appsession" does with default options, but with
12514 support for multi-peer synchronization and state keeping across restarts.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +010012515
Willy Tarreau74ca5042013-06-11 23:12:07 +020012516 This fetch function is deprecated and has been superseded by the "res.cook"
12517 fetch. This keyword will disappear soon.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +010012518
Willy Tarreau74ca5042013-06-11 23:12:07 +020012519 See also : "appsession"
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012520
Willy Tarreau74ca5042013-06-11 23:12:07 +020012521status : integer
12522 Returns an integer containing the HTTP status code in the HTTP response, for
12523 example, 302. It is mostly used within ACLs and integer ranges, for example,
12524 to remove any Location header if the response is not a 3xx.
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012525
Willy Tarreau74ca5042013-06-11 23:12:07 +020012526url : string
12527 This extracts the request's URL as presented in the request. A typical use is
12528 with prefetch-capable caches, and with portals which need to aggregate
12529 multiple information from databases and keep them in caches. With ACLs, using
12530 "path" is preferred over using "url", because clients may send a full URL as
12531 is normally done with proxies. The only real use is to match "*" which does
12532 not match in "path", and for which there is already a predefined ACL. See
12533 also "path" and "base".
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012534
Willy Tarreau74ca5042013-06-11 23:12:07 +020012535 ACL derivatives :
12536 url : exact string match
12537 url_beg : prefix match
12538 url_dir : subdir match
12539 url_dom : domain match
12540 url_end : suffix match
12541 url_len : length match
12542 url_reg : regex match
12543 url_sub : substring match
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012544
Willy Tarreau74ca5042013-06-11 23:12:07 +020012545url_ip : ip
12546 This extracts the IP address from the request's URL when the host part is
12547 presented as an IP address. Its use is very limited. For instance, a
12548 monitoring system might use this field as an alternative for the source IP in
12549 order to test what path a given source address would follow, or to force an
12550 entry in a table for a given source address. With ACLs it can be used to
12551 restrict access to certain systems through a proxy, for example when combined
12552 with option "http_proxy".
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012553
Willy Tarreau74ca5042013-06-11 23:12:07 +020012554url_port : integer
12555 This extracts the port part from the request's URL. Note that if the port is
12556 not specified in the request, port 80 is assumed. With ACLs it can be used to
12557 restrict access to certain systems through a proxy, for example when combined
12558 with option "http_proxy".
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012559
Willy Tarreau74ca5042013-06-11 23:12:07 +020012560urlp(<name>[,<delim>]) : string
12561url_param(<name>[,<delim>]) : string
12562 This extracts the first occurrence of the parameter <name> in the query
12563 string, which begins after either '?' or <delim>, and which ends before '&',
12564 ';' or <delim>. The parameter name is case-sensitive. The result is a string
12565 corresponding to the value of the parameter <name> as presented in the
12566 request (no URL decoding is performed). This can be used for session
12567 stickiness based on a client ID, to extract an application cookie passed as a
12568 URL parameter, or in ACLs to apply some checks. Note that the ACL version of
12569 this fetch do not iterate over multiple parameters and stop at the first one
12570 as well.
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012571
Willy Tarreau74ca5042013-06-11 23:12:07 +020012572 ACL derivatives :
12573 urlp(<name>[,<delim>]) : exact string match
12574 urlp_beg(<name>[,<delim>]) : prefix match
12575 urlp_dir(<name>[,<delim>]) : subdir match
12576 urlp_dom(<name>[,<delim>]) : domain match
12577 urlp_end(<name>[,<delim>]) : suffix match
12578 urlp_len(<name>[,<delim>]) : length match
12579 urlp_reg(<name>[,<delim>]) : regex match
12580 urlp_sub(<name>[,<delim>]) : substring match
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012581
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012582
Willy Tarreau74ca5042013-06-11 23:12:07 +020012583 Example :
12584 # match http://example.com/foo?PHPSESSIONID=some_id
12585 stick on urlp(PHPSESSIONID)
12586 # match http://example.com/foo;JSESSIONID=some_id
12587 stick on urlp(JSESSIONID,;)
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020012588
Willy Tarreau74ca5042013-06-11 23:12:07 +020012589urlp_val(<name>[,<delim>]) : integer
12590 See "urlp" above. This one extracts the URL parameter <name> in the request
12591 and converts it to an integer value. This can be used for session stickiness
12592 based on a user ID for example, or with ACLs to match a page number or price.
Willy Tarreaua9fddca2012-07-31 07:51:48 +020012593
Willy Tarreau198a7442008-01-17 12:05:32 +010012594
Willy Tarreau74ca5042013-06-11 23:12:07 +0200125957.4. Pre-defined ACLs
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012596---------------------
Willy Tarreauced27012008-01-17 20:35:34 +010012597
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012598Some predefined ACLs are hard-coded so that they do not have to be declared in
12599every frontend which needs them. They all have their names in upper case in
Patrick Mézard2382ad62010-05-09 10:43:32 +020012600order to avoid confusion. Their equivalence is provided below.
Willy Tarreauced27012008-01-17 20:35:34 +010012601
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012602ACL name Equivalent to Usage
12603---------------+-----------------------------+---------------------------------
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012604FALSE always_false never match
Willy Tarreau2492d5b2009-07-11 00:06:00 +020012605HTTP req_proto_http match if protocol is valid HTTP
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012606HTTP_1.0 req_ver 1.0 match HTTP version 1.0
12607HTTP_1.1 req_ver 1.1 match HTTP version 1.1
Willy Tarreaud63335a2010-02-26 12:56:52 +010012608HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
12609HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
12610HTTP_URL_SLASH url_beg / match URL beginning with "/"
12611HTTP_URL_STAR url * match URL equal to "*"
12612LOCALHOST src 127.0.0.1/8 match connection from local host
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012613METH_CONNECT method CONNECT match HTTP CONNECT method
12614METH_GET method GET HEAD match HTTP GET or HEAD method
12615METH_HEAD method HEAD match HTTP HEAD method
12616METH_OPTIONS method OPTIONS match HTTP OPTIONS method
12617METH_POST method POST match HTTP POST method
12618METH_TRACE method TRACE match HTTP TRACE method
Emeric Brunbede3d02009-06-30 17:54:00 +020012619RDP_COOKIE req_rdp_cookie_cnt gt 0 match presence of an RDP cookie
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012620REQ_CONTENT req_len gt 0 match data in the request buffer
Willy Tarreaud63335a2010-02-26 12:56:52 +010012621TRUE always_true always match
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012622WAIT_END wait_end wait for end of content analysis
12623---------------+-----------------------------+---------------------------------
Willy Tarreauced27012008-01-17 20:35:34 +010012624
Willy Tarreaub937b7e2010-01-12 15:27:54 +010012625
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200126268. Logging
12627----------
Willy Tarreau844e3c52008-01-11 16:28:18 +010012628
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012629One of HAProxy's strong points certainly lies is its precise logs. It probably
12630provides the finest level of information available for such a product, which is
12631very important for troubleshooting complex environments. Standard information
12632provided in logs include client ports, TCP/HTTP state timers, precise session
12633state at termination and precise termination cause, information about decisions
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010012634to direct traffic to a server, and of course the ability to capture arbitrary
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012635headers.
12636
12637In order to improve administrators reactivity, it offers a great transparency
12638about encountered problems, both internal and external, and it is possible to
12639send logs to different sources at the same time with different level filters :
12640
12641 - global process-level logs (system errors, start/stop, etc..)
12642 - per-instance system and internal errors (lack of resource, bugs, ...)
12643 - per-instance external troubles (servers up/down, max connections)
12644 - per-instance activity (client connections), either at the establishment or
12645 at the termination.
12646
12647The ability to distribute different levels of logs to different log servers
12648allow several production teams to interact and to fix their problems as soon
12649as possible. For example, the system team might monitor system-wide errors,
12650while the application team might be monitoring the up/down for their servers in
12651real time, and the security team might analyze the activity logs with one hour
12652delay.
12653
12654
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200126558.1. Log levels
12656---------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012657
Simon Hormandf791f52011-05-29 15:01:10 +090012658TCP and HTTP connections can be logged with information such as the date, time,
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012659source IP address, destination address, connection duration, response times,
Simon Hormandf791f52011-05-29 15:01:10 +090012660HTTP request, HTTP return code, number of bytes transmitted, conditions
12661in which the session ended, and even exchanged cookies values. For example
12662track a particular user's problems. All messages may be sent to up to two
12663syslog servers. Check the "log" keyword in section 4.2 for more information
12664about log facilities.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012665
12666
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200126678.2. Log formats
12668----------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012669
William Lallemand48940402012-01-30 16:47:22 +010012670HAProxy supports 5 log formats. Several fields are common between these formats
Simon Hormandf791f52011-05-29 15:01:10 +090012671and will be detailed in the following sections. A few of them may vary
12672slightly with the configuration, due to indicators specific to certain
12673options. The supported formats are as follows :
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012674
12675 - the default format, which is very basic and very rarely used. It only
12676 provides very basic information about the incoming connection at the moment
12677 it is accepted : source IP:port, destination IP:port, and frontend-name.
12678 This mode will eventually disappear so it will not be described to great
12679 extents.
12680
12681 - the TCP format, which is more advanced. This format is enabled when "option
12682 tcplog" is set on the frontend. HAProxy will then usually wait for the
12683 connection to terminate before logging. This format provides much richer
12684 information, such as timers, connection counts, queue size, etc... This
12685 format is recommended for pure TCP proxies.
12686
12687 - the HTTP format, which is the most advanced for HTTP proxying. This format
12688 is enabled when "option httplog" is set on the frontend. It provides the
12689 same information as the TCP format with some HTTP-specific fields such as
12690 the request, the status code, and captures of headers and cookies. This
12691 format is recommended for HTTP proxies.
12692
Emeric Brun3a058f32009-06-30 18:26:00 +020012693 - the CLF HTTP format, which is equivalent to the HTTP format, but with the
12694 fields arranged in the same order as the CLF format. In this mode, all
12695 timers, captures, flags, etc... appear one per field after the end of the
12696 common fields, in the same order they appear in the standard HTTP format.
12697
William Lallemand48940402012-01-30 16:47:22 +010012698 - the custom log format, allows you to make your own log line.
12699
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012700Next sections will go deeper into details for each of these formats. Format
12701specification will be performed on a "field" basis. Unless stated otherwise, a
12702field is a portion of text delimited by any number of spaces. Since syslog
12703servers are susceptible of inserting fields at the beginning of a line, it is
12704always assumed that the first field is the one containing the process name and
12705identifier.
12706
12707Note : Since log lines may be quite long, the log examples in sections below
12708 might be broken into multiple lines. The example log lines will be
12709 prefixed with 3 closing angle brackets ('>>>') and each time a log is
12710 broken into multiple lines, each non-final line will end with a
12711 backslash ('\') and the next line will start indented by two characters.
12712
12713
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200127148.2.1. Default log format
12715-------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012716
12717This format is used when no specific option is set. The log is emitted as soon
12718as the connection is accepted. One should note that this currently is the only
12719format which logs the request's destination IP and ports.
12720
12721 Example :
12722 listen www
12723 mode http
12724 log global
12725 server srv1 127.0.0.1:8000
12726
12727 >>> Feb 6 12:12:09 localhost \
12728 haproxy[14385]: Connect from 10.0.1.2:33312 to 10.0.3.31:8012 \
12729 (www/HTTP)
12730
12731 Field Format Extract from the example above
12732 1 process_name '[' pid ']:' haproxy[14385]:
12733 2 'Connect from' Connect from
12734 3 source_ip ':' source_port 10.0.1.2:33312
12735 4 'to' to
12736 5 destination_ip ':' destination_port 10.0.3.31:8012
12737 6 '(' frontend_name '/' mode ')' (www/HTTP)
12738
12739Detailed fields description :
12740 - "source_ip" is the IP address of the client which initiated the connection.
12741 - "source_port" is the TCP port of the client which initiated the connection.
12742 - "destination_ip" is the IP address the client connected to.
12743 - "destination_port" is the TCP port the client connected to.
12744 - "frontend_name" is the name of the frontend (or listener) which received
12745 and processed the connection.
12746 - "mode is the mode the frontend is operating (TCP or HTTP).
12747
Willy Tarreauceb24bc2010-11-09 12:46:41 +010012748In case of a UNIX socket, the source and destination addresses are marked as
12749"unix:" and the ports reflect the internal ID of the socket which accepted the
12750connection (the same ID as reported in the stats).
12751
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012752It is advised not to use this deprecated format for newer installations as it
12753will eventually disappear.
12754
12755
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200127568.2.2. TCP log format
12757---------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012758
12759The TCP format is used when "option tcplog" is specified in the frontend, and
12760is the recommended format for pure TCP proxies. It provides a lot of precious
12761information for troubleshooting. Since this format includes timers and byte
12762counts, the log is normally emitted at the end of the session. It can be
12763emitted earlier if "option logasap" is specified, which makes sense in most
12764environments with long sessions such as remote terminals. Sessions which match
12765the "monitor" rules are never logged. It is also possible not to emit logs for
12766sessions for which no data were exchanged between the client and the server, by
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020012767specifying "option dontlognull" in the frontend. Successful connections will
12768not be logged if "option dontlog-normal" is specified in the frontend. A few
12769fields may slightly vary depending on some configuration options, those are
12770marked with a star ('*') after the field name below.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012771
12772 Example :
12773 frontend fnt
12774 mode tcp
12775 option tcplog
12776 log global
12777 default_backend bck
12778
12779 backend bck
12780 server srv1 127.0.0.1:8000
12781
12782 >>> Feb 6 12:12:56 localhost \
12783 haproxy[14387]: 10.0.1.2:33313 [06/Feb/2009:12:12:51.443] fnt \
12784 bck/srv1 0/0/5007 212 -- 0/0/0/0/3 0/0
12785
12786 Field Format Extract from the example above
12787 1 process_name '[' pid ']:' haproxy[14387]:
12788 2 client_ip ':' client_port 10.0.1.2:33313
12789 3 '[' accept_date ']' [06/Feb/2009:12:12:51.443]
12790 4 frontend_name fnt
12791 5 backend_name '/' server_name bck/srv1
12792 6 Tw '/' Tc '/' Tt* 0/0/5007
12793 7 bytes_read* 212
12794 8 termination_state --
12795 9 actconn '/' feconn '/' beconn '/' srv_conn '/' retries* 0/0/0/0/3
12796 10 srv_queue '/' backend_queue 0/0
12797
12798Detailed fields description :
12799 - "client_ip" is the IP address of the client which initiated the TCP
Willy Tarreauceb24bc2010-11-09 12:46:41 +010012800 connection to haproxy. If the connection was accepted on a UNIX socket
12801 instead, the IP address would be replaced with the word "unix". Note that
12802 when the connection is accepted on a socket configured with "accept-proxy"
12803 and the PROXY protocol is correctly used, then the logs will reflect the
12804 forwarded connection's information.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012805
12806 - "client_port" is the TCP port of the client which initiated the connection.
Willy Tarreauceb24bc2010-11-09 12:46:41 +010012807 If the connection was accepted on a UNIX socket instead, the port would be
12808 replaced with the ID of the accepting socket, which is also reported in the
12809 stats interface.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012810
12811 - "accept_date" is the exact date when the connection was received by haproxy
12812 (which might be very slightly different from the date observed on the
12813 network if there was some queuing in the system's backlog). This is usually
12814 the same date which may appear in any upstream firewall's log.
12815
12816 - "frontend_name" is the name of the frontend (or listener) which received
12817 and processed the connection.
12818
12819 - "backend_name" is the name of the backend (or listener) which was selected
12820 to manage the connection to the server. This will be the same as the
12821 frontend if no switching rule has been applied, which is common for TCP
12822 applications.
12823
12824 - "server_name" is the name of the last server to which the connection was
12825 sent, which might differ from the first one if there were connection errors
12826 and a redispatch occurred. Note that this server belongs to the backend
12827 which processed the request. If the connection was aborted before reaching
12828 a server, "<NOSRV>" is indicated instead of a server name.
12829
12830 - "Tw" is the total time in milliseconds spent waiting in the various queues.
12831 It can be "-1" if the connection was aborted before reaching the queue.
12832 See "Timers" below for more details.
12833
12834 - "Tc" is the total time in milliseconds spent waiting for the connection to
12835 establish to the final server, including retries. It can be "-1" if the
12836 connection was aborted before a connection could be established. See
12837 "Timers" below for more details.
12838
12839 - "Tt" is the total time in milliseconds elapsed between the accept and the
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030012840 last close. It covers all possible processing. There is one exception, if
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012841 "option logasap" was specified, then the time counting stops at the moment
12842 the log is emitted. In this case, a '+' sign is prepended before the value,
12843 indicating that the final one will be larger. See "Timers" below for more
12844 details.
12845
12846 - "bytes_read" is the total number of bytes transmitted from the server to
12847 the client when the log is emitted. If "option logasap" is specified, the
12848 this value will be prefixed with a '+' sign indicating that the final one
12849 may be larger. Please note that this value is a 64-bit counter, so log
12850 analysis tools must be able to handle it without overflowing.
12851
12852 - "termination_state" is the condition the session was in when the session
12853 ended. This indicates the session state, which side caused the end of
12854 session to happen, and for what reason (timeout, error, ...). The normal
12855 flags should be "--", indicating the session was closed by either end with
12856 no data remaining in buffers. See below "Session state at disconnection"
12857 for more details.
12858
12859 - "actconn" is the total number of concurrent connections on the process when
Jamie Gloudonaaa21002012-08-25 00:18:33 -040012860 the session was logged. It is useful to detect when some per-process system
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012861 limits have been reached. For instance, if actconn is close to 512 when
12862 multiple connection errors occur, chances are high that the system limits
12863 the process to use a maximum of 1024 file descriptors and that all of them
Willy Tarreauc57f0e22009-05-10 13:12:33 +020012864 are used. See section 3 "Global parameters" to find how to tune the system.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012865
12866 - "feconn" is the total number of concurrent connections on the frontend when
12867 the session was logged. It is useful to estimate the amount of resource
12868 required to sustain high loads, and to detect when the frontend's "maxconn"
12869 has been reached. Most often when this value increases by huge jumps, it is
12870 because there is congestion on the backend servers, but sometimes it can be
12871 caused by a denial of service attack.
12872
12873 - "beconn" is the total number of concurrent connections handled by the
12874 backend when the session was logged. It includes the total number of
12875 concurrent connections active on servers as well as the number of
12876 connections pending in queues. It is useful to estimate the amount of
12877 additional servers needed to support high loads for a given application.
12878 Most often when this value increases by huge jumps, it is because there is
12879 congestion on the backend servers, but sometimes it can be caused by a
12880 denial of service attack.
12881
12882 - "srv_conn" is the total number of concurrent connections still active on
12883 the server when the session was logged. It can never exceed the server's
12884 configured "maxconn" parameter. If this value is very often close or equal
12885 to the server's "maxconn", it means that traffic regulation is involved a
12886 lot, meaning that either the server's maxconn value is too low, or that
12887 there aren't enough servers to process the load with an optimal response
12888 time. When only one of the server's "srv_conn" is high, it usually means
12889 that this server has some trouble causing the connections to take longer to
12890 be processed than on other servers.
12891
12892 - "retries" is the number of connection retries experienced by this session
12893 when trying to connect to the server. It must normally be zero, unless a
12894 server is being stopped at the same moment the connection was attempted.
12895 Frequent retries generally indicate either a network problem between
12896 haproxy and the server, or a misconfigured system backlog on the server
12897 preventing new connections from being queued. This field may optionally be
12898 prefixed with a '+' sign, indicating that the session has experienced a
12899 redispatch after the maximal retry count has been reached on the initial
12900 server. In this case, the server name appearing in the log is the one the
12901 connection was redispatched to, and not the first one, though both may
12902 sometimes be the same in case of hashing for instance. So as a general rule
12903 of thumb, when a '+' is present in front of the retry count, this count
12904 should not be attributed to the logged server.
12905
12906 - "srv_queue" is the total number of requests which were processed before
12907 this one in the server queue. It is zero when the request has not gone
12908 through the server queue. It makes it possible to estimate the approximate
12909 server's response time by dividing the time spent in queue by the number of
12910 requests in the queue. It is worth noting that if a session experiences a
12911 redispatch and passes through two server queues, their positions will be
12912 cumulated. A request should not pass through both the server queue and the
12913 backend queue unless a redispatch occurs.
12914
12915 - "backend_queue" is the total number of requests which were processed before
12916 this one in the backend's global queue. It is zero when the request has not
12917 gone through the global queue. It makes it possible to estimate the average
12918 queue length, which easily translates into a number of missing servers when
12919 divided by a server's "maxconn" parameter. It is worth noting that if a
12920 session experiences a redispatch, it may pass twice in the backend's queue,
12921 and then both positions will be cumulated. A request should not pass
12922 through both the server queue and the backend queue unless a redispatch
12923 occurs.
12924
12925
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200129268.2.3. HTTP log format
12927----------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012928
12929The HTTP format is the most complete and the best suited for HTTP proxies. It
12930is enabled by when "option httplog" is specified in the frontend. It provides
12931the same level of information as the TCP format with additional features which
12932are specific to the HTTP protocol. Just like the TCP format, the log is usually
12933emitted at the end of the session, unless "option logasap" is specified, which
12934generally only makes sense for download sites. A session which matches the
12935"monitor" rules will never logged. It is also possible not to log sessions for
12936which no data were sent by the client by specifying "option dontlognull" in the
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020012937frontend. Successful connections will not be logged if "option dontlog-normal"
12938is specified in the frontend.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012939
12940Most fields are shared with the TCP log, some being different. A few fields may
12941slightly vary depending on some configuration options. Those ones are marked
12942with a star ('*') after the field name below.
12943
12944 Example :
12945 frontend http-in
12946 mode http
12947 option httplog
12948 log global
12949 default_backend bck
12950
12951 backend static
12952 server srv1 127.0.0.1:8000
12953
12954 >>> Feb 6 12:14:14 localhost \
12955 haproxy[14389]: 10.0.1.2:33317 [06/Feb/2009:12:14:14.655] http-in \
12956 static/srv1 10/0/30/69/109 200 2750 - - ---- 1/1/1/1/0 0/0 {1wt.eu} \
Willy Tarreaud72758d2010-01-12 10:42:19 +010012957 {} "GET /index.html HTTP/1.1"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012958
12959 Field Format Extract from the example above
12960 1 process_name '[' pid ']:' haproxy[14389]:
12961 2 client_ip ':' client_port 10.0.1.2:33317
12962 3 '[' accept_date ']' [06/Feb/2009:12:14:14.655]
12963 4 frontend_name http-in
12964 5 backend_name '/' server_name static/srv1
12965 6 Tq '/' Tw '/' Tc '/' Tr '/' Tt* 10/0/30/69/109
12966 7 status_code 200
12967 8 bytes_read* 2750
12968 9 captured_request_cookie -
12969 10 captured_response_cookie -
12970 11 termination_state ----
12971 12 actconn '/' feconn '/' beconn '/' srv_conn '/' retries* 1/1/1/1/0
12972 13 srv_queue '/' backend_queue 0/0
12973 14 '{' captured_request_headers* '}' {haproxy.1wt.eu}
12974 15 '{' captured_response_headers* '}' {}
12975 16 '"' http_request '"' "GET /index.html HTTP/1.1"
Willy Tarreaud72758d2010-01-12 10:42:19 +010012976
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012977
12978Detailed fields description :
12979 - "client_ip" is the IP address of the client which initiated the TCP
Willy Tarreauceb24bc2010-11-09 12:46:41 +010012980 connection to haproxy. If the connection was accepted on a UNIX socket
12981 instead, the IP address would be replaced with the word "unix". Note that
12982 when the connection is accepted on a socket configured with "accept-proxy"
12983 and the PROXY protocol is correctly used, then the logs will reflect the
12984 forwarded connection's information.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012985
12986 - "client_port" is the TCP port of the client which initiated the connection.
Willy Tarreauceb24bc2010-11-09 12:46:41 +010012987 If the connection was accepted on a UNIX socket instead, the port would be
12988 replaced with the ID of the accepting socket, which is also reported in the
12989 stats interface.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010012990
12991 - "accept_date" is the exact date when the TCP connection was received by
12992 haproxy (which might be very slightly different from the date observed on
12993 the network if there was some queuing in the system's backlog). This is
12994 usually the same date which may appear in any upstream firewall's log. This
12995 does not depend on the fact that the client has sent the request or not.
12996
12997 - "frontend_name" is the name of the frontend (or listener) which received
12998 and processed the connection.
12999
13000 - "backend_name" is the name of the backend (or listener) which was selected
13001 to manage the connection to the server. This will be the same as the
13002 frontend if no switching rule has been applied.
13003
13004 - "server_name" is the name of the last server to which the connection was
13005 sent, which might differ from the first one if there were connection errors
13006 and a redispatch occurred. Note that this server belongs to the backend
13007 which processed the request. If the request was aborted before reaching a
13008 server, "<NOSRV>" is indicated instead of a server name. If the request was
13009 intercepted by the stats subsystem, "<STATS>" is indicated instead.
13010
13011 - "Tq" is the total time in milliseconds spent waiting for the client to send
13012 a full HTTP request, not counting data. It can be "-1" if the connection
13013 was aborted before a complete request could be received. It should always
13014 be very small because a request generally fits in one single packet. Large
13015 times here generally indicate network trouble between the client and
13016 haproxy. See "Timers" below for more details.
13017
13018 - "Tw" is the total time in milliseconds spent waiting in the various queues.
13019 It can be "-1" if the connection was aborted before reaching the queue.
13020 See "Timers" below for more details.
13021
13022 - "Tc" is the total time in milliseconds spent waiting for the connection to
13023 establish to the final server, including retries. It can be "-1" if the
13024 request was aborted before a connection could be established. See "Timers"
13025 below for more details.
13026
13027 - "Tr" is the total time in milliseconds spent waiting for the server to send
13028 a full HTTP response, not counting data. It can be "-1" if the request was
13029 aborted before a complete response could be received. It generally matches
13030 the server's processing time for the request, though it may be altered by
13031 the amount of data sent by the client to the server. Large times here on
13032 "GET" requests generally indicate an overloaded server. See "Timers" below
13033 for more details.
13034
13035 - "Tt" is the total time in milliseconds elapsed between the accept and the
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013036 last close. It covers all possible processing. There is one exception, if
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013037 "option logasap" was specified, then the time counting stops at the moment
13038 the log is emitted. In this case, a '+' sign is prepended before the value,
13039 indicating that the final one will be larger. See "Timers" below for more
13040 details.
13041
13042 - "status_code" is the HTTP status code returned to the client. This status
13043 is generally set by the server, but it might also be set by haproxy when
13044 the server cannot be reached or when its response is blocked by haproxy.
13045
13046 - "bytes_read" is the total number of bytes transmitted to the client when
13047 the log is emitted. This does include HTTP headers. If "option logasap" is
13048 specified, the this value will be prefixed with a '+' sign indicating that
13049 the final one may be larger. Please note that this value is a 64-bit
13050 counter, so log analysis tools must be able to handle it without
13051 overflowing.
13052
13053 - "captured_request_cookie" is an optional "name=value" entry indicating that
13054 the client had this cookie in the request. The cookie name and its maximum
13055 length are defined by the "capture cookie" statement in the frontend
13056 configuration. The field is a single dash ('-') when the option is not
13057 set. Only one cookie may be captured, it is generally used to track session
13058 ID exchanges between a client and a server to detect session crossing
13059 between clients due to application bugs. For more details, please consult
13060 the section "Capturing HTTP headers and cookies" below.
13061
13062 - "captured_response_cookie" is an optional "name=value" entry indicating
13063 that the server has returned a cookie with its response. The cookie name
13064 and its maximum length are defined by the "capture cookie" statement in the
13065 frontend configuration. The field is a single dash ('-') when the option is
13066 not set. Only one cookie may be captured, it is generally used to track
13067 session ID exchanges between a client and a server to detect session
13068 crossing between clients due to application bugs. For more details, please
13069 consult the section "Capturing HTTP headers and cookies" below.
13070
13071 - "termination_state" is the condition the session was in when the session
13072 ended. This indicates the session state, which side caused the end of
13073 session to happen, for what reason (timeout, error, ...), just like in TCP
13074 logs, and information about persistence operations on cookies in the last
13075 two characters. The normal flags should begin with "--", indicating the
13076 session was closed by either end with no data remaining in buffers. See
13077 below "Session state at disconnection" for more details.
13078
13079 - "actconn" is the total number of concurrent connections on the process when
Jamie Gloudonaaa21002012-08-25 00:18:33 -040013080 the session was logged. It is useful to detect when some per-process system
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013081 limits have been reached. For instance, if actconn is close to 512 or 1024
13082 when multiple connection errors occur, chances are high that the system
13083 limits the process to use a maximum of 1024 file descriptors and that all
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013084 of them are used. See section 3 "Global parameters" to find how to tune the
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013085 system.
13086
13087 - "feconn" is the total number of concurrent connections on the frontend when
13088 the session was logged. It is useful to estimate the amount of resource
13089 required to sustain high loads, and to detect when the frontend's "maxconn"
13090 has been reached. Most often when this value increases by huge jumps, it is
13091 because there is congestion on the backend servers, but sometimes it can be
13092 caused by a denial of service attack.
13093
13094 - "beconn" is the total number of concurrent connections handled by the
13095 backend when the session was logged. It includes the total number of
13096 concurrent connections active on servers as well as the number of
13097 connections pending in queues. It is useful to estimate the amount of
13098 additional servers needed to support high loads for a given application.
13099 Most often when this value increases by huge jumps, it is because there is
13100 congestion on the backend servers, but sometimes it can be caused by a
13101 denial of service attack.
13102
13103 - "srv_conn" is the total number of concurrent connections still active on
13104 the server when the session was logged. It can never exceed the server's
13105 configured "maxconn" parameter. If this value is very often close or equal
13106 to the server's "maxconn", it means that traffic regulation is involved a
13107 lot, meaning that either the server's maxconn value is too low, or that
13108 there aren't enough servers to process the load with an optimal response
13109 time. When only one of the server's "srv_conn" is high, it usually means
13110 that this server has some trouble causing the requests to take longer to be
13111 processed than on other servers.
13112
13113 - "retries" is the number of connection retries experienced by this session
13114 when trying to connect to the server. It must normally be zero, unless a
13115 server is being stopped at the same moment the connection was attempted.
13116 Frequent retries generally indicate either a network problem between
13117 haproxy and the server, or a misconfigured system backlog on the server
13118 preventing new connections from being queued. This field may optionally be
13119 prefixed with a '+' sign, indicating that the session has experienced a
13120 redispatch after the maximal retry count has been reached on the initial
13121 server. In this case, the server name appearing in the log is the one the
13122 connection was redispatched to, and not the first one, though both may
13123 sometimes be the same in case of hashing for instance. So as a general rule
13124 of thumb, when a '+' is present in front of the retry count, this count
13125 should not be attributed to the logged server.
13126
13127 - "srv_queue" is the total number of requests which were processed before
13128 this one in the server queue. It is zero when the request has not gone
13129 through the server queue. It makes it possible to estimate the approximate
13130 server's response time by dividing the time spent in queue by the number of
13131 requests in the queue. It is worth noting that if a session experiences a
13132 redispatch and passes through two server queues, their positions will be
13133 cumulated. A request should not pass through both the server queue and the
13134 backend queue unless a redispatch occurs.
13135
13136 - "backend_queue" is the total number of requests which were processed before
13137 this one in the backend's global queue. It is zero when the request has not
13138 gone through the global queue. It makes it possible to estimate the average
13139 queue length, which easily translates into a number of missing servers when
13140 divided by a server's "maxconn" parameter. It is worth noting that if a
13141 session experiences a redispatch, it may pass twice in the backend's queue,
13142 and then both positions will be cumulated. A request should not pass
13143 through both the server queue and the backend queue unless a redispatch
13144 occurs.
13145
13146 - "captured_request_headers" is a list of headers captured in the request due
13147 to the presence of the "capture request header" statement in the frontend.
13148 Multiple headers can be captured, they will be delimited by a vertical bar
13149 ('|'). When no capture is enabled, the braces do not appear, causing a
13150 shift of remaining fields. It is important to note that this field may
13151 contain spaces, and that using it requires a smarter log parser than when
13152 it's not used. Please consult the section "Capturing HTTP headers and
13153 cookies" below for more details.
13154
13155 - "captured_response_headers" is a list of headers captured in the response
13156 due to the presence of the "capture response header" statement in the
13157 frontend. Multiple headers can be captured, they will be delimited by a
13158 vertical bar ('|'). When no capture is enabled, the braces do not appear,
13159 causing a shift of remaining fields. It is important to note that this
13160 field may contain spaces, and that using it requires a smarter log parser
13161 than when it's not used. Please consult the section "Capturing HTTP headers
13162 and cookies" below for more details.
13163
13164 - "http_request" is the complete HTTP request line, including the method,
13165 request and HTTP version string. Non-printable characters are encoded (see
13166 below the section "Non-printable characters"). This is always the last
13167 field, and it is always delimited by quotes and is the only one which can
13168 contain quotes. If new fields are added to the log format, they will be
13169 added before this field. This field might be truncated if the request is
13170 huge and does not fit in the standard syslog buffer (1024 characters). This
13171 is the reason why this field must always remain the last one.
13172
13173
Cyril Bontédc4d9032012-04-08 21:57:39 +0200131748.2.4. Custom log format
13175------------------------
William Lallemand48940402012-01-30 16:47:22 +010013176
Willy Tarreau2beef582012-12-20 17:22:52 +010013177The directive log-format allows you to customize the logs in http mode and tcp
William Lallemandbddd4fd2012-02-27 11:23:10 +010013178mode. It takes a string as argument.
William Lallemand48940402012-01-30 16:47:22 +010013179
13180HAproxy understands some log format variables. % precedes log format variables.
13181Variables can take arguments using braces ('{}'), and multiple arguments are
13182separated by commas within the braces. Flags may be added or removed by
13183prefixing them with a '+' or '-' sign.
13184
13185Special variable "%o" may be used to propagate its flags to all other
13186variables on the same format string. This is particularly handy with quoted
13187string formats ("Q").
13188
Willy Tarreauc8368452012-12-21 00:09:23 +010013189If a variable is named between square brackets ('[' .. ']') then it is used
Willy Tarreaube722a22014-06-13 16:31:59 +020013190as a sample expression rule (see section 7.3). This it useful to add some
Willy Tarreauc8368452012-12-21 00:09:23 +010013191less common information such as the client's SSL certificate's DN, or to log
13192the key that would be used to store an entry into a stick table.
13193
William Lallemand48940402012-01-30 16:47:22 +010013194Note: spaces must be escaped. A space character is considered as a separator.
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013195In order to emit a verbatim '%', it must be preceded by another '%' resulting
Willy Tarreau06d97f92013-12-02 17:45:48 +010013196in '%%'. HAProxy will automatically merge consecutive separators.
William Lallemand48940402012-01-30 16:47:22 +010013197
13198Flags are :
13199 * Q: quote a string
Jamie Gloudonaaa21002012-08-25 00:18:33 -040013200 * X: hexadecimal representation (IPs, Ports, %Ts, %rt, %pid)
William Lallemand48940402012-01-30 16:47:22 +010013201
13202 Example:
13203
13204 log-format %T\ %t\ Some\ Text
13205 log-format %{+Q}o\ %t\ %s\ %{-Q}r
13206
13207At the moment, the default HTTP format is defined this way :
13208
Willy Tarreau2beef582012-12-20 17:22:52 +010013209 log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ \
13210 %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r
William Lallemand48940402012-01-30 16:47:22 +010013211
William Lallemandbddd4fd2012-02-27 11:23:10 +010013212the default CLF format is defined this way :
William Lallemand48940402012-01-30 16:47:22 +010013213
Willy Tarreau2beef582012-12-20 17:22:52 +010013214 log-format %{+Q}o\ %{-Q}ci\ -\ -\ [%T]\ %r\ %ST\ %B\ \"\"\ \"\"\ %cp\ \
Willy Tarreau773d65f2012-10-12 14:56:11 +020013215 %ms\ %ft\ %b\ %s\ \%Tq\ %Tw\ %Tc\ %Tr\ %Tt\ %tsc\ %ac\ %fc\ \
Willy Tarreau2beef582012-12-20 17:22:52 +010013216 %bc\ %sc\ %rc\ %sq\ %bq\ %CC\ %CS\ \%hrl\ %hsl
William Lallemand48940402012-01-30 16:47:22 +010013217
William Lallemandbddd4fd2012-02-27 11:23:10 +010013218and the default TCP format is defined this way :
13219
Willy Tarreau2beef582012-12-20 17:22:52 +010013220 log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tw/%Tc/%Tt\ %B\ %ts\ \
William Lallemandbddd4fd2012-02-27 11:23:10 +010013221 %ac/%fc/%bc/%sc/%rc\ %sq/%bq
13222
William Lallemand48940402012-01-30 16:47:22 +010013223Please refer to the table below for currently defined variables :
13224
William Lallemandbddd4fd2012-02-27 11:23:10 +010013225 +---+------+-----------------------------------------------+-------------+
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020013226 | R | var | field name (8.2.2 and 8.2.3 for description) | type |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013227 +---+------+-----------------------------------------------+-------------+
13228 | | %o | special variable, apply flags on all next var | |
13229 +---+------+-----------------------------------------------+-------------+
Willy Tarreau2beef582012-12-20 17:22:52 +010013230 | | %B | bytes_read (from server to client) | numeric |
13231 | H | %CC | captured_request_cookie | string |
13232 | H | %CS | captured_response_cookie | string |
William Lallemand5f232402012-04-05 18:02:55 +020013233 | | %H | hostname | string |
Andrew Hayworth0ebc55f2015-04-27 21:37:03 +000013234 | H | %HM | HTTP method (ex: POST) | string |
13235 | H | %HP | HTTP request URI without query string (path) | string |
13236 | H | %HU | HTTP request URI (ex: /foo?bar=baz) | string |
13237 | H | %HV | HTTP version (ex: HTTP/1.0) | string |
William Lallemanda73203e2012-03-12 12:48:57 +010013238 | | %ID | unique-id | string |
Willy Tarreau4bf99632014-06-13 12:21:40 +020013239 | | %ST | status_code | numeric |
William Lallemand5f232402012-04-05 18:02:55 +020013240 | | %T | gmt_date_time | date |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013241 | | %Tc | Tc | numeric |
Yuxans Yao4e25b012012-10-19 10:36:09 +080013242 | | %Tl | local_date_time | date |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020013243 | H | %Tq | Tq | numeric |
13244 | H | %Tr | Tr | numeric |
William Lallemand5f232402012-04-05 18:02:55 +020013245 | | %Ts | timestamp | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013246 | | %Tt | Tt | numeric |
13247 | | %Tw | Tw | numeric |
Willy Tarreau2beef582012-12-20 17:22:52 +010013248 | | %U | bytes_uploaded (from client to server) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013249 | | %ac | actconn | numeric |
13250 | | %b | backend_name | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010013251 | | %bc | beconn (backend concurrent connections) | numeric |
13252 | | %bi | backend_source_ip (connecting address) | IP |
13253 | | %bp | backend_source_port (connecting address) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013254 | | %bq | backend_queue | numeric |
Willy Tarreau2beef582012-12-20 17:22:52 +010013255 | | %ci | client_ip (accepted address) | IP |
13256 | | %cp | client_port (accepted address) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013257 | | %f | frontend_name | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010013258 | | %fc | feconn (frontend concurrent connections) | numeric |
13259 | | %fi | frontend_ip (accepting address) | IP |
13260 | | %fp | frontend_port (accepting address) | numeric |
Willy Tarreau773d65f2012-10-12 14:56:11 +020013261 | | %ft | frontend_name_transport ('~' suffix for SSL) | string |
Willy Tarreau7346acb2014-08-28 15:03:15 +020013262 | | %lc | frontend_log_counter | numeric |
Willy Tarreaud9ed3d22014-06-13 12:23:06 +020013263 | | %hr | captured_request_headers default style | string |
13264 | | %hrl | captured_request_headers CLF style | string list |
13265 | | %hs | captured_response_headers default style | string |
13266 | | %hsl | captured_response_headers CLF style | string list |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013267 | | %ms | accept date milliseconds | numeric |
William Lallemand5f232402012-04-05 18:02:55 +020013268 | | %pid | PID | numeric |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020013269 | H | %r | http_request | string |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013270 | | %rc | retries | numeric |
Willy Tarreau1f0da242014-01-25 11:01:50 +010013271 | | %rt | request_counter (HTTP req or TCP session) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013272 | | %s | server_name | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010013273 | | %sc | srv_conn (server concurrent connections) | numeric |
13274 | | %si | server_IP (target address) | IP |
13275 | | %sp | server_port (target address) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013276 | | %sq | srv_queue | numeric |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020013277 | S | %sslc| ssl_ciphers (ex: AES-SHA) | string |
13278 | S | %sslv| ssl_version (ex: TLSv1) | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010013279 | | %t | date_time (with millisecond resolution) | date |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013280 | | %ts | termination_state | string |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020013281 | H | %tsc | termination_state with cookie status | string |
William Lallemandbddd4fd2012-02-27 11:23:10 +010013282 +---+------+-----------------------------------------------+-------------+
William Lallemand48940402012-01-30 16:47:22 +010013283
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020013284 R = Restrictions : H = mode http only ; S = SSL only
William Lallemand48940402012-01-30 16:47:22 +010013285
Willy Tarreau5f51e1a2012-12-03 18:40:10 +010013286
132878.2.5. Error log format
13288-----------------------
13289
13290When an incoming connection fails due to an SSL handshake or an invalid PROXY
13291protocol header, haproxy will log the event using a shorter, fixed line format.
13292By default, logs are emitted at the LOG_INFO level, unless the option
13293"log-separate-errors" is set in the backend, in which case the LOG_ERR level
13294will be used. Connections on which no data are exchanged (eg: probes) are not
13295logged if the "dontlognull" option is set.
13296
13297The format looks like this :
13298
13299 >>> Dec 3 18:27:14 localhost \
13300 haproxy[6103]: 127.0.0.1:56059 [03/Dec/2012:17:35:10.380] frt/f1: \
13301 Connection error during SSL handshake
13302
13303 Field Format Extract from the example above
13304 1 process_name '[' pid ']:' haproxy[6103]:
13305 2 client_ip ':' client_port 127.0.0.1:56059
13306 3 '[' accept_date ']' [03/Dec/2012:17:35:10.380]
13307 4 frontend_name "/" bind_name ":" frt/f1:
13308 5 message Connection error during SSL handshake
13309
13310These fields just provide minimal information to help debugging connection
13311failures.
13312
13313
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200133148.3. Advanced logging options
13315-----------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013316
13317Some advanced logging options are often looked for but are not easy to find out
13318just by looking at the various options. Here is an entry point for the few
13319options which can enable better logging. Please refer to the keywords reference
13320for more information about their usage.
13321
13322
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200133238.3.1. Disabling logging of external tests
13324------------------------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013325
13326It is quite common to have some monitoring tools perform health checks on
13327haproxy. Sometimes it will be a layer 3 load-balancer such as LVS or any
13328commercial load-balancer, and sometimes it will simply be a more complete
13329monitoring system such as Nagios. When the tests are very frequent, users often
13330ask how to disable logging for those checks. There are three possibilities :
13331
13332 - if connections come from everywhere and are just TCP probes, it is often
13333 desired to simply disable logging of connections without data exchange, by
13334 setting "option dontlognull" in the frontend. It also disables logging of
13335 port scans, which may or may not be desired.
13336
13337 - if the connection come from a known source network, use "monitor-net" to
13338 declare this network as monitoring only. Any host in this network will then
13339 only be able to perform health checks, and their requests will not be
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013340 logged. This is generally appropriate to designate a list of equipment
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013341 such as other load-balancers.
13342
13343 - if the tests are performed on a known URI, use "monitor-uri" to declare
13344 this URI as dedicated to monitoring. Any host sending this request will
13345 only get the result of a health-check, and the request will not be logged.
13346
13347
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200133488.3.2. Logging before waiting for the session to terminate
13349----------------------------------------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013350
13351The problem with logging at end of connection is that you have no clue about
13352what is happening during very long sessions, such as remote terminal sessions
13353or large file downloads. This problem can be worked around by specifying
13354"option logasap" in the frontend. Haproxy will then log as soon as possible,
13355just before data transfer begins. This means that in case of TCP, it will still
13356log the connection status to the server, and in case of HTTP, it will log just
13357after processing the server headers. In this case, the number of bytes reported
13358is the number of header bytes sent to the client. In order to avoid confusion
13359with normal logs, the total time field and the number of bytes are prefixed
13360with a '+' sign which means that real numbers are certainly larger.
13361
13362
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200133638.3.3. Raising log level upon errors
13364------------------------------------
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020013365
13366Sometimes it is more convenient to separate normal traffic from errors logs,
13367for instance in order to ease error monitoring from log files. When the option
13368"log-separate-errors" is used, connections which experience errors, timeouts,
13369retries, redispatches or HTTP status codes 5xx will see their syslog level
13370raised from "info" to "err". This will help a syslog daemon store the log in
13371a separate file. It is very important to keep the errors in the normal traffic
13372file too, so that log ordering is not altered. You should also be careful if
13373you already have configured your syslog daemon to store all logs higher than
13374"notice" in an "admin" file, because the "err" level is higher than "notice".
13375
13376
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200133778.3.4. Disabling logging of successful connections
13378--------------------------------------------------
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020013379
13380Although this may sound strange at first, some large sites have to deal with
13381multiple thousands of logs per second and are experiencing difficulties keeping
13382them intact for a long time or detecting errors within them. If the option
13383"dontlog-normal" is set on the frontend, all normal connections will not be
13384logged. In this regard, a normal connection is defined as one without any
13385error, timeout, retry nor redispatch. In HTTP, the status code is checked too,
13386and a response with a status 5xx is not considered normal and will be logged
13387too. Of course, doing is is really discouraged as it will remove most of the
13388useful information from the logs. Do this only if you have no other
13389alternative.
13390
13391
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200133928.4. Timing events
13393------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013394
13395Timers provide a great help in troubleshooting network problems. All values are
13396reported in milliseconds (ms). These timers should be used in conjunction with
13397the session termination flags. In TCP mode with "option tcplog" set on the
13398frontend, 3 control points are reported under the form "Tw/Tc/Tt", and in HTTP
13399mode, 5 control points are reported under the form "Tq/Tw/Tc/Tr/Tt" :
13400
13401 - Tq: total time to get the client request (HTTP mode only). It's the time
13402 elapsed between the moment the client connection was accepted and the
13403 moment the proxy received the last HTTP header. The value "-1" indicates
13404 that the end of headers (empty line) has never been seen. This happens when
13405 the client closes prematurely or times out.
13406
13407 - Tw: total time spent in the queues waiting for a connection slot. It
13408 accounts for backend queue as well as the server queues, and depends on the
13409 queue size, and the time needed for the server to complete previous
13410 requests. The value "-1" means that the request was killed before reaching
13411 the queue, which is generally what happens with invalid or denied requests.
13412
13413 - Tc: total time to establish the TCP connection to the server. It's the time
13414 elapsed between the moment the proxy sent the connection request, and the
13415 moment it was acknowledged by the server, or between the TCP SYN packet and
13416 the matching SYN/ACK packet in return. The value "-1" means that the
13417 connection never established.
13418
13419 - Tr: server response time (HTTP mode only). It's the time elapsed between
13420 the moment the TCP connection was established to the server and the moment
13421 the server sent its complete response headers. It purely shows its request
13422 processing time, without the network overhead due to the data transmission.
13423 It is worth noting that when the client has data to send to the server, for
13424 instance during a POST request, the time already runs, and this can distort
13425 apparent response time. For this reason, it's generally wise not to trust
13426 too much this field for POST requests initiated from clients behind an
13427 untrusted network. A value of "-1" here means that the last the response
13428 header (empty line) was never seen, most likely because the server timeout
13429 stroke before the server managed to process the request.
13430
13431 - Tt: total session duration time, between the moment the proxy accepted it
13432 and the moment both ends were closed. The exception is when the "logasap"
13433 option is specified. In this case, it only equals (Tq+Tw+Tc+Tr), and is
13434 prefixed with a '+' sign. From this field, we can deduce "Td", the data
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013435 transmission time, by subtracting other timers when valid :
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013436
13437 Td = Tt - (Tq + Tw + Tc + Tr)
13438
13439 Timers with "-1" values have to be excluded from this equation. In TCP
13440 mode, "Tq" and "Tr" have to be excluded too. Note that "Tt" can never be
13441 negative.
13442
13443These timers provide precious indications on trouble causes. Since the TCP
13444protocol defines retransmit delays of 3, 6, 12... seconds, we know for sure
13445that timers close to multiples of 3s are nearly always related to lost packets
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010013446due to network problems (wires, negotiation, congestion). Moreover, if "Tt" is
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013447close to a timeout value specified in the configuration, it often means that a
13448session has been aborted on timeout.
13449
13450Most common cases :
13451
13452 - If "Tq" is close to 3000, a packet has probably been lost between the
13453 client and the proxy. This is very rare on local networks but might happen
13454 when clients are on far remote networks and send large requests. It may
13455 happen that values larger than usual appear here without any network cause.
13456 Sometimes, during an attack or just after a resource starvation has ended,
13457 haproxy may accept thousands of connections in a few milliseconds. The time
13458 spent accepting these connections will inevitably slightly delay processing
13459 of other connections, and it can happen that request times in the order of
13460 a few tens of milliseconds are measured after a few thousands of new
Patrick Mezard105faca2010-06-12 17:02:46 +020013461 connections have been accepted at once. Setting "option http-server-close"
13462 may display larger request times since "Tq" also measures the time spent
13463 waiting for additional requests.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013464
13465 - If "Tc" is close to 3000, a packet has probably been lost between the
13466 server and the proxy during the server connection phase. This value should
13467 always be very low, such as 1 ms on local networks and less than a few tens
13468 of ms on remote networks.
13469
Willy Tarreau55165fe2009-05-10 12:02:55 +020013470 - If "Tr" is nearly always lower than 3000 except some rare values which seem
13471 to be the average majored by 3000, there are probably some packets lost
13472 between the proxy and the server.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013473
13474 - If "Tt" is large even for small byte counts, it generally is because
13475 neither the client nor the server decides to close the connection, for
13476 instance because both have agreed on a keep-alive connection mode. In order
13477 to solve this issue, it will be needed to specify "option httpclose" on
13478 either the frontend or the backend. If the problem persists, it means that
13479 the server ignores the "close" connection mode and expects the client to
13480 close. Then it will be required to use "option forceclose". Having the
13481 smallest possible 'Tt' is important when connection regulation is used with
13482 the "maxconn" option on the servers, since no new connection will be sent
13483 to the server until another one is released.
13484
13485Other noticeable HTTP log cases ('xx' means any value to be ignored) :
13486
13487 Tq/Tw/Tc/Tr/+Tt The "option logasap" is present on the frontend and the log
13488 was emitted before the data phase. All the timers are valid
13489 except "Tt" which is shorter than reality.
13490
13491 -1/xx/xx/xx/Tt The client was not able to send a complete request in time
13492 or it aborted too early. Check the session termination flags
13493 then "timeout http-request" and "timeout client" settings.
13494
13495 Tq/-1/xx/xx/Tt It was not possible to process the request, maybe because
13496 servers were out of order, because the request was invalid
13497 or forbidden by ACL rules. Check the session termination
13498 flags.
13499
13500 Tq/Tw/-1/xx/Tt The connection could not establish on the server. Either it
13501 actively refused it or it timed out after Tt-(Tq+Tw) ms.
13502 Check the session termination flags, then check the
13503 "timeout connect" setting. Note that the tarpit action might
13504 return similar-looking patterns, with "Tw" equal to the time
13505 the client connection was maintained open.
13506
13507 Tq/Tw/Tc/-1/Tt The server has accepted the connection but did not return
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013508 a complete response in time, or it closed its connection
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013509 unexpectedly after Tt-(Tq+Tw+Tc) ms. Check the session
13510 termination flags, then check the "timeout server" setting.
13511
13512
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200135138.5. Session state at disconnection
13514-----------------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013515
13516TCP and HTTP logs provide a session termination indicator in the
13517"termination_state" field, just before the number of active connections. It is
135182-characters long in TCP mode, and is extended to 4 characters in HTTP mode,
13519each of which has a special meaning :
13520
13521 - On the first character, a code reporting the first event which caused the
13522 session to terminate :
13523
13524 C : the TCP session was unexpectedly aborted by the client.
13525
13526 S : the TCP session was unexpectedly aborted by the server, or the
13527 server explicitly refused it.
13528
13529 P : the session was prematurely aborted by the proxy, because of a
13530 connection limit enforcement, because a DENY filter was matched,
13531 because of a security check which detected and blocked a dangerous
13532 error in server response which might have caused information leak
Willy Tarreau570f2212013-06-10 16:42:09 +020013533 (eg: cacheable cookie).
13534
13535 L : the session was locally processed by haproxy and was not passed to
13536 a server. This is what happens for stats and redirects.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013537
13538 R : a resource on the proxy has been exhausted (memory, sockets, source
13539 ports, ...). Usually, this appears during the connection phase, and
13540 system logs should contain a copy of the precise error. If this
13541 happens, it must be considered as a very serious anomaly which
13542 should be fixed as soon as possible by any means.
13543
13544 I : an internal error was identified by the proxy during a self-check.
13545 This should NEVER happen, and you are encouraged to report any log
13546 containing this, because this would almost certainly be a bug. It
13547 would be wise to preventively restart the process after such an
13548 event too, in case it would be caused by memory corruption.
13549
Simon Horman752dc4a2011-06-21 14:34:59 +090013550 D : the session was killed by haproxy because the server was detected
13551 as down and was configured to kill all connections when going down.
13552
Justin Karnegeseb2c24a2012-05-24 15:28:52 -070013553 U : the session was killed by haproxy on this backup server because an
13554 active server was detected as up and was configured to kill all
13555 backup connections when going up.
13556
Willy Tarreaua2a64e92011-09-07 23:01:56 +020013557 K : the session was actively killed by an admin operating on haproxy.
13558
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013559 c : the client-side timeout expired while waiting for the client to
13560 send or receive data.
13561
13562 s : the server-side timeout expired while waiting for the server to
13563 send or receive data.
13564
13565 - : normal session completion, both the client and the server closed
13566 with nothing left in the buffers.
13567
13568 - on the second character, the TCP or HTTP session state when it was closed :
13569
Willy Tarreauf7b30a92010-12-06 22:59:17 +010013570 R : the proxy was waiting for a complete, valid REQUEST from the client
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013571 (HTTP mode only). Nothing was sent to any server.
13572
13573 Q : the proxy was waiting in the QUEUE for a connection slot. This can
13574 only happen when servers have a 'maxconn' parameter set. It can
13575 also happen in the global queue after a redispatch consecutive to
13576 a failed attempt to connect to a dying server. If no redispatch is
13577 reported, then no connection attempt was made to any server.
13578
13579 C : the proxy was waiting for the CONNECTION to establish on the
13580 server. The server might at most have noticed a connection attempt.
13581
13582 H : the proxy was waiting for complete, valid response HEADERS from the
13583 server (HTTP only).
13584
13585 D : the session was in the DATA phase.
13586
13587 L : the proxy was still transmitting LAST data to the client while the
13588 server had already finished. This one is very rare as it can only
13589 happen when the client dies while receiving the last packets.
13590
13591 T : the request was tarpitted. It has been held open with the client
13592 during the whole "timeout tarpit" duration or until the client
13593 closed, both of which will be reported in the "Tw" timer.
13594
13595 - : normal session completion after end of data transfer.
13596
13597 - the third character tells whether the persistence cookie was provided by
13598 the client (only in HTTP mode) :
13599
13600 N : the client provided NO cookie. This is usually the case for new
13601 visitors, so counting the number of occurrences of this flag in the
13602 logs generally indicate a valid trend for the site frequentation.
13603
13604 I : the client provided an INVALID cookie matching no known server.
13605 This might be caused by a recent configuration change, mixed
Cyril Bontéa8e7bbc2010-04-25 22:29:29 +020013606 cookies between HTTP/HTTPS sites, persistence conditionally
13607 ignored, or an attack.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013608
13609 D : the client provided a cookie designating a server which was DOWN,
13610 so either "option persist" was used and the client was sent to
13611 this server, or it was not set and the client was redispatched to
13612 another server.
13613
Willy Tarreau996a92c2010-10-13 19:30:47 +020013614 V : the client provided a VALID cookie, and was sent to the associated
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013615 server.
13616
Willy Tarreau996a92c2010-10-13 19:30:47 +020013617 E : the client provided a valid cookie, but with a last date which was
13618 older than what is allowed by the "maxidle" cookie parameter, so
13619 the cookie is consider EXPIRED and is ignored. The request will be
13620 redispatched just as if there was no cookie.
13621
13622 O : the client provided a valid cookie, but with a first date which was
13623 older than what is allowed by the "maxlife" cookie parameter, so
13624 the cookie is consider too OLD and is ignored. The request will be
13625 redispatched just as if there was no cookie.
13626
Willy Tarreauc89ccb62012-04-05 21:18:22 +020013627 U : a cookie was present but was not used to select the server because
13628 some other server selection mechanism was used instead (typically a
13629 "use-server" rule).
13630
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013631 - : does not apply (no cookie set in configuration).
13632
13633 - the last character reports what operations were performed on the persistence
13634 cookie returned by the server (only in HTTP mode) :
13635
13636 N : NO cookie was provided by the server, and none was inserted either.
13637
13638 I : no cookie was provided by the server, and the proxy INSERTED one.
13639 Note that in "cookie insert" mode, if the server provides a cookie,
13640 it will still be overwritten and reported as "I" here.
13641
Willy Tarreau996a92c2010-10-13 19:30:47 +020013642 U : the proxy UPDATED the last date in the cookie that was presented by
13643 the client. This can only happen in insert mode with "maxidle". It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013644 happens every time there is activity at a different date than the
Willy Tarreau996a92c2010-10-13 19:30:47 +020013645 date indicated in the cookie. If any other change happens, such as
13646 a redispatch, then the cookie will be marked as inserted instead.
13647
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013648 P : a cookie was PROVIDED by the server and transmitted as-is.
13649
13650 R : the cookie provided by the server was REWRITTEN by the proxy, which
13651 happens in "cookie rewrite" or "cookie prefix" modes.
13652
13653 D : the cookie provided by the server was DELETED by the proxy.
13654
13655 - : does not apply (no cookie set in configuration).
13656
Willy Tarreau996a92c2010-10-13 19:30:47 +020013657The combination of the two first flags gives a lot of information about what
13658was happening when the session terminated, and why it did terminate. It can be
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013659helpful to detect server saturation, network troubles, local system resource
13660starvation, attacks, etc...
13661
13662The most common termination flags combinations are indicated below. They are
13663alphabetically sorted, with the lowercase set just after the upper case for
13664easier finding and understanding.
13665
13666 Flags Reason
13667
13668 -- Normal termination.
13669
13670 CC The client aborted before the connection could be established to the
13671 server. This can happen when haproxy tries to connect to a recently
13672 dead (or unchecked) server, and the client aborts while haproxy is
13673 waiting for the server to respond or for "timeout connect" to expire.
13674
13675 CD The client unexpectedly aborted during data transfer. This can be
13676 caused by a browser crash, by an intermediate equipment between the
13677 client and haproxy which decided to actively break the connection,
13678 by network routing issues between the client and haproxy, or by a
13679 keep-alive session between the server and the client terminated first
13680 by the client.
Willy Tarreaud72758d2010-01-12 10:42:19 +010013681
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013682 cD The client did not send nor acknowledge any data for as long as the
13683 "timeout client" delay. This is often caused by network failures on
Cyril Bontédc4d9032012-04-08 21:57:39 +020013684 the client side, or the client simply leaving the net uncleanly.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013685
13686 CH The client aborted while waiting for the server to start responding.
13687 It might be the server taking too long to respond or the client
13688 clicking the 'Stop' button too fast.
13689
13690 cH The "timeout client" stroke while waiting for client data during a
13691 POST request. This is sometimes caused by too large TCP MSS values
13692 for PPPoE networks which cannot transport full-sized packets. It can
13693 also happen when client timeout is smaller than server timeout and
13694 the server takes too long to respond.
13695
13696 CQ The client aborted while its session was queued, waiting for a server
13697 with enough empty slots to accept it. It might be that either all the
13698 servers were saturated or that the assigned server was taking too
13699 long a time to respond.
13700
13701 CR The client aborted before sending a full HTTP request. Most likely
13702 the request was typed by hand using a telnet client, and aborted
13703 too early. The HTTP status code is likely a 400 here. Sometimes this
13704 might also be caused by an IDS killing the connection between haproxy
Willy Tarreau0f228a02015-05-01 15:37:53 +020013705 and the client. "option http-ignore-probes" can be used to ignore
13706 connections without any data transfer.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013707
13708 cR The "timeout http-request" stroke before the client sent a full HTTP
13709 request. This is sometimes caused by too large TCP MSS values on the
13710 client side for PPPoE networks which cannot transport full-sized
13711 packets, or by clients sending requests by hand and not typing fast
13712 enough, or forgetting to enter the empty line at the end of the
Willy Tarreau2705a612014-05-23 17:38:34 +020013713 request. The HTTP status code is likely a 408 here. Note: recently,
Willy Tarreau0f228a02015-05-01 15:37:53 +020013714 some browsers started to implement a "pre-connect" feature consisting
13715 in speculatively connecting to some recently visited web sites just
13716 in case the user would like to visit them. This results in many
13717 connections being established to web sites, which end up in 408
13718 Request Timeout if the timeout strikes first, or 400 Bad Request when
13719 the browser decides to close them first. These ones pollute the log
13720 and feed the error counters. Some versions of some browsers have even
13721 been reported to display the error code. It is possible to work
13722 around the undesirable effects of this behaviour by adding "option
13723 http-ignore-probes" in the frontend, resulting in connections with
13724 zero data transfer to be totally ignored. This will definitely hide
13725 the errors of people experiencing connectivity issues though.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013726
13727 CT The client aborted while its session was tarpitted. It is important to
13728 check if this happens on valid requests, in order to be sure that no
Willy Tarreau55165fe2009-05-10 12:02:55 +020013729 wrong tarpit rules have been written. If a lot of them happen, it
13730 might make sense to lower the "timeout tarpit" value to something
13731 closer to the average reported "Tw" timer, in order not to consume
13732 resources for just a few attackers.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013733
Willy Tarreau570f2212013-06-10 16:42:09 +020013734 LR The request was intercepted and locally handled by haproxy. Generally
13735 it means that this was a redirect or a stats request.
13736
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010013737 SC The server or an equipment between it and haproxy explicitly refused
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013738 the TCP connection (the proxy received a TCP RST or an ICMP message
13739 in return). Under some circumstances, it can also be the network
13740 stack telling the proxy that the server is unreachable (eg: no route,
13741 or no ARP response on local network). When this happens in HTTP mode,
13742 the status code is likely a 502 or 503 here.
13743
13744 sC The "timeout connect" stroke before a connection to the server could
13745 complete. When this happens in HTTP mode, the status code is likely a
13746 503 or 504 here.
13747
13748 SD The connection to the server died with an error during the data
13749 transfer. This usually means that haproxy has received an RST from
13750 the server or an ICMP message from an intermediate equipment while
13751 exchanging data with the server. This can be caused by a server crash
13752 or by a network issue on an intermediate equipment.
13753
13754 sD The server did not send nor acknowledge any data for as long as the
13755 "timeout server" setting during the data phase. This is often caused
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010013756 by too short timeouts on L4 equipments before the server (firewalls,
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013757 load-balancers, ...), as well as keep-alive sessions maintained
13758 between the client and the server expiring first on haproxy.
13759
13760 SH The server aborted before sending its full HTTP response headers, or
13761 it crashed while processing the request. Since a server aborting at
13762 this moment is very rare, it would be wise to inspect its logs to
13763 control whether it crashed and why. The logged request may indicate a
13764 small set of faulty requests, demonstrating bugs in the application.
13765 Sometimes this might also be caused by an IDS killing the connection
13766 between haproxy and the server.
13767
13768 sH The "timeout server" stroke before the server could return its
13769 response headers. This is the most common anomaly, indicating too
13770 long transactions, probably caused by server or database saturation.
13771 The immediate workaround consists in increasing the "timeout server"
13772 setting, but it is important to keep in mind that the user experience
13773 will suffer from these long response times. The only long term
13774 solution is to fix the application.
13775
13776 sQ The session spent too much time in queue and has been expired. See
13777 the "timeout queue" and "timeout connect" settings to find out how to
13778 fix this if it happens too often. If it often happens massively in
13779 short periods, it may indicate general problems on the affected
13780 servers due to I/O or database congestion, or saturation caused by
13781 external attacks.
13782
13783 PC The proxy refused to establish a connection to the server because the
13784 process' socket limit has been reached while attempting to connect.
Cyril Bontédc4d9032012-04-08 21:57:39 +020013785 The global "maxconn" parameter may be increased in the configuration
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013786 so that it does not happen anymore. This status is very rare and
13787 might happen when the global "ulimit-n" parameter is forced by hand.
13788
Willy Tarreaued2fd2d2010-12-29 11:23:27 +010013789 PD The proxy blocked an incorrectly formatted chunked encoded message in
13790 a request or a response, after the server has emitted its headers. In
13791 most cases, this will indicate an invalid message from the server to
Willy Tarreauf3a3e132013-08-31 08:16:26 +020013792 the client. Haproxy supports chunk sizes of up to 2GB - 1 (2147483647
13793 bytes). Any larger size will be considered as an error.
Willy Tarreaued2fd2d2010-12-29 11:23:27 +010013794
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013795 PH The proxy blocked the server's response, because it was invalid,
13796 incomplete, dangerous (cache control), or matched a security filter.
13797 In any case, an HTTP 502 error is sent to the client. One possible
13798 cause for this error is an invalid syntax in an HTTP header name
Willy Tarreaued2fd2d2010-12-29 11:23:27 +010013799 containing unauthorized characters. It is also possible but quite
13800 rare, that the proxy blocked a chunked-encoding request from the
13801 client due to an invalid syntax, before the server responded. In this
13802 case, an HTTP 400 error is sent to the client and reported in the
13803 logs.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013804
13805 PR The proxy blocked the client's HTTP request, either because of an
13806 invalid HTTP syntax, in which case it returned an HTTP 400 error to
13807 the client, or because a deny filter matched, in which case it
13808 returned an HTTP 403 error.
13809
13810 PT The proxy blocked the client's request and has tarpitted its
13811 connection before returning it a 500 server error. Nothing was sent
13812 to the server. The connection was maintained open for as long as
13813 reported by the "Tw" timer field.
13814
13815 RC A local resource has been exhausted (memory, sockets, source ports)
13816 preventing the connection to the server from establishing. The error
13817 logs will tell precisely what was missing. This is very rare and can
13818 only be solved by proper system tuning.
13819
Willy Tarreau996a92c2010-10-13 19:30:47 +020013820The combination of the two last flags gives a lot of information about how
13821persistence was handled by the client, the server and by haproxy. This is very
13822important to troubleshoot disconnections, when users complain they have to
13823re-authenticate. The commonly encountered flags are :
13824
13825 -- Persistence cookie is not enabled.
13826
13827 NN No cookie was provided by the client, none was inserted in the
13828 response. For instance, this can be in insert mode with "postonly"
13829 set on a GET request.
13830
13831 II A cookie designating an invalid server was provided by the client,
13832 a valid one was inserted in the response. This typically happens when
Jamie Gloudonaaa21002012-08-25 00:18:33 -040013833 a "server" entry is removed from the configuration, since its cookie
Willy Tarreau996a92c2010-10-13 19:30:47 +020013834 value can be presented by a client when no other server knows it.
13835
13836 NI No cookie was provided by the client, one was inserted in the
13837 response. This typically happens for first requests from every user
13838 in "insert" mode, which makes it an easy way to count real users.
13839
13840 VN A cookie was provided by the client, none was inserted in the
13841 response. This happens for most responses for which the client has
13842 already got a cookie.
13843
13844 VU A cookie was provided by the client, with a last visit date which is
13845 not completely up-to-date, so an updated cookie was provided in
13846 response. This can also happen if there was no date at all, or if
13847 there was a date but the "maxidle" parameter was not set, so that the
13848 cookie can be switched to unlimited time.
13849
13850 EI A cookie was provided by the client, with a last visit date which is
13851 too old for the "maxidle" parameter, so the cookie was ignored and a
13852 new cookie was inserted in the response.
13853
13854 OI A cookie was provided by the client, with a first visit date which is
13855 too old for the "maxlife" parameter, so the cookie was ignored and a
13856 new cookie was inserted in the response.
13857
13858 DI The server designated by the cookie was down, a new server was
13859 selected and a new cookie was emitted in the response.
13860
13861 VI The server designated by the cookie was not marked dead but could not
13862 be reached. A redispatch happened and selected another one, which was
13863 then advertised in the response.
13864
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013865
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200138668.6. Non-printable characters
13867-----------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013868
13869In order not to cause trouble to log analysis tools or terminals during log
13870consulting, non-printable characters are not sent as-is into log files, but are
13871converted to the two-digits hexadecimal representation of their ASCII code,
13872prefixed by the character '#'. The only characters that can be logged without
13873being escaped are comprised between 32 and 126 (inclusive). Obviously, the
13874escape character '#' itself is also encoded to avoid any ambiguity ("#23"). It
13875is the same for the character '"' which becomes "#22", as well as '{', '|' and
13876'}' when logging headers.
13877
13878Note that the space character (' ') is not encoded in headers, which can cause
13879issues for tools relying on space count to locate fields. A typical header
13880containing spaces is "User-Agent".
13881
13882Last, it has been observed that some syslog daemons such as syslog-ng escape
13883the quote ('"') with a backslash ('\'). The reverse operation can safely be
13884performed since no quote may appear anywhere else in the logs.
13885
13886
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200138878.7. Capturing HTTP cookies
13888---------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013889
13890Cookie capture simplifies the tracking a complete user session. This can be
13891achieved using the "capture cookie" statement in the frontend. Please refer to
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013892section 4.2 for more details. Only one cookie can be captured, and the same
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013893cookie will simultaneously be checked in the request ("Cookie:" header) and in
13894the response ("Set-Cookie:" header). The respective values will be reported in
13895the HTTP logs at the "captured_request_cookie" and "captured_response_cookie"
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013896locations (see section 8.2.3 about HTTP log format). When either cookie is
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013897not seen, a dash ('-') replaces the value. This way, it's easy to detect when a
13898user switches to a new session for example, because the server will reassign it
13899a new cookie. It is also possible to detect if a server unexpectedly sets a
13900wrong cookie to a client, leading to session crossing.
13901
13902 Examples :
13903 # capture the first cookie whose name starts with "ASPSESSION"
13904 capture cookie ASPSESSION len 32
13905
13906 # capture the first cookie whose name is exactly "vgnvisitor"
13907 capture cookie vgnvisitor= len 32
13908
13909
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200139108.8. Capturing HTTP headers
13911---------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013912
13913Header captures are useful to track unique request identifiers set by an upper
13914proxy, virtual host names, user-agents, POST content-length, referrers, etc. In
13915the response, one can search for information about the response length, how the
13916server asked the cache to behave, or an object location during a redirection.
13917
13918Header captures are performed using the "capture request header" and "capture
13919response header" statements in the frontend. Please consult their definition in
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013920section 4.2 for more details.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013921
13922It is possible to include both request headers and response headers at the same
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010013923time. Non-existent headers are logged as empty strings, and if one header
13924appears more than once, only its last occurrence will be logged. Request headers
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013925are grouped within braces '{' and '}' in the same order as they were declared,
13926and delimited with a vertical bar '|' without any space. Response headers
13927follow the same representation, but are displayed after a space following the
13928request headers block. These blocks are displayed just before the HTTP request
13929in the logs.
13930
Willy Tarreaud9ed3d22014-06-13 12:23:06 +020013931As a special case, it is possible to specify an HTTP header capture in a TCP
13932frontend. The purpose is to enable logging of headers which will be parsed in
13933an HTTP backend if the request is then switched to this HTTP backend.
13934
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013935 Example :
13936 # This instance chains to the outgoing proxy
13937 listen proxy-out
13938 mode http
13939 option httplog
13940 option logasap
13941 log global
13942 server cache1 192.168.1.1:3128
13943
13944 # log the name of the virtual server
13945 capture request header Host len 20
13946
13947 # log the amount of data uploaded during a POST
13948 capture request header Content-Length len 10
13949
13950 # log the beginning of the referrer
13951 capture request header Referer len 20
13952
13953 # server name (useful for outgoing proxies only)
13954 capture response header Server len 20
13955
13956 # logging the content-length is useful with "option logasap"
13957 capture response header Content-Length len 10
13958
13959 # log the expected cache behaviour on the response
13960 capture response header Cache-Control len 8
13961
13962 # the Via header will report the next proxy's name
13963 capture response header Via len 20
13964
13965 # log the URL location during a redirection
13966 capture response header Location len 20
13967
13968 >>> Aug 9 20:26:09 localhost \
13969 haproxy[2022]: 127.0.0.1:34014 [09/Aug/2004:20:26:09] proxy-out \
13970 proxy-out/cache1 0/0/0/162/+162 200 +350 - - ---- 0/0/0/0/0 0/0 \
13971 {fr.adserver.yahoo.co||http://fr.f416.mail.} {|864|private||} \
13972 "GET http://fr.adserver.yahoo.com/"
13973
13974 >>> Aug 9 20:30:46 localhost \
13975 haproxy[2022]: 127.0.0.1:34020 [09/Aug/2004:20:30:46] proxy-out \
13976 proxy-out/cache1 0/0/0/182/+182 200 +279 - - ---- 0/0/0/0/0 0/0 \
13977 {w.ods.org||} {Formilux/0.1.8|3495|||} \
Willy Tarreaud72758d2010-01-12 10:42:19 +010013978 "GET http://trafic.1wt.eu/ HTTP/1.1"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013979
13980 >>> Aug 9 20:30:46 localhost \
13981 haproxy[2022]: 127.0.0.1:34028 [09/Aug/2004:20:30:46] proxy-out \
13982 proxy-out/cache1 0/0/2/126/+128 301 +223 - - ---- 0/0/0/0/0 0/0 \
13983 {www.sytadin.equipement.gouv.fr||http://trafic.1wt.eu/} \
13984 {Apache|230|||http://www.sytadin.} \
Willy Tarreaud72758d2010-01-12 10:42:19 +010013985 "GET http://www.sytadin.equipement.gouv.fr/ HTTP/1.1"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013986
13987
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200139888.9. Examples of logs
13989---------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013990
13991These are real-world examples of logs accompanied with an explanation. Some of
13992them have been made up by hand. The syslog part has been removed for better
13993reading. Their sole purpose is to explain how to decipher them.
13994
13995 >>> haproxy[674]: 127.0.0.1:33318 [15/Oct/2003:08:31:57.130] px-http \
13996 px-http/srv1 6559/0/7/147/6723 200 243 - - ---- 5/3/3/1/0 0/0 \
13997 "HEAD / HTTP/1.0"
13998
13999 => long request (6.5s) entered by hand through 'telnet'. The server replied
14000 in 147 ms, and the session ended normally ('----')
14001
14002 >>> haproxy[674]: 127.0.0.1:33319 [15/Oct/2003:08:31:57.149] px-http \
14003 px-http/srv1 6559/1230/7/147/6870 200 243 - - ---- 324/239/239/99/0 \
14004 0/9 "HEAD / HTTP/1.0"
14005
14006 => Idem, but the request was queued in the global queue behind 9 other
14007 requests, and waited there for 1230 ms.
14008
14009 >>> haproxy[674]: 127.0.0.1:33320 [15/Oct/2003:08:32:17.654] px-http \
14010 px-http/srv1 9/0/7/14/+30 200 +243 - - ---- 3/3/3/1/0 0/0 \
14011 "GET /image.iso HTTP/1.0"
14012
14013 => request for a long data transfer. The "logasap" option was specified, so
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014014 the log was produced just before transferring data. The server replied in
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014015 14 ms, 243 bytes of headers were sent to the client, and total time from
14016 accept to first data byte is 30 ms.
14017
14018 >>> haproxy[674]: 127.0.0.1:33320 [15/Oct/2003:08:32:17.925] px-http \
14019 px-http/srv1 9/0/7/14/30 502 243 - - PH-- 3/2/2/0/0 0/0 \
14020 "GET /cgi-bin/bug.cgi? HTTP/1.0"
14021
14022 => the proxy blocked a server response either because of an "rspdeny" or
14023 "rspideny" filter, or because the response was improperly formatted and
Willy Tarreau3c92c5f2011-08-28 09:45:47 +020014024 not HTTP-compliant, or because it blocked sensitive information which
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014025 risked being cached. In this case, the response is replaced with a "502
14026 bad gateway". The flags ("PH--") tell us that it was haproxy who decided
14027 to return the 502 and not the server.
14028
14029 >>> haproxy[18113]: 127.0.0.1:34548 [15/Oct/2003:15:18:55.798] px-http \
Willy Tarreaud72758d2010-01-12 10:42:19 +010014030 px-http/<NOSRV> -1/-1/-1/-1/8490 -1 0 - - CR-- 2/2/2/0/0 0/0 ""
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014031
14032 => the client never completed its request and aborted itself ("C---") after
14033 8.5s, while the proxy was waiting for the request headers ("-R--").
14034 Nothing was sent to any server.
14035
14036 >>> haproxy[18113]: 127.0.0.1:34549 [15/Oct/2003:15:19:06.103] px-http \
14037 px-http/<NOSRV> -1/-1/-1/-1/50001 408 0 - - cR-- 2/2/2/0/0 0/0 ""
14038
14039 => The client never completed its request, which was aborted by the
14040 time-out ("c---") after 50s, while the proxy was waiting for the request
14041 headers ("-R--"). Nothing was sent to any server, but the proxy could
14042 send a 408 return code to the client.
14043
14044 >>> haproxy[18989]: 127.0.0.1:34550 [15/Oct/2003:15:24:28.312] px-tcp \
14045 px-tcp/srv1 0/0/5007 0 cD 0/0/0/0/0 0/0
14046
14047 => This log was produced with "option tcplog". The client timed out after
14048 5 seconds ("c----").
14049
14050 >>> haproxy[18989]: 10.0.0.1:34552 [15/Oct/2003:15:26:31.462] px-http \
14051 px-http/srv1 3183/-1/-1/-1/11215 503 0 - - SC-- 205/202/202/115/3 \
Willy Tarreaud72758d2010-01-12 10:42:19 +010014052 0/0 "HEAD / HTTP/1.0"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014053
14054 => The request took 3s to complete (probably a network problem), and the
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014055 connection to the server failed ('SC--') after 4 attempts of 2 seconds
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014056 (config says 'retries 3'), and no redispatch (otherwise we would have
14057 seen "/+3"). Status code 503 was returned to the client. There were 115
14058 connections on this server, 202 connections on this proxy, and 205 on
14059 the global process. It is possible that the server refused the
14060 connection because of too many already established.
Willy Tarreau844e3c52008-01-11 16:28:18 +010014061
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014062
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200140639. Statistics and monitoring
14064----------------------------
14065
14066It is possible to query HAProxy about its status. The most commonly used
14067mechanism is the HTTP statistics page. This page also exposes an alternative
14068CSV output format for monitoring tools. The same format is provided on the
14069Unix socket.
14070
14071
140729.1. CSV format
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014073---------------
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +010014074
Willy Tarreau7f062c42009-03-05 18:43:00 +010014075The statistics may be consulted either from the unix socket or from the HTTP
Willy Tarreaua3310dc2014-06-16 15:43:21 +020014076page. Both means provide a CSV format whose fields follow. The first line
14077begins with a sharp ('#') and has one word per comma-delimited field which
14078represents the title of the column. All other lines starting at the second one
14079use a classical CSV format using a comma as the delimiter, and the double quote
14080('"') as an optional text delimiter, but only if the enclosed text is ambiguous
14081(if it contains a quote or a comma). The double-quote character ('"') in the
14082text is doubled ('""'), which is the format that most tools recognize. Please
14083do not insert any column before these ones in order not to break tools which
14084use hard-coded column positions.
Willy Tarreau7f062c42009-03-05 18:43:00 +010014085
James Westbyebe62d62014-07-08 10:14:57 -040014086In brackets after each field name are the types which may have a value for
14087that field. The types are L (Listeners), F (Frontends), B (Backends), and
14088S (Servers).
14089
14090 0. pxname [LFBS]: proxy name
14091 1. svname [LFBS]: service name (FRONTEND for frontend, BACKEND for backend,
14092 any name for server/listener)
14093 2. qcur [..BS]: current queued requests. For the backend this reports the
14094 number queued without a server assigned.
14095 3. qmax [..BS]: max value of qcur
14096 4. scur [LFBS]: current sessions
14097 5. smax [LFBS]: max sessions
14098 6. slim [LFBS]: configured session limit
14099 7. stot [LFBS]: cumulative number of connections
14100 8. bin [LFBS]: bytes in
14101 9. bout [LFBS]: bytes out
14102 10. dreq [LFB.]: requests denied because of security concerns.
14103 - For tcp this is because of a matched tcp-request content rule.
14104 - For http this is because of a matched http-request or tarpit rule.
14105 11. dresp [LFBS]: responses denied because of security concerns.
14106 - For http this is because of a matched http-request rule, or
14107 "option checkcache".
14108 12. ereq [LF..]: request errors. Some of the possible causes are:
14109 - early termination from the client, before the request has been sent.
14110 - read error from the client
14111 - client timeout
14112 - client closed connection
14113 - various bad requests from the client.
14114 - request was tarpitted.
14115 13. econ [..BS]: number of requests that encountered an error trying to
14116 connect to a backend server. The backend stat is the sum of the stat
14117 for all servers of that backend, plus any connection errors not
14118 associated with a particular server (such as the backend having no
14119 active servers).
14120 14. eresp [..BS]: response errors. srv_abrt will be counted here also.
14121 Some other errors are:
14122 - write error on the client socket (won't be counted for the server stat)
14123 - failure applying filters to the response.
14124 15. wretr [..BS]: number of times a connection to a server was retried.
14125 16. wredis [..BS]: number of times a request was redispatched to another
14126 server. The server value counts the number of times that server was
14127 switched away from.
14128 17. status [LFBS]: status (UP/DOWN/NOLB/MAINT/MAINT(via)...)
14129 18. weight [..BS]: server weight (server), total weight (backend)
14130 19. act [..BS]: server is active (server), number of active servers (backend)
14131 20. bck [..BS]: server is backup (server), number of backup servers (backend)
14132 21. chkfail [...S]: number of failed checks. (Only counts checks failed when
14133 the server is up.)
14134 22. chkdown [..BS]: number of UP->DOWN transitions. The backend counter counts
14135 transitions to the whole backend being down, rather than the sum of the
14136 counters for each server.
14137 23. lastchg [..BS]: number of seconds since the last UP<->DOWN transition
14138 24. downtime [..BS]: total downtime (in seconds). The value for the backend
14139 is the downtime for the whole backend, not the sum of the server downtime.
14140 25. qlimit [...S]: configured maxqueue for the server, or nothing in the
14141 value is 0 (default, meaning no limit)
14142 26. pid [LFBS]: process id (0 for first instance, 1 for second, ...)
14143 27. iid [LFBS]: unique proxy id
14144 28. sid [L..S]: server id (unique inside a proxy)
14145 29. throttle [...S]: current throttle percentage for the server, when
14146 slowstart is active, or no value if not in slowstart.
14147 30. lbtot [..BS]: total number of times a server was selected, either for new
14148 sessions, or when re-dispatching. The server counter is the number
14149 of times that server was selected.
14150 31. tracked [...S]: id of proxy/server if tracking is enabled.
14151 32. type [LFBS]: (0=frontend, 1=backend, 2=server, 3=socket/listener)
14152 33. rate [.FBS]: number of sessions per second over last elapsed second
14153 34. rate_lim [.F..]: configured limit on new sessions per second
14154 35. rate_max [.FBS]: max number of new sessions per second
14155 36. check_status [...S]: status of last health check, one of:
Cyril Bontéf0c60612010-02-06 14:44:47 +010014156 UNK -> unknown
14157 INI -> initializing
14158 SOCKERR -> socket error
14159 L4OK -> check passed on layer 4, no upper layers testing enabled
Jason Harvey83104802015-04-16 11:13:21 -080014160 L4TOUT -> layer 1-4 timeout
Cyril Bontéf0c60612010-02-06 14:44:47 +010014161 L4CON -> layer 1-4 connection problem, for example
14162 "Connection refused" (tcp rst) or "No route to host" (icmp)
14163 L6OK -> check passed on layer 6
14164 L6TOUT -> layer 6 (SSL) timeout
14165 L6RSP -> layer 6 invalid response - protocol error
14166 L7OK -> check passed on layer 7
14167 L7OKC -> check conditionally passed on layer 7, for example 404 with
14168 disable-on-404
14169 L7TOUT -> layer 7 (HTTP/SMTP) timeout
14170 L7RSP -> layer 7 invalid response - protocol error
14171 L7STS -> layer 7 response error, for example HTTP 5xx
James Westbyebe62d62014-07-08 10:14:57 -040014172 37. check_code [...S]: layer5-7 code, if available
14173 38. check_duration [...S]: time in ms took to finish last health check
14174 39. hrsp_1xx [.FBS]: http responses with 1xx code
14175 40. hrsp_2xx [.FBS]: http responses with 2xx code
14176 41. hrsp_3xx [.FBS]: http responses with 3xx code
14177 42. hrsp_4xx [.FBS]: http responses with 4xx code
14178 43. hrsp_5xx [.FBS]: http responses with 5xx code
14179 44. hrsp_other [.FBS]: http responses with other codes (protocol error)
14180 45. hanafail [...S]: failed health checks details
14181 46. req_rate [.F..]: HTTP requests per second over last elapsed second
14182 47. req_rate_max [.F..]: max number of HTTP requests per second observed
14183 48. req_tot [.F..]: total number of HTTP requests received
14184 49. cli_abrt [..BS]: number of data transfers aborted by the client
14185 50. srv_abrt [..BS]: number of data transfers aborted by the server
14186 (inc. in eresp)
14187 51. comp_in [.FB.]: number of HTTP response bytes fed to the compressor
14188 52. comp_out [.FB.]: number of HTTP response bytes emitted by the compressor
14189 53. comp_byp [.FB.]: number of bytes that bypassed the HTTP compressor
14190 (CPU/BW limit)
14191 54. comp_rsp [.FB.]: number of HTTP responses that were compressed
14192 55. lastsess [..BS]: number of seconds since last session assigned to
14193 server/backend
14194 56. last_chk [...S]: last health check contents or textual error
14195 57. last_agt [...S]: last agent check contents or textual error
14196 58. qtime [..BS]: the average queue time in ms over the 1024 last requests
14197 59. ctime [..BS]: the average connect time in ms over the 1024 last requests
14198 60. rtime [..BS]: the average response time in ms over the 1024 last requests
14199 (0 for TCP)
14200 61. ttime [..BS]: the average total session time in ms over the 1024 last
14201 requests
Willy Tarreau844e3c52008-01-11 16:28:18 +010014202
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014203
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200142049.2. Unix Socket commands
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014205-------------------------
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010014206
Willy Tarreau468f4932013-08-01 16:50:16 +020014207The stats socket is not enabled by default. In order to enable it, it is
14208necessary to add one line in the global section of the haproxy configuration.
14209A second line is recommended to set a larger timeout, always appreciated when
14210issuing commands by hand :
14211
14212 global
14213 stats socket /var/run/haproxy.sock mode 600 level admin
14214 stats timeout 2m
14215
14216It is also possible to add multiple instances of the stats socket by repeating
14217the line, and make them listen to a TCP port instead of a UNIX socket. This is
14218never done by default because this is dangerous, but can be handy in some
14219situations :
14220
14221 global
14222 stats socket /var/run/haproxy.sock mode 600 level admin
14223 stats socket ipv4@192.168.0.1:9999 level admin
14224 stats timeout 2m
14225
14226To access the socket, an external utility such as "socat" is required. Socat is a
14227swiss-army knife to connect anything to anything. We use it to connect terminals
14228to the socket, or a couple of stdin/stdout pipes to it for scripts. The two main
14229syntaxes we'll use are the following :
14230
14231 # socat /var/run/haproxy.sock stdio
14232 # socat /var/run/haproxy.sock readline
14233
14234The first one is used with scripts. It is possible to send the output of a
14235script to haproxy, and pass haproxy's output to another script. That's useful
14236for retrieving counters or attack traces for example.
14237
14238The second one is only useful for issuing commands by hand. It has the benefit
14239that the terminal is handled by the readline library which supports line
14240editing and history, which is very convenient when issuing repeated commands
14241(eg: watch a counter).
14242
14243The socket supports two operation modes :
14244 - interactive
14245 - non-interactive
14246
14247The non-interactive mode is the default when socat connects to the socket. In
14248this mode, a single line may be sent. It is processed as a whole, responses are
14249sent back, and the connection closes after the end of the response. This is the
14250mode that scripts and monitoring tools use. It is possible to send multiple
14251commands in this mode, they need to be delimited by a semi-colon (';'). For
14252example :
14253
14254 # echo "show info;show stat;show table" | socat /var/run/haproxy stdio
14255
14256The interactive mode displays a prompt ('>') and waits for commands to be
14257entered on the line, then processes them, and displays the prompt again to wait
14258for a new command. This mode is entered via the "prompt" command which must be
14259sent on the first line in non-interactive mode. The mode is a flip switch, if
14260"prompt" is sent in interactive mode, it is disabled and the connection closes
14261after processing the last command of the same line.
14262
14263For this reason, when debugging by hand, it's quite common to start with the
14264"prompt" command :
14265
14266 # socat /var/run/haproxy readline
14267 prompt
14268 > show info
14269 ...
14270 >
14271
14272Since multiple commands may be issued at once, haproxy uses the empty line as a
14273delimiter to mark an end of output for each command, and takes care of ensuring
14274that no command can emit an empty line on output. A script can thus easily
14275parse the output even when multiple commands were pipelined on a single line.
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014276
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014277It is important to understand that when multiple haproxy processes are started
14278on the same sockets, any process may pick up the request and will output its
14279own stats.
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014280
Willy Tarreau468f4932013-08-01 16:50:16 +020014281The list of commands currently supported on the stats socket is provided below.
14282If an unknown command is sent, haproxy displays the usage message which reminds
14283all supported commands. Some commands support a more complex syntax, generally
14284it will explain what part of the command is invalid when this happens.
14285
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014286add acl <acl> <pattern>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014287 Add an entry into the acl <acl>. <acl> is the #<id> or the <file> returned by
14288 "show acl". This command does not verify if the entry already exists. This
14289 command cannot be used if the reference <acl> is a file also used with a map.
14290 In this case, you must use the command "add map" in place of "add acl".
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014291
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014292add map <map> <key> <value>
14293 Add an entry into the map <map> to associate the value <value> to the key
14294 <key>. This command does not verify if the entry already exists. It is
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014295 mainly used to fill a map after a clear operation. Note that if the reference
14296 <map> is a file and is shared with a map, this map will contain also a new
14297 pattern entry.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014298
Willy Tarreaud63335a2010-02-26 12:56:52 +010014299clear counters
14300 Clear the max values of the statistics counters in each proxy (frontend &
14301 backend) and in each server. The cumulated counters are not affected. This
14302 can be used to get clean counters after an incident, without having to
14303 restart nor to clear traffic counters. This command is restricted and can
14304 only be issued on sockets configured for levels "operator" or "admin".
14305
14306clear counters all
14307 Clear all statistics counters in each proxy (frontend & backend) and in each
14308 server. This has the same effect as restarting. This command is restricted
14309 and can only be issued on sockets configured for level "admin".
14310
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014311clear acl <acl>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014312 Remove all entries from the acl <acl>. <acl> is the #<id> or the <file>
14313 returned by "show acl". Note that if the reference <acl> is a file and is
14314 shared with a map, this map will be also cleared.
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014315
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014316clear map <map>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014317 Remove all entries from the map <map>. <map> is the #<id> or the <file>
14318 returned by "show map". Note that if the reference <map> is a file and is
14319 shared with a acl, this acl will be also cleared.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014320
Simon Hormanc88b8872011-06-15 15:18:49 +090014321clear table <table> [ data.<type> <operator> <value> ] | [ key <key> ]
14322 Remove entries from the stick-table <table>.
14323
14324 This is typically used to unblock some users complaining they have been
14325 abusively denied access to a service, but this can also be used to clear some
14326 stickiness entries matching a server that is going to be replaced (see "show
14327 table" below for details). Note that sometimes, removal of an entry will be
14328 refused because it is currently tracked by a session. Retrying a few seconds
14329 later after the session ends is usual enough.
14330
14331 In the case where no options arguments are given all entries will be removed.
14332
14333 When the "data." form is used entries matching a filter applied using the
14334 stored data (see "stick-table" in section 4.2) are removed. A stored data
14335 type must be specified in <type>, and this data type must be stored in the
14336 table otherwise an error is reported. The data is compared according to
14337 <operator> with the 64-bit integer <value>. Operators are the same as with
14338 the ACLs :
14339
14340 - eq : match entries whose data is equal to this value
14341 - ne : match entries whose data is not equal to this value
14342 - le : match entries whose data is less than or equal to this value
14343 - ge : match entries whose data is greater than or equal to this value
14344 - lt : match entries whose data is less than this value
14345 - gt : match entries whose data is greater than this value
14346
14347 When the key form is used the entry <key> is removed. The key must be of the
Simon Horman619e3cc2011-06-15 15:18:52 +090014348 same type as the table, which currently is limited to IPv4, IPv6, integer and
14349 string.
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014350
14351 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020014352 $ echo "show table http_proxy" | socat stdio /tmp/sock1
Emeric Brun7c6b82e2010-09-24 16:34:28 +020014353 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020014354 >>> 0x80e6a4c: key=127.0.0.1 use=0 exp=3594729 gpc0=0 conn_rate(30000)=1 \
14355 bytes_out_rate(60000)=187
14356 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
14357 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014358
14359 $ echo "clear table http_proxy key 127.0.0.1" | socat stdio /tmp/sock1
14360
14361 $ echo "show table http_proxy" | socat stdio /tmp/sock1
Emeric Brun7c6b82e2010-09-24 16:34:28 +020014362 >>> # table: http_proxy, type: ip, size:204800, used:1
Willy Tarreau62a36c42010-08-17 15:53:10 +020014363 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
14364 bytes_out_rate(60000)=191
Simon Hormanc88b8872011-06-15 15:18:49 +090014365 $ echo "clear table http_proxy data.gpc0 eq 1" | socat stdio /tmp/sock1
14366 $ echo "show table http_proxy" | socat stdio /tmp/sock1
14367 >>> # table: http_proxy, type: ip, size:204800, used:1
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014368
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014369del acl <acl> [<key>|#<ref>]
14370 Delete all the acl entries from the acl <acl> corresponding to the key <key>.
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014371 <acl> is the #<id> or the <file> returned by "show acl". If the <ref> is used,
14372 this command delete only the listed reference. The reference can be found with
14373 listing the content of the acl. Note that if the reference <acl> is a file and
14374 is shared with a map, the entry will be also deleted in the map.
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014375
14376del map <map> [<key>|#<ref>]
Thierry FOURNIER0b90f312014-01-29 20:40:18 +010014377 Delete all the map entries from the map <map> corresponding to the key <key>.
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014378 <map> is the #<id> or the <file> returned by "show map". If the <ref> is used,
14379 this command delete only the listed reference. The reference can be found with
14380 listing the content of the map. Note that if the reference <map> is a file and
14381 is shared with a acl, the entry will be also deleted in the map.
Thierry FOURNIER0b90f312014-01-29 20:40:18 +010014382
14383disable agent <backend>/<server>
Simon Horman671b6f02013-11-25 10:46:39 +090014384 Mark the auxiliary agent check as temporarily stopped.
14385
14386 In the case where an agent check is being run as a auxiliary check, due
14387 to the agent-check parameter of a server directive, new checks are only
14388 initialised when the agent is in the enabled. Thus, disable agent will
14389 prevent any new agent checks from begin initiated until the agent
14390 re-enabled using enable agent.
14391
14392 When an agent is disabled the processing of an auxiliary agent check that
14393 was initiated while the agent was set as enabled is as follows: All
14394 results that would alter the weight, specifically "drain" or a weight
14395 returned by the agent, are ignored. The processing of agent check is
14396 otherwise unchanged.
14397
14398 The motivation for this feature is to allow the weight changing effects
14399 of the agent checks to be paused to allow the weight of a server to be
14400 configured using set weight without being overridden by the agent.
14401
14402 This command is restricted and can only be issued on sockets configured for
14403 level "admin".
14404
Willy Tarreau532a4502011-09-07 22:37:44 +020014405disable frontend <frontend>
14406 Mark the frontend as temporarily stopped. This corresponds to the mode which
14407 is used during a soft restart : the frontend releases the port but can be
14408 enabled again if needed. This should be used with care as some non-Linux OSes
14409 are unable to enable it back. This is intended to be used in environments
14410 where stopping a proxy is not even imaginable but a misconfigured proxy must
14411 be fixed. That way it's possible to release the port and bind it into another
14412 process to restore operations. The frontend will appear with status "STOP"
14413 on the stats page.
14414
14415 The frontend may be specified either by its name or by its numeric ID,
14416 prefixed with a sharp ('#').
14417
14418 This command is restricted and can only be issued on sockets configured for
14419 level "admin".
14420
Willy Tarreau9b5aecd2014-05-23 11:53:10 +020014421disable health <backend>/<server>
14422 Mark the primary health check as temporarily stopped. This will disable
14423 sending of health checks, and the last health check result will be ignored.
14424 The server will be in unchecked state and considered UP unless an auxiliary
14425 agent check forces it down.
14426
14427 This command is restricted and can only be issued on sockets configured for
14428 level "admin".
14429
Willy Tarreaud63335a2010-02-26 12:56:52 +010014430disable server <backend>/<server>
14431 Mark the server DOWN for maintenance. In this mode, no more checks will be
14432 performed on the server until it leaves maintenance.
14433 If the server is tracked by other servers, those servers will be set to DOWN
14434 during the maintenance.
14435
14436 In the statistics page, a server DOWN for maintenance will appear with a
14437 "MAINT" status, its tracking servers with the "MAINT(via)" one.
14438
14439 Both the backend and the server may be specified either by their name or by
Willy Tarreauf5f31922011-08-02 11:32:07 +020014440 their numeric ID, prefixed with a sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010014441
14442 This command is restricted and can only be issued on sockets configured for
14443 level "admin".
14444
Simon Horman671b6f02013-11-25 10:46:39 +090014445enable agent <backend>/<server>
14446 Resume auxiliary agent check that was temporarily stopped.
14447
14448 See "disable agent" for details of the effect of temporarily starting
14449 and stopping an auxiliary agent.
14450
14451 This command is restricted and can only be issued on sockets configured for
14452 level "admin".
14453
Willy Tarreau532a4502011-09-07 22:37:44 +020014454enable frontend <frontend>
14455 Resume a frontend which was temporarily stopped. It is possible that some of
14456 the listening ports won't be able to bind anymore (eg: if another process
14457 took them since the 'disable frontend' operation). If this happens, an error
14458 is displayed. Some operating systems might not be able to resume a frontend
14459 which was disabled.
14460
14461 The frontend may be specified either by its name or by its numeric ID,
14462 prefixed with a sharp ('#').
14463
14464 This command is restricted and can only be issued on sockets configured for
14465 level "admin".
14466
Willy Tarreau9b5aecd2014-05-23 11:53:10 +020014467enable health <backend>/<server>
14468 Resume a primary health check that was temporarily stopped. This will enable
14469 sending of health checks again. Please see "disable health" for details.
14470
14471 This command is restricted and can only be issued on sockets configured for
14472 level "admin".
14473
Willy Tarreaud63335a2010-02-26 12:56:52 +010014474enable server <backend>/<server>
14475 If the server was previously marked as DOWN for maintenance, this marks the
14476 server UP and checks are re-enabled.
14477
14478 Both the backend and the server may be specified either by their name or by
Willy Tarreauf5f31922011-08-02 11:32:07 +020014479 their numeric ID, prefixed with a sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010014480
14481 This command is restricted and can only be issued on sockets configured for
14482 level "admin".
14483
Thierry FOURNIER5b16df72014-02-26 18:07:38 +010014484get map <map> <value>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014485get acl <acl> <value>
14486 Lookup the value <value> in the map <map> or in the ACL <acl>. <map> or <acl>
14487 are the #<id> or the <file> returned by "show map" or "show acl". This command
14488 returns all the matching patterns associated with this map. This is useful for
14489 debugging maps and ACLs. The output format is composed by one line par
14490 matching type. Each line is composed by space-delimited series of words.
Thierry FOURNIER5b16df72014-02-26 18:07:38 +010014491
14492 The first two words are:
14493
14494 <match method>: The match method applied. It can be "found", "bool",
14495 "int", "ip", "bin", "len", "str", "beg", "sub", "dir",
14496 "dom", "end" or "reg".
14497
14498 <match result>: The result. Can be "match" or "no-match".
14499
14500 The following words are returned only if the pattern matches an entry.
14501
14502 <index type>: "tree" or "list". The internal lookup algorithm.
14503
14504 <case>: "case-insensitive" or "case-sensitive". The
14505 interpretation of the case.
14506
14507 <entry matched>: match="<entry>". Return the matched pattern. It is
14508 useful with regular expressions.
14509
14510 The two last word are used to show the returned value and its type. With the
14511 "acl" case, the pattern doesn't exist.
14512
14513 return=nothing: No return because there are no "map".
14514 return="<value>": The value returned in the string format.
14515 return=cannot-display: The value cannot be converted as string.
14516
14517 type="<type>": The type of the returned sample.
14518
Willy Tarreaud63335a2010-02-26 12:56:52 +010014519get weight <backend>/<server>
14520 Report the current weight and the initial weight of server <server> in
14521 backend <backend> or an error if either doesn't exist. The initial weight is
14522 the one that appears in the configuration file. Both are normally equal
14523 unless the current weight has been changed. Both the backend and the server
14524 may be specified either by their name or by their numeric ID, prefixed with a
Willy Tarreauf5f31922011-08-02 11:32:07 +020014525 sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010014526
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014527help
14528 Print the list of known keywords and their basic usage. The same help screen
14529 is also displayed for unknown commands.
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014530
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014531prompt
14532 Toggle the prompt at the beginning of the line and enter or leave interactive
14533 mode. In interactive mode, the connection is not closed after a command
14534 completes. Instead, the prompt will appear again, indicating the user that
14535 the interpreter is waiting for a new command. The prompt consists in a right
14536 angle bracket followed by a space "> ". This mode is particularly convenient
14537 when one wants to periodically check information such as stats or errors.
14538 It is also a good idea to enter interactive mode before issuing a "help"
14539 command.
14540
14541quit
14542 Close the connection when in interactive mode.
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010014543
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014544set map <map> [<key>|#<ref>] <value>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014545 Modify the value corresponding to each key <key> in a map <map>. <map> is the
14546 #<id> or <file> returned by "show map". If the <ref> is used in place of
14547 <key>, only the entry pointed by <ref> is changed. The new value is <value>.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014548
Willy Tarreau2a0f4d22011-08-02 11:49:05 +020014549set maxconn frontend <frontend> <value>
Willy Tarreau3c7a79d2012-09-26 21:07:15 +020014550 Dynamically change the specified frontend's maxconn setting. Any positive
14551 value is allowed including zero, but setting values larger than the global
14552 maxconn does not make much sense. If the limit is increased and connections
14553 were pending, they will immediately be accepted. If it is lowered to a value
14554 below the current number of connections, new connections acceptation will be
Willy Tarreau2a0f4d22011-08-02 11:49:05 +020014555 delayed until the threshold is reached. The frontend might be specified by
14556 either its name or its numeric ID prefixed with a sharp ('#').
14557
Willy Tarreau91886b62011-09-07 14:38:31 +020014558set maxconn global <maxconn>
14559 Dynamically change the global maxconn setting within the range defined by the
14560 initial global maxconn setting. If it is increased and connections were
14561 pending, they will immediately be accepted. If it is lowered to a value below
14562 the current number of connections, new connections acceptation will be
14563 delayed until the threshold is reached. A value of zero restores the initial
14564 setting.
14565
Willy Tarreauf5b22872011-09-07 16:13:44 +020014566set rate-limit connections global <value>
14567 Change the process-wide connection rate limit, which is set by the global
14568 'maxconnrate' setting. A value of zero disables the limitation. This limit
14569 applies to all frontends and the change has an immediate effect. The value
14570 is passed in number of connections per second.
14571
William Lallemandd85f9172012-11-09 17:05:39 +010014572set rate-limit http-compression global <value>
14573 Change the maximum input compression rate, which is set by the global
14574 'maxcomprate' setting. A value of zero disables the limitation. The value is
William Lallemand096f5542012-11-19 17:26:05 +010014575 passed in number of kilobytes per second. The value is available in the "show
14576 info" on the line "CompressBpsRateLim" in bytes.
William Lallemandd85f9172012-11-09 17:05:39 +010014577
Willy Tarreau93e7c002013-10-07 18:51:07 +020014578set rate-limit sessions global <value>
14579 Change the process-wide session rate limit, which is set by the global
14580 'maxsessrate' setting. A value of zero disables the limitation. This limit
14581 applies to all frontends and the change has an immediate effect. The value
14582 is passed in number of sessions per second.
14583
Willy Tarreaue43d5322013-10-07 20:01:52 +020014584set rate-limit ssl-sessions global <value>
14585 Change the process-wide SSL session rate limit, which is set by the global
14586 'maxsslrate' setting. A value of zero disables the limitation. This limit
14587 applies to all frontends and the change has an immediate effect. The value
14588 is passed in number of sessions per second sent to the SSL stack. It applies
14589 before the handshake in order to protect the stack against handshake abuses.
14590
Willy Tarreau2a4b70f2014-05-22 18:42:35 +020014591set server <backend>/<server> agent [ up | down ]
14592 Force a server's agent to a new state. This can be useful to immediately
14593 switch a server's state regardless of some slow agent checks for example.
14594 Note that the change is propagated to tracking servers if any.
14595
14596set server <backend>/<server> health [ up | stopping | down ]
14597 Force a server's health to a new state. This can be useful to immediately
14598 switch a server's state regardless of some slow health checks for example.
14599 Note that the change is propagated to tracking servers if any.
14600
14601set server <backend>/<server> state [ ready | drain | maint ]
14602 Force a server's administrative state to a new state. This can be useful to
14603 disable load balancing and/or any traffic to a server. Setting the state to
14604 "ready" puts the server in normal mode, and the command is the equivalent of
14605 the "enable server" command. Setting the state to "maint" disables any traffic
14606 to the server as well as any health checks. This is the equivalent of the
14607 "disable server" command. Setting the mode to "drain" only removes the server
14608 from load balancing but still allows it to be checked and to accept new
14609 persistent connections. Changes are propagated to tracking servers if any.
14610
14611set server <backend>/<server> weight <weight>[%]
14612 Change a server's weight to the value passed in argument. This is the exact
14613 equivalent of the "set weight" command below.
14614
Emeric Brun4147b2e2014-06-16 18:36:30 +020014615set ssl ocsp-response <response>
14616 This command is used to update an OCSP Response for a certificate (see "crt"
14617 on "bind" lines). Same controls are performed as during the initial loading of
14618 the response. The <response> must be passed as a base64 encoded string of the
14619 DER encoded response from the OCSP server.
14620
14621 Example:
14622 openssl ocsp -issuer issuer.pem -cert server.pem \
14623 -host ocsp.issuer.com:80 -respout resp.der
14624 echo "set ssl ocsp-response $(base64 -w 10000 resp.der)" | \
14625 socat stdio /var/run/haproxy.stat
14626
Willy Tarreau47060b62013-08-01 21:11:42 +020014627set table <table> key <key> [data.<data_type> <value>]*
Willy Tarreau654694e2012-06-07 01:03:16 +020014628 Create or update a stick-table entry in the table. If the key is not present,
14629 an entry is inserted. See stick-table in section 4.2 to find all possible
14630 values for <data_type>. The most likely use consists in dynamically entering
14631 entries for source IP addresses, with a flag in gpc0 to dynamically block an
Willy Tarreau47060b62013-08-01 21:11:42 +020014632 IP address or affect its quality of service. It is possible to pass multiple
14633 data_types in a single call.
Willy Tarreau654694e2012-06-07 01:03:16 +020014634
Willy Tarreaud63335a2010-02-26 12:56:52 +010014635set timeout cli <delay>
14636 Change the CLI interface timeout for current connection. This can be useful
14637 during long debugging sessions where the user needs to constantly inspect
14638 some indicators without being disconnected. The delay is passed in seconds.
14639
14640set weight <backend>/<server> <weight>[%]
14641 Change a server's weight to the value passed in argument. If the value ends
14642 with the '%' sign, then the new weight will be relative to the initially
Simon Horman58b5d292013-02-12 10:45:52 +090014643 configured weight. Absolute weights are permitted between 0 and 256.
14644 Relative weights must be positive with the resulting absolute weight is
14645 capped at 256. Servers which are part of a farm running a static
14646 load-balancing algorithm have stricter limitations because the weight
14647 cannot change once set. Thus for these servers, the only accepted values
14648 are 0 and 100% (or 0 and the initial weight). Changes take effect
14649 immediately, though certain LB algorithms require a certain amount of
14650 requests to consider changes. A typical usage of this command is to
14651 disable a server during an update by setting its weight to zero, then to
14652 enable it again after the update by setting it back to 100%. This command
14653 is restricted and can only be issued on sockets configured for level
14654 "admin". Both the backend and the server may be specified either by their
14655 name or by their numeric ID, prefixed with a sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010014656
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010014657show errors [<iid>]
14658 Dump last known request and response errors collected by frontends and
14659 backends. If <iid> is specified, the limit the dump to errors concerning
Willy Tarreau6162db22009-10-10 17:13:00 +020014660 either frontend or backend whose ID is <iid>. This command is restricted
14661 and can only be issued on sockets configured for levels "operator" or
14662 "admin".
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010014663
14664 The errors which may be collected are the last request and response errors
14665 caused by protocol violations, often due to invalid characters in header
14666 names. The report precisely indicates what exact character violated the
14667 protocol. Other important information such as the exact date the error was
14668 detected, frontend and backend names, the server name (when known), the
14669 internal session ID and the source address which has initiated the session
14670 are reported too.
14671
14672 All characters are returned, and non-printable characters are encoded. The
14673 most common ones (\t = 9, \n = 10, \r = 13 and \e = 27) are encoded as one
14674 letter following a backslash. The backslash itself is encoded as '\\' to
14675 avoid confusion. Other non-printable characters are encoded '\xNN' where
14676 NN is the two-digits hexadecimal representation of the character's ASCII
14677 code.
14678
14679 Lines are prefixed with the position of their first character, starting at 0
14680 for the beginning of the buffer. At most one input line is printed per line,
14681 and large lines will be broken into multiple consecutive output lines so that
14682 the output never goes beyond 79 characters wide. It is easy to detect if a
14683 line was broken, because it will not end with '\n' and the next line's offset
14684 will be followed by a '+' sign, indicating it is a continuation of previous
14685 line.
14686
14687 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020014688 $ echo "show errors" | socat stdio /tmp/sock1
14689 >>> [04/Mar/2009:15:46:56.081] backend http-in (#2) : invalid response
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010014690 src 127.0.0.1, session #54, frontend fe-eth0 (#1), server s2 (#1)
14691 response length 213 bytes, error at position 23:
14692
14693 00000 HTTP/1.0 200 OK\r\n
14694 00017 header/bizarre:blah\r\n
14695 00038 Location: blah\r\n
14696 00054 Long-line: this is a very long line which should b
14697 00104+ e broken into multiple lines on the output buffer,
14698 00154+ otherwise it would be too large to print in a ter
14699 00204+ minal\r\n
14700 00211 \r\n
14701
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014702 In the example above, we see that the backend "http-in" which has internal
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010014703 ID 2 has blocked an invalid response from its server s2 which has internal
14704 ID 1. The request was on session 54 initiated by source 127.0.0.1 and
14705 received by frontend fe-eth0 whose ID is 1. The total response length was
14706 213 bytes when the error was detected, and the error was at byte 23. This
14707 is the slash ('/') in header name "header/bizarre", which is not a valid
14708 HTTP character for a header name.
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010014709
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014710show info
14711 Dump info about haproxy status on current process.
14712
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014713show map [<map>]
14714 Dump info about map converters. Without argument, the list of all available
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014715 maps is returned. If a <map> is specified, its contents are dumped. <map> is
14716 the #<id> or <file>. The first column is a unique identifier. It can be used
14717 as reference for the operation "del map" and "set map". The second column is
14718 the pattern and the third column is the sample if available. The data returned
14719 are not directly a list of available maps, but are the list of all patterns
14720 composing any map. Many of these patterns can be shared with ACL.
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010014721
14722show acl [<acl>]
14723 Dump info about acl converters. Without argument, the list of all available
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010014724 acls is returned. If a <acl> is specified, its contents are dumped. <acl> if
14725 the #<id> or <file>. The dump format is the same than the map even for the
14726 sample value. The data returned are not a list of available ACL, but are the
14727 list of all patterns composing any ACL. Many of these patterns can be shared
14728 with maps.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010014729
Willy Tarreau12833bb2014-01-28 16:49:56 +010014730show pools
14731 Dump the status of internal memory pools. This is useful to track memory
14732 usage when suspecting a memory leak for example. It does exactly the same
14733 as the SIGQUIT when running in foreground except that it does not flush
14734 the pools.
14735
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014736show sess
14737 Dump all known sessions. Avoid doing this on slow connections as this can
Willy Tarreau6162db22009-10-10 17:13:00 +020014738 be huge. This command is restricted and can only be issued on sockets
14739 configured for levels "operator" or "admin".
14740
Willy Tarreau66dc20a2010-03-05 17:53:32 +010014741show sess <id>
14742 Display a lot of internal information about the specified session identifier.
14743 This identifier is the first field at the beginning of the lines in the dumps
14744 of "show sess" (it corresponds to the session pointer). Those information are
14745 useless to most users but may be used by haproxy developers to troubleshoot a
14746 complex bug. The output format is intentionally not documented so that it can
Olivierce31e6e2014-09-05 18:49:10 +020014747 freely evolve depending on demands. You may find a description of all fields
14748 returned in src/dumpstats.c
14749
14750 The special id "all" dumps the states of all sessions, which must be avoided
14751 as much as possible as it is highly CPU intensive and can take a lot of time.
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014752
14753show stat [<iid> <type> <sid>]
14754 Dump statistics in the CSV format. By passing <id>, <type> and <sid>, it is
14755 possible to dump only selected items :
14756 - <iid> is a proxy ID, -1 to dump everything
14757 - <type> selects the type of dumpable objects : 1 for frontends, 2 for
14758 backends, 4 for servers, -1 for everything. These values can be ORed,
14759 for example:
14760 1 + 2 = 3 -> frontend + backend.
14761 1 + 2 + 4 = 7 -> frontend + backend + server.
14762 - <sid> is a server ID, -1 to dump everything from the selected proxy.
14763
14764 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020014765 $ echo "show info;show stat" | socat stdio unix-connect:/tmp/sock1
14766 >>> Name: HAProxy
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014767 Version: 1.4-dev2-49
14768 Release_date: 2009/09/23
14769 Nbproc: 1
14770 Process_num: 1
14771 (...)
14772
14773 # pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq, (...)
14774 stats,FRONTEND,,,0,0,1000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,1,0, (...)
14775 stats,BACKEND,0,0,0,0,1000,0,0,0,0,0,,0,0,0,0,UP,0,0,0,,0,250,(...)
14776 (...)
14777 www1,BACKEND,0,0,0,0,1000,0,0,0,0,0,,0,0,0,0,UP,1,1,0,,0,250, (...)
14778
14779 $
14780
14781 Here, two commands have been issued at once. That way it's easy to find
14782 which process the stats apply to in multi-process mode. Notice the empty
14783 line after the information output which marks the end of the first block.
14784 A similar empty line appears at the end of the second block (stats) so that
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014785 the reader knows the output has not been truncated.
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020014786
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014787show table
14788 Dump general information on all known stick-tables. Their name is returned
14789 (the name of the proxy which holds them), their type (currently zero, always
14790 IP), their size in maximum possible number of entries, and the number of
14791 entries currently in use.
14792
14793 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020014794 $ echo "show table" | socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090014795 >>> # table: front_pub, type: ip, size:204800, used:171454
14796 >>> # table: back_rdp, type: ip, size:204800, used:0
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014797
Simon Horman17bce342011-06-15 15:18:47 +090014798show table <name> [ data.<type> <operator> <value> ] | [ key <key> ]
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014799 Dump contents of stick-table <name>. In this mode, a first line of generic
14800 information about the table is reported as with "show table", then all
14801 entries are dumped. Since this can be quite heavy, it is possible to specify
Simon Horman17bce342011-06-15 15:18:47 +090014802 a filter in order to specify what entries to display.
14803
14804 When the "data." form is used the filter applies to the stored data (see
14805 "stick-table" in section 4.2). A stored data type must be specified
14806 in <type>, and this data type must be stored in the table otherwise an
14807 error is reported. The data is compared according to <operator> with the
14808 64-bit integer <value>. Operators are the same as with the ACLs :
14809
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014810 - eq : match entries whose data is equal to this value
14811 - ne : match entries whose data is not equal to this value
14812 - le : match entries whose data is less than or equal to this value
14813 - ge : match entries whose data is greater than or equal to this value
14814 - lt : match entries whose data is less than this value
14815 - gt : match entries whose data is greater than this value
14816
Simon Hormanc88b8872011-06-15 15:18:49 +090014817
14818 When the key form is used the entry <key> is shown. The key must be of the
Simon Horman619e3cc2011-06-15 15:18:52 +090014819 same type as the table, which currently is limited to IPv4, IPv6, integer,
14820 and string.
Simon Horman17bce342011-06-15 15:18:47 +090014821
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014822 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020014823 $ echo "show table http_proxy" | socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090014824 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020014825 >>> 0x80e6a4c: key=127.0.0.1 use=0 exp=3594729 gpc0=0 conn_rate(30000)=1 \
14826 bytes_out_rate(60000)=187
14827 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
14828 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014829
Willy Tarreau62a36c42010-08-17 15:53:10 +020014830 $ echo "show table http_proxy data.gpc0 gt 0" | socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090014831 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020014832 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
14833 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014834
Willy Tarreau62a36c42010-08-17 15:53:10 +020014835 $ echo "show table http_proxy data.conn_rate gt 5" | \
14836 socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090014837 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020014838 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
14839 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014840
Simon Horman17bce342011-06-15 15:18:47 +090014841 $ echo "show table http_proxy key 127.0.0.2" | \
14842 socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090014843 >>> # table: http_proxy, type: ip, size:204800, used:2
Simon Horman17bce342011-06-15 15:18:47 +090014844 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
14845 bytes_out_rate(60000)=191
14846
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014847 When the data criterion applies to a dynamic value dependent on time such as
14848 a bytes rate, the value is dynamically computed during the evaluation of the
14849 entry in order to decide whether it has to be dumped or not. This means that
14850 such a filter could match for some time then not match anymore because as
14851 time goes, the average event rate drops.
14852
14853 It is possible to use this to extract lists of IP addresses abusing the
14854 service, in order to monitor them or even blacklist them in a firewall.
14855 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020014856 $ echo "show table http_proxy data.gpc0 gt 0" \
14857 | socat stdio /tmp/sock1 \
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020014858 | fgrep 'key=' | cut -d' ' -f2 | cut -d= -f2 > abusers-ip.txt
14859 ( or | awk '/key/{ print a[split($2,a,"=")]; }' )
Krzysztof Piotr Oledzki719e7262009-10-04 15:02:46 +020014860
Willy Tarreau532a4502011-09-07 22:37:44 +020014861shutdown frontend <frontend>
14862 Completely delete the specified frontend. All the ports it was bound to will
14863 be released. It will not be possible to enable the frontend anymore after
14864 this operation. This is intended to be used in environments where stopping a
14865 proxy is not even imaginable but a misconfigured proxy must be fixed. That
14866 way it's possible to release the port and bind it into another process to
14867 restore operations. The frontend will not appear at all on the stats page
14868 once it is terminated.
14869
14870 The frontend may be specified either by its name or by its numeric ID,
14871 prefixed with a sharp ('#').
14872
14873 This command is restricted and can only be issued on sockets configured for
14874 level "admin".
14875
Willy Tarreaua295edc2011-09-07 23:21:03 +020014876shutdown session <id>
14877 Immediately terminate the session matching the specified session identifier.
14878 This identifier is the first field at the beginning of the lines in the dumps
14879 of "show sess" (it corresponds to the session pointer). This can be used to
14880 terminate a long-running session without waiting for a timeout or when an
14881 endless transfer is ongoing. Such terminated sessions are reported with a 'K'
14882 flag in the logs.
14883
Cyril Bontée63a1eb2014-07-12 18:22:42 +020014884shutdown sessions server <backend>/<server>
Willy Tarreau52b2d222011-09-07 23:48:48 +020014885 Immediately terminate all the sessions attached to the specified server. This
14886 can be used to terminate long-running sessions after a server is put into
14887 maintenance mode, for instance. Such terminated sessions are reported with a
14888 'K' flag in the logs.
14889
Willy Tarreau0ba27502007-12-24 16:55:16 +010014890/*
14891 * Local variables:
14892 * fill-column: 79
14893 * End:
14894 */