blob: 8447ff1d38d382535cd0e4ee0a2634e401994593 [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 Tarreau50bdda62015-07-22 17:32:56 +02007 2015/07/22
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
William Lallemandf9873ba2015-05-05 17:37:14 +0200422.2. Quoting and escaping
William Lallemandb2f07452015-05-12 14:27:13 +0200432.3. Environment variables
442.4. Time format
452.5. Examples
Willy Tarreauc57f0e22009-05-10 13:12:33 +020046
473. Global parameters
483.1. Process management and security
493.2. Performance tuning
503.3. Debugging
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +0100513.4. Userlists
Cyril Bontédc4d9032012-04-08 21:57:39 +0200523.5. Peers
Willy Tarreauc57f0e22009-05-10 13:12:33 +020053
544. Proxies
554.1. Proxy keywords matrix
564.2. Alphabetically sorted keywords reference
57
Willy Tarreau086fbf52012-09-24 20:34:51 +0200585. Bind and Server options
595.1. Bind options
605.2. Server and default-server options
Baptiste Assmann1fa66662015-04-14 00:28:47 +0200615.3. Server DNS resolution
625.3.1. Global overview
635.3.2. The resolvers section
Willy Tarreauc57f0e22009-05-10 13:12:33 +020064
656. HTTP header manipulation
66
Willy Tarreau74ca5042013-06-11 23:12:07 +0200677. Using ACLs and fetching samples
687.1. ACL basics
697.1.1. Matching booleans
707.1.2. Matching integers
717.1.3. Matching strings
727.1.4. Matching regular expressions (regexes)
737.1.5. Matching arbitrary data blocks
747.1.6. Matching IPv4 and IPv6 addresses
757.2. Using ACLs to form conditions
767.3. Fetching samples
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200777.3.1. Converters
787.3.2. Fetching samples from internal states
797.3.3. Fetching samples at Layer 4
807.3.4. Fetching samples at Layer 5
817.3.5. Fetching samples from buffer contents (Layer 6)
827.3.6. Fetching HTTP samples (Layer 7)
Willy Tarreau74ca5042013-06-11 23:12:07 +0200837.4. Pre-defined ACLs
Willy Tarreauc57f0e22009-05-10 13:12:33 +020084
858. Logging
868.1. Log levels
878.2. Log formats
888.2.1. Default log format
898.2.2. TCP log format
908.2.3. HTTP log format
William Lallemand48940402012-01-30 16:47:22 +0100918.2.4. Custom log format
Willy Tarreau5f51e1a2012-12-03 18:40:10 +0100928.2.5. Error log format
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200938.3. Advanced logging options
948.3.1. Disabling logging of external tests
958.3.2. Logging before waiting for the session to terminate
968.3.3. Raising log level upon errors
978.3.4. Disabling logging of successful connections
988.4. Timing events
998.5. Session state at disconnection
1008.6. Non-printable characters
1018.7. Capturing HTTP cookies
1028.8. Capturing HTTP headers
1038.9. Examples of logs
104
1059. Statistics and monitoring
1069.1. CSV format
1079.2. Unix Socket commands
108
109
1101. Quick reminder about HTTP
111----------------------------
112
113When haproxy is running in HTTP mode, both the request and the response are
114fully analyzed and indexed, thus it becomes possible to build matching criteria
115on almost anything found in the contents.
116
117However, it is important to understand how HTTP requests and responses are
118formed, and how HAProxy decomposes them. It will then become easier to write
119correct rules and to debug existing configurations.
120
121
1221.1. The HTTP transaction model
123-------------------------------
124
125The HTTP protocol is transaction-driven. This means that each request will lead
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +0100126to one and only one response. Traditionally, a TCP connection is established
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200127from the client to the server, a request is sent by the client on the
128connection, the server responds and the connection is closed. A new request
129will involve a new connection :
130
131 [CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ...
132
133In this mode, called the "HTTP close" mode, there are as many connection
134establishments as there are HTTP transactions. Since the connection is closed
135by the server after the response, the client does not need to know the content
136length.
137
138Due to the transactional nature of the protocol, it was possible to improve it
139to avoid closing a connection between two subsequent transactions. In this mode
140however, it is mandatory that the server indicates the content length for each
141response so that the client does not wait indefinitely. For this, a special
142header is used: "Content-length". This mode is called the "keep-alive" mode :
143
144 [CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ...
145
146Its advantages are a reduced latency between transactions, and less processing
147power required on the server side. It is generally better than the close mode,
148but not always because the clients often limit their concurrent connections to
Patrick Mezard9ec2ec42010-06-12 17:02:45 +0200149a smaller value.
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200150
151A last improvement in the communications is the pipelining mode. It still uses
152keep-alive, but the client does not wait for the first response to send the
153second request. This is useful for fetching large number of images composing a
154page :
155
156 [CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ...
157
158This can obviously have a tremendous benefit on performance because the network
159latency is eliminated between subsequent requests. Many HTTP agents do not
160correctly support pipelining since there is no way to associate a response with
161the corresponding request in HTTP. For this reason, it is mandatory for the
Cyril Bonté78caf842010-03-10 22:41:43 +0100162server to reply in the exact same order as the requests were received.
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200163
Willy Tarreau70dffda2014-01-30 03:07:23 +0100164By default HAProxy operates in keep-alive mode with regards to persistent
165connections: for each connection it processes each request and response, and
166leaves the connection idle on both sides between the end of a response and the
167start of a new request.
Patrick Mezard9ec2ec42010-06-12 17:02:45 +0200168
Willy Tarreau70dffda2014-01-30 03:07:23 +0100169HAProxy supports 5 connection modes :
170 - keep alive : all requests and responses are processed (default)
171 - tunnel : only the first request and response are processed,
172 everything else is forwarded with no analysis.
173 - passive close : tunnel with "Connection: close" added in both directions.
174 - server close : the server-facing connection is closed after the response.
175 - forced close : the connection is actively closed after end of response.
176
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200177
1781.2. HTTP request
179-----------------
180
181First, let's consider this HTTP request :
182
183 Line Contents
Willy Tarreaud72758d2010-01-12 10:42:19 +0100184 number
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200185 1 GET /serv/login.php?lang=en&profile=2 HTTP/1.1
186 2 Host: www.mydomain.com
187 3 User-agent: my small browser
188 4 Accept: image/jpeg, image/gif
189 5 Accept: image/png
190
191
1921.2.1. The Request line
193-----------------------
194
195Line 1 is the "request line". It is always composed of 3 fields :
196
197 - a METHOD : GET
198 - a URI : /serv/login.php?lang=en&profile=2
199 - a version tag : HTTP/1.1
200
201All of them are delimited by what the standard calls LWS (linear white spaces),
202which are commonly spaces, but can also be tabs or line feeds/carriage returns
203followed by spaces/tabs. The method itself cannot contain any colon (':') and
204is limited to alphabetic letters. All those various combinations make it
205desirable that HAProxy performs the splitting itself rather than leaving it to
206the user to write a complex or inaccurate regular expression.
207
208The URI itself can have several forms :
209
210 - A "relative URI" :
211
212 /serv/login.php?lang=en&profile=2
213
214 It is a complete URL without the host part. This is generally what is
215 received by servers, reverse proxies and transparent proxies.
216
217 - An "absolute URI", also called a "URL" :
218
219 http://192.168.0.12:8080/serv/login.php?lang=en&profile=2
220
221 It is composed of a "scheme" (the protocol name followed by '://'), a host
222 name or address, optionally a colon (':') followed by a port number, then
223 a relative URI beginning at the first slash ('/') after the address part.
224 This is generally what proxies receive, but a server supporting HTTP/1.1
225 must accept this form too.
226
227 - a star ('*') : this form is only accepted in association with the OPTIONS
228 method and is not relayable. It is used to inquiry a next hop's
229 capabilities.
Willy Tarreaud72758d2010-01-12 10:42:19 +0100230
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200231 - an address:port combination : 192.168.0.12:80
232 This is used with the CONNECT method, which is used to establish TCP
233 tunnels through HTTP proxies, generally for HTTPS, but sometimes for
234 other protocols too.
235
236In a relative URI, two sub-parts are identified. The part before the question
237mark is called the "path". It is typically the relative path to static objects
238on the server. The part after the question mark is called the "query string".
239It is mostly used with GET requests sent to dynamic scripts and is very
240specific to the language, framework or application in use.
241
242
2431.2.2. The request headers
244--------------------------
245
246The headers start at the second line. They are composed of a name at the
247beginning of the line, immediately followed by a colon (':'). Traditionally,
248an LWS is added after the colon but that's not required. Then come the values.
249Multiple identical headers may be folded into one single line, delimiting the
250values with commas, provided that their order is respected. This is commonly
251encountered in the "Cookie:" field. A header may span over multiple lines if
252the subsequent lines begin with an LWS. In the example in 1.2, lines 4 and 5
253define a total of 3 values for the "Accept:" header.
254
255Contrary to a common mis-conception, header names are not case-sensitive, and
256their values are not either if they refer to other header names (such as the
257"Connection:" header).
258
259The end of the headers is indicated by the first empty line. People often say
260that it's a double line feed, which is not exact, even if a double line feed
261is one valid form of empty line.
262
263Fortunately, HAProxy takes care of all these complex combinations when indexing
264headers, checking values and counting them, so there is no reason to worry
265about the way they could be written, but it is important not to accuse an
266application of being buggy if it does unusual, valid things.
267
268Important note:
269 As suggested by RFC2616, HAProxy normalizes headers by replacing line breaks
270 in the middle of headers by LWS in order to join multi-line headers. This
271 is necessary for proper analysis and helps less capable HTTP parsers to work
272 correctly and not to be fooled by such complex constructs.
273
274
2751.3. HTTP response
276------------------
277
278An HTTP response looks very much like an HTTP request. Both are called HTTP
279messages. Let's consider this HTTP response :
280
281 Line Contents
Willy Tarreaud72758d2010-01-12 10:42:19 +0100282 number
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200283 1 HTTP/1.1 200 OK
284 2 Content-length: 350
285 3 Content-Type: text/html
286
Willy Tarreau816b9792009-09-15 21:25:21 +0200287As a special case, HTTP supports so called "Informational responses" as status
288codes 1xx. These messages are special in that they don't convey any part of the
289response, they're just used as sort of a signaling message to ask a client to
Willy Tarreau5843d1a2010-02-01 15:13:32 +0100290continue to post its request for instance. In the case of a status 100 response
291the requested information will be carried by the next non-100 response message
292following the informational one. This implies that multiple responses may be
293sent to a single request, and that this only works when keep-alive is enabled
294(1xx messages are HTTP/1.1 only). HAProxy handles these messages and is able to
295correctly forward and skip them, and only process the next non-100 response. As
296such, these messages are neither logged nor transformed, unless explicitly
297state otherwise. Status 101 messages indicate that the protocol is changing
298over the same connection and that haproxy must switch to tunnel mode, just as
299if a CONNECT had occurred. Then the Upgrade header would contain additional
300information about the type of protocol the connection is switching to.
Willy Tarreau816b9792009-09-15 21:25:21 +0200301
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200302
3031.3.1. The Response line
304------------------------
305
306Line 1 is the "response line". It is always composed of 3 fields :
307
308 - a version tag : HTTP/1.1
309 - a status code : 200
310 - a reason : OK
311
312The status code is always 3-digit. The first digit indicates a general status :
Willy Tarreau816b9792009-09-15 21:25:21 +0200313 - 1xx = informational message to be skipped (eg: 100, 101)
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200314 - 2xx = OK, content is following (eg: 200, 206)
315 - 3xx = OK, no content following (eg: 302, 304)
316 - 4xx = error caused by the client (eg: 401, 403, 404)
317 - 5xx = error caused by the server (eg: 500, 502, 503)
318
319Please refer to RFC2616 for the detailed meaning of all such codes. The
Willy Tarreaud72758d2010-01-12 10:42:19 +0100320"reason" field is just a hint, but is not parsed by clients. Anything can be
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200321found there, but it's a common practice to respect the well-established
322messages. It can be composed of one or multiple words, such as "OK", "Found",
323or "Authentication Required".
324
325Haproxy may emit the following status codes by itself :
326
327 Code When / reason
328 200 access to stats page, and when replying to monitoring requests
329 301 when performing a redirection, depending on the configured code
330 302 when performing a redirection, depending on the configured code
331 303 when performing a redirection, depending on the configured code
Willy Tarreaub67fdc42013-03-29 19:28:11 +0100332 307 when performing a redirection, depending on the configured code
333 308 when performing a redirection, depending on the configured code
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200334 400 for an invalid or too large request
335 401 when an authentication is required to perform the action (when
336 accessing the stats page)
337 403 when a request is forbidden by a "block" ACL or "reqdeny" filter
338 408 when the request timeout strikes before the request is complete
339 500 when haproxy encounters an unrecoverable internal error, such as a
340 memory allocation failure, which should never happen
341 502 when the server returns an empty, invalid or incomplete response, or
342 when an "rspdeny" filter blocks the response.
343 503 when no server was available to handle the request, or in response to
344 monitoring requests which match the "monitor fail" condition
345 504 when the response timeout strikes before the server responds
346
347The error 4xx and 5xx codes above may be customized (see "errorloc" in section
3484.2).
349
350
3511.3.2. The response headers
352---------------------------
353
354Response headers work exactly like request headers, and as such, HAProxy uses
355the same parsing function for both. Please refer to paragraph 1.2.2 for more
356details.
357
358
3592. Configuring HAProxy
360----------------------
361
3622.1. Configuration file format
363------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +0200364
365HAProxy's configuration process involves 3 major sources of parameters :
366
367 - the arguments from the command-line, which always take precedence
368 - the "global" section, which sets process-wide parameters
369 - the proxies sections which can take form of "defaults", "listen",
370 "frontend" and "backend".
371
Willy Tarreau0ba27502007-12-24 16:55:16 +0100372The configuration file syntax consists in lines beginning with a keyword
373referenced in this manual, optionally followed by one or several parameters
William Lallemandf9873ba2015-05-05 17:37:14 +0200374delimited by spaces.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100375
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200376
William Lallemandf9873ba2015-05-05 17:37:14 +02003772.2. Quoting and escaping
378-------------------------
379
380HAProxy's configuration introduces a quoting and escaping system similar to
381many programming languages. The configuration file supports 3 types: escaping
382with a backslash, weak quoting with double quotes, and strong quoting with
383single quotes.
384
385If spaces have to be entered in strings, then they must be escaped by preceding
386them by a backslash ('\') or by quoting them. Backslashes also have to be
387escaped by doubling or strong quoting them.
388
389Escaping is achieved by preceding a special character by a backslash ('\'):
390
391 \ to mark a space and differentiate it from a delimiter
392 \# to mark a hash and differentiate it from a comment
393 \\ to use a backslash
394 \' to use a single quote and differentiate it from strong quoting
395 \" to use a double quote and differentiate it from weak quoting
396
397Weak quoting is achieved by using double quotes (""). Weak quoting prevents
398the interpretation of:
399
400 space as a parameter separator
401 ' single quote as a strong quoting delimiter
402 # hash as a comment start
403
William Lallemandb2f07452015-05-12 14:27:13 +0200404Weak quoting permits the interpretation of variables, if you want to use a non
405-interpreted dollar within a double quoted string, you should escape it with a
406backslash ("\$"), it does not work outside weak quoting.
407
408Interpretation of escaping and special characters are not prevented by weak
William Lallemandf9873ba2015-05-05 17:37:14 +0200409quoting.
410
411Strong quoting is achieved by using single quotes (''). Inside single quotes,
412nothing is interpreted, it's the efficient way to quote regexes.
413
414Quoted and escaped strings are replaced in memory by their interpreted
415equivalent, it allows you to perform concatenation.
416
417 Example:
418 # those are equivalents:
419 log-format %{+Q}o\ %t\ %s\ %{-Q}r
420 log-format "%{+Q}o %t %s %{-Q}r"
421 log-format '%{+Q}o %t %s %{-Q}r'
422 log-format "%{+Q}o %t"' %s %{-Q}r'
423 log-format "%{+Q}o %t"' %s'\ %{-Q}r
424
425 # those are equivalents:
426 reqrep "^([^\ :]*)\ /static/(.*)" \1\ /\2
427 reqrep "^([^ :]*)\ /static/(.*)" '\1 /\2'
428 reqrep "^([^ :]*)\ /static/(.*)" "\1 /\2"
429 reqrep "^([^ :]*)\ /static/(.*)" "\1\ /\2"
430
431
William Lallemandb2f07452015-05-12 14:27:13 +02004322.3. Environment variables
433--------------------------
434
435HAProxy's configuration supports environment variables. Those variables are
436interpreted only within double quotes. Variables are expanded during the
437configuration parsing. Variable names must be preceded by a dollar ("$") and
438optionally enclosed with braces ("{}") similarly to what is done in Bourne
439shell. Variable names can contain alphanumerical characters or the character
440underscore ("_") but should not start with a digit.
441
442 Example:
443
444 bind "fd@${FD_APP1}"
445
446 log "${LOCAL_SYSLOG}:514" local0 notice # send to local server
447
448 user "$HAPROXY_USER"
449
450
4512.4. Time format
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200452----------------
453
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +0100454Some parameters involve values representing time, such as timeouts. These
Willy Tarreau0ba27502007-12-24 16:55:16 +0100455values are generally expressed in milliseconds (unless explicitly stated
456otherwise) but may be expressed in any other unit by suffixing the unit to the
457numeric value. It is important to consider this because it will not be repeated
458for every keyword. Supported units are :
459
460 - us : microseconds. 1 microsecond = 1/1000000 second
461 - ms : milliseconds. 1 millisecond = 1/1000 second. This is the default.
462 - s : seconds. 1s = 1000ms
463 - m : minutes. 1m = 60s = 60000ms
464 - h : hours. 1h = 60m = 3600s = 3600000ms
465 - d : days. 1d = 24h = 1440m = 86400s = 86400000ms
466
467
William Lallemandf9873ba2015-05-05 17:37:14 +02004682.4. Examples
Patrick Mezard35da19c2010-06-12 17:02:47 +0200469-------------
470
471 # Simple configuration for an HTTP proxy listening on port 80 on all
472 # interfaces and forwarding requests to a single backend "servers" with a
473 # single server "server1" listening on 127.0.0.1:8000
474 global
475 daemon
476 maxconn 256
477
478 defaults
479 mode http
480 timeout connect 5000ms
481 timeout client 50000ms
482 timeout server 50000ms
483
484 frontend http-in
485 bind *:80
486 default_backend servers
487
488 backend servers
489 server server1 127.0.0.1:8000 maxconn 32
490
491
492 # The same configuration defined with a single listen block. Shorter but
493 # less expressive, especially in HTTP mode.
494 global
495 daemon
496 maxconn 256
497
498 defaults
499 mode http
500 timeout connect 5000ms
501 timeout client 50000ms
502 timeout server 50000ms
503
504 listen http-in
505 bind *:80
506 server server1 127.0.0.1:8000 maxconn 32
507
508
509Assuming haproxy is in $PATH, test these configurations in a shell with:
510
Willy Tarreauccb289d2010-12-11 20:19:38 +0100511 $ sudo haproxy -f configuration.conf -c
Patrick Mezard35da19c2010-06-12 17:02:47 +0200512
513
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005143. Global parameters
Willy Tarreau6a06a402007-07-15 20:15:28 +0200515--------------------
516
517Parameters in the "global" section are process-wide and often OS-specific. They
518are generally set once for all and do not need being changed once correct. Some
519of them have command-line equivalents.
520
521The following keywords are supported in the "global" section :
522
523 * Process management and security
Emeric Brunc8e8d122012-10-02 18:42:10 +0200524 - ca-base
Willy Tarreau6a06a402007-07-15 20:15:28 +0200525 - chroot
Emeric Brunc8e8d122012-10-02 18:42:10 +0200526 - crt-base
Willy Tarreau6a06a402007-07-15 20:15:28 +0200527 - daemon
Simon Horman98637e52014-06-20 12:30:16 +0900528 - external-check
Willy Tarreau6a06a402007-07-15 20:15:28 +0200529 - gid
530 - group
531 - log
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100532 - log-send-hostname
Willy Tarreau6a06a402007-07-15 20:15:28 +0200533 - nbproc
534 - pidfile
535 - uid
536 - ulimit-n
537 - user
Willy Tarreaufbee7132007-10-18 13:53:22 +0200538 - stats
Emeric Brun850efd52014-01-29 12:24:34 +0100539 - ssl-server-verify
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +0200540 - node
541 - description
Willy Tarreauceb24bc2010-11-09 12:46:41 +0100542 - unix-bind
Thomas Holmesdb04f192015-05-18 13:21:39 +0100543 - 51degrees-data-file
544 - 51degrees-property-name-list
Dragan Dosen93b38d92015-06-29 16:43:25 +0200545 - 51degrees-property-separator
Dragan Dosenae6d39a2015-06-29 16:43:27 +0200546 - 51degrees-cache-size
Willy Tarreaud72758d2010-01-12 10:42:19 +0100547
Willy Tarreau6a06a402007-07-15 20:15:28 +0200548 * Performance tuning
Willy Tarreau1746eec2014-04-25 10:46:47 +0200549 - max-spread-checks
Willy Tarreau6a06a402007-07-15 20:15:28 +0200550 - maxconn
Willy Tarreau81c25d02011-09-07 15:17:21 +0200551 - maxconnrate
William Lallemandd85f9172012-11-09 17:05:39 +0100552 - maxcomprate
William Lallemand072a2bf2012-11-20 17:01:01 +0100553 - maxcompcpuusage
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100554 - maxpipes
Willy Tarreau93e7c002013-10-07 18:51:07 +0200555 - maxsessrate
Willy Tarreau403edff2012-09-06 11:58:37 +0200556 - maxsslconn
Willy Tarreaue43d5322013-10-07 20:01:52 +0200557 - maxsslrate
Willy Tarreau6a06a402007-07-15 20:15:28 +0200558 - noepoll
559 - nokqueue
560 - nopoll
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100561 - nosplice
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300562 - nogetaddrinfo
Willy Tarreaufe255b72007-10-14 23:09:26 +0200563 - spread-checks
Willy Tarreau27a674e2009-08-17 07:23:33 +0200564 - tune.bufsize
Willy Tarreau43961d52010-10-04 20:39:20 +0200565 - tune.chksize
William Lallemandf3747832012-11-09 12:33:10 +0100566 - tune.comp.maxlevel
Willy Tarreau193b8c62012-11-22 00:17:38 +0100567 - tune.http.cookielen
Willy Tarreauac1932d2011-10-24 19:14:41 +0200568 - tune.http.maxhdr
Willy Tarreau7e312732014-02-12 16:35:14 +0100569 - tune.idletimer
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100570 - tune.lua.forced-yield
Willy Tarreau32f61e22015-03-18 17:54:59 +0100571 - tune.lua.maxmem
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100572 - tune.lua.session-timeout
573 - tune.lua.task-timeout
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100574 - tune.maxaccept
575 - tune.maxpollevents
Willy Tarreau27a674e2009-08-17 07:23:33 +0200576 - tune.maxrewrite
Willy Tarreauf3045d22015-04-29 16:24:50 +0200577 - tune.pattern.cache-size
Willy Tarreaubd9a0a72011-10-23 21:14:29 +0200578 - tune.pipesize
Willy Tarreaue803de22010-01-21 17:43:04 +0100579 - tune.rcvbuf.client
580 - tune.rcvbuf.server
581 - tune.sndbuf.client
582 - tune.sndbuf.server
Willy Tarreau6ec58db2012-11-16 16:32:15 +0100583 - tune.ssl.cachesize
Willy Tarreaubfd59462013-02-21 07:46:09 +0100584 - tune.ssl.lifetime
Emeric Brun8dc60392014-05-09 13:52:00 +0200585 - tune.ssl.force-private-cache
Willy Tarreaubfd59462013-02-21 07:46:09 +0100586 - tune.ssl.maxrecord
Remi Gacognef46cd6e2014-06-12 14:58:40 +0200587 - tune.ssl.default-dh-param
Christopher Faulet31af49d2015-06-09 17:29:50 +0200588 - tune.ssl.ssl-ctx-cache-size
Thierry FOURNIER4834bc72015-06-06 19:29:07 +0200589 - tune.vars.global-max-size
590 - tune.vars.reqres-max-size
591 - tune.vars.sess-max-size
592 - tune.vars.txn-max-size
William Lallemanda509e4c2012-11-07 16:54:34 +0100593 - tune.zlib.memlevel
594 - tune.zlib.windowsize
Willy Tarreaud72758d2010-01-12 10:42:19 +0100595
Willy Tarreau6a06a402007-07-15 20:15:28 +0200596 * Debugging
597 - debug
598 - quiet
Willy Tarreau6a06a402007-07-15 20:15:28 +0200599
600
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006013.1. Process management and security
Willy Tarreau6a06a402007-07-15 20:15:28 +0200602------------------------------------
603
Emeric Brunc8e8d122012-10-02 18:42:10 +0200604ca-base <dir>
605 Assigns a default directory to fetch SSL CA certificates and CRLs from when a
Emeric Brunfd33a262012-10-11 16:28:27 +0200606 relative path is used with "ca-file" or "crl-file" directives. Absolute
607 locations specified in "ca-file" and "crl-file" prevail and ignore "ca-base".
Emeric Brunc8e8d122012-10-02 18:42:10 +0200608
Willy Tarreau6a06a402007-07-15 20:15:28 +0200609chroot <jail dir>
610 Changes current directory to <jail dir> and performs a chroot() there before
611 dropping privileges. This increases the security level in case an unknown
612 vulnerability would be exploited, since it would make it very hard for the
613 attacker to exploit the system. This only works when the process is started
614 with superuser privileges. It is important to ensure that <jail_dir> is both
615 empty and unwritable to anyone.
Willy Tarreaud72758d2010-01-12 10:42:19 +0100616
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100617cpu-map <"all"|"odd"|"even"|process_num> <cpu-set>...
618 On Linux 2.6 and above, it is possible to bind a process to a specific CPU
619 set. This means that the process will never run on other CPUs. The "cpu-map"
620 directive specifies CPU sets for process sets. The first argument is the
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100621 process number to bind. This process must have a number between 1 and 32 or
622 64, depending on the machine's word size, and any process IDs above nbproc
623 are ignored. It is possible to specify all processes at once using "all",
624 only odd numbers using "odd" or even numbers using "even", just like with the
625 "bind-process" directive. The second and forthcoming arguments are CPU sets.
626 Each CPU set is either a unique number between 0 and 31 or 63 or a range with
627 two such numbers delimited by a dash ('-'). Multiple CPU numbers or ranges
628 may be specified, and the processes will be allowed to bind to all of them.
629 Obviously, multiple "cpu-map" directives may be specified. Each "cpu-map"
630 directive will replace the previous ones when they overlap.
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100631
Emeric Brunc8e8d122012-10-02 18:42:10 +0200632crt-base <dir>
633 Assigns a default directory to fetch SSL certificates from when a relative
634 path is used with "crtfile" directives. Absolute locations specified after
635 "crtfile" prevail and ignore "crt-base".
636
Willy Tarreau6a06a402007-07-15 20:15:28 +0200637daemon
638 Makes the process fork into background. This is the recommended mode of
639 operation. It is equivalent to the command line "-D" argument. It can be
640 disabled by the command line "-db" argument.
641
David Carlier8167f302015-06-01 13:50:06 +0200642deviceatlas-json-file <path>
643 Sets the path of the DeviceAtlas JSON data file to be loaded by the API.
644 The path must be a valid JSON data file and accessible by Haproxy process.
645
646deviceatlas-log-level <value>
647 Sets the level of informations returned by the API. This directive is
648 optional and set to 0 by default if not set.
649
650deviceatlas-separator <char>
651 Sets the character separator for the API properties results. This directive
652 is optional and set to | by default if not set.
653
Simon Horman98637e52014-06-20 12:30:16 +0900654external-check
655 Allows the use of an external agent to perform health checks.
656 This is disabled by default as a security precaution.
657 See "option external-check".
658
Willy Tarreau6a06a402007-07-15 20:15:28 +0200659gid <number>
660 Changes the process' group ID to <number>. It is recommended that the group
661 ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
662 be started with a user belonging to this group, or with superuser privileges.
Michael Schererab012dd2013-01-12 18:35:19 +0100663 Note that if haproxy is started from a user having supplementary groups, it
664 will only be able to drop these groups if started with superuser privileges.
Willy Tarreau6a06a402007-07-15 20:15:28 +0200665 See also "group" and "uid".
Willy Tarreaud72758d2010-01-12 10:42:19 +0100666
Willy Tarreau6a06a402007-07-15 20:15:28 +0200667group <group name>
668 Similar to "gid" but uses the GID of group name <group name> from /etc/group.
669 See also "gid" and "user".
Willy Tarreaud72758d2010-01-12 10:42:19 +0100670
Willy Tarreau18324f52014-06-27 18:10:07 +0200671log <address> [len <length>] <facility> [max level [min level]]
Willy Tarreau6a06a402007-07-15 20:15:28 +0200672 Adds a global syslog server. Up to two global servers can be defined. They
673 will receive logs for startups and exits, as well as all logs from proxies
Robert Tsai81ae1952007-12-05 10:47:29 +0100674 configured with "log global".
675
676 <address> can be one of:
677
Willy Tarreau2769aa02007-12-27 18:26:09 +0100678 - An IPv4 address optionally followed by a colon and a UDP port. If
Robert Tsai81ae1952007-12-05 10:47:29 +0100679 no port is specified, 514 is used by default (the standard syslog
680 port).
681
David du Colombier24bb5f52011-03-17 10:40:23 +0100682 - An IPv6 address followed by a colon and optionally a UDP port. If
683 no port is specified, 514 is used by default (the standard syslog
684 port).
685
Robert Tsai81ae1952007-12-05 10:47:29 +0100686 - A filesystem path to a UNIX domain socket, keeping in mind
687 considerations for chroot (be sure the path is accessible inside
688 the chroot) and uid/gid (be sure the path is appropriately
689 writeable).
690
William Lallemandb2f07452015-05-12 14:27:13 +0200691 You may want to reference some environment variables in the address
692 parameter, see section 2.3 about environment variables.
Willy Tarreaudad36a32013-03-11 01:20:04 +0100693
Willy Tarreau18324f52014-06-27 18:10:07 +0200694 <length> is an optional maximum line length. Log lines larger than this value
695 will be truncated before being sent. The reason is that syslog
696 servers act differently on log line length. All servers support the
697 default value of 1024, but some servers simply drop larger lines
698 while others do log them. If a server supports long lines, it may
699 make sense to set this value here in order to avoid truncating long
700 lines. Similarly, if a server drops long lines, it is preferable to
701 truncate them before sending them. Accepted values are 80 to 65535
702 inclusive. The default value of 1024 is generally fine for all
703 standard usages. Some specific cases of long captures or
704 JSON-formated logs may require larger values.
705
Robert Tsai81ae1952007-12-05 10:47:29 +0100706 <facility> must be one of the 24 standard syslog facilities :
Willy Tarreau6a06a402007-07-15 20:15:28 +0200707
708 kern user mail daemon auth syslog lpr news
709 uucp cron auth2 ftp ntp audit alert cron2
710 local0 local1 local2 local3 local4 local5 local6 local7
711
712 An optional level can be specified to filter outgoing messages. By default,
Willy Tarreauf7edefa2009-05-10 17:20:05 +0200713 all messages are sent. If a maximum level is specified, only messages with a
714 severity at least as important as this level will be sent. An optional minimum
715 level can be specified. If it is set, logs emitted with a more severe level
716 than this one will be capped to this level. This is used to avoid sending
717 "emerg" messages on all terminals on some default syslog configurations.
718 Eight levels are known :
Willy Tarreau6a06a402007-07-15 20:15:28 +0200719
Cyril Bontédc4d9032012-04-08 21:57:39 +0200720 emerg alert crit err warning notice info debug
Willy Tarreau6a06a402007-07-15 20:15:28 +0200721
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100722log-send-hostname [<string>]
723 Sets the hostname field in the syslog header. If optional "string" parameter
724 is set the header is set to the string contents, otherwise uses the hostname
725 of the system. Generally used if one is not relaying logs through an
726 intermediate syslog server or for simply customizing the hostname printed in
727 the logs.
728
Kevinm48936af2010-12-22 16:08:21 +0000729log-tag <string>
730 Sets the tag field in the syslog header to this string. It defaults to the
731 program name as launched from the command line, which usually is "haproxy".
732 Sometimes it can be useful to differentiate between multiple processes
Willy Tarreau094af4e2015-01-07 15:03:42 +0100733 running on the same host. See also the per-proxy "log-tag" directive.
Kevinm48936af2010-12-22 16:08:21 +0000734
Thierry FOURNIER90da1912015-03-05 11:17:06 +0100735lua-load <file>
736 This global directive loads and executes a Lua file. This directive can be
737 used multiple times.
738
Willy Tarreau6a06a402007-07-15 20:15:28 +0200739nbproc <number>
740 Creates <number> processes when going daemon. This requires the "daemon"
741 mode. By default, only one process is created, which is the recommended mode
742 of operation. For systems limited to small sets of file descriptors per
743 process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
744 IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
745
746pidfile <pidfile>
747 Writes pids of all daemons into file <pidfile>. This option is equivalent to
748 the "-p" command line argument. The file must be accessible to the user
749 starting the process. See also "daemon".
750
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100751stats bind-process [ all | odd | even | <number 1-64>[-<number 1-64>] ] ...
Willy Tarreau35b7b162012-10-22 23:17:18 +0200752 Limits the stats socket to a certain set of processes numbers. By default the
753 stats socket is bound to all processes, causing a warning to be emitted when
754 nbproc is greater than 1 because there is no way to select the target process
755 when connecting. However, by using this setting, it becomes possible to pin
756 the stats socket to a specific set of processes, typically the first one. The
757 warning will automatically be disabled when this setting is used, whatever
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100758 the number of processes used. The maximum process ID depends on the machine's
Willy Tarreauae302532014-05-07 19:22:24 +0200759 word size (32 or 64). A better option consists in using the "process" setting
760 of the "stats socket" line to force the process on each line.
Willy Tarreau35b7b162012-10-22 23:17:18 +0200761
Willy Tarreau610f04b2014-02-13 11:36:41 +0100762ssl-default-bind-ciphers <ciphers>
763 This setting is only available when support for OpenSSL was built in. It sets
764 the default string describing the list of cipher algorithms ("cipher suite")
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300765 that are negotiated during the SSL/TLS handshake for all "bind" lines which
Willy Tarreau610f04b2014-02-13 11:36:41 +0100766 do not explicitly define theirs. The format of the string is defined in
767 "man 1 ciphers" from OpenSSL man pages, and can be for instance a string such
768 as "AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH" (without quotes). Please check the
769 "bind" keyword for more information.
770
Emeric Brun2c86cbf2014-10-30 15:56:50 +0100771ssl-default-bind-options [<option>]...
772 This setting is only available when support for OpenSSL was built in. It sets
773 default ssl-options to force on all "bind" lines. Please check the "bind"
774 keyword to see available options.
775
776 Example:
777 global
778 ssl-default-bind-options no-sslv3 no-tls-tickets
779
Willy Tarreau610f04b2014-02-13 11:36:41 +0100780ssl-default-server-ciphers <ciphers>
781 This setting is only available when support for OpenSSL was built in. It
782 sets the default string describing the list of cipher algorithms that are
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300783 negotiated during the SSL/TLS handshake with the server, for all "server"
Willy Tarreau610f04b2014-02-13 11:36:41 +0100784 lines which do not explicitly define theirs. The format of the string is
785 defined in "man 1 ciphers". Please check the "server" keyword for more
786 information.
787
Emeric Brun2c86cbf2014-10-30 15:56:50 +0100788ssl-default-server-options [<option>]...
789 This setting is only available when support for OpenSSL was built in. It sets
790 default ssl-options to force on all "server" lines. Please check the "server"
791 keyword to see available options.
792
Remi Gacogne47783ef2015-05-29 15:53:22 +0200793ssl-dh-param-file <file>
794 This setting is only available when support for OpenSSL was built in. It sets
795 the default DH parameters that are used during the SSL/TLS handshake when
796 ephemeral Diffie-Hellman (DHE) key exchange is used, for all "bind" lines
797 which do not explicitely define theirs. It will be overridden by custom DH
798 parameters found in a bind certificate file if any. If custom DH parameters
799 are not specified either by using ssl-dh-param-file or by setting them directly
800 in the certificate file, pre-generated DH parameters of the size specified
801 by tune.ssl.default-dh-param will be used. Custom parameters are known to be
802 more secure and therefore their use is recommended.
803 Custom DH parameters may be generated by using the OpenSSL command
804 "openssl dhparam <size>", where size should be at least 2048, as 1024-bit DH
805 parameters should not be considered secure anymore.
806
Emeric Brun850efd52014-01-29 12:24:34 +0100807ssl-server-verify [none|required]
808 The default behavior for SSL verify on servers side. If specified to 'none',
809 servers certificates are not verified. The default is 'required' except if
810 forced using cmdline option '-dV'.
811
Willy Tarreauabb175f2012-09-24 12:43:26 +0200812stats socket [<address:port>|<path>] [param*]
813 Binds a UNIX socket to <path> or a TCPv4/v6 address to <address:port>.
814 Connections to this socket will return various statistics outputs and even
815 allow some commands to be issued to change some runtime settings. Please
816 consult section 9.2 "Unix Socket commands" for more details.
Willy Tarreau6162db22009-10-10 17:13:00 +0200817
Willy Tarreauabb175f2012-09-24 12:43:26 +0200818 All parameters supported by "bind" lines are supported, for instance to
819 restrict access to some users or their access rights. Please consult
820 section 5.1 for more information.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200821
822stats timeout <timeout, in milliseconds>
823 The default timeout on the stats socket is set to 10 seconds. It is possible
824 to change this value with "stats timeout". The value must be passed in
Willy Tarreaubefdff12007-12-02 22:27:38 +0100825 milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200826
827stats maxconn <connections>
828 By default, the stats socket is limited to 10 concurrent connections. It is
829 possible to change this value with "stats maxconn".
830
Willy Tarreau6a06a402007-07-15 20:15:28 +0200831uid <number>
832 Changes the process' user ID to <number>. It is recommended that the user ID
833 is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
834 be started with superuser privileges in order to be able to switch to another
835 one. See also "gid" and "user".
836
837ulimit-n <number>
838 Sets the maximum number of per-process file-descriptors to <number>. By
839 default, it is automatically computed, so it is recommended not to use this
840 option.
841
Willy Tarreauceb24bc2010-11-09 12:46:41 +0100842unix-bind [ prefix <prefix> ] [ mode <mode> ] [ user <user> ] [ uid <uid> ]
843 [ group <group> ] [ gid <gid> ]
844
845 Fixes common settings to UNIX listening sockets declared in "bind" statements.
846 This is mainly used to simplify declaration of those UNIX sockets and reduce
847 the risk of errors, since those settings are most commonly required but are
848 also process-specific. The <prefix> setting can be used to force all socket
849 path to be relative to that directory. This might be needed to access another
850 component's chroot. Note that those paths are resolved before haproxy chroots
851 itself, so they are absolute. The <mode>, <user>, <uid>, <group> and <gid>
852 all have the same meaning as their homonyms used by the "bind" statement. If
853 both are specified, the "bind" statement has priority, meaning that the
854 "unix-bind" settings may be seen as process-wide default settings.
855
Willy Tarreau6a06a402007-07-15 20:15:28 +0200856user <user name>
857 Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
858 See also "uid" and "group".
859
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +0200860node <name>
861 Only letters, digits, hyphen and underscore are allowed, like in DNS names.
862
863 This statement is useful in HA configurations where two or more processes or
864 servers share the same IP address. By setting a different node-name on all
865 nodes, it becomes easy to immediately spot what server is handling the
866 traffic.
867
868description <text>
869 Add a text that describes the instance.
870
871 Please note that it is required to escape certain characters (# for example)
872 and this text is inserted into a html page so you should avoid using
873 "<" and ">" characters.
874
Thomas Holmesdb04f192015-05-18 13:21:39 +010087551degrees-data-file <file path>
876 The path of the 51Degrees data file to provide device detection services. The
877 file should be unzipped and accessible by HAProxy with relevavnt permissions.
878
Dragan Dosenae6d39a2015-06-29 16:43:27 +0200879 Please note that this option is only available when haproxy has been
Thomas Holmesdb04f192015-05-18 13:21:39 +0100880 compiled with USE_51DEGREES.
881
88251degrees-property-name-list [<string>]
883 A list of 51Degrees property names to be load from the dataset. A full list
884 of names is available on the 51Degrees website:
885 https://51degrees.com/resources/property-dictionary
886
Dragan Dosenae6d39a2015-06-29 16:43:27 +0200887 Please note that this option is only available when haproxy has been
Thomas Holmesdb04f192015-05-18 13:21:39 +0100888 compiled with USE_51DEGREES.
889
Dragan Dosen93b38d92015-06-29 16:43:25 +020089051degrees-property-separator <char>
Thomas Holmesdb04f192015-05-18 13:21:39 +0100891 A char that will be appended to every property value in a response header
892 containing 51Degrees results. If not set that will be set as ','.
893
Dragan Dosenae6d39a2015-06-29 16:43:27 +0200894 Please note that this option is only available when haproxy has been
895 compiled with USE_51DEGREES.
896
89751degrees-cache-size <number>
898 Sets the size of the 51Degrees converter cache to <number> entries. This
899 is an LRU cache which reminds previous device detections and their results.
900 By default, this cache is disabled.
901
902 Please note that this option is only available when haproxy has been
Thomas Holmesdb04f192015-05-18 13:21:39 +0100903 compiled with USE_51DEGREES.
904
Willy Tarreau6a06a402007-07-15 20:15:28 +0200905
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009063.2. Performance tuning
Willy Tarreau6a06a402007-07-15 20:15:28 +0200907-----------------------
908
Willy Tarreau1746eec2014-04-25 10:46:47 +0200909max-spread-checks <delay in milliseconds>
910 By default, haproxy tries to spread the start of health checks across the
911 smallest health check interval of all the servers in a farm. The principle is
912 to avoid hammering services running on the same server. But when using large
913 check intervals (10 seconds or more), the last servers in the farm take some
914 time before starting to be tested, which can be a problem. This parameter is
915 used to enforce an upper bound on delay between the first and the last check,
916 even if the servers' check intervals are larger. When servers run with
917 shorter intervals, their intervals will be respected though.
918
Willy Tarreau6a06a402007-07-15 20:15:28 +0200919maxconn <number>
920 Sets the maximum per-process number of concurrent connections to <number>. It
921 is equivalent to the command-line argument "-n". Proxies will stop accepting
922 connections when this limit is reached. The "ulimit-n" parameter is
Willy Tarreau8274e102014-06-19 15:31:25 +0200923 automatically adjusted according to this value. See also "ulimit-n". Note:
924 the "select" poller cannot reliably use more than 1024 file descriptors on
925 some platforms. If your platform only supports select and reports "select
926 FAILED" on startup, you need to reduce maxconn until it works (slightly
Willy Tarreaud0256482015-01-15 21:45:22 +0100927 below 500 in general). If this value is not set, it will default to the value
928 set in DEFAULT_MAXCONN at build time (reported in haproxy -vv) if no memory
929 limit is enforced, or will be computed based on the memory limit, the buffer
930 size, memory allocated to compression, SSL cache size, and use or not of SSL
931 and the associated maxsslconn (which can also be automatic).
Willy Tarreau6a06a402007-07-15 20:15:28 +0200932
Willy Tarreau81c25d02011-09-07 15:17:21 +0200933maxconnrate <number>
934 Sets the maximum per-process number of connections per second to <number>.
935 Proxies will stop accepting connections when this limit is reached. It can be
936 used to limit the global capacity regardless of each frontend capacity. It is
937 important to note that this can only be used as a service protection measure,
938 as there will not necessarily be a fair share between frontends when the
939 limit is reached, so it's a good idea to also limit each frontend to some
940 value close to its expected share. Also, lowering tune.maxaccept can improve
941 fairness.
942
William Lallemandd85f9172012-11-09 17:05:39 +0100943maxcomprate <number>
944 Sets the maximum per-process input compression rate to <number> kilobytes
Jarno Huuskonen0e82b922014-04-12 18:22:19 +0300945 per second. For each session, if the maximum is reached, the compression
William Lallemandd85f9172012-11-09 17:05:39 +0100946 level will be decreased during the session. If the maximum is reached at the
947 beginning of a session, the session will not compress at all. If the maximum
948 is not reached, the compression level will be increased up to
949 tune.comp.maxlevel. A value of zero means there is no limit, this is the
950 default value.
951
William Lallemand072a2bf2012-11-20 17:01:01 +0100952maxcompcpuusage <number>
953 Sets the maximum CPU usage HAProxy can reach before stopping the compression
954 for new requests or decreasing the compression level of current requests.
955 It works like 'maxcomprate' but measures CPU usage instead of incoming data
956 bandwidth. The value is expressed in percent of the CPU used by haproxy. In
957 case of multiple processes (nbproc > 1), each process manages its individual
958 usage. A value of 100 disable the limit. The default value is 100. Setting
959 a lower value will prevent the compression work from slowing the whole
960 process down and from introducing high latencies.
961
Willy Tarreauff4f82d2009-02-06 11:28:13 +0100962maxpipes <number>
963 Sets the maximum per-process number of pipes to <number>. Currently, pipes
964 are only used by kernel-based tcp splicing. Since a pipe contains two file
965 descriptors, the "ulimit-n" value will be increased accordingly. The default
966 value is maxconn/4, which seems to be more than enough for most heavy usages.
967 The splice code dynamically allocates and releases pipes, and can fall back
968 to standard copy, so setting this value too low may only impact performance.
969
Willy Tarreau93e7c002013-10-07 18:51:07 +0200970maxsessrate <number>
971 Sets the maximum per-process number of sessions per second to <number>.
972 Proxies will stop accepting connections when this limit is reached. It can be
973 used to limit the global capacity regardless of each frontend capacity. It is
974 important to note that this can only be used as a service protection measure,
975 as there will not necessarily be a fair share between frontends when the
976 limit is reached, so it's a good idea to also limit each frontend to some
977 value close to its expected share. Also, lowering tune.maxaccept can improve
978 fairness.
979
Willy Tarreau403edff2012-09-06 11:58:37 +0200980maxsslconn <number>
981 Sets the maximum per-process number of concurrent SSL connections to
982 <number>. By default there is no SSL-specific limit, which means that the
983 global maxconn setting will apply to all connections. Setting this limit
984 avoids having openssl use too much memory and crash when malloc returns NULL
985 (since it unfortunately does not reliably check for such conditions). Note
986 that the limit applies both to incoming and outgoing connections, so one
987 connection which is deciphered then ciphered accounts for 2 SSL connections.
Willy Tarreaud0256482015-01-15 21:45:22 +0100988 If this value is not set, but a memory limit is enforced, this value will be
989 automatically computed based on the memory limit, maxconn, the buffer size,
990 memory allocated to compression, SSL cache size, and use of SSL in either
991 frontends, backends or both. If neither maxconn nor maxsslconn are specified
992 when there is a memory limit, haproxy will automatically adjust these values
993 so that 100% of the connections can be made over SSL with no risk, and will
994 consider the sides where it is enabled (frontend, backend, both).
Willy Tarreau403edff2012-09-06 11:58:37 +0200995
Willy Tarreaue43d5322013-10-07 20:01:52 +0200996maxsslrate <number>
997 Sets the maximum per-process number of SSL sessions per second to <number>.
998 SSL listeners will stop accepting connections when this limit is reached. It
999 can be used to limit the global SSL CPU usage regardless of each frontend
1000 capacity. It is important to note that this can only be used as a service
1001 protection measure, as there will not necessarily be a fair share between
1002 frontends when the limit is reached, so it's a good idea to also limit each
1003 frontend to some value close to its expected share. It is also important to
1004 note that the sessions are accounted before they enter the SSL stack and not
1005 after, which also protects the stack against bad handshakes. Also, lowering
1006 tune.maxaccept can improve fairness.
1007
William Lallemand9d5f5482012-11-07 16:12:57 +01001008maxzlibmem <number>
1009 Sets the maximum amount of RAM in megabytes per process usable by the zlib.
1010 When the maximum amount is reached, future sessions will not compress as long
1011 as RAM is unavailable. When sets to 0, there is no limit.
William Lallemande3a7d992012-11-20 11:25:20 +01001012 The default value is 0. The value is available in bytes on the UNIX socket
1013 with "show info" on the line "MaxZlibMemUsage", the memory used by zlib is
1014 "ZlibMemUsage" in bytes.
1015
Willy Tarreau6a06a402007-07-15 20:15:28 +02001016noepoll
1017 Disables the use of the "epoll" event polling system on Linux. It is
1018 equivalent to the command-line argument "-de". The next polling system
Willy Tarreaue9f49e72012-11-11 17:42:00 +01001019 used will generally be "poll". See also "nopoll".
Willy Tarreau6a06a402007-07-15 20:15:28 +02001020
1021nokqueue
1022 Disables the use of the "kqueue" event polling system on BSD. It is
1023 equivalent to the command-line argument "-dk". The next polling system
1024 used will generally be "poll". See also "nopoll".
1025
1026nopoll
1027 Disables the use of the "poll" event polling system. It is equivalent to the
1028 command-line argument "-dp". The next polling system used will be "select".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001029 It should never be needed to disable "poll" since it's available on all
Willy Tarreaue9f49e72012-11-11 17:42:00 +01001030 platforms supported by HAProxy. See also "nokqueue" and "noepoll".
Willy Tarreau6a06a402007-07-15 20:15:28 +02001031
Willy Tarreauff4f82d2009-02-06 11:28:13 +01001032nosplice
1033 Disables the use of kernel tcp splicing between sockets on Linux. It is
1034 equivalent to the command line argument "-dS". Data will then be copied
1035 using conventional and more portable recv/send calls. Kernel tcp splicing is
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001036 limited to some very recent instances of kernel 2.6. Most versions between
Willy Tarreauff4f82d2009-02-06 11:28:13 +01001037 2.6.25 and 2.6.28 are buggy and will forward corrupted data, so they must not
1038 be used. This option makes it easier to globally disable kernel splicing in
1039 case of doubt. See also "option splice-auto", "option splice-request" and
1040 "option splice-response".
1041
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001042nogetaddrinfo
1043 Disables the use of getaddrinfo(3) for name resolving. It is equivalent to
1044 the command line argument "-dG". Deprecated gethostbyname(3) will be used.
1045
Willy Tarreaufe255b72007-10-14 23:09:26 +02001046spread-checks <0..50, in percent>
Simon Hormand60d6912013-11-25 10:46:36 +09001047 Sometimes it is desirable to avoid sending agent and health checks to
1048 servers at exact intervals, for instance when many logical servers are
1049 located on the same physical server. With the help of this parameter, it
1050 becomes possible to add some randomness in the check interval between 0
1051 and +/- 50%. A value between 2 and 5 seems to show good results. The
1052 default value remains at 0.
Willy Tarreaufe255b72007-10-14 23:09:26 +02001053
Willy Tarreau33cb0652014-12-23 22:52:37 +01001054tune.buffers.limit <number>
1055 Sets a hard limit on the number of buffers which may be allocated per process.
1056 The default value is zero which means unlimited. The minimum non-zero value
1057 will always be greater than "tune.buffers.reserve" and should ideally always
1058 be about twice as large. Forcing this value can be particularly useful to
1059 limit the amount of memory a process may take, while retaining a sane
1060 behaviour. When this limit is reached, sessions which need a buffer wait for
1061 another one to be released by another session. Since buffers are dynamically
1062 allocated and released, the waiting time is very short and not perceptible
1063 provided that limits remain reasonable. In fact sometimes reducing the limit
1064 may even increase performance by increasing the CPU cache's efficiency. Tests
1065 have shown good results on average HTTP traffic with a limit to 1/10 of the
1066 expected global maxconn setting, which also significantly reduces memory
1067 usage. The memory savings come from the fact that a number of connections
1068 will not allocate 2*tune.bufsize. It is best not to touch this value unless
1069 advised to do so by an haproxy core developer.
1070
Willy Tarreau1058ae72014-12-23 22:40:40 +01001071tune.buffers.reserve <number>
1072 Sets the number of buffers which are pre-allocated and reserved for use only
1073 during memory shortage conditions resulting in failed memory allocations. The
1074 minimum value is 2 and is also the default. There is no reason a user would
1075 want to change this value, it's mostly aimed at haproxy core developers.
1076
Willy Tarreau27a674e2009-08-17 07:23:33 +02001077tune.bufsize <number>
1078 Sets the buffer size to this size (in bytes). Lower values allow more
1079 sessions to coexist in the same amount of RAM, and higher values allow some
1080 applications with very large cookies to work. The default value is 16384 and
1081 can be changed at build time. It is strongly recommended not to change this
1082 from the default value, as very low values will break some services such as
1083 statistics, and values larger than default size will increase memory usage,
1084 possibly causing the system to run out of memory. At least the global maxconn
1085 parameter should be decreased by the same factor as this one is increased.
Dmitry Sivachenkof6f4f7b2012-10-21 18:10:25 +04001086 If HTTP request is larger than (tune.bufsize - tune.maxrewrite), haproxy will
1087 return HTTP 400 (Bad Request) error. Similarly if an HTTP response is larger
1088 than this size, haproxy will return HTTP 502 (Bad Gateway).
Willy Tarreau27a674e2009-08-17 07:23:33 +02001089
Willy Tarreau43961d52010-10-04 20:39:20 +02001090tune.chksize <number>
1091 Sets the check buffer size to this size (in bytes). Higher values may help
1092 find string or regex patterns in very large pages, though doing so may imply
1093 more memory and CPU usage. The default value is 16384 and can be changed at
1094 build time. It is not recommended to change this value, but to use better
1095 checks whenever possible.
1096
William Lallemandf3747832012-11-09 12:33:10 +01001097tune.comp.maxlevel <number>
1098 Sets the maximum compression level. The compression level affects CPU
1099 usage during compression. This value affects CPU usage during compression.
1100 Each session using compression initializes the compression algorithm with
1101 this value. The default value is 1.
1102
Willy Tarreau193b8c62012-11-22 00:17:38 +01001103tune.http.cookielen <number>
1104 Sets the maximum length of captured cookies. This is the maximum value that
1105 the "capture cookie xxx len yyy" will be allowed to take, and any upper value
1106 will automatically be truncated to this one. It is important not to set too
1107 high a value because all cookie captures still allocate this size whatever
1108 their configured value (they share a same pool). This value is per request
1109 per response, so the memory allocated is twice this value per connection.
1110 When not specified, the limit is set to 63 characters. It is recommended not
1111 to change this value.
1112
Willy Tarreauac1932d2011-10-24 19:14:41 +02001113tune.http.maxhdr <number>
1114 Sets the maximum number of headers in a request. When a request comes with a
1115 number of headers greater than this value (including the first line), it is
1116 rejected with a "400 Bad Request" status code. Similarly, too large responses
1117 are blocked with "502 Bad Gateway". The default value is 101, which is enough
1118 for all usages, considering that the widely deployed Apache server uses the
1119 same limit. It can be useful to push this limit further to temporarily allow
1120 a buggy application to work by the time it gets fixed. Keep in mind that each
1121 new header consumes 32bits of memory for each session, so don't push this
1122 limit too high.
1123
Willy Tarreau7e312732014-02-12 16:35:14 +01001124tune.idletimer <timeout>
1125 Sets the duration after which haproxy will consider that an empty buffer is
1126 probably associated with an idle stream. This is used to optimally adjust
1127 some packet sizes while forwarding large and small data alternatively. The
1128 decision to use splice() or to send large buffers in SSL is modulated by this
1129 parameter. The value is in milliseconds between 0 and 65535. A value of zero
1130 means that haproxy will not try to detect idle streams. The default is 1000,
1131 which seems to correctly detect end user pauses (eg: read a page before
1132 clicking). There should be not reason for changing this value. Please check
1133 tune.ssl.maxrecord below.
1134
Thierry FOURNIER90da1912015-03-05 11:17:06 +01001135tune.lua.forced-yield <number>
1136 This directive forces the Lua engine to execute a yield each <number> of
1137 instructions executed. This permits interruptng a long script and allows the
1138 HAProxy scheduler to process other tasks like accepting connections or
1139 forwarding traffic. The default value is 10000 instructions. If HAProxy often
1140 executes some Lua code but more reactivity is required, this value can be
1141 lowered. If the Lua code is quite long and its result is absolutely required
1142 to process the data, the <number> can be increased.
1143
Willy Tarreau32f61e22015-03-18 17:54:59 +01001144tune.lua.maxmem
1145 Sets the maximum amount of RAM in megabytes per process usable by Lua. By
1146 default it is zero which means unlimited. It is important to set a limit to
1147 ensure that a bug in a script will not result in the system running out of
1148 memory.
1149
Thierry FOURNIER90da1912015-03-05 11:17:06 +01001150tune.lua.session-timeout <timeout>
1151 This is the execution timeout for the Lua sessions. This is useful for
1152 preventing infinite loops or spending too much time in Lua. This timeout has a
1153 priority over other timeouts. For example, if this timeout is set to 4s and
1154 you run a 5s sleep, the code will be interrupted with an error after waiting
1155 4s.
1156
1157tune.lua.task-timeout <timeout>
1158 Purpose is the same as "tune.lua.session-timeout", but this timeout is
1159 dedicated to the tasks. By default, this timeout isn't set because a task may
1160 remain alive during of the lifetime of HAProxy. For example, a task used to
1161 check servers.
1162
Willy Tarreaua0250ba2008-01-06 11:22:57 +01001163tune.maxaccept <number>
Willy Tarreau16a21472012-11-19 12:39:59 +01001164 Sets the maximum number of consecutive connections a process may accept in a
1165 row before switching to other work. In single process mode, higher numbers
1166 give better performance at high connection rates. However in multi-process
1167 modes, keeping a bit of fairness between processes generally is better to
1168 increase performance. This value applies individually to each listener, so
1169 that the number of processes a listener is bound to is taken into account.
1170 This value defaults to 64. In multi-process mode, it is divided by twice
1171 the number of processes the listener is bound to. Setting this value to -1
1172 completely disables the limitation. It should normally not be needed to tweak
1173 this value.
Willy Tarreaua0250ba2008-01-06 11:22:57 +01001174
1175tune.maxpollevents <number>
1176 Sets the maximum amount of events that can be processed at once in a call to
1177 the polling system. The default value is adapted to the operating system. It
1178 has been noticed that reducing it below 200 tends to slightly decrease
1179 latency at the expense of network bandwidth, and increasing it above 200
1180 tends to trade latency for slightly increased bandwidth.
1181
Willy Tarreau27a674e2009-08-17 07:23:33 +02001182tune.maxrewrite <number>
1183 Sets the reserved buffer space to this size in bytes. The reserved space is
1184 used for header rewriting or appending. The first reads on sockets will never
1185 fill more than bufsize-maxrewrite. Historically it has defaulted to half of
1186 bufsize, though that does not make much sense since there are rarely large
1187 numbers of headers to add. Setting it too high prevents processing of large
1188 requests or responses. Setting it too low prevents addition of new headers
1189 to already large requests or to POST requests. It is generally wise to set it
1190 to about 1024. It is automatically readjusted to half of bufsize if it is
1191 larger than that. This means you don't have to worry about it when changing
1192 bufsize.
1193
Willy Tarreauf3045d22015-04-29 16:24:50 +02001194tune.pattern.cache-size <number>
1195 Sets the size of the pattern lookup cache to <number> entries. This is an LRU
1196 cache which reminds previous lookups and their results. It is used by ACLs
1197 and maps on slow pattern lookups, namely the ones using the "sub", "reg",
1198 "dir", "dom", "end", "bin" match methods as well as the case-insensitive
1199 strings. It applies to pattern expressions which means that it will be able
1200 to memorize the result of a lookup among all the patterns specified on a
1201 configuration line (including all those loaded from files). It automatically
1202 invalidates entries which are updated using HTTP actions or on the CLI. The
1203 default cache size is set to 10000 entries, which limits its footprint to
1204 about 5 MB on 32-bit systems and 8 MB on 64-bit systems. There is a very low
1205 risk of collision in this cache, which is in the order of the size of the
1206 cache divided by 2^64. Typically, at 10000 requests per second with the
1207 default cache size of 10000 entries, there's 1% chance that a brute force
1208 attack could cause a single collision after 60 years, or 0.1% after 6 years.
1209 This is considered much lower than the risk of a memory corruption caused by
1210 aging components. If this is not acceptable, the cache can be disabled by
1211 setting this parameter to 0.
1212
Willy Tarreaubd9a0a72011-10-23 21:14:29 +02001213tune.pipesize <number>
1214 Sets the kernel pipe buffer size to this size (in bytes). By default, pipes
1215 are the default size for the system. But sometimes when using TCP splicing,
1216 it can improve performance to increase pipe sizes, especially if it is
1217 suspected that pipes are not filled and that many calls to splice() are
1218 performed. This has an impact on the kernel's memory footprint, so this must
1219 not be changed if impacts are not understood.
1220
Willy Tarreaue803de22010-01-21 17:43:04 +01001221tune.rcvbuf.client <number>
1222tune.rcvbuf.server <number>
1223 Forces the kernel socket receive buffer size on the client or the server side
1224 to the specified value in bytes. This value applies to all TCP/HTTP frontends
1225 and backends. It should normally never be set, and the default size (0) lets
1226 the kernel autotune this value depending on the amount of available memory.
1227 However it can sometimes help to set it to very low values (eg: 4096) in
1228 order to save kernel memory by preventing it from buffering too large amounts
1229 of received data. Lower values will significantly increase CPU usage though.
1230
1231tune.sndbuf.client <number>
1232tune.sndbuf.server <number>
1233 Forces the kernel socket send buffer size on the client or the server side to
1234 the specified value in bytes. This value applies to all TCP/HTTP frontends
1235 and backends. It should normally never be set, and the default size (0) lets
1236 the kernel autotune this value depending on the amount of available memory.
1237 However it can sometimes help to set it to very low values (eg: 4096) in
1238 order to save kernel memory by preventing it from buffering too large amounts
1239 of received data. Lower values will significantly increase CPU usage though.
1240 Another use case is to prevent write timeouts with extremely slow clients due
1241 to the kernel waiting for a large part of the buffer to be read before
1242 notifying haproxy again.
1243
Willy Tarreau6ec58db2012-11-16 16:32:15 +01001244tune.ssl.cachesize <number>
Emeric Brunaf9619d2012-11-28 18:47:52 +01001245 Sets the size of the global SSL session cache, in a number of blocks. A block
1246 is large enough to contain an encoded session without peer certificate.
1247 An encoded session with peer certificate is stored in multiple blocks
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001248 depending on the size of the peer certificate. A block uses approximately
Emeric Brunaf9619d2012-11-28 18:47:52 +01001249 200 bytes of memory. The default value may be forced at build time, otherwise
1250 defaults to 20000. When the cache is full, the most idle entries are purged
1251 and reassigned. Higher values reduce the occurrence of such a purge, hence
1252 the number of CPU-intensive SSL handshakes by ensuring that all users keep
1253 their session as long as possible. All entries are pre-allocated upon startup
Emeric Brun22890a12012-12-28 14:41:32 +01001254 and are shared between all processes if "nbproc" is greater than 1. Setting
1255 this value to 0 disables the SSL session cache.
Willy Tarreau6ec58db2012-11-16 16:32:15 +01001256
Emeric Brun8dc60392014-05-09 13:52:00 +02001257tune.ssl.force-private-cache
1258 This boolean disables SSL session cache sharing between all processes. It
1259 should normally not be used since it will force many renegotiations due to
1260 clients hitting a random process. But it may be required on some operating
1261 systems where none of the SSL cache synchronization method may be used. In
1262 this case, adding a first layer of hash-based load balancing before the SSL
1263 layer might limit the impact of the lack of session sharing.
1264
Emeric Brun4f65bff2012-11-16 15:11:00 +01001265tune.ssl.lifetime <timeout>
1266 Sets how long a cached SSL session may remain valid. This time is expressed
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001267 in seconds and defaults to 300 (5 min). It is important to understand that it
Emeric Brun4f65bff2012-11-16 15:11:00 +01001268 does not guarantee that sessions will last that long, because if the cache is
1269 full, the longest idle sessions will be purged despite their configured
1270 lifetime. The real usefulness of this setting is to prevent sessions from
1271 being used for too long.
1272
Willy Tarreaubfd59462013-02-21 07:46:09 +01001273tune.ssl.maxrecord <number>
1274 Sets the maximum amount of bytes passed to SSL_write() at a time. Default
1275 value 0 means there is no limit. Over SSL/TLS, the client can decipher the
1276 data only once it has received a full record. With large records, it means
1277 that clients might have to download up to 16kB of data before starting to
1278 process them. Limiting the value can improve page load times on browsers
1279 located over high latency or low bandwidth networks. It is suggested to find
1280 optimal values which fit into 1 or 2 TCP segments (generally 1448 bytes over
1281 Ethernet with TCP timestamps enabled, or 1460 when timestamps are disabled),
1282 keeping in mind that SSL/TLS add some overhead. Typical values of 1419 and
1283 2859 gave good results during tests. Use "strace -e trace=write" to find the
Willy Tarreau7e312732014-02-12 16:35:14 +01001284 best value. Haproxy will automatically switch to this setting after an idle
1285 stream has been detected (see tune.idletimer above).
Willy Tarreaubfd59462013-02-21 07:46:09 +01001286
Remi Gacognef46cd6e2014-06-12 14:58:40 +02001287tune.ssl.default-dh-param <number>
1288 Sets the maximum size of the Diffie-Hellman parameters used for generating
1289 the ephemeral/temporary Diffie-Hellman key in case of DHE key exchange. The
1290 final size will try to match the size of the server's RSA (or DSA) key (e.g,
1291 a 2048 bits temporary DH key for a 2048 bits RSA key), but will not exceed
1292 this maximum value. Default value if 1024. Only 1024 or higher values are
1293 allowed. Higher values will increase the CPU load, and values greater than
1294 1024 bits are not supported by Java 7 and earlier clients. This value is not
Remi Gacogne47783ef2015-05-29 15:53:22 +02001295 used if static Diffie-Hellman parameters are supplied either directly
1296 in the certificate file or by using the ssl-dh-param-file parameter.
Remi Gacognef46cd6e2014-06-12 14:58:40 +02001297
Christopher Faulet31af49d2015-06-09 17:29:50 +02001298tune.ssl.ssl-ctx-cache-size <number>
1299 Sets the size of the cache used to store generated certificates to <number>
1300 entries. This is a LRU cache. Because generating a SSL certificate
1301 dynamically is expensive, they are cached. The default cache size is set to
1302 1000 entries.
1303
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02001304tune.vars.global-max-size <size>
1305tune.vars.reqres-max-size <size>
1306tune.vars.sess-max-size <size>
1307tune.vars.txn-max-size <size>
1308 These four tunes helps to manage the allowed amount of memory used by the
1309 variables system. "global" limits the memory for all the systems. "sess" limit
1310 the memory by session, "txn" limits the memory by transaction and "reqres"
1311 limits the memory for each request or response processing. during the
1312 accounting, "sess" embbed "txn" and "txn" embed "reqres".
1313
1314 By example, we considers that "tune.vars.sess-max-size" is fixed to 100,
1315 "tune.vars.txn-max-size" is fixed to 100, "tune.vars.reqres-max-size" is
1316 also fixed to 100. If we create a variable "txn.var" that contains 100 bytes,
1317 we cannot create any more variable in the other contexts.
1318
William Lallemanda509e4c2012-11-07 16:54:34 +01001319tune.zlib.memlevel <number>
1320 Sets the memLevel parameter in zlib initialization for each session. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001321 defines how much memory should be allocated for the internal compression
William Lallemanda509e4c2012-11-07 16:54:34 +01001322 state. A value of 1 uses minimum memory but is slow and reduces compression
1323 ratio, a value of 9 uses maximum memory for optimal speed. Can be a value
1324 between 1 and 9. The default value is 8.
1325
1326tune.zlib.windowsize <number>
1327 Sets the window size (the size of the history buffer) as a parameter of the
1328 zlib initialization for each session. Larger values of this parameter result
1329 in better compression at the expense of memory usage. Can be a value between
1330 8 and 15. The default value is 15.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001331
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013323.3. Debugging
1333--------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02001334
1335debug
1336 Enables debug mode which dumps to stdout all exchanges, and disables forking
1337 into background. It is the equivalent of the command-line argument "-d". It
1338 should never be used in a production configuration since it may prevent full
1339 system startup.
1340
1341quiet
1342 Do not display any message during startup. It is equivalent to the command-
1343 line argument "-q".
1344
Emeric Brunf099e792010-09-27 12:05:28 +02001345
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +010013463.4. Userlists
1347--------------
1348It is possible to control access to frontend/backend/listen sections or to
1349http stats by allowing only authenticated and authorized users. To do this,
1350it is required to create at least one userlist and to define users.
1351
1352userlist <listname>
Cyril Bonté78caf842010-03-10 22:41:43 +01001353 Creates new userlist with name <listname>. Many independent userlists can be
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001354 used to store authentication & authorization data for independent customers.
1355
1356group <groupname> [users <user>,<user>,(...)]
Cyril Bonté78caf842010-03-10 22:41:43 +01001357 Adds group <groupname> to the current userlist. It is also possible to
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001358 attach users to this group by using a comma separated list of names
1359 proceeded by "users" keyword.
1360
Cyril Bontéf0c60612010-02-06 14:44:47 +01001361user <username> [password|insecure-password <password>]
1362 [groups <group>,<group>,(...)]
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001363 Adds user <username> to the current userlist. Both secure (encrypted) and
1364 insecure (unencrypted) passwords can be used. Encrypted passwords are
Cyril Bonté78caf842010-03-10 22:41:43 +01001365 evaluated using the crypt(3) function so depending of the system's
1366 capabilities, different algorithms are supported. For example modern Glibc
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001367 based Linux system supports MD5, SHA-256, SHA-512 and of course classic,
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001368 DES-based method of encrypting passwords.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001369
1370
1371 Example:
Cyril Bontéf0c60612010-02-06 14:44:47 +01001372 userlist L1
1373 group G1 users tiger,scott
1374 group G2 users xdb,scott
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001375
Cyril Bontéf0c60612010-02-06 14:44:47 +01001376 user tiger password $6$k6y3o.eP$JlKBx9za9667qe4(...)xHSwRv6J.C0/D7cV91
1377 user scott insecure-password elgato
1378 user xdb insecure-password hello
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001379
Cyril Bontéf0c60612010-02-06 14:44:47 +01001380 userlist L2
1381 group G1
1382 group G2
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001383
Cyril Bontéf0c60612010-02-06 14:44:47 +01001384 user tiger password $6$k6y3o.eP$JlKBx(...)xHSwRv6J.C0/D7cV91 groups G1
1385 user scott insecure-password elgato groups G1,G2
1386 user xdb insecure-password hello groups G2
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01001387
1388 Please note that both lists are functionally identical.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001389
Emeric Brunf099e792010-09-27 12:05:28 +02001390
13913.5. Peers
Cyril Bontédc4d9032012-04-08 21:57:39 +02001392----------
Emeric Brun94900952015-06-11 18:25:54 +02001393It is possible to propagate entries of any data-types in stick-tables between
1394several haproxy instances over TCP connections in a multi-master fashion. Each
1395instance pushes its local updates and insertions to remote peers. The pushed
1396values overwrite remote ones without aggregation. Interrupted exchanges are
1397automatically detected and recovered from the last known point.
1398In addition, during a soft restart, the old process connects to the new one
1399using such a TCP connection to push all its entries before the new process
1400tries to connect to other peers. That ensures very fast replication during a
1401reload, it typically takes a fraction of a second even for large tables.
1402Note that Server IDs are used to identify servers remotely, so it is important
1403that configurations look similar or at least that the same IDs are forced on
1404each server on all participants.
Emeric Brunf099e792010-09-27 12:05:28 +02001405
1406peers <peersect>
Jamie Gloudon801a0a32012-08-25 00:18:33 -04001407 Creates a new peer list with name <peersect>. It is an independent section,
Emeric Brunf099e792010-09-27 12:05:28 +02001408 which is referenced by one or more stick-tables.
1409
Willy Tarreau77e4bd12015-05-01 20:02:17 +02001410disabled
1411 Disables a peers section. It disables both listening and any synchronization
1412 related to this section. This is provided to disable synchronization of stick
1413 tables without having to comment out all "peers" references.
1414
1415enable
1416 This re-enables a disabled peers section which was previously disabled.
1417
Emeric Brunf099e792010-09-27 12:05:28 +02001418peer <peername> <ip>:<port>
1419 Defines a peer inside a peers section.
1420 If <peername> is set to the local peer name (by default hostname, or forced
1421 using "-L" command line option), haproxy will listen for incoming remote peer
1422 connection on <ip>:<port>. Otherwise, <ip>:<port> defines where to connect to
1423 to join the remote peer, and <peername> is used at the protocol level to
1424 identify and validate the remote peer on the server side.
1425
1426 During a soft restart, local peer <ip>:<port> is used by the old instance to
1427 connect the new one and initiate a complete replication (teaching process).
1428
1429 It is strongly recommended to have the exact same peers declaration on all
1430 peers and to only rely on the "-L" command line argument to change the local
1431 peer name. This makes it easier to maintain coherent configuration files
1432 across all peers.
1433
William Lallemandb2f07452015-05-12 14:27:13 +02001434 You may want to reference some environment variables in the address
1435 parameter, see section 2.3 about environment variables.
Willy Tarreaudad36a32013-03-11 01:20:04 +01001436
Cyril Bontédc4d9032012-04-08 21:57:39 +02001437 Example:
Emeric Brunf099e792010-09-27 12:05:28 +02001438 peers mypeers
Willy Tarreauf7b30a92010-12-06 22:59:17 +01001439 peer haproxy1 192.168.0.1:1024
1440 peer haproxy2 192.168.0.2:1024
1441 peer haproxy3 10.2.0.1:1024
Emeric Brunf099e792010-09-27 12:05:28 +02001442
1443 backend mybackend
1444 mode tcp
1445 balance roundrobin
1446 stick-table type ip size 20k peers mypeers
1447 stick on src
1448
Willy Tarreauf7b30a92010-12-06 22:59:17 +01001449 server srv1 192.168.0.30:80
1450 server srv2 192.168.0.31:80
Emeric Brunf099e792010-09-27 12:05:28 +02001451
1452
Simon Horman51a1cf62015-02-03 13:00:44 +090014533.6. Mailers
1454------------
1455It is possible to send email alerts when the state of servers changes.
1456If configured email alerts are sent to each mailer that is configured
1457in a mailers section. Email is sent to mailers using SMTP.
1458
Pieter Baauw386a1272015-08-16 15:26:24 +02001459mailers <mailersect>
Simon Horman51a1cf62015-02-03 13:00:44 +09001460 Creates a new mailer list with the name <mailersect>. It is an
1461 independent section which is referenced by one or more proxies.
1462
1463mailer <mailername> <ip>:<port>
1464 Defines a mailer inside a mailers section.
1465
1466 Example:
1467 mailers mymailers
1468 mailer smtp1 192.168.0.1:587
1469 mailer smtp2 192.168.0.2:587
1470
1471 backend mybackend
1472 mode tcp
1473 balance roundrobin
1474
1475 email-alert mailers mymailers
1476 email-alert from test1@horms.org
1477 email-alert to test2@horms.org
1478
1479 server srv1 192.168.0.30:80
1480 server srv2 192.168.0.31:80
1481
1482
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014834. Proxies
Willy Tarreau6a06a402007-07-15 20:15:28 +02001484----------
Willy Tarreau0ba27502007-12-24 16:55:16 +01001485
Willy Tarreau6a06a402007-07-15 20:15:28 +02001486Proxy configuration can be located in a set of sections :
William Lallemand6e62fb62015-04-28 16:55:23 +02001487 - defaults [<name>]
Willy Tarreau6a06a402007-07-15 20:15:28 +02001488 - frontend <name>
1489 - backend <name>
1490 - listen <name>
1491
1492A "defaults" section sets default parameters for all other sections following
1493its declaration. Those default parameters are reset by the next "defaults"
1494section. See below for the list of parameters which can be set in a "defaults"
Willy Tarreau0ba27502007-12-24 16:55:16 +01001495section. The name is optional but its use is encouraged for better readability.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001496
1497A "frontend" section describes a set of listening sockets accepting client
1498connections.
1499
1500A "backend" section describes a set of servers to which the proxy will connect
1501to forward incoming connections.
1502
1503A "listen" section defines a complete proxy with its frontend and backend
1504parts combined in one section. It is generally useful for TCP-only traffic.
1505
Willy Tarreau0ba27502007-12-24 16:55:16 +01001506All proxy names must be formed from upper and lower case letters, digits,
1507'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
1508case-sensitive, which means that "www" and "WWW" are two different proxies.
1509
1510Historically, all proxy names could overlap, it just caused troubles in the
1511logs. Since the introduction of content switching, it is mandatory that two
1512proxies with overlapping capabilities (frontend/backend) have different names.
1513However, it is still permitted that a frontend and a backend share the same
1514name, as this configuration seems to be commonly encountered.
1515
1516Right now, two major proxy modes are supported : "tcp", also known as layer 4,
1517and "http", also known as layer 7. In layer 4 mode, HAProxy simply forwards
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001518bidirectional traffic between two sides. In layer 7 mode, HAProxy analyzes the
Willy Tarreau0ba27502007-12-24 16:55:16 +01001519protocol, and can interact with it by allowing, blocking, switching, adding,
1520modifying, or removing arbitrary contents in requests or responses, based on
1521arbitrary criteria.
1522
Willy Tarreau70dffda2014-01-30 03:07:23 +01001523In HTTP mode, the processing applied to requests and responses flowing over
1524a connection depends in the combination of the frontend's HTTP options and
1525the backend's. HAProxy supports 5 connection modes :
1526
1527 - KAL : keep alive ("option http-keep-alive") which is the default mode : all
1528 requests and responses are processed, and connections remain open but idle
1529 between responses and new requests.
1530
1531 - TUN: tunnel ("option http-tunnel") : this was the default mode for versions
1532 1.0 to 1.5-dev21 : only the first request and response are processed, and
1533 everything else is forwarded with no analysis at all. This mode should not
1534 be used as it creates lots of trouble with logging and HTTP processing.
1535
1536 - PCL: passive close ("option httpclose") : exactly the same as tunnel mode,
1537 but with "Connection: close" appended in both directions to try to make
1538 both ends close after the first request/response exchange.
1539
1540 - SCL: server close ("option http-server-close") : the server-facing
1541 connection is closed after the end of the response is received, but the
1542 client-facing connection remains open.
1543
1544 - FCL: forced close ("option forceclose") : the connection is actively closed
1545 after the end of the response.
1546
1547The effective mode that will be applied to a connection passing through a
1548frontend and a backend can be determined by both proxy modes according to the
1549following matrix, but in short, the modes are symmetric, keep-alive is the
1550weakest option and force close is the strongest.
1551
1552 Backend mode
1553
1554 | KAL | TUN | PCL | SCL | FCL
1555 ----+-----+-----+-----+-----+----
1556 KAL | KAL | TUN | PCL | SCL | FCL
1557 ----+-----+-----+-----+-----+----
1558 TUN | TUN | TUN | PCL | SCL | FCL
1559 Frontend ----+-----+-----+-----+-----+----
1560 mode PCL | PCL | PCL | PCL | FCL | FCL
1561 ----+-----+-----+-----+-----+----
1562 SCL | SCL | SCL | FCL | SCL | FCL
1563 ----+-----+-----+-----+-----+----
1564 FCL | FCL | FCL | FCL | FCL | FCL
1565
Willy Tarreau0ba27502007-12-24 16:55:16 +01001566
Willy Tarreau70dffda2014-01-30 03:07:23 +01001567
Willy Tarreauc57f0e22009-05-10 13:12:33 +020015684.1. Proxy keywords matrix
1569--------------------------
Willy Tarreau0ba27502007-12-24 16:55:16 +01001570
Willy Tarreauc57f0e22009-05-10 13:12:33 +02001571The following list of keywords is supported. Most of them may only be used in a
1572limited set of section types. Some of them are marked as "deprecated" because
1573they are inherited from an old syntax which may be confusing or functionally
1574limited, and there are new recommended keywords to replace them. Keywords
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001575marked with "(*)" can be optionally inverted using the "no" prefix, eg. "no
Willy Tarreauc57f0e22009-05-10 13:12:33 +02001576option contstats". This makes sense when the option has been enabled by default
Willy Tarreau3842f002009-06-14 11:39:52 +02001577and must be disabled for a specific instance. Such options may also be prefixed
1578with "default" in order to restore default settings regardless of what has been
1579specified in a previous "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001580
Willy Tarreau6a06a402007-07-15 20:15:28 +02001581
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001582 keyword defaults frontend listen backend
1583------------------------------------+----------+----------+---------+---------
1584acl - X X X
Willy Tarreau294d0f02015-08-10 19:40:12 +02001585appsession - - - -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001586backlog X X X -
1587balance X - X X
1588bind - X X -
1589bind-process X X X X
1590block - X X X
1591capture cookie - X X -
1592capture request header - X X -
1593capture response header - X X -
1594clitimeout (deprecated) X X X -
William Lallemand82fe75c2012-10-23 10:25:10 +02001595compression X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001596contimeout (deprecated) X - X X
1597cookie X - X X
Thierry FOURNIERa0a1b752015-05-26 17:44:32 +02001598declare capture - X X -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001599default-server X - X X
1600default_backend X X X -
1601description - X X X
1602disabled X X X X
1603dispatch - - X X
Simon Horman51a1cf62015-02-03 13:00:44 +09001604email-alert from X X X X
Simon Horman64e34162015-02-06 11:11:57 +09001605email-alert level X X X X
Simon Horman51a1cf62015-02-03 13:00:44 +09001606email-alert mailers X X X X
1607email-alert myhostname X X X X
1608email-alert to X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001609enabled X X X X
1610errorfile X X X X
1611errorloc X X X X
1612errorloc302 X X X X
1613-- keyword -------------------------- defaults - frontend - listen -- backend -
1614errorloc303 X X X X
Cyril Bonté0d4bf012010-04-25 23:21:46 +02001615force-persist - X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001616fullconn X - X X
1617grace X X X X
1618hash-type X - X X
1619http-check disable-on-404 X - X X
Willy Tarreaubd741542010-03-16 18:46:54 +01001620http-check expect - - X X
Willy Tarreau7ab6aff2010-10-12 06:30:16 +02001621http-check send-state X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001622http-request - X X X
Willy Tarreaue365c0b2013-06-11 16:06:12 +02001623http-response - X X X
Willy Tarreau30631952015-08-06 15:05:24 +02001624http-reuse X - X X
Baptiste Assmann2c42ef52013-10-09 21:57:02 +02001625http-send-name-header - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001626id - X X X
Cyril Bonté0d4bf012010-04-25 23:21:46 +02001627ignore-persist - X X X
William Lallemand0f99e342011-10-12 17:50:54 +02001628log (*) X X X X
Willy Tarreaufb4e7ea2015-01-07 14:55:17 +01001629log-format X X X -
Willy Tarreau094af4e2015-01-07 15:03:42 +01001630log-tag X X X X
Willy Tarreauc35362a2014-04-25 13:58:37 +02001631max-keep-alive-queue X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001632maxconn X X X -
1633mode X X X X
1634monitor fail - X X -
1635monitor-net X X X -
1636monitor-uri X X X -
1637option abortonclose (*) X - X X
1638option accept-invalid-http-request (*) X X X -
1639option accept-invalid-http-response (*) X - X X
1640option allbackups (*) X - X X
1641option checkcache (*) X - X X
1642option clitcpka (*) X X X -
1643option contstats (*) X X X -
1644option dontlog-normal (*) X X X -
1645option dontlognull (*) X X X -
1646option forceclose (*) X X X X
1647-- keyword -------------------------- defaults - frontend - listen -- backend -
1648option forwardfor X X X X
Willy Tarreau9fbe18e2015-05-01 22:42:08 +02001649option http-buffer-request (*) X X X X
Willy Tarreau82649f92015-05-01 22:40:51 +02001650option http-ignore-probes (*) X X X -
Willy Tarreau16bfb022010-01-16 19:48:41 +01001651option http-keep-alive (*) X X X X
Willy Tarreau96e31212011-05-30 18:10:30 +02001652option http-no-delay (*) X X X X
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02001653option http-pretend-keepalive (*) X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001654option http-server-close (*) X X X X
Willy Tarreau02bce8b2014-01-30 00:15:28 +01001655option http-tunnel (*) X X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001656option http-use-proxy-header (*) X X X -
1657option httpchk X - X X
1658option httpclose (*) X X X X
1659option httplog X X X X
1660option http_proxy (*) X X X X
Jamie Gloudon801a0a32012-08-25 00:18:33 -04001661option independent-streams (*) X X X X
Gabor Lekenyb4c81e42010-09-29 18:17:05 +02001662option ldap-check X - X X
Simon Horman98637e52014-06-20 12:30:16 +09001663option external-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001664option log-health-checks (*) X - X X
1665option log-separate-errors (*) X X X -
1666option logasap (*) X X X -
1667option mysql-check X - X X
Rauf Kuliyev38b41562011-01-04 15:14:13 +01001668option pgsql-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001669option nolinger (*) X X X X
1670option originalto X X X X
1671option persist (*) X - X X
1672option redispatch (*) X - X X
Hervé COMMOWICKec032d62011-08-05 16:23:48 +02001673option redis-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001674option smtpchk X - X X
1675option socket-stats (*) X X X -
1676option splice-auto (*) X X X X
1677option splice-request (*) X X X X
1678option splice-response (*) X X X X
1679option srvtcpka (*) X - X X
1680option ssl-hello-chk X - X X
1681-- keyword -------------------------- defaults - frontend - listen -- backend -
Willy Tarreaued179852013-12-16 01:07:00 +01001682option tcp-check X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001683option tcp-smart-accept (*) X X X -
1684option tcp-smart-connect (*) X - X X
1685option tcpka X X X X
1686option tcplog X X X X
1687option transparent (*) X - X X
Simon Horman98637e52014-06-20 12:30:16 +09001688external-check command X - X X
1689external-check path X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001690persist rdp-cookie X - X X
1691rate-limit sessions X X X -
1692redirect - X X X
1693redisp (deprecated) X - X X
1694redispatch (deprecated) X - X X
1695reqadd - X X X
1696reqallow - X X X
1697reqdel - X X X
1698reqdeny - X X X
1699reqiallow - X X X
1700reqidel - X X X
1701reqideny - X X X
1702reqipass - X X X
1703reqirep - X X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001704reqitarpit - X X X
1705reqpass - X X X
1706reqrep - X X X
1707-- keyword -------------------------- defaults - frontend - listen -- backend -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001708reqtarpit - X X X
1709retries X - X X
1710rspadd - X X X
1711rspdel - X X X
1712rspdeny - X X X
1713rspidel - X X X
1714rspideny - X X X
1715rspirep - X X X
1716rsprep - X X X
1717server - - X X
1718source X - X X
1719srvtimeout (deprecated) X - X X
Cyril Bonté66c327d2010-10-12 00:14:37 +02001720stats admin - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001721stats auth X - X X
1722stats enable X - X X
1723stats hide-version X - X X
Cyril Bonté2be1b3f2010-09-30 23:46:30 +02001724stats http-request - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001725stats realm X - X X
1726stats refresh X - X X
1727stats scope X - X X
1728stats show-desc X - X X
1729stats show-legends X - X X
1730stats show-node X - X X
1731stats uri X - X X
1732-- keyword -------------------------- defaults - frontend - listen -- backend -
1733stick match - - X X
1734stick on - - X X
1735stick store-request - - X X
Willy Tarreaud8dc99f2011-07-01 11:33:25 +02001736stick store-response - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001737stick-table - - X X
Willy Tarreau938c7fe2014-04-25 14:21:39 +02001738tcp-check connect - - X X
1739tcp-check expect - - X X
1740tcp-check send - - X X
1741tcp-check send-binary - - X X
Willy Tarreaue9656522010-08-17 15:40:09 +02001742tcp-request connection - X X -
1743tcp-request content - X X X
Willy Tarreaua56235c2010-09-14 11:31:36 +02001744tcp-request inspect-delay - X X X
Emeric Brun0a3b67f2010-09-24 15:34:53 +02001745tcp-response content - - X X
1746tcp-response inspect-delay - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001747timeout check X - X X
1748timeout client X X X -
Willy Tarreau05cdd962014-05-10 14:30:07 +02001749timeout client-fin X X X -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001750timeout clitimeout (deprecated) X X X -
1751timeout connect X - X X
1752timeout contimeout (deprecated) X - X X
1753timeout http-keep-alive X X X X
1754timeout http-request X X X X
1755timeout queue X - X X
1756timeout server X - X X
Willy Tarreau05cdd962014-05-10 14:30:07 +02001757timeout server-fin X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001758timeout srvtimeout (deprecated) X - X X
1759timeout tarpit X X X X
Willy Tarreauce887fd2012-05-12 12:50:00 +02001760timeout tunnel X - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001761transparent (deprecated) X - X X
William Lallemanda73203e2012-03-12 12:48:57 +01001762unique-id-format X X X -
1763unique-id-header X X X -
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001764use_backend - X X -
Willy Tarreau4a5cade2012-04-05 21:09:48 +02001765use-server - - X X
Willy Tarreau5c6f7b32010-02-26 13:34:29 +01001766------------------------------------+----------+----------+---------+---------
1767 keyword defaults frontend listen backend
Willy Tarreau6a06a402007-07-15 20:15:28 +02001768
Willy Tarreau0ba27502007-12-24 16:55:16 +01001769
Willy Tarreauc57f0e22009-05-10 13:12:33 +020017704.2. Alphabetically sorted keywords reference
1771---------------------------------------------
Willy Tarreau0ba27502007-12-24 16:55:16 +01001772
1773This section provides a description of each keyword and its usage.
1774
1775
1776acl <aclname> <criterion> [flags] [operator] <value> ...
1777 Declare or complete an access list.
1778 May be used in sections : defaults | frontend | listen | backend
1779 no | yes | yes | yes
1780 Example:
1781 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
1782 acl invalid_src src_port 0:1023
1783 acl local_dst hdr(host) -i localhost
1784
Willy Tarreauc57f0e22009-05-10 13:12:33 +02001785 See section 7 about ACL usage.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001786
1787
Cyril Bontéb21570a2009-11-29 20:04:48 +01001788appsession <cookie> len <length> timeout <holdtime>
1789 [request-learn] [prefix] [mode <path-parameters|query-string>]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001790 Define session stickiness on an existing application cookie.
1791 May be used in sections : defaults | frontend | listen | backend
1792 no | no | yes | yes
1793 Arguments :
1794 <cookie> this is the name of the cookie used by the application and which
1795 HAProxy will have to learn for each new session.
1796
Cyril Bontéb21570a2009-11-29 20:04:48 +01001797 <length> this is the max number of characters that will be memorized and
Willy Tarreau0ba27502007-12-24 16:55:16 +01001798 checked in each cookie value.
1799
1800 <holdtime> this is the time after which the cookie will be removed from
1801 memory if unused. If no unit is specified, this time is in
1802 milliseconds.
1803
Cyril Bontébf47aeb2009-10-15 00:15:40 +02001804 request-learn
1805 If this option is specified, then haproxy will be able to learn
1806 the cookie found in the request in case the server does not
1807 specify any in response. This is typically what happens with
1808 PHPSESSID cookies, or when haproxy's session expires before
1809 the application's session and the correct server is selected.
1810 It is recommended to specify this option to improve reliability.
1811
Cyril Bontéb21570a2009-11-29 20:04:48 +01001812 prefix When this option is specified, haproxy will match on the cookie
1813 prefix (or URL parameter prefix). The appsession value is the
1814 data following this prefix.
1815
1816 Example :
1817 appsession ASPSESSIONID len 64 timeout 3h prefix
1818
1819 This will match the cookie ASPSESSIONIDXXXX=XXXXX,
1820 the appsession value will be XXXX=XXXXX.
1821
1822 mode This option allows to change the URL parser mode.
1823 2 modes are currently supported :
1824 - path-parameters :
1825 The parser looks for the appsession in the path parameters
1826 part (each parameter is separated by a semi-colon), which is
1827 convenient for JSESSIONID for example.
1828 This is the default mode if the option is not set.
1829 - query-string :
1830 In this mode, the parser will look for the appsession in the
1831 query string.
1832
Willy Tarreau294d0f02015-08-10 19:40:12 +02001833 As of version 1.6, appsessions was removed. It is more flexible and more
1834 convenient to use stick-tables instead, and stick-tables support multi-master
1835 replication and data conservation across reloads, which appsessions did not.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001836
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01001837 See also : "cookie", "capture cookie", "balance", "stick", "stick-table",
1838 "ignore-persist", "nbproc" and "bind-process".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001839
1840
Willy Tarreauc73ce2b2008-01-06 10:55:10 +01001841backlog <conns>
1842 Give hints to the system about the approximate listen backlog desired size
1843 May be used in sections : defaults | frontend | listen | backend
1844 yes | yes | yes | no
1845 Arguments :
1846 <conns> is the number of pending connections. Depending on the operating
1847 system, it may represent the number of already acknowledged
Cyril Bontédc4d9032012-04-08 21:57:39 +02001848 connections, of non-acknowledged ones, or both.
Willy Tarreauc73ce2b2008-01-06 10:55:10 +01001849
1850 In order to protect against SYN flood attacks, one solution is to increase
1851 the system's SYN backlog size. Depending on the system, sometimes it is just
1852 tunable via a system parameter, sometimes it is not adjustable at all, and
1853 sometimes the system relies on hints given by the application at the time of
1854 the listen() syscall. By default, HAProxy passes the frontend's maxconn value
1855 to the listen() syscall. On systems which can make use of this value, it can
1856 sometimes be useful to be able to specify a different value, hence this
1857 backlog parameter.
1858
1859 On Linux 2.4, the parameter is ignored by the system. On Linux 2.6, it is
1860 used as a hint and the system accepts up to the smallest greater power of
1861 two, and never more than some limits (usually 32768).
1862
1863 See also : "maxconn" and the target operating system's tuning guide.
1864
1865
Willy Tarreau0ba27502007-12-24 16:55:16 +01001866balance <algorithm> [ <arguments> ]
Willy Tarreau226071e2014-04-10 11:55:45 +02001867balance url_param <param> [check_post]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001868 Define the load balancing algorithm to be used in a backend.
1869 May be used in sections : defaults | frontend | listen | backend
1870 yes | no | yes | yes
1871 Arguments :
1872 <algorithm> is the algorithm used to select a server when doing load
1873 balancing. This only applies when no persistence information
1874 is available, or when a connection is redispatched to another
1875 server. <algorithm> may be one of the following :
1876
1877 roundrobin Each server is used in turns, according to their weights.
1878 This is the smoothest and fairest algorithm when the server's
1879 processing time remains equally distributed. This algorithm
1880 is dynamic, which means that server weights may be adjusted
Willy Tarreau9757a382009-10-03 12:56:50 +02001881 on the fly for slow starts for instance. It is limited by
Godbacha34bdc02013-07-22 07:44:53 +08001882 design to 4095 active servers per backend. Note that in some
Willy Tarreau9757a382009-10-03 12:56:50 +02001883 large farms, when a server becomes up after having been down
1884 for a very short time, it may sometimes take a few hundreds
1885 requests for it to be re-integrated into the farm and start
1886 receiving traffic. This is normal, though very rare. It is
1887 indicated here in case you would have the chance to observe
1888 it, so that you don't worry.
1889
1890 static-rr Each server is used in turns, according to their weights.
1891 This algorithm is as similar to roundrobin except that it is
1892 static, which means that changing a server's weight on the
1893 fly will have no effect. On the other hand, it has no design
1894 limitation on the number of servers, and when a server goes
1895 up, it is always immediately reintroduced into the farm, once
1896 the full map is recomputed. It also uses slightly less CPU to
1897 run (around -1%).
Willy Tarreau0ba27502007-12-24 16:55:16 +01001898
Willy Tarreau2d2a7f82008-03-17 12:07:56 +01001899 leastconn The server with the lowest number of connections receives the
1900 connection. Round-robin is performed within groups of servers
1901 of the same load to ensure that all servers will be used. Use
1902 of this algorithm is recommended where very long sessions are
1903 expected, such as LDAP, SQL, TSE, etc... but is not very well
1904 suited for protocols using short sessions such as HTTP. This
1905 algorithm is dynamic, which means that server weights may be
1906 adjusted on the fly for slow starts for instance.
1907
Willy Tarreauf09c6602012-02-13 17:12:08 +01001908 first The first server with available connection slots receives the
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03001909 connection. The servers are chosen from the lowest numeric
Willy Tarreauf09c6602012-02-13 17:12:08 +01001910 identifier to the highest (see server parameter "id"), which
1911 defaults to the server's position in the farm. Once a server
Willy Tarreau64559c52012-04-07 09:08:45 +02001912 reaches its maxconn value, the next server is used. It does
Willy Tarreauf09c6602012-02-13 17:12:08 +01001913 not make sense to use this algorithm without setting maxconn.
1914 The purpose of this algorithm is to always use the smallest
1915 number of servers so that extra servers can be powered off
1916 during non-intensive hours. This algorithm ignores the server
1917 weight, and brings more benefit to long session such as RDP
Willy Tarreau64559c52012-04-07 09:08:45 +02001918 or IMAP than HTTP, though it can be useful there too. In
1919 order to use this algorithm efficiently, it is recommended
1920 that a cloud controller regularly checks server usage to turn
1921 them off when unused, and regularly checks backend queue to
1922 turn new servers on when the queue inflates. Alternatively,
1923 using "http-check send-state" may inform servers on the load.
Willy Tarreauf09c6602012-02-13 17:12:08 +01001924
Willy Tarreau0ba27502007-12-24 16:55:16 +01001925 source The source IP address is hashed and divided by the total
1926 weight of the running servers to designate which server will
1927 receive the request. This ensures that the same client IP
1928 address will always reach the same server as long as no
1929 server goes down or up. If the hash result changes due to the
1930 number of running servers changing, many clients will be
1931 directed to a different server. This algorithm is generally
1932 used in TCP mode where no cookie may be inserted. It may also
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01001933 be used on the Internet to provide a best-effort stickiness
Willy Tarreau0ba27502007-12-24 16:55:16 +01001934 to clients which refuse session cookies. This algorithm is
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001935 static by default, which means that changing a server's
1936 weight on the fly will have no effect, but this can be
1937 changed using "hash-type".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001938
Oskar Stolc8dc41842012-05-19 10:19:54 +01001939 uri This algorithm hashes either the left part of the URI (before
1940 the question mark) or the whole URI (if the "whole" parameter
1941 is present) and divides the hash value by the total weight of
1942 the running servers. The result designates which server will
1943 receive the request. This ensures that the same URI will
1944 always be directed to the same server as long as no server
1945 goes up or down. This is used with proxy caches and
1946 anti-virus proxies in order to maximize the cache hit rate.
1947 Note that this algorithm may only be used in an HTTP backend.
1948 This algorithm is static by default, which means that
1949 changing a server's weight on the fly will have no effect,
1950 but this can be changed using "hash-type".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001951
Oskar Stolc8dc41842012-05-19 10:19:54 +01001952 This algorithm supports two optional parameters "len" and
Marek Majkowski9c30fc12008-04-27 23:25:55 +02001953 "depth", both followed by a positive integer number. These
1954 options may be helpful when it is needed to balance servers
1955 based on the beginning of the URI only. The "len" parameter
1956 indicates that the algorithm should only consider that many
1957 characters at the beginning of the URI to compute the hash.
1958 Note that having "len" set to 1 rarely makes sense since most
1959 URIs start with a leading "/".
1960
1961 The "depth" parameter indicates the maximum directory depth
1962 to be used to compute the hash. One level is counted for each
1963 slash in the request. If both parameters are specified, the
1964 evaluation stops when either is reached.
1965
Willy Tarreau0ba27502007-12-24 16:55:16 +01001966 url_param The URL parameter specified in argument will be looked up in
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001967 the query string of each HTTP GET request.
1968
1969 If the modifier "check_post" is used, then an HTTP POST
Cyril Bontédc4d9032012-04-08 21:57:39 +02001970 request entity will be searched for the parameter argument,
1971 when it is not found in a query string after a question mark
Willy Tarreau226071e2014-04-10 11:55:45 +02001972 ('?') in the URL. The message body will only start to be
1973 analyzed once either the advertised amount of data has been
1974 received or the request buffer is full. In the unlikely event
1975 that chunked encoding is used, only the first chunk is
Cyril Bontédc4d9032012-04-08 21:57:39 +02001976 scanned. Parameter values separated by a chunk boundary, may
Willy Tarreau226071e2014-04-10 11:55:45 +02001977 be randomly balanced if at all. This keyword used to support
1978 an optional <max_wait> parameter which is now ignored.
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02001979
1980 If the parameter is found followed by an equal sign ('=') and
1981 a value, then the value is hashed and divided by the total
1982 weight of the running servers. The result designates which
1983 server will receive the request.
1984
1985 This is used to track user identifiers in requests and ensure
1986 that a same user ID will always be sent to the same server as
1987 long as no server goes up or down. If no value is found or if
1988 the parameter is not found, then a round robin algorithm is
1989 applied. Note that this algorithm may only be used in an HTTP
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02001990 backend. This algorithm is static by default, which means
1991 that changing a server's weight on the fly will have no
1992 effect, but this can be changed using "hash-type".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001993
Cyril Bontédc4d9032012-04-08 21:57:39 +02001994 hdr(<name>) The HTTP header <name> will be looked up in each HTTP
1995 request. Just as with the equivalent ACL 'hdr()' function,
1996 the header name in parenthesis is not case sensitive. If the
1997 header is absent or if it does not contain any value, the
1998 roundrobin algorithm is applied instead.
Benoitaffb4812009-03-25 13:02:10 +01001999
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002000 An optional 'use_domain_only' parameter is available, for
Benoitaffb4812009-03-25 13:02:10 +01002001 reducing the hash algorithm to the main domain part with some
2002 specific headers such as 'Host'. For instance, in the Host
2003 value "haproxy.1wt.eu", only "1wt" will be considered.
2004
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02002005 This algorithm is static by default, which means that
2006 changing a server's weight on the fly will have no effect,
2007 but this can be changed using "hash-type".
2008
Emeric Brun736aa232009-06-30 17:56:00 +02002009 rdp-cookie
Hervé COMMOWICKa3eb39c2011-08-05 18:48:51 +02002010 rdp-cookie(<name>)
Emeric Brun736aa232009-06-30 17:56:00 +02002011 The RDP cookie <name> (or "mstshash" if omitted) will be
2012 looked up and hashed for each incoming TCP request. Just as
2013 with the equivalent ACL 'req_rdp_cookie()' function, the name
2014 is not case-sensitive. This mechanism is useful as a degraded
2015 persistence mode, as it makes it possible to always send the
2016 same user (or the same session ID) to the same server. If the
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002017 cookie is not found, the normal roundrobin algorithm is
Emeric Brun736aa232009-06-30 17:56:00 +02002018 used instead.
2019
2020 Note that for this to work, the frontend must ensure that an
2021 RDP cookie is already present in the request buffer. For this
2022 you must use 'tcp-request content accept' rule combined with
2023 a 'req_rdp_cookie_cnt' ACL.
2024
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02002025 This algorithm is static by default, which means that
2026 changing a server's weight on the fly will have no effect,
2027 but this can be changed using "hash-type".
2028
Cyril Bontédc4d9032012-04-08 21:57:39 +02002029 See also the rdp_cookie pattern fetch function.
Simon Hormanab814e02011-06-24 14:50:20 +09002030
Willy Tarreau0ba27502007-12-24 16:55:16 +01002031 <arguments> is an optional list of arguments which may be needed by some
Marek Majkowski9c30fc12008-04-27 23:25:55 +02002032 algorithms. Right now, only "url_param" and "uri" support an
2033 optional argument.
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02002034
Willy Tarreau3cd9af22009-03-15 14:06:41 +01002035 The load balancing algorithm of a backend is set to roundrobin when no other
2036 algorithm, mode nor option have been set. The algorithm may only be set once
2037 for each backend.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002038
2039 Examples :
2040 balance roundrobin
2041 balance url_param userid
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02002042 balance url_param session_id check_post 64
Benoitaffb4812009-03-25 13:02:10 +01002043 balance hdr(User-Agent)
2044 balance hdr(host)
2045 balance hdr(Host) use_domain_only
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02002046
2047 Note: the following caveats and limitations on using the "check_post"
2048 extension with "url_param" must be considered :
2049
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002050 - all POST requests are eligible for consideration, because there is no way
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02002051 to determine if the parameters will be found in the body or entity which
2052 may contain binary data. Therefore another method may be required to
2053 restrict consideration of POST requests that have no URL parameters in
2054 the body. (see acl reqideny http_end)
2055
2056 - using a <max_wait> value larger than the request buffer size does not
2057 make sense and is useless. The buffer size is set at build time, and
2058 defaults to 16 kB.
2059
2060 - Content-Encoding is not supported, the parameter search will probably
2061 fail; and load balancing will fall back to Round Robin.
2062
2063 - Expect: 100-continue is not supported, load balancing will fall back to
2064 Round Robin.
2065
2066 - Transfer-Encoding (RFC2616 3.6.1) is only supported in the first chunk.
2067 If the entire parameter value is not present in the first chunk, the
2068 selection of server is undefined (actually, defined by how little
2069 actually appeared in the first chunk).
2070
2071 - This feature does not support generation of a 100, 411 or 501 response.
2072
2073 - In some cases, requesting "check_post" MAY attempt to scan the entire
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002074 contents of a message body. Scanning normally terminates when linear
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +02002075 white space or control characters are found, indicating the end of what
2076 might be a URL parameter list. This is probably not a concern with SGML
2077 type message bodies.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002078
Willy Tarreau294d0f02015-08-10 19:40:12 +02002079 See also : "dispatch", "cookie", "transparent", "hash-type" and "http_proxy".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002080
2081
Willy Tarreaub6205fd2012-09-24 12:27:33 +02002082bind [<address>]:<port_range> [, ...] [param*]
2083bind /<path> [, ...] [param*]
Willy Tarreau0ba27502007-12-24 16:55:16 +01002084 Define one or several listening addresses and/or ports in a frontend.
2085 May be used in sections : defaults | frontend | listen | backend
2086 no | yes | yes | no
2087 Arguments :
Willy Tarreaub1e52e82008-01-13 14:49:51 +01002088 <address> is optional and can be a host name, an IPv4 address, an IPv6
2089 address, or '*'. It designates the address the frontend will
2090 listen on. If unset, all IPv4 addresses of the system will be
2091 listened on. The same will apply for '*' or the system's
David du Colombier9c938da2011-03-17 10:40:27 +01002092 special address "0.0.0.0". The IPv6 equivalent is '::'.
Willy Tarreau24709282013-03-10 21:32:12 +01002093 Optionally, an address family prefix may be used before the
2094 address to force the family regardless of the address format,
2095 which can be useful to specify a path to a unix socket with
2096 no slash ('/'). Currently supported prefixes are :
2097 - 'ipv4@' -> address is always IPv4
2098 - 'ipv6@' -> address is always IPv6
2099 - 'unix@' -> address is a path to a local unix socket
Willy Tarreau70f72e02014-07-08 00:37:50 +02002100 - 'abns@' -> address is in abstract namespace (Linux only).
2101 Note: since abstract sockets are not "rebindable", they
2102 do not cope well with multi-process mode during
2103 soft-restart, so it is better to avoid them if
2104 nbproc is greater than 1. The effect is that if the
2105 new process fails to start, only one of the old ones
2106 will be able to rebind to the socket.
Willy Tarreau40aa0702013-03-10 23:51:38 +01002107 - 'fd@<n>' -> use file descriptor <n> inherited from the
2108 parent. The fd must be bound and may or may not already
2109 be listening.
William Lallemandb2f07452015-05-12 14:27:13 +02002110 You may want to reference some environment variables in the
2111 address parameter, see section 2.3 about environment
2112 variables.
Willy Tarreaub1e52e82008-01-13 14:49:51 +01002113
Willy Tarreauc5011ca2010-03-22 11:53:56 +01002114 <port_range> is either a unique TCP port, or a port range for which the
2115 proxy will accept connections for the IP address specified
Willy Tarreauceb24bc2010-11-09 12:46:41 +01002116 above. The port is mandatory for TCP listeners. Note that in
2117 the case of an IPv6 address, the port is always the number
2118 after the last colon (':'). A range can either be :
Willy Tarreauc5011ca2010-03-22 11:53:56 +01002119 - a numerical port (ex: '80')
2120 - a dash-delimited ports range explicitly stating the lower
2121 and upper bounds (ex: '2000-2100') which are included in
2122 the range.
2123
2124 Particular care must be taken against port ranges, because
2125 every <address:port> couple consumes one socket (= a file
2126 descriptor), so it's easy to consume lots of descriptors
2127 with a simple range, and to run out of sockets. Also, each
2128 <address:port> couple must be used only once among all
2129 instances running on a same system. Please note that binding
2130 to ports lower than 1024 generally require particular
Jamie Gloudon801a0a32012-08-25 00:18:33 -04002131 privileges to start the program, which are independent of
Willy Tarreauc5011ca2010-03-22 11:53:56 +01002132 the 'uid' parameter.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002133
Willy Tarreauceb24bc2010-11-09 12:46:41 +01002134 <path> is a UNIX socket path beginning with a slash ('/'). This is
2135 alternative to the TCP listening port. Haproxy will then
2136 receive UNIX connections on the socket located at this place.
2137 The path must begin with a slash and by default is absolute.
2138 It can be relative to the prefix defined by "unix-bind" in
2139 the global section. Note that the total length of the prefix
2140 followed by the socket path cannot exceed some system limits
2141 for UNIX sockets, which commonly are set to 107 characters.
2142
Willy Tarreaub6205fd2012-09-24 12:27:33 +02002143 <param*> is a list of parameters common to all sockets declared on the
2144 same line. These numerous parameters depend on OS and build
2145 options and have a complete section dedicated to them. Please
2146 refer to section 5 to for more details.
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02002147
Willy Tarreau0ba27502007-12-24 16:55:16 +01002148 It is possible to specify a list of address:port combinations delimited by
2149 commas. The frontend will then listen on all of these addresses. There is no
2150 fixed limit to the number of addresses and ports which can be listened on in
2151 a frontend, as well as there is no limit to the number of "bind" statements
2152 in a frontend.
2153
2154 Example :
2155 listen http_proxy
2156 bind :80,:443
2157 bind 10.0.0.1:10080,10.0.0.1:10443
Willy Tarreauceb24bc2010-11-09 12:46:41 +01002158 bind /var/run/ssl-frontend.sock user root mode 600 accept-proxy
Willy Tarreau0ba27502007-12-24 16:55:16 +01002159
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02002160 listen http_https_proxy
2161 bind :80
Cyril Bonté0d44fc62012-10-09 22:45:33 +02002162 bind :443 ssl crt /etc/haproxy/site.pem
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02002163
Willy Tarreau24709282013-03-10 21:32:12 +01002164 listen http_https_proxy_explicit
2165 bind ipv6@:80
2166 bind ipv4@public_ssl:443 ssl crt /etc/haproxy/site.pem
2167 bind unix@ssl-frontend.sock user root mode 600 accept-proxy
2168
Willy Tarreaudad36a32013-03-11 01:20:04 +01002169 listen external_bind_app1
William Lallemandb2f07452015-05-12 14:27:13 +02002170 bind "fd@${FD_APP1}"
Willy Tarreaudad36a32013-03-11 01:20:04 +01002171
Willy Tarreauceb24bc2010-11-09 12:46:41 +01002172 See also : "source", "option forwardfor", "unix-bind" and the PROXY protocol
Willy Tarreaub6205fd2012-09-24 12:27:33 +02002173 documentation, and section 5 about bind options.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002174
2175
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002176bind-process [ all | odd | even | <number 1-64>[-<number 1-64>] ] ...
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002177 Limit visibility of an instance to a certain set of processes numbers.
2178 May be used in sections : defaults | frontend | listen | backend
2179 yes | yes | yes | yes
2180 Arguments :
2181 all All process will see this instance. This is the default. It
2182 may be used to override a default value.
2183
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002184 odd This instance will be enabled on processes 1,3,5,...63. This
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002185 option may be combined with other numbers.
2186
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002187 even This instance will be enabled on processes 2,4,6,...64. This
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002188 option may be combined with other numbers. Do not use it
2189 with less than 2 processes otherwise some instances might be
2190 missing from all processes.
2191
Willy Tarreau110ecc12012-11-15 17:50:01 +01002192 number The instance will be enabled on this process number or range,
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002193 whose values must all be between 1 and 32 or 64 depending on
Willy Tarreau102df612014-05-07 23:56:38 +02002194 the machine's word size. If a proxy is bound to process
2195 numbers greater than the configured global.nbproc, it will
2196 either be forced to process #1 if a single process was
2197 specified, or to all processes otherwise.
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002198
2199 This keyword limits binding of certain instances to certain processes. This
2200 is useful in order not to have too many processes listening to the same
2201 ports. For instance, on a dual-core machine, it might make sense to set
2202 'nbproc 2' in the global section, then distributes the listeners among 'odd'
2203 and 'even' instances.
2204
Willy Tarreaua9db57e2013-01-18 11:29:29 +01002205 At the moment, it is not possible to reference more than 32 or 64 processes
2206 using this keyword, but this should be more than enough for most setups.
2207 Please note that 'all' really means all processes regardless of the machine's
2208 word size, and is not limited to the first 32 or 64.
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002209
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02002210 Each "bind" line may further be limited to a subset of the proxy's processes,
2211 please consult the "process" bind keyword in section 5.1.
2212
Willy Tarreaub369a042014-09-16 13:21:03 +02002213 When a frontend has no explicit "bind-process" line, it tries to bind to all
2214 the processes referenced by its "bind" lines. That means that frontends can
2215 easily adapt to their listeners' processes.
2216
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002217 If some backends are referenced by frontends bound to other processes, the
2218 backend automatically inherits the frontend's processes.
2219
2220 Example :
2221 listen app_ip1
2222 bind 10.0.0.1:80
Willy Tarreaubfcd3112010-10-23 11:22:08 +02002223 bind-process odd
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002224
2225 listen app_ip2
2226 bind 10.0.0.2:80
Willy Tarreaubfcd3112010-10-23 11:22:08 +02002227 bind-process even
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002228
2229 listen management
2230 bind 10.0.0.3:80
Willy Tarreaubfcd3112010-10-23 11:22:08 +02002231 bind-process 1 2 3 4
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002232
Willy Tarreau110ecc12012-11-15 17:50:01 +01002233 listen management
2234 bind 10.0.0.4:80
2235 bind-process 1-4
2236
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02002237 See also : "nbproc" in global section, and "process" in section 5.1.
Willy Tarreau0b9c02c2009-02-04 22:05:05 +01002238
2239
Willy Tarreau0ba27502007-12-24 16:55:16 +01002240block { if | unless } <condition>
2241 Block a layer 7 request if/unless a condition is matched
2242 May be used in sections : defaults | frontend | listen | backend
2243 no | yes | yes | yes
2244
2245 The HTTP request will be blocked very early in the layer 7 processing
2246 if/unless <condition> is matched. A 403 error will be returned if the request
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002247 is blocked. The condition has to reference ACLs (see section 7). This is
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02002248 typically used to deny access to certain sensitive resources if some
Willy Tarreau0ba27502007-12-24 16:55:16 +01002249 conditions are met or not met. There is no fixed limit to the number of
2250 "block" statements per instance.
2251
2252 Example:
2253 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
2254 acl invalid_src src_port 0:1023
2255 acl local_dst hdr(host) -i localhost
2256 block if invalid_src || local_dst
2257
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002258 See section 7 about ACL usage.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002259
2260
2261capture cookie <name> len <length>
2262 Capture and log a cookie in the request and in the response.
2263 May be used in sections : defaults | frontend | listen | backend
2264 no | yes | yes | no
2265 Arguments :
2266 <name> is the beginning of the name of the cookie to capture. In order
2267 to match the exact name, simply suffix the name with an equal
2268 sign ('='). The full name will appear in the logs, which is
2269 useful with application servers which adjust both the cookie name
2270 and value (eg: ASPSESSIONXXXXX).
2271
2272 <length> is the maximum number of characters to report in the logs, which
2273 include the cookie name, the equal sign and the value, all in the
2274 standard "name=value" form. The string will be truncated on the
2275 right if it exceeds <length>.
2276
2277 Only the first cookie is captured. Both the "cookie" request headers and the
2278 "set-cookie" response headers are monitored. This is particularly useful to
2279 check for application bugs causing session crossing or stealing between
2280 users, because generally the user's cookies can only change on a login page.
2281
2282 When the cookie was not presented by the client, the associated log column
2283 will report "-". When a request does not cause a cookie to be assigned by the
2284 server, a "-" is reported in the response column.
2285
2286 The capture is performed in the frontend only because it is necessary that
2287 the log format does not change for a given frontend depending on the
2288 backends. This may change in the future. Note that there can be only one
Willy Tarreau193b8c62012-11-22 00:17:38 +01002289 "capture cookie" statement in a frontend. The maximum capture length is set
2290 by the global "tune.http.cookielen" setting and defaults to 63 characters. It
2291 is not possible to specify a capture in a "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002292
2293 Example:
2294 capture cookie ASPSESSION len 32
2295
2296 See also : "capture request header", "capture response header" as well as
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002297 section 8 about logging.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002298
2299
2300capture request header <name> len <length>
Willy Tarreau4460d032012-11-21 23:37:37 +01002301 Capture and log the last occurrence of the specified request header.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002302 May be used in sections : defaults | frontend | listen | backend
2303 no | yes | yes | no
2304 Arguments :
2305 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002306 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +01002307 appear in the requests, with the first letter of each word in
2308 upper case. The header name will not appear in the logs, only the
2309 value is reported, but the position in the logs is respected.
2310
2311 <length> is the maximum number of characters to extract from the value and
2312 report in the logs. The string will be truncated on the right if
2313 it exceeds <length>.
2314
Willy Tarreau4460d032012-11-21 23:37:37 +01002315 The complete value of the last occurrence of the header is captured. The
Willy Tarreau0ba27502007-12-24 16:55:16 +01002316 value will be added to the logs between braces ('{}'). If multiple headers
2317 are captured, they will be delimited by a vertical bar ('|') and will appear
Willy Tarreaucc6c8912009-02-22 10:53:55 +01002318 in the same order they were declared in the configuration. Non-existent
2319 headers will be logged just as an empty string. Common uses for request
2320 header captures include the "Host" field in virtual hosting environments, the
2321 "Content-length" when uploads are supported, "User-agent" to quickly
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002322 differentiate between real users and robots, and "X-Forwarded-For" in proxied
Willy Tarreaucc6c8912009-02-22 10:53:55 +01002323 environments to find where the request came from.
2324
2325 Note that when capturing headers such as "User-agent", some spaces may be
2326 logged, making the log analysis more difficult. Thus be careful about what
2327 you log if you know your log parser is not smart enough to rely on the
2328 braces.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002329
Willy Tarreau0900abb2012-11-22 00:21:46 +01002330 There is no limit to the number of captured request headers nor to their
2331 length, though it is wise to keep them low to limit memory usage per session.
2332 In order to keep log format consistent for a same frontend, header captures
2333 can only be declared in a frontend. It is not possible to specify a capture
2334 in a "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002335
2336 Example:
2337 capture request header Host len 15
2338 capture request header X-Forwarded-For len 15
2339 capture request header Referrer len 15
2340
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002341 See also : "capture cookie", "capture response header" as well as section 8
Willy Tarreau0ba27502007-12-24 16:55:16 +01002342 about logging.
2343
2344
2345capture response header <name> len <length>
Willy Tarreau4460d032012-11-21 23:37:37 +01002346 Capture and log the last occurrence of the specified response header.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002347 May be used in sections : defaults | frontend | listen | backend
2348 no | yes | yes | no
2349 Arguments :
2350 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002351 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +01002352 appear in the response, with the first letter of each word in
2353 upper case. The header name will not appear in the logs, only the
2354 value is reported, but the position in the logs is respected.
2355
2356 <length> is the maximum number of characters to extract from the value and
2357 report in the logs. The string will be truncated on the right if
2358 it exceeds <length>.
2359
Willy Tarreau4460d032012-11-21 23:37:37 +01002360 The complete value of the last occurrence of the header is captured. The
Willy Tarreau0ba27502007-12-24 16:55:16 +01002361 result will be added to the logs between braces ('{}') after the captured
2362 request headers. If multiple headers are captured, they will be delimited by
2363 a vertical bar ('|') and will appear in the same order they were declared in
Willy Tarreaucc6c8912009-02-22 10:53:55 +01002364 the configuration. Non-existent headers will be logged just as an empty
2365 string. Common uses for response header captures include the "Content-length"
2366 header which indicates how many bytes are expected to be returned, the
2367 "Location" header to track redirections.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002368
Willy Tarreau0900abb2012-11-22 00:21:46 +01002369 There is no limit to the number of captured response headers nor to their
2370 length, though it is wise to keep them low to limit memory usage per session.
2371 In order to keep log format consistent for a same frontend, header captures
2372 can only be declared in a frontend. It is not possible to specify a capture
2373 in a "defaults" section.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002374
2375 Example:
2376 capture response header Content-length len 9
2377 capture response header Location len 15
2378
Willy Tarreauc57f0e22009-05-10 13:12:33 +02002379 See also : "capture cookie", "capture request header" as well as section 8
Willy Tarreau0ba27502007-12-24 16:55:16 +01002380 about logging.
2381
2382
Cyril Bontéf0c60612010-02-06 14:44:47 +01002383clitimeout <timeout> (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +01002384 Set the maximum inactivity time on the client side.
2385 May be used in sections : defaults | frontend | listen | backend
2386 yes | yes | yes | no
2387 Arguments :
2388 <timeout> is the timeout value is specified in milliseconds by default, but
2389 can be in any other unit if the number is suffixed by the unit,
2390 as explained at the top of this document.
2391
2392 The inactivity timeout applies when the client is expected to acknowledge or
2393 send data. In HTTP mode, this timeout is particularly important to consider
2394 during the first phase, when the client sends the request, and during the
2395 response while it is reading data sent by the server. The value is specified
2396 in milliseconds by default, but can be in any other unit if the number is
2397 suffixed by the unit, as specified at the top of this document. In TCP mode
2398 (and to a lesser extent, in HTTP mode), it is highly recommended that the
2399 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002400 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01002401 losses by specifying timeouts that are slightly above multiples of 3 seconds
2402 (eg: 4 or 5 seconds).
2403
2404 This parameter is specific to frontends, but can be specified once for all in
2405 "defaults" sections. This is in fact one of the easiest solutions not to
2406 forget about it. An unspecified timeout results in an infinite timeout, which
2407 is not recommended. Such a usage is accepted and works but reports a warning
2408 during startup because it may results in accumulation of expired sessions in
2409 the system if the system's timeouts are not configured either.
2410
2411 This parameter is provided for compatibility but is currently deprecated.
2412 Please use "timeout client" instead.
2413
Willy Tarreau036fae02008-01-06 13:24:40 +01002414 See also : "timeout client", "timeout http-request", "timeout server", and
2415 "srvtimeout".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002416
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002417compression algo <algorithm> ...
2418compression type <mime type> ...
Willy Tarreau70737d12012-10-27 00:34:28 +02002419compression offload
William Lallemand82fe75c2012-10-23 10:25:10 +02002420 Enable HTTP compression.
2421 May be used in sections : defaults | frontend | listen | backend
2422 yes | yes | yes | yes
2423 Arguments :
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002424 algo is followed by the list of supported compression algorithms.
2425 type is followed by the list of MIME types that will be compressed.
2426 offload makes haproxy work as a compression offloader only (see notes).
2427
2428 The currently supported algorithms are :
Willy Tarreauc91840a2015-03-28 17:00:39 +01002429 identity this is mostly for debugging, and it was useful for developing
2430 the compression feature. Identity does not apply any change on
2431 data.
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002432
Willy Tarreauc91840a2015-03-28 17:00:39 +01002433 gzip applies gzip compression. This setting is only available when
2434 support for zlib was built in.
2435
2436 deflate same as "gzip", but with deflate algorithm and zlib format.
2437 Note that this algorithm has ambiguous support on many
2438 browsers and no support at all from recent ones. It is
2439 strongly recommended not to use it for anything else than
2440 experimentation. This setting is only available when support
2441 for zlib was built in.
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002442
Willy Tarreauc91840a2015-03-28 17:00:39 +01002443 raw-deflate same as "deflate" without the zlib wrapper, and used as an
2444 alternative when the browser wants "deflate". All major
2445 browsers understand it and despite violating the standards,
2446 it is known to work better than "deflate", at least on MSIE
2447 and some versions of Safari. Do not use it in conjunction
2448 with "deflate", use either one or the other since both react
2449 to the same Accept-Encoding token. This setting is only
2450 available when support for zlib was built in.
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002451
Dmitry Sivachenko87c208b2012-11-22 20:03:26 +04002452 Compression will be activated depending on the Accept-Encoding request
Cyril Bonté316a8cf2012-11-11 13:38:27 +01002453 header. With identity, it does not take care of that header.
Dmitry Sivachenkoc9f3b452012-11-28 17:47:11 +04002454 If backend servers support HTTP compression, these directives
2455 will be no-op: haproxy will see the compressed response and will not
2456 compress again. If backend servers do not support HTTP compression and
2457 there is Accept-Encoding header in request, haproxy will compress the
2458 matching response.
Willy Tarreau70737d12012-10-27 00:34:28 +02002459
2460 The "offload" setting makes haproxy remove the Accept-Encoding header to
2461 prevent backend servers from compressing responses. It is strongly
2462 recommended not to do this because this means that all the compression work
2463 will be done on the single point where haproxy is located. However in some
2464 deployment scenarios, haproxy may be installed in front of a buggy gateway
Dmitry Sivachenkoc9f3b452012-11-28 17:47:11 +04002465 with broken HTTP compression implementation which can't be turned off.
2466 In that case haproxy can be used to prevent that gateway from emitting
2467 invalid payloads. In this case, simply removing the header in the
2468 configuration does not work because it applies before the header is parsed,
2469 so that prevents haproxy from compressing. The "offload" setting should
Willy Tarreauffea9fd2014-07-12 16:37:02 +02002470 then be used for such scenarios. Note: for now, the "offload" setting is
2471 ignored when set in a defaults section.
William Lallemand82fe75c2012-10-23 10:25:10 +02002472
William Lallemand05097442012-11-20 12:14:28 +01002473 Compression is disabled when:
Baptiste Assmann650d53d2013-01-05 15:44:44 +01002474 * the request does not advertise a supported compression algorithm in the
2475 "Accept-Encoding" header
2476 * the response message is not HTTP/1.1
William Lallemandd3002612012-11-26 14:34:47 +01002477 * HTTP status code is not 200
William Lallemand8bb4e342013-12-10 17:28:48 +01002478 * response header "Transfer-Encoding" contains "chunked" (Temporary
2479 Workaround)
Baptiste Assmann650d53d2013-01-05 15:44:44 +01002480 * response contain neither a "Content-Length" header nor a
2481 "Transfer-Encoding" whose last value is "chunked"
2482 * response contains a "Content-Type" header whose first value starts with
2483 "multipart"
2484 * the response contains the "no-transform" value in the "Cache-control"
2485 header
2486 * User-Agent matches "Mozilla/4" unless it is MSIE 6 with XP SP2, or MSIE 7
2487 and later
2488 * The response contains a "Content-Encoding" header, indicating that the
2489 response is already compressed (see compression offload)
William Lallemand05097442012-11-20 12:14:28 +01002490
Baptiste Assmann650d53d2013-01-05 15:44:44 +01002491 Note: The compression does not rewrite Etag headers, and does not emit the
2492 Warning header.
William Lallemand05097442012-11-20 12:14:28 +01002493
William Lallemand82fe75c2012-10-23 10:25:10 +02002494 Examples :
2495 compression algo gzip
2496 compression type text/html text/plain
Willy Tarreau0ba27502007-12-24 16:55:16 +01002497
Cyril Bontéf0c60612010-02-06 14:44:47 +01002498contimeout <timeout> (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +01002499 Set the maximum time to wait for a connection attempt to a server to succeed.
2500 May be used in sections : defaults | frontend | listen | backend
2501 yes | no | yes | yes
2502 Arguments :
2503 <timeout> is the timeout value is specified in milliseconds by default, but
2504 can be in any other unit if the number is suffixed by the unit,
2505 as explained at the top of this document.
2506
2507 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002508 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreaud72758d2010-01-12 10:42:19 +01002509 cover one or several TCP packet losses by specifying timeouts that are
Willy Tarreau0ba27502007-12-24 16:55:16 +01002510 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
2511 connect timeout also presets the queue timeout to the same value if this one
2512 has not been specified. Historically, the contimeout was also used to set the
2513 tarpit timeout in a listen section, which is not possible in a pure frontend.
2514
2515 This parameter is specific to backends, but can be specified once for all in
2516 "defaults" sections. This is in fact one of the easiest solutions not to
2517 forget about it. An unspecified timeout results in an infinite timeout, which
2518 is not recommended. Such a usage is accepted and works but reports a warning
2519 during startup because it may results in accumulation of failed sessions in
2520 the system if the system's timeouts are not configured either.
2521
2522 This parameter is provided for backwards compatibility but is currently
2523 deprecated. Please use "timeout connect", "timeout queue" or "timeout tarpit"
2524 instead.
2525
2526 See also : "timeout connect", "timeout queue", "timeout tarpit",
2527 "timeout server", "contimeout".
2528
2529
Willy Tarreau55165fe2009-05-10 12:02:55 +02002530cookie <name> [ rewrite | insert | prefix ] [ indirect ] [ nocache ]
Willy Tarreau4992dd22012-05-31 21:02:17 +02002531 [ postonly ] [ preserve ] [ httponly ] [ secure ]
2532 [ domain <domain> ]* [ maxidle <idle> ] [ maxlife <life> ]
Willy Tarreau0ba27502007-12-24 16:55:16 +01002533 Enable cookie-based persistence in a backend.
2534 May be used in sections : defaults | frontend | listen | backend
2535 yes | no | yes | yes
2536 Arguments :
2537 <name> is the name of the cookie which will be monitored, modified or
2538 inserted in order to bring persistence. This cookie is sent to
2539 the client via a "Set-Cookie" header in the response, and is
2540 brought back by the client in a "Cookie" header in all requests.
2541 Special care should be taken to choose a name which does not
2542 conflict with any likely application cookie. Also, if the same
2543 backends are subject to be used by the same clients (eg:
2544 HTTP/HTTPS), care should be taken to use different cookie names
2545 between all backends if persistence between them is not desired.
2546
2547 rewrite This keyword indicates that the cookie will be provided by the
2548 server and that haproxy will have to modify its value to set the
2549 server's identifier in it. This mode is handy when the management
2550 of complex combinations of "Set-cookie" and "Cache-control"
2551 headers is left to the application. The application can then
2552 decide whether or not it is appropriate to emit a persistence
2553 cookie. Since all responses should be monitored, this mode only
2554 works in HTTP close mode. Unless the application behaviour is
2555 very complex and/or broken, it is advised not to start with this
2556 mode for new deployments. This keyword is incompatible with
2557 "insert" and "prefix".
2558
2559 insert This keyword indicates that the persistence cookie will have to
Willy Tarreaua79094d2010-08-31 22:54:15 +02002560 be inserted by haproxy in server responses if the client did not
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002561
Willy Tarreaua79094d2010-08-31 22:54:15 +02002562 already have a cookie that would have permitted it to access this
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002563 server. When used without the "preserve" option, if the server
2564 emits a cookie with the same name, it will be remove before
2565 processing. For this reason, this mode can be used to upgrade
2566 existing configurations running in the "rewrite" mode. The cookie
2567 will only be a session cookie and will not be stored on the
2568 client's disk. By default, unless the "indirect" option is added,
2569 the server will see the cookies emitted by the client. Due to
2570 caching effects, it is generally wise to add the "nocache" or
2571 "postonly" keywords (see below). The "insert" keyword is not
2572 compatible with "rewrite" and "prefix".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002573
2574 prefix This keyword indicates that instead of relying on a dedicated
2575 cookie for the persistence, an existing one will be completed.
2576 This may be needed in some specific environments where the client
2577 does not support more than one single cookie and the application
2578 already needs it. In this case, whenever the server sets a cookie
2579 named <name>, it will be prefixed with the server's identifier
2580 and a delimiter. The prefix will be removed from all client
2581 requests so that the server still finds the cookie it emitted.
2582 Since all requests and responses are subject to being modified,
2583 this mode requires the HTTP close mode. The "prefix" keyword is
Willy Tarreau37229df2011-10-17 12:24:55 +02002584 not compatible with "rewrite" and "insert". Note: it is highly
2585 recommended not to use "indirect" with "prefix", otherwise server
2586 cookie updates would not be sent to clients.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002587
Willy Tarreaua79094d2010-08-31 22:54:15 +02002588 indirect When this option is specified, no cookie will be emitted to a
2589 client which already has a valid one for the server which has
2590 processed the request. If the server sets such a cookie itself,
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002591 it will be removed, unless the "preserve" option is also set. In
2592 "insert" mode, this will additionally remove cookies from the
2593 requests transmitted to the server, making the persistence
2594 mechanism totally transparent from an application point of view.
Willy Tarreau37229df2011-10-17 12:24:55 +02002595 Note: it is highly recommended not to use "indirect" with
2596 "prefix", otherwise server cookie updates would not be sent to
2597 clients.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002598
2599 nocache This option is recommended in conjunction with the insert mode
2600 when there is a cache between the client and HAProxy, as it
2601 ensures that a cacheable response will be tagged non-cacheable if
2602 a cookie needs to be inserted. This is important because if all
2603 persistence cookies are added on a cacheable home page for
2604 instance, then all customers will then fetch the page from an
2605 outer cache and will all share the same persistence cookie,
2606 leading to one server receiving much more traffic than others.
2607 See also the "insert" and "postonly" options.
2608
2609 postonly This option ensures that cookie insertion will only be performed
2610 on responses to POST requests. It is an alternative to the
2611 "nocache" option, because POST responses are not cacheable, so
2612 this ensures that the persistence cookie will never get cached.
2613 Since most sites do not need any sort of persistence before the
2614 first POST which generally is a login request, this is a very
2615 efficient method to optimize caching without risking to find a
2616 persistence cookie in the cache.
2617 See also the "insert" and "nocache" options.
2618
Willy Tarreauba4c5be2010-10-23 12:46:42 +02002619 preserve This option may only be used with "insert" and/or "indirect". It
2620 allows the server to emit the persistence cookie itself. In this
2621 case, if a cookie is found in the response, haproxy will leave it
2622 untouched. This is useful in order to end persistence after a
2623 logout request for instance. For this, the server just has to
2624 emit a cookie with an invalid value (eg: empty) or with a date in
2625 the past. By combining this mechanism with the "disable-on-404"
2626 check option, it is possible to perform a completely graceful
2627 shutdown because users will definitely leave the server after
2628 they logout.
2629
Willy Tarreau4992dd22012-05-31 21:02:17 +02002630 httponly This option tells haproxy to add an "HttpOnly" cookie attribute
2631 when a cookie is inserted. This attribute is used so that a
2632 user agent doesn't share the cookie with non-HTTP components.
2633 Please check RFC6265 for more information on this attribute.
2634
2635 secure This option tells haproxy to add a "Secure" cookie attribute when
2636 a cookie is inserted. This attribute is used so that a user agent
2637 never emits this cookie over non-secure channels, which means
2638 that a cookie learned with this flag will be presented only over
2639 SSL/TLS connections. Please check RFC6265 for more information on
2640 this attribute.
2641
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02002642 domain This option allows to specify the domain at which a cookie is
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01002643 inserted. It requires exactly one parameter: a valid domain
Willy Tarreau68a897b2009-12-03 23:28:34 +01002644 name. If the domain begins with a dot, the browser is allowed to
2645 use it for any host ending with that name. It is also possible to
2646 specify several domain names by invoking this option multiple
2647 times. Some browsers might have small limits on the number of
2648 domains, so be careful when doing that. For the record, sending
2649 10 domains to MSIE 6 or Firefox 2 works as expected.
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02002650
Willy Tarreau996a92c2010-10-13 19:30:47 +02002651 maxidle This option allows inserted cookies to be ignored after some idle
2652 time. It only works with insert-mode cookies. When a cookie is
2653 sent to the client, the date this cookie was emitted is sent too.
2654 Upon further presentations of this cookie, if the date is older
2655 than the delay indicated by the parameter (in seconds), it will
2656 be ignored. Otherwise, it will be refreshed if needed when the
2657 response is sent to the client. This is particularly useful to
2658 prevent users who never close their browsers from remaining for
2659 too long on the same server (eg: after a farm size change). When
2660 this option is set and a cookie has no date, it is always
2661 accepted, but gets refreshed in the response. This maintains the
2662 ability for admins to access their sites. Cookies that have a
2663 date in the future further than 24 hours are ignored. Doing so
2664 lets admins fix timezone issues without risking kicking users off
2665 the site.
2666
2667 maxlife This option allows inserted cookies to be ignored after some life
2668 time, whether they're in use or not. It only works with insert
2669 mode cookies. When a cookie is first sent to the client, the date
2670 this cookie was emitted is sent too. Upon further presentations
2671 of this cookie, if the date is older than the delay indicated by
2672 the parameter (in seconds), it will be ignored. If the cookie in
2673 the request has no date, it is accepted and a date will be set.
2674 Cookies that have a date in the future further than 24 hours are
2675 ignored. Doing so lets admins fix timezone issues without risking
2676 kicking users off the site. Contrary to maxidle, this value is
2677 not refreshed, only the first visit date counts. Both maxidle and
2678 maxlife may be used at the time. This is particularly useful to
2679 prevent users who never close their browsers from remaining for
2680 too long on the same server (eg: after a farm size change). This
2681 is stronger than the maxidle method in that it forces a
2682 redispatch after some absolute delay.
2683
Willy Tarreau0ba27502007-12-24 16:55:16 +01002684 There can be only one persistence cookie per HTTP backend, and it can be
2685 declared in a defaults section. The value of the cookie will be the value
2686 indicated after the "cookie" keyword in a "server" statement. If no cookie
2687 is declared for a given server, the cookie is not set.
Willy Tarreau6a06a402007-07-15 20:15:28 +02002688
Willy Tarreau0ba27502007-12-24 16:55:16 +01002689 Examples :
2690 cookie JSESSIONID prefix
2691 cookie SRV insert indirect nocache
2692 cookie SRV insert postonly indirect
Willy Tarreau996a92c2010-10-13 19:30:47 +02002693 cookie SRV insert indirect nocache maxidle 30m maxlife 8h
Willy Tarreau0ba27502007-12-24 16:55:16 +01002694
Willy Tarreau294d0f02015-08-10 19:40:12 +02002695 See also : "balance source", "capture cookie", "server" and "ignore-persist".
Willy Tarreau0ba27502007-12-24 16:55:16 +01002696
Willy Tarreau983e01e2010-01-11 18:42:06 +01002697
Thierry FOURNIERa0a1b752015-05-26 17:44:32 +02002698declare capture [ request | response ] len <length>
2699 Declares a capture slot.
2700 May be used in sections : defaults | frontend | listen | backend
2701 no | yes | yes | no
2702 Arguments:
2703 <length> is the length allowed for the capture.
2704
2705 This declaration is only available in the frontend or listen section, but the
2706 reserved slot can be used in the backends. The "request" keyword allocates a
2707 capture slot for use in the request, and "response" allocates a capture slot
2708 for use in the response.
2709
2710 See also: "capture-req", "capture-res" (sample converters),
2711 "http-request capture" and "http-response capture".
2712
2713
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01002714default-server [param*]
2715 Change default options for a server in a backend
2716 May be used in sections : defaults | frontend | listen | backend
2717 yes | no | yes | yes
2718 Arguments:
Willy Tarreau983e01e2010-01-11 18:42:06 +01002719 <param*> is a list of parameters for this server. The "default-server"
2720 keyword accepts an important number of options and has a complete
2721 section dedicated to it. Please refer to section 5 for more
2722 details.
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01002723
Willy Tarreau983e01e2010-01-11 18:42:06 +01002724 Example :
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01002725 default-server inter 1000 weight 13
2726
2727 See also: "server" and section 5 about server options
Willy Tarreau0ba27502007-12-24 16:55:16 +01002728
Willy Tarreau983e01e2010-01-11 18:42:06 +01002729
Willy Tarreau0ba27502007-12-24 16:55:16 +01002730default_backend <backend>
2731 Specify the backend to use when no "use_backend" rule has been matched.
2732 May be used in sections : defaults | frontend | listen | backend
2733 yes | yes | yes | no
2734 Arguments :
2735 <backend> is the name of the backend to use.
2736
2737 When doing content-switching between frontend and backends using the
2738 "use_backend" keyword, it is often useful to indicate which backend will be
2739 used when no rule has matched. It generally is the dynamic backend which
2740 will catch all undetermined requests.
2741
Willy Tarreau0ba27502007-12-24 16:55:16 +01002742 Example :
2743
2744 use_backend dynamic if url_dyn
2745 use_backend static if url_css url_img extension_img
2746 default_backend dynamic
2747
Willy Tarreau98d04852015-05-26 12:18:29 +02002748 See also : "use_backend"
Willy Tarreau2769aa02007-12-27 18:26:09 +01002749
Willy Tarreau0ba27502007-12-24 16:55:16 +01002750
Baptiste Assmann27f51342013-10-09 06:51:49 +02002751description <string>
2752 Describe a listen, frontend or backend.
2753 May be used in sections : defaults | frontend | listen | backend
2754 no | yes | yes | yes
2755 Arguments : string
2756
2757 Allows to add a sentence to describe the related object in the HAProxy HTML
2758 stats page. The description will be printed on the right of the object name
2759 it describes.
2760 No need to backslash spaces in the <string> arguments.
2761
2762
Willy Tarreau0ba27502007-12-24 16:55:16 +01002763disabled
2764 Disable a proxy, frontend or backend.
2765 May be used in sections : defaults | frontend | listen | backend
2766 yes | yes | yes | yes
2767 Arguments : none
2768
2769 The "disabled" keyword is used to disable an instance, mainly in order to
2770 liberate a listening port or to temporarily disable a service. The instance
2771 will still be created and its configuration will be checked, but it will be
2772 created in the "stopped" state and will appear as such in the statistics. It
2773 will not receive any traffic nor will it send any health-checks or logs. It
2774 is possible to disable many instances at once by adding the "disabled"
2775 keyword in a "defaults" section.
2776
2777 See also : "enabled"
2778
2779
Willy Tarreau5ce94572010-06-07 14:35:41 +02002780dispatch <address>:<port>
2781 Set a default server address
2782 May be used in sections : defaults | frontend | listen | backend
2783 no | no | yes | yes
Cyril Bonté108cf6e2012-04-21 23:30:29 +02002784 Arguments :
Willy Tarreau5ce94572010-06-07 14:35:41 +02002785
2786 <address> is the IPv4 address of the default server. Alternatively, a
2787 resolvable hostname is supported, but this name will be resolved
2788 during start-up.
2789
2790 <ports> is a mandatory port specification. All connections will be sent
2791 to this port, and it is not permitted to use port offsets as is
2792 possible with normal servers.
2793
Willy Tarreau787aed52011-04-15 06:45:37 +02002794 The "dispatch" keyword designates a default server for use when no other
Willy Tarreau5ce94572010-06-07 14:35:41 +02002795 server can take the connection. In the past it was used to forward non
2796 persistent connections to an auxiliary load balancer. Due to its simple
2797 syntax, it has also been used for simple TCP relays. It is recommended not to
2798 use it for more clarity, and to use the "server" directive instead.
2799
2800 See also : "server"
2801
2802
Willy Tarreau0ba27502007-12-24 16:55:16 +01002803enabled
2804 Enable a proxy, frontend or backend.
2805 May be used in sections : defaults | frontend | listen | backend
2806 yes | yes | yes | yes
2807 Arguments : none
2808
2809 The "enabled" keyword is used to explicitly enable an instance, when the
2810 defaults has been set to "disabled". This is very rarely used.
2811
2812 See also : "disabled"
2813
2814
2815errorfile <code> <file>
2816 Return a file contents instead of errors generated by HAProxy
2817 May be used in sections : defaults | frontend | listen | backend
2818 yes | yes | yes | yes
2819 Arguments :
2820 <code> is the HTTP status code. Currently, HAProxy is capable of
CJ Ess108b1dd2015-04-07 12:03:37 -04002821 generating codes 200, 400, 403, 405, 408, 429, 500, 502, 503, and
2822 504.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002823
2824 <file> designates a file containing the full HTTP response. It is
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002825 recommended to follow the common practice of appending ".http" to
Willy Tarreau0ba27502007-12-24 16:55:16 +01002826 the filename so that people do not confuse the response with HTML
Willy Tarreau59140a22009-02-22 12:02:30 +01002827 error pages, and to use absolute paths, since files are read
2828 before any chroot is performed.
Willy Tarreau0ba27502007-12-24 16:55:16 +01002829
2830 It is important to understand that this keyword is not meant to rewrite
2831 errors returned by the server, but errors detected and returned by HAProxy.
2832 This is why the list of supported errors is limited to a small set.
2833
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002834 Code 200 is emitted in response to requests matching a "monitor-uri" rule.
2835
Willy Tarreau0ba27502007-12-24 16:55:16 +01002836 The files are returned verbatim on the TCP socket. This allows any trick such
2837 as redirections to another URL or site, as well as tricks to clean cookies,
2838 force enable or disable caching, etc... The package provides default error
2839 files returning the same contents as default errors.
2840
Willy Tarreau59140a22009-02-22 12:02:30 +01002841 The files should not exceed the configured buffer size (BUFSIZE), which
2842 generally is 8 or 16 kB, otherwise they will be truncated. It is also wise
2843 not to put any reference to local contents (eg: images) in order to avoid
2844 loops between the client and HAProxy when all servers are down, causing an
2845 error to be returned instead of an image. For better HTTP compliance, it is
2846 recommended that all header lines end with CR-LF and not LF alone.
2847
Willy Tarreau0ba27502007-12-24 16:55:16 +01002848 The files are read at the same time as the configuration and kept in memory.
2849 For this reason, the errors continue to be returned even when the process is
2850 chrooted, and no file change is considered while the process is running. A
Willy Tarreauc27debf2008-01-06 08:57:02 +01002851 simple method for developing those files consists in associating them to the
Willy Tarreau0ba27502007-12-24 16:55:16 +01002852 403 status code and interrogating a blocked URL.
2853
2854 See also : "errorloc", "errorloc302", "errorloc303"
2855
Willy Tarreau59140a22009-02-22 12:02:30 +01002856 Example :
2857 errorfile 400 /etc/haproxy/errorfiles/400badreq.http
Willy Tarreau2705a612014-05-23 17:38:34 +02002858 errorfile 408 /dev/null # workaround Chrome pre-connect bug
Willy Tarreau59140a22009-02-22 12:02:30 +01002859 errorfile 403 /etc/haproxy/errorfiles/403forbid.http
2860 errorfile 503 /etc/haproxy/errorfiles/503sorry.http
2861
Willy Tarreau2769aa02007-12-27 18:26:09 +01002862
2863errorloc <code> <url>
2864errorloc302 <code> <url>
2865 Return an HTTP redirection to a URL instead of errors generated by HAProxy
2866 May be used in sections : defaults | frontend | listen | backend
2867 yes | yes | yes | yes
2868 Arguments :
2869 <code> is the HTTP status code. Currently, HAProxy is capable of
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002870 generating codes 200, 400, 403, 408, 500, 502, 503, and 504.
Willy Tarreau2769aa02007-12-27 18:26:09 +01002871
2872 <url> it is the exact contents of the "Location" header. It may contain
2873 either a relative URI to an error page hosted on the same site,
2874 or an absolute URI designating an error page on another site.
2875 Special care should be given to relative URIs to avoid redirect
2876 loops if the URI itself may generate the same error (eg: 500).
2877
2878 It is important to understand that this keyword is not meant to rewrite
2879 errors returned by the server, but errors detected and returned by HAProxy.
2880 This is why the list of supported errors is limited to a small set.
2881
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002882 Code 200 is emitted in response to requests matching a "monitor-uri" rule.
2883
Willy Tarreau2769aa02007-12-27 18:26:09 +01002884 Note that both keyword return the HTTP 302 status code, which tells the
2885 client to fetch the designated URL using the same HTTP method. This can be
2886 quite problematic in case of non-GET methods such as POST, because the URL
2887 sent to the client might not be allowed for something other than GET. To
2888 workaround this problem, please use "errorloc303" which send the HTTP 303
2889 status code, indicating to the client that the URL must be fetched with a GET
2890 request.
2891
2892 See also : "errorfile", "errorloc303"
2893
2894
2895errorloc303 <code> <url>
2896 Return an HTTP redirection to a URL instead of errors generated by HAProxy
2897 May be used in sections : defaults | frontend | listen | backend
2898 yes | yes | yes | yes
2899 Arguments :
2900 <code> is the HTTP status code. Currently, HAProxy is capable of
2901 generating codes 400, 403, 408, 500, 502, 503, and 504.
2902
2903 <url> it is the exact contents of the "Location" header. It may contain
2904 either a relative URI to an error page hosted on the same site,
2905 or an absolute URI designating an error page on another site.
2906 Special care should be given to relative URIs to avoid redirect
2907 loops if the URI itself may generate the same error (eg: 500).
2908
2909 It is important to understand that this keyword is not meant to rewrite
2910 errors returned by the server, but errors detected and returned by HAProxy.
2911 This is why the list of supported errors is limited to a small set.
2912
Willy Tarreauae94d4d2011-05-11 16:28:49 +02002913 Code 200 is emitted in response to requests matching a "monitor-uri" rule.
2914
Willy Tarreau2769aa02007-12-27 18:26:09 +01002915 Note that both keyword return the HTTP 303 status code, which tells the
2916 client to fetch the designated URL using the same HTTP GET method. This
2917 solves the usual problems associated with "errorloc" and the 302 code. It is
2918 possible that some very old browsers designed before HTTP/1.1 do not support
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002919 it, but no such problem has been reported till now.
Willy Tarreau2769aa02007-12-27 18:26:09 +01002920
2921 See also : "errorfile", "errorloc", "errorloc302"
2922
2923
Simon Horman51a1cf62015-02-03 13:00:44 +09002924email-alert from <emailaddr>
2925 Declare the from email address to be used in both the envelope and header
2926 of email alerts. This is the address that email alerts are sent from.
2927 May be used in sections: defaults | frontend | listen | backend
2928 yes | yes | yes | yes
2929
2930 Arguments :
2931
2932 <emailaddr> is the from email address to use when sending email alerts
2933
2934 Also requires "email-alert mailers" and "email-alert to" to be set
2935 and if so sending email alerts is enabled for the proxy.
2936
Simon Horman64e34162015-02-06 11:11:57 +09002937 See also : "email-alert level", "email-alert mailers",
2938 "email-alert myhostname", "email-alert to", section 3.6 about mailers.
2939
2940
2941email-alert level <level>
2942 Declare the maximum log level of messages for which email alerts will be
2943 sent. This acts as a filter on the sending of email alerts.
2944 May be used in sections: defaults | frontend | listen | backend
2945 yes | yes | yes | yes
2946
2947 Arguments :
2948
2949 <level> One of the 8 syslog levels:
2950 emerg alert crit err warning notice info debug
2951 The above syslog levels are ordered from lowest to highest.
2952
2953 By default level is alert
2954
2955 Also requires "email-alert from", "email-alert mailers" and
2956 "email-alert to" to be set and if so sending email alerts is enabled
2957 for the proxy.
2958
Simon Horman1421e212015-04-30 13:10:35 +09002959 Alerts are sent when :
2960
2961 * An un-paused server is marked as down and <level> is alert or lower
2962 * A paused server is marked as down and <level> is notice or lower
2963 * A server is marked as up or enters the drain state and <level>
2964 is notice or lower
2965 * "option log-health-checks" is enabled, <level> is info or lower,
2966 and a health check status update occurs
2967
Simon Horman64e34162015-02-06 11:11:57 +09002968 See also : "email-alert from", "email-alert mailers",
2969 "email-alert myhostname", "email-alert to",
Simon Horman51a1cf62015-02-03 13:00:44 +09002970 section 3.6 about mailers.
2971
2972
2973email-alert mailers <mailersect>
2974 Declare the mailers to be used when sending email alerts
2975 May be used in sections: defaults | frontend | listen | backend
2976 yes | yes | yes | yes
2977
2978 Arguments :
2979
2980 <mailersect> is the name of the mailers section to send email alerts.
2981
2982 Also requires "email-alert from" and "email-alert to" to be set
2983 and if so sending email alerts is enabled for the proxy.
2984
Simon Horman64e34162015-02-06 11:11:57 +09002985 See also : "email-alert from", "email-alert level", "email-alert myhostname",
2986 "email-alert to", section 3.6 about mailers.
Simon Horman51a1cf62015-02-03 13:00:44 +09002987
2988
2989email-alert myhostname <hostname>
2990 Declare the to hostname address to be used when communicating with
2991 mailers.
2992 May be used in sections: defaults | frontend | listen | backend
2993 yes | yes | yes | yes
2994
2995 Arguments :
2996
2997 <emailaddr> is the to email address to use when sending email alerts
2998
2999 By default the systems hostname is used.
3000
3001 Also requires "email-alert from", "email-alert mailers" and
3002 "email-alert to" to be set and if so sending email alerts is enabled
3003 for the proxy.
3004
Simon Horman64e34162015-02-06 11:11:57 +09003005 See also : "email-alert from", "email-alert level", "email-alert mailers",
3006 "email-alert to", section 3.6 about mailers.
Simon Horman51a1cf62015-02-03 13:00:44 +09003007
3008
3009email-alert to <emailaddr>
3010 Declare both the recipent address in the envelope and to address in the
3011 header of email alerts. This is the address that email alerts are sent to.
3012 May be used in sections: defaults | frontend | listen | backend
3013 yes | yes | yes | yes
3014
3015 Arguments :
3016
3017 <emailaddr> is the to email address to use when sending email alerts
3018
3019 Also requires "email-alert mailers" and "email-alert to" to be set
3020 and if so sending email alerts is enabled for the proxy.
3021
Simon Horman64e34162015-02-06 11:11:57 +09003022 See also : "email-alert from", "email-alert level", "email-alert mailers",
Simon Horman51a1cf62015-02-03 13:00:44 +09003023 "email-alert myhostname", section 3.6 about mailers.
3024
3025
Willy Tarreau4de91492010-01-22 19:10:05 +01003026force-persist { if | unless } <condition>
3027 Declare a condition to force persistence on down servers
3028 May be used in sections: defaults | frontend | listen | backend
3029 no | yes | yes | yes
3030
3031 By default, requests are not dispatched to down servers. It is possible to
3032 force this using "option persist", but it is unconditional and redispatches
3033 to a valid server if "option redispatch" is set. That leaves with very little
3034 possibilities to force some requests to reach a server which is artificially
3035 marked down for maintenance operations.
3036
3037 The "force-persist" statement allows one to declare various ACL-based
3038 conditions which, when met, will cause a request to ignore the down status of
3039 a server and still try to connect to it. That makes it possible to start a
3040 server, still replying an error to the health checks, and run a specially
3041 configured browser to test the service. Among the handy methods, one could
3042 use a specific source IP address, or a specific cookie. The cookie also has
3043 the advantage that it can easily be added/removed on the browser from a test
3044 page. Once the service is validated, it is then possible to open the service
3045 to the world by returning a valid response to health checks.
3046
3047 The forced persistence is enabled when an "if" condition is met, or unless an
3048 "unless" condition is met. The final redispatch is always disabled when this
3049 is used.
3050
Cyril Bonté0d4bf012010-04-25 23:21:46 +02003051 See also : "option redispatch", "ignore-persist", "persist",
Cyril Bontéa8e7bbc2010-04-25 22:29:29 +02003052 and section 7 about ACL usage.
Willy Tarreau4de91492010-01-22 19:10:05 +01003053
3054
Willy Tarreau2769aa02007-12-27 18:26:09 +01003055fullconn <conns>
3056 Specify at what backend load the servers will reach their maxconn
3057 May be used in sections : defaults | frontend | listen | backend
3058 yes | no | yes | yes
3059 Arguments :
3060 <conns> is the number of connections on the backend which will make the
3061 servers use the maximal number of connections.
3062
Willy Tarreau198a7442008-01-17 12:05:32 +01003063 When a server has a "maxconn" parameter specified, it means that its number
Willy Tarreau2769aa02007-12-27 18:26:09 +01003064 of concurrent connections will never go higher. Additionally, if it has a
Willy Tarreau198a7442008-01-17 12:05:32 +01003065 "minconn" parameter, it indicates a dynamic limit following the backend's
Willy Tarreau2769aa02007-12-27 18:26:09 +01003066 load. The server will then always accept at least <minconn> connections,
3067 never more than <maxconn>, and the limit will be on the ramp between both
3068 values when the backend has less than <conns> concurrent connections. This
3069 makes it possible to limit the load on the servers during normal loads, but
3070 push it further for important loads without overloading the servers during
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01003071 exceptional loads.
Willy Tarreau2769aa02007-12-27 18:26:09 +01003072
Willy Tarreaufbb78422011-06-05 15:38:35 +02003073 Since it's hard to get this value right, haproxy automatically sets it to
3074 10% of the sum of the maxconns of all frontends that may branch to this
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01003075 backend (based on "use_backend" and "default_backend" rules). That way it's
3076 safe to leave it unset. However, "use_backend" involving dynamic names are
3077 not counted since there is no way to know if they could match or not.
Willy Tarreaufbb78422011-06-05 15:38:35 +02003078
Willy Tarreau2769aa02007-12-27 18:26:09 +01003079 Example :
3080 # The servers will accept between 100 and 1000 concurrent connections each
3081 # and the maximum of 1000 will be reached when the backend reaches 10000
3082 # connections.
3083 backend dynamic
3084 fullconn 10000
3085 server srv1 dyn1:80 minconn 100 maxconn 1000
3086 server srv2 dyn2:80 minconn 100 maxconn 1000
3087
3088 See also : "maxconn", "server"
3089
3090
3091grace <time>
3092 Maintain a proxy operational for some time after a soft stop
3093 May be used in sections : defaults | frontend | listen | backend
Cyril Bonté99ed3272010-01-24 23:29:44 +01003094 yes | yes | yes | yes
Willy Tarreau2769aa02007-12-27 18:26:09 +01003095 Arguments :
3096 <time> is the time (by default in milliseconds) for which the instance
3097 will remain operational with the frontend sockets still listening
3098 when a soft-stop is received via the SIGUSR1 signal.
3099
3100 This may be used to ensure that the services disappear in a certain order.
3101 This was designed so that frontends which are dedicated to monitoring by an
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01003102 external equipment fail immediately while other ones remain up for the time
Willy Tarreau2769aa02007-12-27 18:26:09 +01003103 needed by the equipment to detect the failure.
3104
3105 Note that currently, there is very little benefit in using this parameter,
3106 and it may in fact complicate the soft-reconfiguration process more than
3107 simplify it.
3108
Willy Tarreau0ba27502007-12-24 16:55:16 +01003109
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05003110hash-type <method> <function> <modifier>
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02003111 Specify a method to use for mapping hashes to servers
3112 May be used in sections : defaults | frontend | listen | backend
3113 yes | no | yes | yes
3114 Arguments :
Bhaskar98634f02013-10-29 23:30:51 -04003115 <method> is the method used to select a server from the hash computed by
3116 the <function> :
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02003117
Bhaskar98634f02013-10-29 23:30:51 -04003118 map-based the hash table is a static array containing all alive servers.
3119 The hashes will be very smooth, will consider weights, but
3120 will be static in that weight changes while a server is up
3121 will be ignored. This means that there will be no slow start.
3122 Also, since a server is selected by its position in the array,
3123 most mappings are changed when the server count changes. This
3124 means that when a server goes up or down, or when a server is
3125 added to a farm, most connections will be redistributed to
3126 different servers. This can be inconvenient with caches for
3127 instance.
Willy Tarreau798a39c2010-11-24 15:04:29 +01003128
Bhaskar98634f02013-10-29 23:30:51 -04003129 consistent the hash table is a tree filled with many occurrences of each
3130 server. The hash key is looked up in the tree and the closest
3131 server is chosen. This hash is dynamic, it supports changing
3132 weights while the servers are up, so it is compatible with the
3133 slow start feature. It has the advantage that when a server
3134 goes up or down, only its associations are moved. When a
3135 server is added to the farm, only a few part of the mappings
3136 are redistributed, making it an ideal method for caches.
3137 However, due to its principle, the distribution will never be
3138 very smooth and it may sometimes be necessary to adjust a
3139 server's weight or its ID to get a more balanced distribution.
3140 In order to get the same distribution on multiple load
3141 balancers, it is important that all servers have the exact
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05003142 same IDs. Note: consistent hash uses sdbm and avalanche if no
3143 hash function is specified.
Bhaskar98634f02013-10-29 23:30:51 -04003144
3145 <function> is the hash function to be used :
3146
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03003147 sdbm this function was created initially for sdbm (a public-domain
Bhaskar98634f02013-10-29 23:30:51 -04003148 reimplementation of ndbm) database library. It was found to do
3149 well in scrambling bits, causing better distribution of the keys
3150 and fewer splits. It also happens to be a good general hashing
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05003151 function with good distribution, unless the total server weight
3152 is a multiple of 64, in which case applying the avalanche
3153 modifier may help.
Bhaskar98634f02013-10-29 23:30:51 -04003154
3155 djb2 this function was first proposed by Dan Bernstein many years ago
3156 on comp.lang.c. Studies have shown that for certain workload this
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05003157 function provides a better distribution than sdbm. It generally
3158 works well with text-based inputs though it can perform extremely
3159 poorly with numeric-only input or when the total server weight is
3160 a multiple of 33, unless the avalanche modifier is also used.
3161
Willy Tarreaua0f42712013-11-14 14:30:35 +01003162 wt6 this function was designed for haproxy while testing other
3163 functions in the past. It is not as smooth as the other ones, but
3164 is much less sensible to the input data set or to the number of
3165 servers. It can make sense as an alternative to sdbm+avalanche or
3166 djb2+avalanche for consistent hashing or when hashing on numeric
3167 data such as a source IP address or a visitor identifier in a URL
3168 parameter.
3169
Willy Tarreau324f07f2015-01-20 19:44:50 +01003170 crc32 this is the most common CRC32 implementation as used in Ethernet,
3171 gzip, PNG, etc. It is slower than the other ones but may provide
3172 a better distribution or less predictable results especially when
3173 used on strings.
3174
Bhaskar Maddalab6c0ac92013-11-05 11:54:02 -05003175 <modifier> indicates an optional method applied after hashing the key :
3176
3177 avalanche This directive indicates that the result from the hash
3178 function above should not be used in its raw form but that
3179 a 4-byte full avalanche hash must be applied first. The
3180 purpose of this step is to mix the resulting bits from the
3181 previous hash in order to avoid any undesired effect when
3182 the input contains some limited values or when the number of
3183 servers is a multiple of one of the hash's components (64
3184 for SDBM, 33 for DJB2). Enabling avalanche tends to make the
3185 result less predictable, but it's also not as smooth as when
3186 using the original function. Some testing might be needed
3187 with some workloads. This hash is one of the many proposed
3188 by Bob Jenkins.
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02003189
Bhaskar98634f02013-10-29 23:30:51 -04003190 The default hash type is "map-based" and is recommended for most usages. The
3191 default function is "sdbm", the selection of a function should be based on
3192 the range of the values being hashed.
Willy Tarreau6b2e11b2009-10-01 07:52:15 +02003193
3194 See also : "balance", "server"
3195
3196
Willy Tarreau0ba27502007-12-24 16:55:16 +01003197http-check disable-on-404
3198 Enable a maintenance mode upon HTTP/404 response to health-checks
3199 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau2769aa02007-12-27 18:26:09 +01003200 yes | no | yes | yes
Willy Tarreau0ba27502007-12-24 16:55:16 +01003201 Arguments : none
3202
3203 When this option is set, a server which returns an HTTP code 404 will be
3204 excluded from further load-balancing, but will still receive persistent
3205 connections. This provides a very convenient method for Web administrators
3206 to perform a graceful shutdown of their servers. It is also important to note
3207 that a server which is detected as failed while it was in this mode will not
3208 generate an alert, just a notice. If the server responds 2xx or 3xx again, it
3209 will immediately be reinserted into the farm. The status on the stats page
3210 reports "NOLB" for a server in this mode. It is important to note that this
Willy Tarreaubd741542010-03-16 18:46:54 +01003211 option only works in conjunction with the "httpchk" option. If this option
3212 is used with "http-check expect", then it has precedence over it so that 404
3213 responses will still be considered as soft-stop.
3214
3215 See also : "option httpchk", "http-check expect"
3216
3217
3218http-check expect [!] <match> <pattern>
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003219 Make HTTP health checks consider response contents or specific status codes
Willy Tarreaubd741542010-03-16 18:46:54 +01003220 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau1ee51a62011-08-19 20:04:17 +02003221 yes | no | yes | yes
Willy Tarreaubd741542010-03-16 18:46:54 +01003222 Arguments :
3223 <match> is a keyword indicating how to look for a specific pattern in the
3224 response. The keyword may be one of "status", "rstatus",
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003225 "string", or "rstring". The keyword may be preceded by an
Willy Tarreaubd741542010-03-16 18:46:54 +01003226 exclamation mark ("!") to negate the match. Spaces are allowed
3227 between the exclamation mark and the keyword. See below for more
3228 details on the supported keywords.
3229
3230 <pattern> is the pattern to look for. It may be a string or a regular
3231 expression. If the pattern contains spaces, they must be escaped
3232 with the usual backslash ('\').
3233
3234 By default, "option httpchk" considers that response statuses 2xx and 3xx
3235 are valid, and that others are invalid. When "http-check expect" is used,
3236 it defines what is considered valid or invalid. Only one "http-check"
3237 statement is supported in a backend. If a server fails to respond or times
3238 out, the check obviously fails. The available matches are :
3239
3240 status <string> : test the exact string match for the HTTP status code.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003241 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003242 response's status code is exactly this string. If the
3243 "status" keyword is prefixed with "!", then the response
3244 will be considered invalid if the status code matches.
3245
3246 rstatus <regex> : test a regular expression for the HTTP status code.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003247 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003248 response's status code matches the expression. If the
3249 "rstatus" keyword is prefixed with "!", then the response
3250 will be considered invalid if the status code matches.
3251 This is mostly used to check for multiple codes.
3252
3253 string <string> : test the exact string match in the HTTP response body.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003254 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003255 response's body contains this exact string. If the
3256 "string" keyword is prefixed with "!", then the response
3257 will be considered invalid if the body contains this
3258 string. This can be used to look for a mandatory word at
3259 the end of a dynamic page, or to detect a failure when a
3260 specific error appears on the check page (eg: a stack
3261 trace).
3262
3263 rstring <regex> : test a regular expression on the HTTP response body.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04003264 A health check response will be considered valid if the
Willy Tarreaubd741542010-03-16 18:46:54 +01003265 response's body matches this expression. If the "rstring"
3266 keyword is prefixed with "!", then the response will be
3267 considered invalid if the body matches the expression.
3268 This can be used to look for a mandatory word at the end
3269 of a dynamic page, or to detect a failure when a specific
3270 error appears on the check page (eg: a stack trace).
3271
3272 It is important to note that the responses will be limited to a certain size
3273 defined by the global "tune.chksize" option, which defaults to 16384 bytes.
3274 Thus, too large responses may not contain the mandatory pattern when using
3275 "string" or "rstring". If a large response is absolutely required, it is
3276 possible to change the default max size by setting the global variable.
3277 However, it is worth keeping in mind that parsing very large responses can
3278 waste some CPU cycles, especially when regular expressions are used, and that
3279 it is always better to focus the checks on smaller resources.
3280
Cyril Bonté32602d22015-01-30 00:07:07 +01003281 Also "http-check expect" doesn't support HTTP keep-alive. Keep in mind that it
3282 will automatically append a "Connection: close" header, meaning that this
3283 header should not be present in the request provided by "option httpchk".
3284
Willy Tarreaubd741542010-03-16 18:46:54 +01003285 Last, if "http-check expect" is combined with "http-check disable-on-404",
3286 then this last one has precedence when the server responds with 404.
3287
3288 Examples :
3289 # only accept status 200 as valid
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003290 http-check expect status 200
Willy Tarreaubd741542010-03-16 18:46:54 +01003291
3292 # consider SQL errors as errors
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003293 http-check expect ! string SQL\ Error
Willy Tarreaubd741542010-03-16 18:46:54 +01003294
3295 # consider status 5xx only as errors
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003296 http-check expect ! rstatus ^5
Willy Tarreaubd741542010-03-16 18:46:54 +01003297
3298 # check that we have a correct hexadecimal tag before /html
Willy Tarreau8f2a1e72011-01-06 16:36:10 +01003299 http-check expect rstring <!--tag:[0-9a-f]*</html>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003300
Willy Tarreaubd741542010-03-16 18:46:54 +01003301 See also : "option httpchk", "http-check disable-on-404"
Willy Tarreau2769aa02007-12-27 18:26:09 +01003302
3303
Willy Tarreauef781042010-01-27 11:53:01 +01003304http-check send-state
3305 Enable emission of a state header with HTTP health checks
3306 May be used in sections : defaults | frontend | listen | backend
3307 yes | no | yes | yes
3308 Arguments : none
3309
3310 When this option is set, haproxy will systematically send a special header
3311 "X-Haproxy-Server-State" with a list of parameters indicating to each server
3312 how they are seen by haproxy. This can be used for instance when a server is
3313 manipulated without access to haproxy and the operator needs to know whether
3314 haproxy still sees it up or not, or if the server is the last one in a farm.
3315
3316 The header is composed of fields delimited by semi-colons, the first of which
3317 is a word ("UP", "DOWN", "NOLB"), possibly followed by a number of valid
3318 checks on the total number before transition, just as appears in the stats
3319 interface. Next headers are in the form "<variable>=<value>", indicating in
3320 no specific order some values available in the stats interface :
Joseph Lynch514061c2015-01-15 17:52:59 -08003321 - a variable "address", containing the address of the backend server.
3322 This corresponds to the <address> field in the server declaration. For
3323 unix domain sockets, it will read "unix".
3324
3325 - a variable "port", containing the port of the backend server. This
3326 corresponds to the <port> field in the server declaration. For unix
3327 domain sockets, it will read "unix".
3328
Willy Tarreauef781042010-01-27 11:53:01 +01003329 - a variable "name", containing the name of the backend followed by a slash
3330 ("/") then the name of the server. This can be used when a server is
3331 checked in multiple backends.
3332
3333 - a variable "node" containing the name of the haproxy node, as set in the
3334 global "node" variable, otherwise the system's hostname if unspecified.
3335
3336 - a variable "weight" indicating the weight of the server, a slash ("/")
3337 and the total weight of the farm (just counting usable servers). This
3338 helps to know if other servers are available to handle the load when this
3339 one fails.
3340
3341 - a variable "scur" indicating the current number of concurrent connections
3342 on the server, followed by a slash ("/") then the total number of
3343 connections on all servers of the same backend.
3344
3345 - a variable "qcur" indicating the current number of requests in the
3346 server's queue.
3347
3348 Example of a header received by the application server :
3349 >>> X-Haproxy-Server-State: UP 2/3; name=bck/srv2; node=lb1; weight=1/2; \
3350 scur=13/22; qcur=0
3351
3352 See also : "option httpchk", "http-check disable-on-404"
3353
Willy Tarreauccbcc372012-12-27 12:37:57 +01003354http-request { allow | deny | tarpit | auth [realm <realm>] | redirect <rule> |
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003355 add-header <name> <fmt> | set-header <name> <fmt> |
Thierry FOURNIER82bf70d2015-05-26 17:58:29 +02003356 capture <sample> [ len <length> | id <id> ] |
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003357 del-header <name> | set-nice <nice> | set-log-level <level> |
Sasha Pachev218f0642014-06-16 12:05:59 -06003358 replace-header <name> <match-regex> <replace-fmt> |
3359 replace-value <name> <match-regex> <replace-fmt> |
Willy Tarreaua0dc23f2015-01-22 20:46:11 +01003360 set-method <fmt> | set-path <fmt> | set-query <fmt> |
3361 set-uri <fmt> | set-tos <tos> | set-mark <mark> |
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003362 add-acl(<file name>) <key fmt> |
3363 del-acl(<file name>) <key fmt> |
3364 del-map(<file name>) <key fmt> |
Baptiste Assmannbb7e86a2014-09-03 18:29:47 +02003365 set-map(<file name>) <key fmt> <value fmt> |
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02003366 set-var(<var name>) <expr> |
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003367 { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>] |
Thierry FOURNIER236657b2015-08-19 08:25:14 +02003368 sc-set-gpt0(<sc-id>) <int> |
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003369 lua <function name>
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003370 }
Cyril Bontéf0c60612010-02-06 14:44:47 +01003371 [ { if | unless } <condition> ]
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003372 Access control for Layer 7 requests
3373
3374 May be used in sections: defaults | frontend | listen | backend
3375 no | yes | yes | yes
3376
Willy Tarreau20b0de52012-12-24 15:45:22 +01003377 The http-request statement defines a set of rules which apply to layer 7
3378 processing. The rules are evaluated in their declaration order when they are
3379 met in a frontend, listen or backend section. Any rule may optionally be
3380 followed by an ACL-based condition, in which case it will only be evaluated
3381 if the condition is true.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003382
Willy Tarreau20b0de52012-12-24 15:45:22 +01003383 The first keyword is the rule's action. Currently supported actions include :
3384 - "allow" : this stops the evaluation of the rules and lets the request
3385 pass the check. No further "http-request" rules are evaluated.
3386
3387 - "deny" : this stops the evaluation of the rules and immediately rejects
3388 the request and emits an HTTP 403 error. No further "http-request" rules
3389 are evaluated.
3390
Willy Tarreauccbcc372012-12-27 12:37:57 +01003391 - "tarpit" : this stops the evaluation of the rules and immediately blocks
3392 the request without responding for a delay specified by "timeout tarpit"
3393 or "timeout connect" if the former is not set. After that delay, if the
3394 client is still connected, an HTTP error 500 is returned so that the
3395 client does not suspect it has been tarpitted. Logs will report the flags
3396 "PT". The goal of the tarpit rule is to slow down robots during an attack
3397 when they're limited on the number of concurrent requests. It can be very
3398 efficient against very dumb robots, and will significantly reduce the
3399 load on firewalls compared to a "deny" rule. But when facing "correctly"
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03003400 developed robots, it can make things worse by forcing haproxy and the
Willy Tarreauccbcc372012-12-27 12:37:57 +01003401 front firewall to support insane number of concurrent connections.
3402
Willy Tarreau20b0de52012-12-24 15:45:22 +01003403 - "auth" : this stops the evaluation of the rules and immediately responds
3404 with an HTTP 401 or 407 error code to invite the user to present a valid
3405 user name and password. No further "http-request" rules are evaluated. An
3406 optional "realm" parameter is supported, it sets the authentication realm
3407 that is returned with the response (typically the application's name).
3408
Willy Tarreau81499eb2012-12-27 12:19:02 +01003409 - "redirect" : this performs an HTTP redirection based on a redirect rule.
3410 This is exactly the same as the "redirect" statement except that it
3411 inserts a redirect rule which can be processed in the middle of other
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01003412 "http-request" rules and that these rules use the "log-format" strings.
3413 See the "redirect" keyword for the rule's syntax.
Willy Tarreau81499eb2012-12-27 12:19:02 +01003414
Willy Tarreau20b0de52012-12-24 15:45:22 +01003415 - "add-header" appends an HTTP header field whose name is specified in
3416 <name> and whose value is defined by <fmt> which follows the log-format
3417 rules (see Custom Log Format in section 8.2.4). This is particularly
3418 useful to pass connection-specific information to the server (eg: the
3419 client's SSL certificate), or to combine several headers into one. This
3420 rule is not final, so it is possible to add other similar rules. Note
3421 that header addition is performed immediately, so one rule might reuse
3422 the resulting header from a previous rule.
3423
3424 - "set-header" does the same as "add-header" except that the header name
3425 is first removed if it existed. This is useful when passing security
3426 information to the server, where the header must not be manipulated by
Willy Tarreau85603282015-01-21 20:39:27 +01003427 external users. Note that the new value is computed before the removal so
3428 it is possible to concatenate a value to an existing header.
Willy Tarreau20b0de52012-12-24 15:45:22 +01003429
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003430 - "del-header" removes all HTTP header fields whose name is specified in
3431 <name>.
3432
Sasha Pachev218f0642014-06-16 12:05:59 -06003433 - "replace-header" matches the regular expression in all occurrences of
3434 header field <name> according to <match-regex>, and replaces them with
3435 the <replace-fmt> argument. Format characters are allowed in replace-fmt
3436 and work like in <fmt> arguments in "add-header". The match is only
3437 case-sensitive. It is important to understand that this action only
3438 considers whole header lines, regardless of the number of values they
3439 may contain. This usage is suited to headers naturally containing commas
3440 in their value, such as If-Modified-Since and so on.
3441
3442 Example:
3443
3444 http-request replace-header Cookie foo=([^;]*);(.*) foo=\1;ip=%bi;\2
3445
3446 applied to:
3447
3448 Cookie: foo=foobar; expires=Tue, 14-Jun-2016 01:40:45 GMT;
3449
3450 outputs:
3451
3452 Cookie: foo=foobar;ip=192.168.1.20; expires=Tue, 14-Jun-2016 01:40:45 GMT;
3453
3454 assuming the backend IP is 192.168.1.20
3455
3456 - "replace-value" works like "replace-header" except that it matches the
3457 regex against every comma-delimited value of the header field <name>
3458 instead of the entire header. This is suited for all headers which are
3459 allowed to carry more than one value. An example could be the Accept
3460 header.
3461
3462 Example:
3463
3464 http-request replace-value X-Forwarded-For ^192\.168\.(.*)$ 172.16.\1
3465
3466 applied to:
3467
3468 X-Forwarded-For: 192.168.10.1, 192.168.13.24, 10.0.0.37
3469
3470 outputs:
3471
3472 X-Forwarded-For: 172.16.10.1, 172.16.13.24, 10.0.0.37
3473
Willy Tarreaua0dc23f2015-01-22 20:46:11 +01003474 - "set-method" rewrites the request method with the result of the
3475 evaluation of format string <fmt>. There should be very few valid reasons
3476 for having to do so as this is more likely to break something than to fix
3477 it.
3478
3479 - "set-path" rewrites the request path with the result of the evaluation of
3480 format string <fmt>. The query string, if any, is left intact. If a
3481 scheme and authority is found before the path, they are left intact as
3482 well. If the request doesn't have a path ("*"), this one is replaced with
3483 the format. This can be used to prepend a directory component in front of
3484 a path for example. See also "set-query" and "set-uri".
3485
3486 Example :
3487 # prepend the host name before the path
3488 http-request set-path /%[hdr(host)]%[path]
3489
3490 - "set-query" rewrites the request's query string which appears after the
3491 first question mark ("?") with the result of the evaluation of format
3492 string <fmt>. The part prior to the question mark is left intact. If the
3493 request doesn't contain a question mark and the new value is not empty,
3494 then one is added at the end of the URI, followed by the new value. If
3495 a question mark was present, it will never be removed even if the value
3496 is empty. This can be used to add or remove parameters from the query
3497 string. See also "set-query" and "set-uri".
3498
3499 Example :
3500 # replace "%3D" with "=" in the query string
3501 http-request set-query %[query,regsub(%3D,=,g)]
3502
3503 - "set-uri" rewrites the request URI with the result of the evaluation of
3504 format string <fmt>. The scheme, authority, path and query string are all
3505 replaced at once. This can be used to rewrite hosts in front of proxies,
3506 or to perform complex modifications to the URI such as moving parts
3507 between the path and the query string. See also "set-path" and
3508 "set-query".
3509
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003510 - "set-nice" sets the "nice" factor of the current request being processed.
3511 It only has effect against the other requests being processed at the same
3512 time. The default value is 0, unless altered by the "nice" setting on the
3513 "bind" line. The accepted range is -1024..1024. The higher the value, the
3514 nicest the request will be. Lower values will make the request more
3515 important than other ones. This can be useful to improve the speed of
3516 some requests, or lower the priority of non-important requests. Using
3517 this setting without prior experimentation can cause some major slowdown.
3518
Willy Tarreau9a355ec2013-06-11 17:45:46 +02003519 - "set-log-level" is used to change the log level of the current request
3520 when a certain condition is met. Valid levels are the 8 syslog levels
3521 (see the "log" keyword) plus the special level "silent" which disables
3522 logging for this request. This rule is not final so the last matching
3523 rule wins. This rule can be useful to disable health checks coming from
3524 another equipment.
3525
Willy Tarreau42cf39e2013-06-11 18:51:32 +02003526 - "set-tos" is used to set the TOS or DSCP field value of packets sent to
3527 the client to the value passed in <tos> on platforms which support this.
3528 This value represents the whole 8 bits of the IP TOS field, and can be
3529 expressed both in decimal or hexadecimal format (prefixed by "0x"). Note
3530 that only the 6 higher bits are used in DSCP or TOS, and the two lower
3531 bits are always 0. This can be used to adjust some routing behaviour on
3532 border routers based on some information from the request. See RFC 2474,
3533 2597, 3260 and 4594 for more information.
3534
Willy Tarreau51347ed2013-06-11 19:34:13 +02003535 - "set-mark" is used to set the Netfilter MARK on all packets sent to the
3536 client to the value passed in <mark> on platforms which support it. This
3537 value is an unsigned 32 bit value which can be matched by netfilter and
3538 by the routing table. It can be expressed both in decimal or hexadecimal
3539 format (prefixed by "0x"). This can be useful to force certain packets to
3540 take a different route (for example a cheaper network path for bulk
3541 downloads). This works on Linux kernels 2.6.32 and above and requires
3542 admin privileges.
3543
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003544 - "add-acl" is used to add a new entry into an ACL. The ACL must be loaded
3545 from a file (even a dummy empty file). The file name of the ACL to be
3546 updated is passed between parentheses. It takes one argument: <key fmt>,
3547 which follows log-format rules, to collect content of the new entry. It
3548 performs a lookup in the ACL before insertion, to avoid duplicated (or
3549 more) values. This lookup is done by a linear search and can be expensive
3550 with large lists! It is the equivalent of the "add acl" command from the
3551 stats socket, but can be triggered by an HTTP request.
3552
3553 - "del-acl" is used to delete an entry from an ACL. The ACL must be loaded
3554 from a file (even a dummy empty file). The file name of the ACL to be
3555 updated is passed between parentheses. It takes one argument: <key fmt>,
3556 which follows log-format rules, to collect content of the entry to delete.
3557 It is the equivalent of the "del acl" command from the stats socket, but
3558 can be triggered by an HTTP request.
3559
3560 - "del-map" is used to delete an entry from a MAP. The MAP must be loaded
3561 from a file (even a dummy empty file). The file name of the MAP to be
3562 updated is passed between parentheses. It takes one argument: <key fmt>,
3563 which follows log-format rules, to collect content of the entry to delete.
3564 It takes one argument: "file name" It is the equivalent of the "del map"
3565 command from the stats socket, but can be triggered by an HTTP request.
3566
3567 - "set-map" is used to add a new entry into a MAP. The MAP must be loaded
3568 from a file (even a dummy empty file). The file name of the MAP to be
3569 updated is passed between parentheses. It takes 2 arguments: <key fmt>,
3570 which follows log-format rules, used to collect MAP key, and <value fmt>,
3571 which follows log-format rules, used to collect content for the new entry.
3572 It performs a lookup in the MAP before insertion, to avoid duplicated (or
3573 more) values. This lookup is done by a linear search and can be expensive
3574 with large lists! It is the equivalent of the "set map" command from the
3575 stats socket, but can be triggered by an HTTP request.
3576
Thierry FOURNIER82bf70d2015-05-26 17:58:29 +02003577 - capture <sample> [ len <length> | id <id> ] :
Willy Tarreaua9083d02015-05-08 15:27:59 +02003578 captures sample expression <sample> from the request buffer, and converts
3579 it to a string of at most <len> characters. The resulting string is
3580 stored into the next request "capture" slot, so it will possibly appear
3581 next to some captured HTTP headers. It will then automatically appear in
3582 the logs, and it will be possible to extract it using sample fetch rules
3583 to feed it into headers or anything. The length should be limited given
3584 that this size will be allocated for each capture during the whole
3585 session life. Please check section 7.3 (Fetching samples) and "capture
3586 request header" for more information.
3587
Thierry FOURNIER82bf70d2015-05-26 17:58:29 +02003588 If the keyword "id" is used instead of "len", the action tries to store
3589 the captured string in a previously declared capture slot. This is useful
3590 to run captures in backends. The slot id can be declared by a previous
3591 directive "http-request capture" or with the "declare capture" keyword.
3592
Willy Tarreau09448f72014-06-25 18:12:15 +02003593 - { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>] :
3594 enables tracking of sticky counters from current request. These rules
3595 do not stop evaluation and do not change default action. Three sets of
3596 counters may be simultaneously tracked by the same connection. The first
3597 "track-sc0" rule executed enables tracking of the counters of the
3598 specified table as the first set. The first "track-sc1" rule executed
3599 enables tracking of the counters of the specified table as the second
3600 set. The first "track-sc2" rule executed enables tracking of the
3601 counters of the specified table as the third set. It is a recommended
3602 practice to use the first set of counters for the per-frontend counters
3603 and the second set for the per-backend ones. But this is just a
3604 guideline, all may be used everywhere.
3605
3606 These actions take one or two arguments :
3607 <key> is mandatory, and is a sample expression rule as described
3608 in section 7.3. It describes what elements of the incoming
3609 request or connection will be analysed, extracted, combined,
3610 and used to select which table entry to update the counters.
3611
3612 <table> is an optional table to be used instead of the default one,
3613 which is the stick-table declared in the current proxy. All
3614 the counters for the matches and updates for the key will
3615 then be performed in that table until the session ends.
3616
3617 Once a "track-sc*" rule is executed, the key is looked up in the table
3618 and if it is not found, an entry is allocated for it. Then a pointer to
3619 that entry is kept during all the session's life, and this entry's
3620 counters are updated as often as possible, every time the session's
3621 counters are updated, and also systematically when the session ends.
3622 Counters are only updated for events that happen after the tracking has
3623 been started. As an exception, connection counters and request counters
3624 are systematically updated so that they reflect useful information.
3625
3626 If the entry tracks concurrent connection counters, one connection is
3627 counted for as long as the entry is tracked, and the entry will not
3628 expire during that time. Tracking counters also provides a performance
3629 advantage over just checking the keys, because only one table lookup is
3630 performed for all ACL checks that make use of it.
3631
Thierry FOURNIER236657b2015-08-19 08:25:14 +02003632 - sc-set-gpt0(<sc-id>) <int> :
3633 This action sets the GPT0 tag according to the sticky counter designated
3634 by <sc-id> and the value of <int>. The expected result is a boolean. If
3635 an error occurs, this action silently fails and the actions evaluation
3636 continues.
3637
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003638 - "lua" is used to run a Lua function if the action is executed. The single
3639 parameter is the name of the function to run. The prototype of the
3640 function is documented in the API documentation.
3641
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02003642 - set-var(<var-name>) <expr> :
3643 Is used to set the contents of a variable. The variable is declared
3644 inline.
3645
3646 <var-name> The name of the variable starts by an indication about its
3647 scope. The allowed scopes are:
3648 "sess" : the variable is shared with all the session,
3649 "txn" : the variable is shared with all the transaction
3650 (request and response)
3651 "req" : the variable is shared only during the request
3652 processing
3653 "res" : the variable is shared only during the response
3654 processing.
3655 This prefix is followed by a name. The separator is a '.'.
3656 The name may only contain characters 'a-z', 'A-Z', '0-9',
3657 and '_'.
3658
3659 <expr> Is a standard HAProxy expression formed by a sample-fetch
3660 followed by some converters.
3661
3662 Example:
3663
3664 http-request set-var(req.my_var) req.fhdr(user-agent),lower
3665
Adis Nezirovic2fbcafc2015-07-06 15:44:30 +02003666 - set-src <expr> :
3667 Is used to set the source IP address to the value of specified
3668 expression. Useful when a proxy in front of HAProxy rewrites source IP,
3669 but provides the correct IP in a HTTP header; or you want to mask
3670 source IP for privacy.
3671
3672 <expr> Is a standard HAProxy expression formed by a sample-fetch
3673 followed by some converters.
3674
3675 Example:
3676
3677 http-request set-src hdr(x-forwarded-for)
3678 http-request set-src src,ipmask(24)
3679
3680 When set-src is successful, the source port is set to 0.
3681
Willy Tarreau20b0de52012-12-24 15:45:22 +01003682 There is no limit to the number of http-request statements per instance.
3683
3684 It is important to know that http-request rules are processed very early in
3685 the HTTP processing, just after "block" rules and before "reqdel" or "reqrep"
3686 rules. That way, headers added by "add-header"/"set-header" are visible by
3687 almost all further ACL rules.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003688
3689 Example:
Cyril Bonté78caf842010-03-10 22:41:43 +01003690 acl nagios src 192.168.129.3
3691 acl local_net src 192.168.0.0/16
3692 acl auth_ok http_auth(L1)
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003693
Cyril Bonté78caf842010-03-10 22:41:43 +01003694 http-request allow if nagios
3695 http-request allow if local_net auth_ok
3696 http-request auth realm Gimme if local_net auth_ok
3697 http-request deny
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003698
Cyril Bonté78caf842010-03-10 22:41:43 +01003699 Example:
3700 acl auth_ok http_auth_group(L1) G1
Cyril Bonté78caf842010-03-10 22:41:43 +01003701 http-request auth unless auth_ok
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +01003702
Willy Tarreau20b0de52012-12-24 15:45:22 +01003703 Example:
3704 http-request set-header X-Haproxy-Current-Date %T
3705 http-request set-header X-SSL %[ssl_fc]
3706 http-request set-header X-SSL-Session_ID %[ssl_fc_session_id]
3707 http-request set-header X-SSL-Client-Verify %[ssl_c_verify]
3708 http-request set-header X-SSL-Client-DN %{+Q}[ssl_c_s_dn]
3709 http-request set-header X-SSL-Client-CN %{+Q}[ssl_c_s_dn(cn)]
3710 http-request set-header X-SSL-Issuer %{+Q}[ssl_c_i_dn]
3711 http-request set-header X-SSL-Client-NotBefore %{+Q}[ssl_c_notbefore]
3712 http-request set-header X-SSL-Client-NotAfter %{+Q}[ssl_c_notafter]
3713
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003714 Example:
3715 acl key req.hdr(X-Add-Acl-Key) -m found
3716 acl add path /addacl
3717 acl del path /delacl
3718
3719 acl myhost hdr(Host) -f myhost.lst
3720
3721 http-request add-acl(myhost.lst) %[req.hdr(X-Add-Acl-Key)] if key add
3722 http-request del-acl(myhost.lst) %[req.hdr(X-Add-Acl-Key)] if key del
3723
3724 Example:
3725 acl value req.hdr(X-Value) -m found
3726 acl setmap path /setmap
3727 acl delmap path /delmap
3728
3729 use_backend bk_appli if { hdr(Host),map_str(map.lst) -m found }
3730
3731 http-request set-map(map.lst) %[src] %[req.hdr(X-Value)] if setmap value
3732 http-request del-map(map.lst) %[src] if delmap
3733
Cyril Bonté2be1b3f2010-09-30 23:46:30 +02003734 See also : "stats http-request", section 3.4 about userlists and section 7
3735 about ACL usage.
Willy Tarreauef781042010-01-27 11:53:01 +01003736
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003737http-response { allow | deny | add-header <name> <fmt> | set-nice <nice> |
Willy Tarreau51d861a2015-05-22 17:30:48 +02003738 capture <sample> id <id> | redirect <rule> |
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003739 set-header <name> <fmt> | del-header <name> |
Sasha Pachev218f0642014-06-16 12:05:59 -06003740 replace-header <name> <regex-match> <replace-fmt> |
3741 replace-value <name> <regex-match> <replace-fmt> |
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003742 set-log-level <level> | set-mark <mark> | set-tos <tos> |
3743 add-acl(<file name>) <key fmt> |
3744 del-acl(<file name>) <key fmt> |
3745 del-map(<file name>) <key fmt> |
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003746 set-map(<file name>) <key fmt> <value fmt> |
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02003747 set-var(<var-name>) <expr> |
Thierry FOURNIER236657b2015-08-19 08:25:14 +02003748 sc-set-gpt0(<sc-id>) <int> |
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003749 lua <function name>
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003750 }
Lukas Tribus2dd1d1a2013-06-19 23:34:41 +02003751 [ { if | unless } <condition> ]
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003752 Access control for Layer 7 responses
3753
3754 May be used in sections: defaults | frontend | listen | backend
3755 no | yes | yes | yes
3756
3757 The http-response statement defines a set of rules which apply to layer 7
3758 processing. The rules are evaluated in their declaration order when they are
3759 met in a frontend, listen or backend section. Any rule may optionally be
3760 followed by an ACL-based condition, in which case it will only be evaluated
3761 if the condition is true. Since these rules apply on responses, the backend
3762 rules are applied first, followed by the frontend's rules.
3763
3764 The first keyword is the rule's action. Currently supported actions include :
3765 - "allow" : this stops the evaluation of the rules and lets the response
3766 pass the check. No further "http-response" rules are evaluated for the
3767 current section.
3768
3769 - "deny" : this stops the evaluation of the rules and immediately rejects
3770 the response and emits an HTTP 502 error. No further "http-response"
3771 rules are evaluated.
3772
3773 - "add-header" appends an HTTP header field whose name is specified in
3774 <name> and whose value is defined by <fmt> which follows the log-format
3775 rules (see Custom Log Format in section 8.2.4). This may be used to send
3776 a cookie to a client for example, or to pass some internal information.
3777 This rule is not final, so it is possible to add other similar rules.
3778 Note that header addition is performed immediately, so one rule might
3779 reuse the resulting header from a previous rule.
3780
3781 - "set-header" does the same as "add-header" except that the header name
3782 is first removed if it existed. This is useful when passing security
3783 information to the server, where the header must not be manipulated by
3784 external users.
3785
Thierry FOURNIERdad3d1d2014-04-22 18:07:25 +02003786 - "del-header" removes all HTTP header fields whose name is specified in
3787 <name>.
3788
Sasha Pachev218f0642014-06-16 12:05:59 -06003789 - "replace-header" matches the regular expression in all occurrences of
3790 header field <name> according to <match-regex>, and replaces them with
3791 the <replace-fmt> argument. Format characters are allowed in replace-fmt
3792 and work like in <fmt> arguments in "add-header". The match is only
3793 case-sensitive. It is important to understand that this action only
3794 considers whole header lines, regardless of the number of values they
3795 may contain. This usage is suited to headers naturally containing commas
3796 in their value, such as Set-Cookie, Expires and so on.
3797
3798 Example:
3799
3800 http-response replace-header Set-Cookie (C=[^;]*);(.*) \1;ip=%bi;\2
3801
3802 applied to:
3803
3804 Set-Cookie: C=1; expires=Tue, 14-Jun-2016 01:40:45 GMT
3805
3806 outputs:
3807
3808 Set-Cookie: C=1;ip=192.168.1.20; expires=Tue, 14-Jun-2016 01:40:45 GMT
3809
3810 assuming the backend IP is 192.168.1.20.
3811
3812 - "replace-value" works like "replace-header" except that it matches the
3813 regex against every comma-delimited value of the header field <name>
3814 instead of the entire header. This is suited for all headers which are
3815 allowed to carry more than one value. An example could be the Accept
3816 header.
3817
3818 Example:
3819
3820 http-response replace-value Cache-control ^public$ private
3821
3822 applied to:
3823
3824 Cache-Control: max-age=3600, public
3825
3826 outputs:
3827
3828 Cache-Control: max-age=3600, private
3829
Willy Tarreauf4c43c12013-06-11 17:01:13 +02003830 - "set-nice" sets the "nice" factor of the current request being processed.
3831 It only has effect against the other requests being processed at the same
3832 time. The default value is 0, unless altered by the "nice" setting on the
3833 "bind" line. The accepted range is -1024..1024. The higher the value, the
3834 nicest the request will be. Lower values will make the request more
3835 important than other ones. This can be useful to improve the speed of
3836 some requests, or lower the priority of non-important requests. Using
3837 this setting without prior experimentation can cause some major slowdown.
3838
Willy Tarreau9a355ec2013-06-11 17:45:46 +02003839 - "set-log-level" is used to change the log level of the current request
3840 when a certain condition is met. Valid levels are the 8 syslog levels
3841 (see the "log" keyword) plus the special level "silent" which disables
3842 logging for this request. This rule is not final so the last matching
3843 rule wins. This rule can be useful to disable health checks coming from
3844 another equipment.
3845
Willy Tarreau42cf39e2013-06-11 18:51:32 +02003846 - "set-tos" is used to set the TOS or DSCP field value of packets sent to
3847 the client to the value passed in <tos> on platforms which support this.
3848 This value represents the whole 8 bits of the IP TOS field, and can be
3849 expressed both in decimal or hexadecimal format (prefixed by "0x"). Note
3850 that only the 6 higher bits are used in DSCP or TOS, and the two lower
3851 bits are always 0. This can be used to adjust some routing behaviour on
3852 border routers based on some information from the request. See RFC 2474,
3853 2597, 3260 and 4594 for more information.
3854
Willy Tarreau51347ed2013-06-11 19:34:13 +02003855 - "set-mark" is used to set the Netfilter MARK on all packets sent to the
3856 client to the value passed in <mark> on platforms which support it. This
3857 value is an unsigned 32 bit value which can be matched by netfilter and
3858 by the routing table. It can be expressed both in decimal or hexadecimal
3859 format (prefixed by "0x"). This can be useful to force certain packets to
3860 take a different route (for example a cheaper network path for bulk
3861 downloads). This works on Linux kernels 2.6.32 and above and requires
3862 admin privileges.
3863
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003864 - "add-acl" is used to add a new entry into an ACL. The ACL must be loaded
3865 from a file (even a dummy empty file). The file name of the ACL to be
3866 updated is passed between parentheses. It takes one argument: <key fmt>,
3867 which follows log-format rules, to collect content of the new entry. It
3868 performs a lookup in the ACL before insertion, to avoid duplicated (or
3869 more) values. This lookup is done by a linear search and can be expensive
3870 with large lists! It is the equivalent of the "add acl" command from the
3871 stats socket, but can be triggered by an HTTP response.
3872
3873 - "del-acl" is used to delete an entry from an ACL. The ACL must be loaded
3874 from a file (even a dummy empty file). The file name of the ACL to be
3875 updated is passed between parentheses. It takes one argument: <key fmt>,
3876 which follows log-format rules, to collect content of the entry to delete.
3877 It is the equivalent of the "del acl" command from the stats socket, but
3878 can be triggered by an HTTP response.
3879
3880 - "del-map" is used to delete an entry from a MAP. The MAP must be loaded
3881 from a file (even a dummy empty file). The file name of the MAP to be
3882 updated is passed between parentheses. It takes one argument: <key fmt>,
3883 which follows log-format rules, to collect content of the entry to delete.
3884 It takes one argument: "file name" It is the equivalent of the "del map"
3885 command from the stats socket, but can be triggered by an HTTP response.
3886
3887 - "set-map" is used to add a new entry into a MAP. The MAP must be loaded
3888 from a file (even a dummy empty file). The file name of the MAP to be
3889 updated is passed between parentheses. It takes 2 arguments: <key fmt>,
3890 which follows log-format rules, used to collect MAP key, and <value fmt>,
3891 which follows log-format rules, used to collect content for the new entry.
3892 It performs a lookup in the MAP before insertion, to avoid duplicated (or
3893 more) values. This lookup is done by a linear search and can be expensive
3894 with large lists! It is the equivalent of the "set map" command from the
3895 stats socket, but can be triggered by an HTTP response.
3896
Thierry FOURNIER90da1912015-03-05 11:17:06 +01003897 - "lua" is used to run a Lua function if the action is executed. The single
3898 parameter is the name of the function to run. The prototype of the
3899 function is documented in the API documentation.
3900
Thierry FOURNIERe80fada2015-05-26 18:06:31 +02003901 - capture <sample> id <id> :
3902 captures sample expression <sample> from the response buffer, and converts
3903 it to a string. The resulting string is stored into the next request
3904 "capture" slot, so it will possibly appear next to some captured HTTP
3905 headers. It will then automatically appear in the logs, and it will be
3906 possible to extract it using sample fetch rules to feed it into headers or
3907 anything. Please check section 7.3 (Fetching samples) and "capture
3908 response header" for more information.
3909
3910 The keyword "id" is the id of the capture slot which is used for storing
3911 the string. The capture slot must be defined in an associated frontend.
3912 This is useful to run captures in backends. The slot id can be declared by
3913 a previous directive "http-response capture" or with the "declare capture"
3914 keyword.
3915
Willy Tarreau51d861a2015-05-22 17:30:48 +02003916 - "redirect" : this performs an HTTP redirection based on a redirect rule.
3917 This supports a format string similarly to "http-request redirect" rules,
3918 with the exception that only the "location" type of redirect is possible
3919 on the response. See the "redirect" keyword for the rule's syntax. When
3920 a redirect rule is applied during a response, connections to the server
3921 are closed so that no data can be forwarded from the server to the client.
3922
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02003923 - set-var(<var-name>) expr:
3924 Is used to set the contents of a variable. The variable is declared
3925 inline.
3926
3927 <var-name> The name of the variable starts by an indication about its
3928 scope. The allowed scopes are:
3929 "sess" : the variable is shared with all the session,
3930 "txn" : the variable is shared with all the transaction
3931 (request and response)
3932 "req" : the variable is shared only during the request
3933 processing
3934 "res" : the variable is shared only during the response
3935 processing.
3936 This prefix is followed by a name. The separator is a '.'.
3937 The name may only contain characters 'a-z', 'A-Z', '0-9',
3938 and '_'.
3939
3940 <expr> Is a standard HAProxy expression formed by a sample-fetch
3941 followed by some converters.
3942
3943 Example:
3944
3945 http-response set-var(sess.last_redir) res.hdr(location)
3946
Thierry FOURNIER236657b2015-08-19 08:25:14 +02003947 - sc-set-gpt0(<sc-id>) <int> :
3948 This action sets the GPT0 tag according to the sticky counter designated
3949 by <sc-id> and the value of <int>. The expected result is a boolean. If
3950 an error occurs, this action silently fails and the actions evaluation
3951 continues.
3952
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003953 There is no limit to the number of http-response statements per instance.
3954
Godbach09250262013-07-02 01:19:15 +08003955 It is important to know that http-response rules are processed very early in
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003956 the HTTP processing, before "reqdel" or "reqrep" rules. That way, headers
3957 added by "add-header"/"set-header" are visible by almost all further ACL
3958 rules.
3959
Baptiste Assmannfabcbe02014-04-24 22:16:59 +02003960 Example:
3961 acl key_acl res.hdr(X-Acl-Key) -m found
3962
3963 acl myhost hdr(Host) -f myhost.lst
3964
3965 http-response add-acl(myhost.lst) %[res.hdr(X-Acl-Key)] if key_acl
3966 http-response del-acl(myhost.lst) %[res.hdr(X-Acl-Key)] if key_acl
3967
3968 Example:
3969 acl value res.hdr(X-Value) -m found
3970
3971 use_backend bk_appli if { hdr(Host),map_str(map.lst) -m found }
3972
3973 http-response set-map(map.lst) %[src] %[res.hdr(X-Value)] if value
3974 http-response del-map(map.lst) %[src] if ! value
3975
Willy Tarreaue365c0b2013-06-11 16:06:12 +02003976 See also : "http-request", section 3.4 about userlists and section 7 about
3977 ACL usage.
3978
Baptiste Assmann5ecb77f2013-10-06 23:24:13 +02003979
Willy Tarreau30631952015-08-06 15:05:24 +02003980http-reuse { never | safe | aggressive | always }
3981 Declare how idle HTTP connections may be shared between requests
3982
3983 May be used in sections: defaults | frontend | listen | backend
3984 yes | no | yes | yes
3985
3986 By default, a connection established between haproxy and the backend server
3987 belongs to the session that initiated it. The downside is that between the
3988 response and the next request, the connection remains idle and is not used.
3989 In many cases for performance reasons it is desirable to make it possible to
3990 reuse these idle connections to serve other requests from different sessions.
3991 This directive allows to tune this behaviour.
3992
3993 The argument indicates the desired connection reuse strategy :
3994
3995 - "never" : idle connections are never shared between sessions. This is
3996 the default choice. It may be enforced to cancel a different
3997 strategy inherited from a defaults section or for
3998 troubleshooting. For example, if an old bogus application
3999 considers that multiple requests over the same connection come
4000 from the same client and it is not possible to fix the
4001 application, it may be desirable to disable connection sharing
4002 in a single backend. An example of such an application could
4003 be an old haproxy using cookie insertion in tunnel mode and
4004 not checking any request past the first one.
4005
4006 - "safe" : this is the recommended strategy. The first request of a
4007 session is always sent over its own connection, and only
4008 subsequent requests may be dispatched over other existing
4009 connections. This ensures that in case the server closes the
4010 connection when the request is being sent, the browser can
4011 decide to silently retry it. Since it is exactly equivalent to
4012 regular keep-alive, there should be no side effects.
4013
4014 - "aggressive" : this mode may be useful in webservices environments where
4015 all servers are not necessarily known and where it would be
4016 appreciable to deliver most first requests over existing
4017 connections. In this case, first requests are only delivered
4018 over existing connections that have been reused at least once,
4019 proving that the server correctly supports connection reuse.
4020 It should only be used when it's sure that the client can
4021 retry a failed request once in a while and where the benefit
4022 of aggressive connection reuse significantly outweights the
4023 downsides of rare connection failures.
4024
4025 - "always" : this mode is only recommended when the path to the server is
4026 known for never breaking existing connections quickly after
4027 releasing them. It allows the first request of a session to be
4028 sent to an existing connection. This can provide a significant
4029 performance increase over the "safe" strategy when the backend
4030 is a cache farm, since such components tend to show a
4031 consistent behaviour and will benefit from the connection
4032 sharing. It is recommended that the "http-keep-alive" timeout
4033 remains low in this mode so that no dead connections remain
4034 usable. In most cases, this will lead to the same performance
4035 gains as "aggressive" but with more risks. It should only be
4036 used when it improves the situation over "aggressive".
4037
4038 When http connection sharing is enabled, a great care is taken to respect the
4039 connection properties and compatiblities. Specifically :
4040 - connections made with "usesrc" followed by a client-dependant value
4041 ("client", "clientip", "hdr_ip") are marked private and never shared ;
4042
4043 - connections sent to a server with a TLS SNI extension are marked private
4044 and are never shared ;
4045
4046 - connections receiving a status code 401 or 407 expect some authentication
4047 to be sent in return. Due to certain bogus authentication schemes (such
4048 as NTLM) relying on the connection, these connections are marked private
4049 and are never shared ;
4050
4051 No connection pool is involved, once a session dies, the last idle connection
4052 it was attached to is deleted at the same time. This ensures that connections
4053 may not last after all sessions are closed.
4054
4055 Note: connection reuse improves the accuracy of the "server maxconn" setting,
4056 because almost no new connection will be established while idle connections
4057 remain available. This is particularly true with the "always" strategy.
4058
4059 See also : "option http-keep-alive", "server maxconn"
4060
4061
Mark Lamourinec2247f02012-01-04 13:02:01 -05004062http-send-name-header [<header>]
4063 Add the server name to a request. Use the header string given by <header>
4064
4065 May be used in sections: defaults | frontend | listen | backend
4066 yes | no | yes | yes
4067
4068 Arguments :
4069
4070 <header> The header string to use to send the server name
4071
4072 The "http-send-name-header" statement causes the name of the target
4073 server to be added to the headers of an HTTP request. The name
4074 is added with the header string proved.
4075
4076 See also : "server"
4077
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004078id <value>
Willy Tarreau53fb4ae2009-10-04 23:04:08 +02004079 Set a persistent ID to a proxy.
4080 May be used in sections : defaults | frontend | listen | backend
4081 no | yes | yes | yes
4082 Arguments : none
4083
4084 Set a persistent ID for the proxy. This ID must be unique and positive.
4085 An unused ID will automatically be assigned if unset. The first assigned
4086 value will be 1. This ID is currently only returned in statistics.
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004087
4088
Cyril Bonté0d4bf012010-04-25 23:21:46 +02004089ignore-persist { if | unless } <condition>
4090 Declare a condition to ignore persistence
4091 May be used in sections: defaults | frontend | listen | backend
4092 no | yes | yes | yes
4093
4094 By default, when cookie persistence is enabled, every requests containing
4095 the cookie are unconditionally persistent (assuming the target server is up
4096 and running).
4097
4098 The "ignore-persist" statement allows one to declare various ACL-based
4099 conditions which, when met, will cause a request to ignore persistence.
4100 This is sometimes useful to load balance requests for static files, which
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03004101 often don't require persistence. This can also be used to fully disable
Cyril Bonté0d4bf012010-04-25 23:21:46 +02004102 persistence for a specific User-Agent (for example, some web crawler bots).
4103
Cyril Bonté0d4bf012010-04-25 23:21:46 +02004104 The persistence is ignored when an "if" condition is met, or unless an
4105 "unless" condition is met.
4106
4107 See also : "force-persist", "cookie", and section 7 about ACL usage.
4108
4109
Willy Tarreau2769aa02007-12-27 18:26:09 +01004110log global
Willy Tarreau18324f52014-06-27 18:10:07 +02004111log <address> [len <length>] <facility> [<level> [<minlevel>]]
William Lallemand0f99e342011-10-12 17:50:54 +02004112no log
Willy Tarreau2769aa02007-12-27 18:26:09 +01004113 Enable per-instance logging of events and traffic.
4114 May be used in sections : defaults | frontend | listen | backend
4115 yes | yes | yes | yes
William Lallemand0f99e342011-10-12 17:50:54 +02004116
4117 Prefix :
4118 no should be used when the logger list must be flushed. For example,
4119 if you don't want to inherit from the default logger list. This
4120 prefix does not allow arguments.
4121
Willy Tarreau2769aa02007-12-27 18:26:09 +01004122 Arguments :
4123 global should be used when the instance's logging parameters are the
4124 same as the global ones. This is the most common usage. "global"
4125 replaces <address>, <facility> and <level> with those of the log
4126 entries found in the "global" section. Only one "log global"
4127 statement may be used per instance, and this form takes no other
4128 parameter.
4129
4130 <address> indicates where to send the logs. It takes the same format as
4131 for the "global" section's logs, and can be one of :
4132
4133 - An IPv4 address optionally followed by a colon (':') and a UDP
4134 port. If no port is specified, 514 is used by default (the
4135 standard syslog port).
4136
David du Colombier24bb5f52011-03-17 10:40:23 +01004137 - An IPv6 address followed by a colon (':') and optionally a UDP
4138 port. If no port is specified, 514 is used by default (the
4139 standard syslog port).
4140
Willy Tarreau2769aa02007-12-27 18:26:09 +01004141 - A filesystem path to a UNIX domain socket, keeping in mind
4142 considerations for chroot (be sure the path is accessible
4143 inside the chroot) and uid/gid (be sure the path is
4144 appropriately writeable).
4145
William Lallemandb2f07452015-05-12 14:27:13 +02004146 You may want to reference some environment variables in the
4147 address parameter, see section 2.3 about environment variables.
Willy Tarreaudad36a32013-03-11 01:20:04 +01004148
Willy Tarreau18324f52014-06-27 18:10:07 +02004149 <length> is an optional maximum line length. Log lines larger than this
4150 value will be truncated before being sent. The reason is that
4151 syslog servers act differently on log line length. All servers
4152 support the default value of 1024, but some servers simply drop
4153 larger lines while others do log them. If a server supports long
4154 lines, it may make sense to set this value here in order to avoid
4155 truncating long lines. Similarly, if a server drops long lines,
4156 it is preferable to truncate them before sending them. Accepted
4157 values are 80 to 65535 inclusive. The default value of 1024 is
4158 generally fine for all standard usages. Some specific cases of
4159 long captures or JSON-formated logs may require larger values.
4160
Willy Tarreau2769aa02007-12-27 18:26:09 +01004161 <facility> must be one of the 24 standard syslog facilities :
4162
4163 kern user mail daemon auth syslog lpr news
4164 uucp cron auth2 ftp ntp audit alert cron2
4165 local0 local1 local2 local3 local4 local5 local6 local7
4166
4167 <level> is optional and can be specified to filter outgoing messages. By
4168 default, all messages are sent. If a level is specified, only
4169 messages with a severity at least as important as this level
Willy Tarreauf7edefa2009-05-10 17:20:05 +02004170 will be sent. An optional minimum level can be specified. If it
4171 is set, logs emitted with a more severe level than this one will
4172 be capped to this level. This is used to avoid sending "emerg"
4173 messages on all terminals on some default syslog configurations.
4174 Eight levels are known :
Willy Tarreau2769aa02007-12-27 18:26:09 +01004175
4176 emerg alert crit err warning notice info debug
4177
William Lallemand0f99e342011-10-12 17:50:54 +02004178 It is important to keep in mind that it is the frontend which decides what to
4179 log from a connection, and that in case of content switching, the log entries
4180 from the backend will be ignored. Connections are logged at level "info".
Willy Tarreaucc6c8912009-02-22 10:53:55 +01004181
4182 However, backend log declaration define how and where servers status changes
4183 will be logged. Level "notice" will be used to indicate a server going up,
4184 "warning" will be used for termination signals and definitive service
4185 termination, and "alert" will be used for when a server goes down.
4186
4187 Note : According to RFC3164, messages are truncated to 1024 bytes before
4188 being emitted.
Willy Tarreau2769aa02007-12-27 18:26:09 +01004189
4190 Example :
4191 log global
Willy Tarreauf7edefa2009-05-10 17:20:05 +02004192 log 127.0.0.1:514 local0 notice # only send important events
4193 log 127.0.0.1:514 local0 notice notice # same but limit output level
William Lallemandb2f07452015-05-12 14:27:13 +02004194 log "${LOCAL_SYSLOG}:514" local0 notice # send to local server
Willy Tarreaudad36a32013-03-11 01:20:04 +01004195
Willy Tarreau2769aa02007-12-27 18:26:09 +01004196
William Lallemand48940402012-01-30 16:47:22 +01004197log-format <string>
Willy Tarreaufb4e7ea2015-01-07 14:55:17 +01004198 Specifies the log format string to use for traffic logs
4199 May be used in sections: defaults | frontend | listen | backend
4200 yes | yes | yes | no
William Lallemand48940402012-01-30 16:47:22 +01004201
Willy Tarreaufb4e7ea2015-01-07 14:55:17 +01004202 This directive specifies the log format string that will be used for all logs
4203 resulting from traffic passing through the frontend using this line. If the
4204 directive is used in a defaults section, all subsequent frontends will use
4205 the same log format. Please see section 8.2.4 which covers the log format
4206 string in depth.
William Lallemand48940402012-01-30 16:47:22 +01004207
Willy Tarreau094af4e2015-01-07 15:03:42 +01004208log-tag <string>
4209 Specifies the log tag to use for all outgoing logs
4210 May be used in sections: defaults | frontend | listen | backend
4211 yes | yes | yes | yes
4212
4213 Sets the tag field in the syslog header to this string. It defaults to the
4214 log-tag set in the global section, otherwise the program name as launched
4215 from the command line, which usually is "haproxy". Sometimes it can be useful
4216 to differentiate between multiple processes running on the same host, or to
4217 differentiate customer instances running in the same process. In the backend,
4218 logs about servers up/down will use this tag. As a hint, it can be convenient
4219 to set a log-tag related to a hosted customer in a defaults section then put
4220 all the frontends and backends for that customer, then start another customer
4221 in a new defaults section. See also the global "log-tag" directive.
Willy Tarreau2769aa02007-12-27 18:26:09 +01004222
Willy Tarreauc35362a2014-04-25 13:58:37 +02004223max-keep-alive-queue <value>
4224 Set the maximum server queue size for maintaining keep-alive connections
4225 May be used in sections: defaults | frontend | listen | backend
4226 yes | no | yes | yes
4227
4228 HTTP keep-alive tries to reuse the same server connection whenever possible,
4229 but sometimes it can be counter-productive, for example if a server has a lot
4230 of connections while other ones are idle. This is especially true for static
4231 servers.
4232
4233 The purpose of this setting is to set a threshold on the number of queued
4234 connections at which haproxy stops trying to reuse the same server and prefers
4235 to find another one. The default value, -1, means there is no limit. A value
4236 of zero means that keep-alive requests will never be queued. For very close
4237 servers which can be reached with a low latency and which are not sensible to
4238 breaking keep-alive, a low value is recommended (eg: local static server can
4239 use a value of 10 or less). For remote servers suffering from a high latency,
4240 higher values might be needed to cover for the latency and/or the cost of
4241 picking a different server.
4242
4243 Note that this has no impact on responses which are maintained to the same
4244 server consecutively to a 401 response. They will still go to the same server
4245 even if they have to be queued.
4246
4247 See also : "option http-server-close", "option prefer-last-server", server
4248 "maxconn" and cookie persistence.
4249
4250
Willy Tarreau2769aa02007-12-27 18:26:09 +01004251maxconn <conns>
4252 Fix the maximum number of concurrent connections on a frontend
4253 May be used in sections : defaults | frontend | listen | backend
4254 yes | yes | yes | no
4255 Arguments :
4256 <conns> is the maximum number of concurrent connections the frontend will
4257 accept to serve. Excess connections will be queued by the system
4258 in the socket's listen queue and will be served once a connection
4259 closes.
4260
4261 If the system supports it, it can be useful on big sites to raise this limit
4262 very high so that haproxy manages connection queues, instead of leaving the
4263 clients with unanswered connection attempts. This value should not exceed the
4264 global maxconn. Also, keep in mind that a connection contains two buffers
4265 of 8kB each, as well as some other data resulting in about 17 kB of RAM being
4266 consumed per established connection. That means that a medium system equipped
4267 with 1GB of RAM can withstand around 40000-50000 concurrent connections if
4268 properly tuned.
4269
4270 Also, when <conns> is set to large values, it is possible that the servers
4271 are not sized to accept such loads, and for this reason it is generally wise
4272 to assign them some reasonable connection limits.
4273
Vincent Bernat6341be52012-06-27 17:18:30 +02004274 By default, this value is set to 2000.
4275
Willy Tarreau2769aa02007-12-27 18:26:09 +01004276 See also : "server", global section's "maxconn", "fullconn"
4277
4278
4279mode { tcp|http|health }
4280 Set the running mode or protocol of the instance
4281 May be used in sections : defaults | frontend | listen | backend
4282 yes | yes | yes | yes
4283 Arguments :
4284 tcp The instance will work in pure TCP mode. A full-duplex connection
4285 will be established between clients and servers, and no layer 7
4286 examination will be performed. This is the default mode. It
4287 should be used for SSL, SSH, SMTP, ...
4288
4289 http The instance will work in HTTP mode. The client request will be
4290 analyzed in depth before connecting to any server. Any request
4291 which is not RFC-compliant will be rejected. Layer 7 filtering,
4292 processing and switching will be possible. This is the mode which
4293 brings HAProxy most of its value.
4294
4295 health The instance will work in "health" mode. It will just reply "OK"
Willy Tarreau82569f92012-09-27 23:48:56 +02004296 to incoming connections and close the connection. Alternatively,
4297 If the "httpchk" option is set, "HTTP/1.0 200 OK" will be sent
4298 instead. Nothing will be logged in either case. This mode is used
4299 to reply to external components health checks. This mode is
4300 deprecated and should not be used anymore as it is possible to do
4301 the same and even better by combining TCP or HTTP modes with the
4302 "monitor" keyword.
Willy Tarreau2769aa02007-12-27 18:26:09 +01004303
Cyril Bonté108cf6e2012-04-21 23:30:29 +02004304 When doing content switching, it is mandatory that the frontend and the
4305 backend are in the same mode (generally HTTP), otherwise the configuration
4306 will be refused.
Willy Tarreau2769aa02007-12-27 18:26:09 +01004307
Cyril Bonté108cf6e2012-04-21 23:30:29 +02004308 Example :
Willy Tarreau2769aa02007-12-27 18:26:09 +01004309 defaults http_instances
4310 mode http
4311
Cyril Bonté108cf6e2012-04-21 23:30:29 +02004312 See also : "monitor", "monitor-net"
Willy Tarreau2769aa02007-12-27 18:26:09 +01004313
Willy Tarreau0ba27502007-12-24 16:55:16 +01004314
Cyril Bontéf0c60612010-02-06 14:44:47 +01004315monitor fail { if | unless } <condition>
Willy Tarreau2769aa02007-12-27 18:26:09 +01004316 Add a condition to report a failure to a monitor HTTP request.
Willy Tarreau0ba27502007-12-24 16:55:16 +01004317 May be used in sections : defaults | frontend | listen | backend
4318 no | yes | yes | no
Willy Tarreau0ba27502007-12-24 16:55:16 +01004319 Arguments :
4320 if <cond> the monitor request will fail if the condition is satisfied,
4321 and will succeed otherwise. The condition should describe a
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004322 combined test which must induce a failure if all conditions
Willy Tarreau0ba27502007-12-24 16:55:16 +01004323 are met, for instance a low number of servers both in a
4324 backend and its backup.
4325
4326 unless <cond> the monitor request will succeed only if the condition is
4327 satisfied, and will fail otherwise. Such a condition may be
4328 based on a test on the presence of a minimum number of active
4329 servers in a list of backends.
4330
4331 This statement adds a condition which can force the response to a monitor
4332 request to report a failure. By default, when an external component queries
4333 the URI dedicated to monitoring, a 200 response is returned. When one of the
4334 conditions above is met, haproxy will return 503 instead of 200. This is
4335 very useful to report a site failure to an external component which may base
4336 routing advertisements between multiple sites on the availability reported by
4337 haproxy. In this case, one would rely on an ACL involving the "nbsrv"
Willy Tarreauae94d4d2011-05-11 16:28:49 +02004338 criterion. Note that "monitor fail" only works in HTTP mode. Both status
4339 messages may be tweaked using "errorfile" or "errorloc" if needed.
Willy Tarreau0ba27502007-12-24 16:55:16 +01004340
4341 Example:
4342 frontend www
Willy Tarreau2769aa02007-12-27 18:26:09 +01004343 mode http
Willy Tarreau0ba27502007-12-24 16:55:16 +01004344 acl site_dead nbsrv(dynamic) lt 2
4345 acl site_dead nbsrv(static) lt 2
4346 monitor-uri /site_alive
4347 monitor fail if site_dead
4348
Willy Tarreauae94d4d2011-05-11 16:28:49 +02004349 See also : "monitor-net", "monitor-uri", "errorfile", "errorloc"
Willy Tarreau2769aa02007-12-27 18:26:09 +01004350
4351
4352monitor-net <source>
4353 Declare a source network which is limited to monitor requests
4354 May be used in sections : defaults | frontend | listen | backend
4355 yes | yes | yes | no
4356 Arguments :
4357 <source> is the source IPv4 address or network which will only be able to
4358 get monitor responses to any request. It can be either an IPv4
4359 address, a host name, or an address followed by a slash ('/')
4360 followed by a mask.
4361
4362 In TCP mode, any connection coming from a source matching <source> will cause
4363 the connection to be immediately closed without any log. This allows another
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004364 equipment to probe the port and verify that it is still listening, without
Willy Tarreau2769aa02007-12-27 18:26:09 +01004365 forwarding the connection to a remote server.
4366
4367 In HTTP mode, a connection coming from a source matching <source> will be
4368 accepted, the following response will be sent without waiting for a request,
4369 then the connection will be closed : "HTTP/1.0 200 OK". This is normally
4370 enough for any front-end HTTP probe to detect that the service is UP and
Willy Tarreau82569f92012-09-27 23:48:56 +02004371 running without forwarding the request to a backend server. Note that this
4372 response is sent in raw format, without any transformation. This is important
4373 as it means that it will not be SSL-encrypted on SSL listeners.
Willy Tarreau2769aa02007-12-27 18:26:09 +01004374
Willy Tarreau82569f92012-09-27 23:48:56 +02004375 Monitor requests are processed very early, just after tcp-request connection
4376 ACLs which are the only ones able to block them. These connections are short
4377 lived and never wait for any data from the client. They cannot be logged, and
4378 it is the intended purpose. They are only used to report HAProxy's health to
4379 an upper component, nothing more. Please note that "monitor fail" rules do
4380 not apply to connections intercepted by "monitor-net".
Willy Tarreau2769aa02007-12-27 18:26:09 +01004381
Willy Tarreau95cd2832010-03-04 23:36:33 +01004382 Last, please note that only one "monitor-net" statement can be specified in
4383 a frontend. If more than one is found, only the last one will be considered.
Cyril Bonté108cf6e2012-04-21 23:30:29 +02004384
Willy Tarreau2769aa02007-12-27 18:26:09 +01004385 Example :
4386 # addresses .252 and .253 are just probing us.
4387 frontend www
4388 monitor-net 192.168.0.252/31
4389
4390 See also : "monitor fail", "monitor-uri"
4391
4392
4393monitor-uri <uri>
4394 Intercept a URI used by external components' monitor requests
4395 May be used in sections : defaults | frontend | listen | backend
4396 yes | yes | yes | no
4397 Arguments :
4398 <uri> is the exact URI which we want to intercept to return HAProxy's
4399 health status instead of forwarding the request.
4400
4401 When an HTTP request referencing <uri> will be received on a frontend,
4402 HAProxy will not forward it nor log it, but instead will return either
4403 "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure
4404 conditions defined with "monitor fail". This is normally enough for any
4405 front-end HTTP probe to detect that the service is UP and running without
4406 forwarding the request to a backend server. Note that the HTTP method, the
4407 version and all headers are ignored, but the request must at least be valid
4408 at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
4409
4410 Monitor requests are processed very early. It is not possible to block nor
4411 divert them using ACLs. They cannot be logged either, and it is the intended
4412 purpose. They are only used to report HAProxy's health to an upper component,
4413 nothing more. However, it is possible to add any number of conditions using
4414 "monitor fail" and ACLs so that the result can be adjusted to whatever check
4415 can be imagined (most often the number of available servers in a backend).
4416
4417 Example :
4418 # Use /haproxy_test to report haproxy's status
4419 frontend www
4420 mode http
4421 monitor-uri /haproxy_test
4422
4423 See also : "monitor fail", "monitor-net"
4424
Willy Tarreau0ba27502007-12-24 16:55:16 +01004425
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004426option abortonclose
4427no option abortonclose
4428 Enable or disable early dropping of aborted requests pending in queues.
4429 May be used in sections : defaults | frontend | listen | backend
4430 yes | no | yes | yes
4431 Arguments : none
4432
4433 In presence of very high loads, the servers will take some time to respond.
4434 The per-instance connection queue will inflate, and the response time will
4435 increase respective to the size of the queue times the average per-session
4436 response time. When clients will wait for more than a few seconds, they will
Willy Tarreau198a7442008-01-17 12:05:32 +01004437 often hit the "STOP" button on their browser, leaving a useless request in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004438 the queue, and slowing down other users, and the servers as well, because the
4439 request will eventually be served, then aborted at the first error
4440 encountered while delivering the response.
4441
4442 As there is no way to distinguish between a full STOP and a simple output
4443 close on the client side, HTTP agents should be conservative and consider
4444 that the client might only have closed its output channel while waiting for
4445 the response. However, this introduces risks of congestion when lots of users
4446 do the same, and is completely useless nowadays because probably no client at
4447 all will close the session while waiting for the response. Some HTTP agents
Willy Tarreaud72758d2010-01-12 10:42:19 +01004448 support this behaviour (Squid, Apache, HAProxy), and others do not (TUX, most
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004449 hardware-based load balancers). So the probability for a closed input channel
Willy Tarreau198a7442008-01-17 12:05:32 +01004450 to represent a user hitting the "STOP" button is close to 100%, and the risk
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004451 of being the single component to break rare but valid traffic is extremely
4452 low, which adds to the temptation to be able to abort a session early while
4453 still not served and not pollute the servers.
4454
4455 In HAProxy, the user can choose the desired behaviour using the option
4456 "abortonclose". By default (without the option) the behaviour is HTTP
4457 compliant and aborted requests will be served. But when the option is
4458 specified, a session with an incoming channel closed will be aborted while
4459 it is still possible, either pending in the queue for a connection slot, or
4460 during the connection establishment if the server has not yet acknowledged
4461 the connection request. This considerably reduces the queue size and the load
4462 on saturated servers when users are tempted to click on STOP, which in turn
Willy Tarreaud72758d2010-01-12 10:42:19 +01004463 reduces the response time for other users.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004464
4465 If this option has been enabled in a "defaults" section, it can be disabled
4466 in a specific instance by prepending the "no" keyword before it.
4467
4468 See also : "timeout queue" and server's "maxconn" and "maxqueue" parameters
4469
4470
Willy Tarreau4076a152009-04-02 15:18:36 +02004471option accept-invalid-http-request
4472no option accept-invalid-http-request
4473 Enable or disable relaxing of HTTP request parsing
4474 May be used in sections : defaults | frontend | listen | backend
4475 yes | yes | yes | no
4476 Arguments : none
4477
Willy Tarreau91852eb2015-05-01 13:26:00 +02004478 By default, HAProxy complies with RFC7230 in terms of message parsing. This
Willy Tarreau4076a152009-04-02 15:18:36 +02004479 means that invalid characters in header names are not permitted and cause an
4480 error to be returned to the client. This is the desired behaviour as such
4481 forbidden characters are essentially used to build attacks exploiting server
4482 weaknesses, and bypass security filtering. Sometimes, a buggy browser or
4483 server will emit invalid header names for whatever reason (configuration,
4484 implementation) and the issue will not be immediately fixed. In such a case,
4485 it is possible to relax HAProxy's header name parser to accept any character
Willy Tarreau422246e2012-01-07 23:54:13 +01004486 even if that does not make sense, by specifying this option. Similarly, the
4487 list of characters allowed to appear in a URI is well defined by RFC3986, and
4488 chars 0-31, 32 (space), 34 ('"'), 60 ('<'), 62 ('>'), 92 ('\'), 94 ('^'), 96
4489 ('`'), 123 ('{'), 124 ('|'), 125 ('}'), 127 (delete) and anything above are
4490 not allowed at all. Haproxy always blocks a number of them (0..32, 127). The
Willy Tarreau91852eb2015-05-01 13:26:00 +02004491 remaining ones are blocked by default unless this option is enabled. This
Willy Tarreau13317662015-05-01 13:47:08 +02004492 option also relaxes the test on the HTTP version, it allows HTTP/0.9 requests
4493 to pass through (no version specified) and multiple digits for both the major
4494 and the minor version.
Willy Tarreau4076a152009-04-02 15:18:36 +02004495
4496 This option should never be enabled by default as it hides application bugs
4497 and open security breaches. It should only be deployed after a problem has
4498 been confirmed.
4499
4500 When this option is enabled, erroneous header names will still be accepted in
4501 requests, but the complete request will be captured in order to permit later
Willy Tarreau422246e2012-01-07 23:54:13 +01004502 analysis using the "show errors" request on the UNIX stats socket. Similarly,
4503 requests containing invalid chars in the URI part will be logged. Doing this
Willy Tarreau4076a152009-04-02 15:18:36 +02004504 also helps confirming that the issue has been solved.
4505
4506 If this option has been enabled in a "defaults" section, it can be disabled
4507 in a specific instance by prepending the "no" keyword before it.
4508
4509 See also : "option accept-invalid-http-response" and "show errors" on the
4510 stats socket.
4511
4512
4513option accept-invalid-http-response
4514no option accept-invalid-http-response
4515 Enable or disable relaxing of HTTP response parsing
4516 May be used in sections : defaults | frontend | listen | backend
4517 yes | no | yes | yes
4518 Arguments : none
4519
Willy Tarreau91852eb2015-05-01 13:26:00 +02004520 By default, HAProxy complies with RFC7230 in terms of message parsing. This
Willy Tarreau4076a152009-04-02 15:18:36 +02004521 means that invalid characters in header names are not permitted and cause an
4522 error to be returned to the client. This is the desired behaviour as such
4523 forbidden characters are essentially used to build attacks exploiting server
4524 weaknesses, and bypass security filtering. Sometimes, a buggy browser or
4525 server will emit invalid header names for whatever reason (configuration,
4526 implementation) and the issue will not be immediately fixed. In such a case,
4527 it is possible to relax HAProxy's header name parser to accept any character
Willy Tarreau91852eb2015-05-01 13:26:00 +02004528 even if that does not make sense, by specifying this option. This option also
4529 relaxes the test on the HTTP version format, it allows multiple digits for
4530 both the major and the minor version.
Willy Tarreau4076a152009-04-02 15:18:36 +02004531
4532 This option should never be enabled by default as it hides application bugs
4533 and open security breaches. It should only be deployed after a problem has
4534 been confirmed.
4535
4536 When this option is enabled, erroneous header names will still be accepted in
4537 responses, but the complete response will be captured in order to permit
4538 later analysis using the "show errors" request on the UNIX stats socket.
4539 Doing this also helps confirming that the issue has been solved.
4540
4541 If this option has been enabled in a "defaults" section, it can be disabled
4542 in a specific instance by prepending the "no" keyword before it.
4543
4544 See also : "option accept-invalid-http-request" and "show errors" on the
4545 stats socket.
4546
4547
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004548option allbackups
4549no option allbackups
4550 Use either all backup servers at a time or only the first one
4551 May be used in sections : defaults | frontend | listen | backend
4552 yes | no | yes | yes
4553 Arguments : none
4554
4555 By default, the first operational backup server gets all traffic when normal
4556 servers are all down. Sometimes, it may be preferred to use multiple backups
4557 at once, because one will not be enough. When "option allbackups" is enabled,
4558 the load balancing will be performed among all backup servers when all normal
4559 ones are unavailable. The same load balancing algorithm will be used and the
4560 servers' weights will be respected. Thus, there will not be any priority
4561 order between the backup servers anymore.
4562
4563 This option is mostly used with static server farms dedicated to return a
4564 "sorry" page when an application is completely offline.
4565
4566 If this option has been enabled in a "defaults" section, it can be disabled
4567 in a specific instance by prepending the "no" keyword before it.
4568
4569
4570option checkcache
4571no option checkcache
Godbach7056a352013-12-11 20:01:07 +08004572 Analyze all server responses and block responses with cacheable cookies
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004573 May be used in sections : defaults | frontend | listen | backend
4574 yes | no | yes | yes
4575 Arguments : none
4576
4577 Some high-level frameworks set application cookies everywhere and do not
4578 always let enough control to the developer to manage how the responses should
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004579 be cached. When a session cookie is returned on a cacheable object, there is a
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004580 high risk of session crossing or stealing between users traversing the same
4581 caches. In some situations, it is better to block the response than to let
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02004582 some sensitive session information go in the wild.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004583
4584 The option "checkcache" enables deep inspection of all server responses for
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004585 strict compliance with HTTP specification in terms of cacheability. It
Willy Tarreau198a7442008-01-17 12:05:32 +01004586 carefully checks "Cache-control", "Pragma" and "Set-cookie" headers in server
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004587 response to check if there's a risk of caching a cookie on a client-side
4588 proxy. When this option is enabled, the only responses which can be delivered
Willy Tarreau198a7442008-01-17 12:05:32 +01004589 to the client are :
4590 - all those without "Set-Cookie" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004591 - all those with a return code other than 200, 203, 206, 300, 301, 410,
Willy Tarreau198a7442008-01-17 12:05:32 +01004592 provided that the server has not set a "Cache-control: public" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004593 - all those that come from a POST request, provided that the server has not
4594 set a 'Cache-Control: public' header ;
4595 - those with a 'Pragma: no-cache' header
4596 - those with a 'Cache-control: private' header
4597 - those with a 'Cache-control: no-store' header
4598 - those with a 'Cache-control: max-age=0' header
4599 - those with a 'Cache-control: s-maxage=0' header
4600 - those with a 'Cache-control: no-cache' header
4601 - those with a 'Cache-control: no-cache="set-cookie"' header
4602 - those with a 'Cache-control: no-cache="set-cookie,' header
4603 (allowing other fields after set-cookie)
4604
4605 If a response doesn't respect these requirements, then it will be blocked
Willy Tarreau198a7442008-01-17 12:05:32 +01004606 just as if it was from an "rspdeny" filter, with an "HTTP 502 bad gateway".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004607 The session state shows "PH--" meaning that the proxy blocked the response
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01004608 during headers processing. Additionally, an alert will be sent in the logs so
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004609 that admins are informed that there's something to be fixed.
4610
4611 Due to the high impact on the application, the application should be tested
4612 in depth with the option enabled before going to production. It is also a
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01004613 good practice to always activate it during tests, even if it is not used in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004614 production, as it will report potentially dangerous application behaviours.
4615
4616 If this option has been enabled in a "defaults" section, it can be disabled
4617 in a specific instance by prepending the "no" keyword before it.
4618
4619
4620option clitcpka
4621no option clitcpka
4622 Enable or disable the sending of TCP keepalive packets on the client side
4623 May be used in sections : defaults | frontend | listen | backend
4624 yes | yes | yes | no
4625 Arguments : none
4626
4627 When there is a firewall or any session-aware component between a client and
4628 a server, and when the protocol involves very long sessions with long idle
4629 periods (eg: remote desktops), there is a risk that one of the intermediate
4630 components decides to expire a session which has remained idle for too long.
4631
4632 Enabling socket-level TCP keep-alives makes the system regularly send packets
4633 to the other end of the connection, leaving it active. The delay between
4634 keep-alive probes is controlled by the system only and depends both on the
4635 operating system and its tuning parameters.
4636
4637 It is important to understand that keep-alive packets are neither emitted nor
4638 received at the application level. It is only the network stacks which sees
4639 them. For this reason, even if one side of the proxy already uses keep-alives
4640 to maintain its connection alive, those keep-alive packets will not be
4641 forwarded to the other side of the proxy.
4642
4643 Please note that this has nothing to do with HTTP keep-alive.
4644
4645 Using option "clitcpka" enables the emission of TCP keep-alive probes on the
4646 client side of a connection, which should help when session expirations are
4647 noticed between HAProxy and a client.
4648
4649 If this option has been enabled in a "defaults" section, it can be disabled
4650 in a specific instance by prepending the "no" keyword before it.
4651
4652 See also : "option srvtcpka", "option tcpka"
4653
4654
Willy Tarreau0ba27502007-12-24 16:55:16 +01004655option contstats
4656 Enable continuous traffic statistics updates
4657 May be used in sections : defaults | frontend | listen | backend
4658 yes | yes | yes | no
4659 Arguments : none
4660
4661 By default, counters used for statistics calculation are incremented
4662 only when a session finishes. It works quite well when serving small
4663 objects, but with big ones (for example large images or archives) or
4664 with A/V streaming, a graph generated from haproxy counters looks like
4665 a hedgehog. With this option enabled counters get incremented continuously,
4666 during a whole session. Recounting touches a hotpath directly so
4667 it is not enabled by default, as it has small performance impact (~0.5%).
4668
4669
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02004670option dontlog-normal
4671no option dontlog-normal
4672 Enable or disable logging of normal, successful connections
4673 May be used in sections : defaults | frontend | listen | backend
4674 yes | yes | yes | no
4675 Arguments : none
4676
4677 There are large sites dealing with several thousand connections per second
4678 and for which logging is a major pain. Some of them are even forced to turn
4679 logs off and cannot debug production issues. Setting this option ensures that
4680 normal connections, those which experience no error, no timeout, no retry nor
4681 redispatch, will not be logged. This leaves disk space for anomalies. In HTTP
4682 mode, the response status code is checked and return codes 5xx will still be
4683 logged.
4684
4685 It is strongly discouraged to use this option as most of the time, the key to
4686 complex issues is in the normal logs which will not be logged here. If you
4687 need to separate logs, see the "log-separate-errors" option instead.
4688
Willy Tarreauc57f0e22009-05-10 13:12:33 +02004689 See also : "log", "dontlognull", "log-separate-errors" and section 8 about
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02004690 logging.
4691
4692
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004693option dontlognull
4694no option dontlognull
4695 Enable or disable logging of null connections
4696 May be used in sections : defaults | frontend | listen | backend
4697 yes | yes | yes | no
4698 Arguments : none
4699
4700 In certain environments, there are components which will regularly connect to
4701 various systems to ensure that they are still alive. It can be the case from
4702 another load balancer as well as from monitoring systems. By default, even a
4703 simple port probe or scan will produce a log. If those connections pollute
4704 the logs too much, it is possible to enable option "dontlognull" to indicate
4705 that a connection on which no data has been transferred will not be logged,
Willy Tarreau0f228a02015-05-01 15:37:53 +02004706 which typically corresponds to those probes. Note that errors will still be
4707 returned to the client and accounted for in the stats. If this is not what is
4708 desired, option http-ignore-probes can be used instead.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004709
4710 It is generally recommended not to use this option in uncontrolled
4711 environments (eg: internet), otherwise scans and other malicious activities
4712 would not be logged.
4713
4714 If this option has been enabled in a "defaults" section, it can be disabled
4715 in a specific instance by prepending the "no" keyword before it.
4716
Willy Tarreau0f228a02015-05-01 15:37:53 +02004717 See also : "log", "http-ignore-probes", "monitor-net", "monitor-uri", and
4718 section 8 about logging.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004719
4720
4721option forceclose
4722no option forceclose
4723 Enable or disable active connection closing after response is transferred.
4724 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaua31e5df2009-12-30 01:10:35 +01004725 yes | yes | yes | yes
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004726 Arguments : none
4727
4728 Some HTTP servers do not necessarily close the connections when they receive
4729 the "Connection: close" set by "option httpclose", and if the client does not
4730 close either, then the connection remains open till the timeout expires. This
4731 causes high number of simultaneous connections on the servers and shows high
4732 global session times in the logs.
4733
4734 When this happens, it is possible to use "option forceclose". It will
Willy Tarreau82eeaf22009-12-29 12:09:05 +01004735 actively close the outgoing server channel as soon as the server has finished
Cyril Bonté653dcd62014-02-20 00:13:15 +01004736 to respond and release some resources earlier than with "option httpclose".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004737
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004738 This option may also be combined with "option http-pretend-keepalive", which
4739 will disable sending of the "Connection: close" header, but will still cause
4740 the connection to be closed once the whole response is received.
4741
Cyril Bonté653dcd62014-02-20 00:13:15 +01004742 This option disables and replaces any previous "option httpclose", "option
4743 http-server-close", "option http-keep-alive", or "option http-tunnel".
Willy Tarreau02bce8b2014-01-30 00:15:28 +01004744
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004745 If this option has been enabled in a "defaults" section, it can be disabled
4746 in a specific instance by prepending the "no" keyword before it.
4747
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004748 See also : "option httpclose" and "option http-pretend-keepalive"
Willy Tarreaubf1f8162007-12-28 17:42:56 +01004749
4750
Willy Tarreau87cf5142011-08-19 22:57:24 +02004751option forwardfor [ except <network> ] [ header <name> ] [ if-none ]
Willy Tarreauc27debf2008-01-06 08:57:02 +01004752 Enable insertion of the X-Forwarded-For header to requests sent to servers
4753 May be used in sections : defaults | frontend | listen | backend
4754 yes | yes | yes | yes
4755 Arguments :
4756 <network> is an optional argument used to disable this option for sources
4757 matching <network>
Ross Westaf72a1d2008-08-03 10:51:45 +02004758 <name> an optional argument to specify a different "X-Forwarded-For"
Willy Tarreaud72758d2010-01-12 10:42:19 +01004759 header name.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004760
4761 Since HAProxy works in reverse-proxy mode, the servers see its IP address as
4762 their client address. This is sometimes annoying when the client's IP address
4763 is expected in server logs. To solve this problem, the well-known HTTP header
4764 "X-Forwarded-For" may be added by HAProxy to all requests sent to the server.
4765 This header contains a value representing the client's IP address. Since this
4766 header is always appended at the end of the existing header list, the server
4767 must be configured to always use the last occurrence of this header only. See
Ross Westaf72a1d2008-08-03 10:51:45 +02004768 the server's manual to find how to enable use of this standard header. Note
4769 that only the last occurrence of the header must be used, since it is really
4770 possible that the client has already brought one.
4771
Willy Tarreaud72758d2010-01-12 10:42:19 +01004772 The keyword "header" may be used to supply a different header name to replace
Ross Westaf72a1d2008-08-03 10:51:45 +02004773 the default "X-Forwarded-For". This can be useful where you might already
Willy Tarreaud72758d2010-01-12 10:42:19 +01004774 have a "X-Forwarded-For" header from a different application (eg: stunnel),
4775 and you need preserve it. Also if your backend server doesn't use the
Ross Westaf72a1d2008-08-03 10:51:45 +02004776 "X-Forwarded-For" header and requires different one (eg: Zeus Web Servers
4777 require "X-Cluster-Client-IP").
Willy Tarreauc27debf2008-01-06 08:57:02 +01004778
4779 Sometimes, a same HAProxy instance may be shared between a direct client
4780 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
4781 used to decrypt HTTPS traffic). It is possible to disable the addition of the
4782 header for a known source address or network by adding the "except" keyword
4783 followed by the network address. In this case, any source IP matching the
4784 network will not cause an addition of this header. Most common uses are with
4785 private networks or 127.0.0.1.
4786
Willy Tarreau87cf5142011-08-19 22:57:24 +02004787 Alternatively, the keyword "if-none" states that the header will only be
4788 added if it is not present. This should only be used in perfectly trusted
4789 environment, as this might cause a security issue if headers reaching haproxy
4790 are under the control of the end-user.
4791
Willy Tarreauc27debf2008-01-06 08:57:02 +01004792 This option may be specified either in the frontend or in the backend. If at
Ross Westaf72a1d2008-08-03 10:51:45 +02004793 least one of them uses it, the header will be added. Note that the backend's
4794 setting of the header subargument takes precedence over the frontend's if
Willy Tarreau87cf5142011-08-19 22:57:24 +02004795 both are defined. In the case of the "if-none" argument, if at least one of
4796 the frontend or the backend does not specify it, it wants the addition to be
4797 mandatory, so it wins.
Willy Tarreauc27debf2008-01-06 08:57:02 +01004798
Ross Westaf72a1d2008-08-03 10:51:45 +02004799 Examples :
Willy Tarreauc27debf2008-01-06 08:57:02 +01004800 # Public HTTP address also used by stunnel on the same machine
4801 frontend www
4802 mode http
4803 option forwardfor except 127.0.0.1 # stunnel already adds the header
4804
Ross Westaf72a1d2008-08-03 10:51:45 +02004805 # Those servers want the IP Address in X-Client
4806 backend www
4807 mode http
4808 option forwardfor header X-Client
4809
Willy Tarreau87cf5142011-08-19 22:57:24 +02004810 See also : "option httpclose", "option http-server-close",
Willy Tarreau70dffda2014-01-30 03:07:23 +01004811 "option forceclose", "option http-keep-alive"
Willy Tarreauc27debf2008-01-06 08:57:02 +01004812
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004813
Willy Tarreau9fbe18e2015-05-01 22:42:08 +02004814option http-buffer-request
4815no option http-buffer-request
4816 Enable or disable waiting for whole HTTP request body before proceeding
4817 May be used in sections : defaults | frontend | listen | backend
4818 yes | yes | yes | yes
4819 Arguments : none
4820
4821 It is sometimes desirable to wait for the body of an HTTP request before
4822 taking a decision. This is what is being done by "balance url_param" for
4823 example. The first use case is to buffer requests from slow clients before
4824 connecting to the server. Another use case consists in taking the routing
4825 decision based on the request body's contents. This option placed in a
4826 frontend or backend forces the HTTP processing to wait until either the whole
4827 body is received, or the request buffer is full, or the first chunk is
4828 complete in case of chunked encoding. It can have undesired side effects with
4829 some applications abusing HTTP by expecting unbufferred transmissions between
4830 the frontend and the backend, so this should definitely not be used by
4831 default.
4832
4833 See also : "option http-no-delay"
4834
4835
Willy Tarreau0f228a02015-05-01 15:37:53 +02004836option http-ignore-probes
4837no option http-ignore-probes
4838 Enable or disable logging of null connections and request timeouts
4839 May be used in sections : defaults | frontend | listen | backend
4840 yes | yes | yes | no
4841 Arguments : none
4842
4843 Recently some browsers started to implement a "pre-connect" feature
4844 consisting in speculatively connecting to some recently visited web sites
4845 just in case the user would like to visit them. This results in many
4846 connections being established to web sites, which end up in 408 Request
4847 Timeout if the timeout strikes first, or 400 Bad Request when the browser
4848 decides to close them first. These ones pollute the log and feed the error
4849 counters. There was already "option dontlognull" but it's insufficient in
4850 this case. Instead, this option does the following things :
4851 - prevent any 400/408 message from being sent to the client if nothing
4852 was received over a connection before it was closed ;
4853 - prevent any log from being emitted in this situation ;
4854 - prevent any error counter from being incremented
4855
4856 That way the empty connection is silently ignored. Note that it is better
4857 not to use this unless it is clear that it is needed, because it will hide
4858 real problems. The most common reason for not receiving a request and seeing
4859 a 408 is due to an MTU inconsistency between the client and an intermediary
4860 element such as a VPN, which blocks too large packets. These issues are
4861 generally seen with POST requests as well as GET with large cookies. The logs
4862 are often the only way to detect them.
4863
4864 If this option has been enabled in a "defaults" section, it can be disabled
4865 in a specific instance by prepending the "no" keyword before it.
4866
4867 See also : "log", "dontlognull", "errorfile", and section 8 about logging.
4868
4869
Willy Tarreau16bfb022010-01-16 19:48:41 +01004870option http-keep-alive
4871no option http-keep-alive
4872 Enable or disable HTTP keep-alive from client to server
4873 May be used in sections : defaults | frontend | listen | backend
4874 yes | yes | yes | yes
4875 Arguments : none
4876
Willy Tarreau70dffda2014-01-30 03:07:23 +01004877 By default HAProxy operates in keep-alive mode with regards to persistent
4878 connections: for each connection it processes each request and response, and
4879 leaves the connection idle on both sides between the end of a response and the
4880 start of a new request. This mode may be changed by several options such as
4881 "option http-server-close", "option forceclose", "option httpclose" or
4882 "option http-tunnel". This option allows to set back the keep-alive mode,
4883 which can be useful when another mode was used in a defaults section.
4884
4885 Setting "option http-keep-alive" enables HTTP keep-alive mode on the client-
4886 and server- sides. This provides the lowest latency on the client side (slow
Willy Tarreau16bfb022010-01-16 19:48:41 +01004887 network) and the fastest session reuse on the server side at the expense
4888 of maintaining idle connections to the servers. In general, it is possible
4889 with this option to achieve approximately twice the request rate that the
4890 "http-server-close" option achieves on small objects. There are mainly two
4891 situations where this option may be useful :
4892
4893 - when the server is non-HTTP compliant and authenticates the connection
4894 instead of requests (eg: NTLM authentication)
4895
4896 - when the cost of establishing the connection to the server is significant
4897 compared to the cost of retrieving the associated object from the server.
4898
4899 This last case can happen when the server is a fast static server of cache.
4900 In this case, the server will need to be properly tuned to support high enough
4901 connection counts because connections will last until the client sends another
4902 request.
4903
4904 If the client request has to go to another backend or another server due to
4905 content switching or the load balancing algorithm, the idle connection will
Willy Tarreau9420b122013-12-15 18:58:25 +01004906 immediately be closed and a new one re-opened. Option "prefer-last-server" is
4907 available to try optimize server selection so that if the server currently
4908 attached to an idle connection is usable, it will be used.
Willy Tarreau16bfb022010-01-16 19:48:41 +01004909
4910 In general it is preferred to use "option http-server-close" with application
4911 servers, and some static servers might benefit from "option http-keep-alive".
4912
4913 At the moment, logs will not indicate whether requests came from the same
4914 session or not. The accept date reported in the logs corresponds to the end
4915 of the previous request, and the request time corresponds to the time spent
4916 waiting for a new request. The keep-alive request time is still bound to the
4917 timeout defined by "timeout http-keep-alive" or "timeout http-request" if
4918 not set.
4919
Cyril Bonté653dcd62014-02-20 00:13:15 +01004920 This option disables and replaces any previous "option httpclose", "option
4921 http-server-close", "option forceclose" or "option http-tunnel". When backend
Willy Tarreau70dffda2014-01-30 03:07:23 +01004922 and frontend options differ, all of these 4 options have precedence over
Cyril Bonté653dcd62014-02-20 00:13:15 +01004923 "option http-keep-alive".
Willy Tarreau16bfb022010-01-16 19:48:41 +01004924
4925 See also : "option forceclose", "option http-server-close",
Willy Tarreau9420b122013-12-15 18:58:25 +01004926 "option prefer-last-server", "option http-pretend-keepalive",
4927 "option httpclose", and "1.1. The HTTP transaction model".
Willy Tarreau16bfb022010-01-16 19:48:41 +01004928
4929
Willy Tarreau96e31212011-05-30 18:10:30 +02004930option http-no-delay
4931no option http-no-delay
4932 Instruct the system to favor low interactive delays over performance in HTTP
4933 May be used in sections : defaults | frontend | listen | backend
4934 yes | yes | yes | yes
4935 Arguments : none
4936
4937 In HTTP, each payload is unidirectional and has no notion of interactivity.
4938 Any agent is expected to queue data somewhat for a reasonably low delay.
4939 There are some very rare server-to-server applications that abuse the HTTP
4940 protocol and expect the payload phase to be highly interactive, with many
4941 interleaved data chunks in both directions within a single request. This is
4942 absolutely not supported by the HTTP specification and will not work across
4943 most proxies or servers. When such applications attempt to do this through
4944 haproxy, it works but they will experience high delays due to the network
4945 optimizations which favor performance by instructing the system to wait for
4946 enough data to be available in order to only send full packets. Typical
4947 delays are around 200 ms per round trip. Note that this only happens with
4948 abnormal uses. Normal uses such as CONNECT requests nor WebSockets are not
4949 affected.
4950
4951 When "option http-no-delay" is present in either the frontend or the backend
4952 used by a connection, all such optimizations will be disabled in order to
4953 make the exchanges as fast as possible. Of course this offers no guarantee on
4954 the functionality, as it may break at any other place. But if it works via
4955 HAProxy, it will work as fast as possible. This option should never be used
4956 by default, and should never be used at all unless such a buggy application
4957 is discovered. The impact of using this option is an increase of bandwidth
4958 usage and CPU usage, which may significantly lower performance in high
4959 latency environments.
4960
Willy Tarreau9fbe18e2015-05-01 22:42:08 +02004961 See also : "option http-buffer-request"
4962
Willy Tarreau96e31212011-05-30 18:10:30 +02004963
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02004964option http-pretend-keepalive
4965no option http-pretend-keepalive
4966 Define whether haproxy will announce keepalive to the server or not
4967 May be used in sections : defaults | frontend | listen | backend
4968 yes | yes | yes | yes
4969 Arguments : none
4970
4971 When running with "option http-server-close" or "option forceclose", haproxy
4972 adds a "Connection: close" header to the request forwarded to the server.
4973 Unfortunately, when some servers see this header, they automatically refrain
4974 from using the chunked encoding for responses of unknown length, while this
4975 is totally unrelated. The immediate effect is that this prevents haproxy from
4976 maintaining the client connection alive. A second effect is that a client or
4977 a cache could receive an incomplete response without being aware of it, and
4978 consider the response complete.
4979
4980 By setting "option http-pretend-keepalive", haproxy will make the server
4981 believe it will keep the connection alive. The server will then not fall back
4982 to the abnormal undesired above. When haproxy gets the whole response, it
4983 will close the connection with the server just as it would do with the
4984 "forceclose" option. That way the client gets a normal response and the
4985 connection is correctly closed on the server side.
4986
4987 It is recommended not to enable this option by default, because most servers
4988 will more efficiently close the connection themselves after the last packet,
4989 and release its buffers slightly earlier. Also, the added packet on the
4990 network could slightly reduce the overall peak performance. However it is
4991 worth noting that when this option is enabled, haproxy will have slightly
4992 less work to do. So if haproxy is the bottleneck on the whole architecture,
4993 enabling this option might save a few CPU cycles.
4994
4995 This option may be set both in a frontend and in a backend. It is enabled if
4996 at least one of the frontend or backend holding a connection has it enabled.
Jamie Gloudonaaa21002012-08-25 00:18:33 -04004997 This option may be combined with "option httpclose", which will cause
Willy Tarreau22a95342010-09-29 14:31:41 +02004998 keepalive to be announced to the server and close to be announced to the
4999 client. This practice is discouraged though.
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02005000
5001 If this option has been enabled in a "defaults" section, it can be disabled
5002 in a specific instance by prepending the "no" keyword before it.
5003
Willy Tarreau16bfb022010-01-16 19:48:41 +01005004 See also : "option forceclose", "option http-server-close", and
5005 "option http-keep-alive"
Willy Tarreau8a8e1d92010-04-05 16:15:16 +02005006
Willy Tarreauc27debf2008-01-06 08:57:02 +01005007
Willy Tarreaub608feb2010-01-02 22:47:18 +01005008option http-server-close
5009no option http-server-close
5010 Enable or disable HTTP connection closing on the server side
5011 May be used in sections : defaults | frontend | listen | backend
5012 yes | yes | yes | yes
5013 Arguments : none
5014
Willy Tarreau70dffda2014-01-30 03:07:23 +01005015 By default HAProxy operates in keep-alive mode with regards to persistent
5016 connections: for each connection it processes each request and response, and
5017 leaves the connection idle on both sides between the end of a response and
5018 the start of a new request. This mode may be changed by several options such
5019 as "option http-server-close", "option forceclose", "option httpclose" or
5020 "option http-tunnel". Setting "option http-server-close" enables HTTP
5021 connection-close mode on the server side while keeping the ability to support
5022 HTTP keep-alive and pipelining on the client side. This provides the lowest
5023 latency on the client side (slow network) and the fastest session reuse on
5024 the server side to save server resources, similarly to "option forceclose".
5025 It also permits non-keepalive capable servers to be served in keep-alive mode
5026 to the clients if they conform to the requirements of RFC2616. Please note
5027 that some servers do not always conform to those requirements when they see
5028 "Connection: close" in the request. The effect will be that keep-alive will
5029 never be used. A workaround consists in enabling "option
5030 http-pretend-keepalive".
Willy Tarreaub608feb2010-01-02 22:47:18 +01005031
5032 At the moment, logs will not indicate whether requests came from the same
5033 session or not. The accept date reported in the logs corresponds to the end
5034 of the previous request, and the request time corresponds to the time spent
5035 waiting for a new request. The keep-alive request time is still bound to the
Willy Tarreaub16a5742010-01-10 14:46:16 +01005036 timeout defined by "timeout http-keep-alive" or "timeout http-request" if
5037 not set.
Willy Tarreaub608feb2010-01-02 22:47:18 +01005038
5039 This option may be set both in a frontend and in a backend. It is enabled if
5040 at least one of the frontend or backend holding a connection has it enabled.
Cyril Bonté653dcd62014-02-20 00:13:15 +01005041 It disables and replaces any previous "option httpclose", "option forceclose",
5042 "option http-tunnel" or "option http-keep-alive". Please check section 4
Willy Tarreau70dffda2014-01-30 03:07:23 +01005043 ("Proxies") to see how this option combines with others when frontend and
5044 backend options differ.
Willy Tarreaub608feb2010-01-02 22:47:18 +01005045
5046 If this option has been enabled in a "defaults" section, it can be disabled
5047 in a specific instance by prepending the "no" keyword before it.
5048
Patrick Mezard9ec2ec42010-06-12 17:02:45 +02005049 See also : "option forceclose", "option http-pretend-keepalive",
Willy Tarreau16bfb022010-01-16 19:48:41 +01005050 "option httpclose", "option http-keep-alive", and
5051 "1.1. The HTTP transaction model".
Willy Tarreaub608feb2010-01-02 22:47:18 +01005052
5053
Willy Tarreau02bce8b2014-01-30 00:15:28 +01005054option http-tunnel
5055no option http-tunnel
5056 Disable or enable HTTP connection processing after first transaction
5057 May be used in sections : defaults | frontend | listen | backend
5058 yes | yes | yes | yes
5059 Arguments : none
5060
Willy Tarreau70dffda2014-01-30 03:07:23 +01005061 By default HAProxy operates in keep-alive mode with regards to persistent
5062 connections: for each connection it processes each request and response, and
5063 leaves the connection idle on both sides between the end of a response and
5064 the start of a new request. This mode may be changed by several options such
5065 as "option http-server-close", "option forceclose", "option httpclose" or
5066 "option http-tunnel".
5067
5068 Option "http-tunnel" disables any HTTP processing past the first request and
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005069 the first response. This is the mode which was used by default in versions
Willy Tarreau70dffda2014-01-30 03:07:23 +01005070 1.0 to 1.5-dev21. It is the mode with the lowest processing overhead, which
5071 is normally not needed anymore unless in very specific cases such as when
5072 using an in-house protocol that looks like HTTP but is not compatible, or
5073 just to log one request per client in order to reduce log size. Note that
5074 everything which works at the HTTP level, including header parsing/addition,
5075 cookie processing or content switching will only work for the first request
5076 and will be ignored after the first response.
Willy Tarreau02bce8b2014-01-30 00:15:28 +01005077
5078 If this option has been enabled in a "defaults" section, it can be disabled
5079 in a specific instance by prepending the "no" keyword before it.
5080
5081 See also : "option forceclose", "option http-server-close",
5082 "option httpclose", "option http-keep-alive", and
5083 "1.1. The HTTP transaction model".
5084
5085
Willy Tarreau88d349d2010-01-25 12:15:43 +01005086option http-use-proxy-header
Cyril Bontéf0c60612010-02-06 14:44:47 +01005087no option http-use-proxy-header
Willy Tarreau88d349d2010-01-25 12:15:43 +01005088 Make use of non-standard Proxy-Connection header instead of Connection
5089 May be used in sections : defaults | frontend | listen | backend
5090 yes | yes | yes | no
5091 Arguments : none
5092
5093 While RFC2616 explicitly states that HTTP/1.1 agents must use the
5094 Connection header to indicate their wish of persistent or non-persistent
5095 connections, both browsers and proxies ignore this header for proxied
5096 connections and make use of the undocumented, non-standard Proxy-Connection
5097 header instead. The issue begins when trying to put a load balancer between
5098 browsers and such proxies, because there will be a difference between what
5099 haproxy understands and what the client and the proxy agree on.
5100
5101 By setting this option in a frontend, haproxy can automatically switch to use
5102 that non-standard header if it sees proxied requests. A proxied request is
5103 defined here as one where the URI begins with neither a '/' nor a '*'. The
5104 choice of header only affects requests passing through proxies making use of
5105 one of the "httpclose", "forceclose" and "http-server-close" options. Note
5106 that this option can only be specified in a frontend and will affect the
5107 request along its whole life.
5108
Willy Tarreau844a7e72010-01-31 21:46:18 +01005109 Also, when this option is set, a request which requires authentication will
5110 automatically switch to use proxy authentication headers if it is itself a
5111 proxied request. That makes it possible to check or enforce authentication in
5112 front of an existing proxy.
5113
Willy Tarreau88d349d2010-01-25 12:15:43 +01005114 This option should normally never be used, except in front of a proxy.
5115
5116 See also : "option httpclose", "option forceclose" and "option
5117 http-server-close".
5118
5119
Willy Tarreaud63335a2010-02-26 12:56:52 +01005120option httpchk
5121option httpchk <uri>
5122option httpchk <method> <uri>
5123option httpchk <method> <uri> <version>
5124 Enable HTTP protocol to check on the servers health
5125 May be used in sections : defaults | frontend | listen | backend
5126 yes | no | yes | yes
5127 Arguments :
5128 <method> is the optional HTTP method used with the requests. When not set,
5129 the "OPTIONS" method is used, as it generally requires low server
5130 processing and is easy to filter out from the logs. Any method
5131 may be used, though it is not recommended to invent non-standard
5132 ones.
5133
5134 <uri> is the URI referenced in the HTTP requests. It defaults to " / "
5135 which is accessible by default on almost any server, but may be
5136 changed to any other URI. Query strings are permitted.
5137
5138 <version> is the optional HTTP version string. It defaults to "HTTP/1.0"
5139 but some servers might behave incorrectly in HTTP 1.0, so turning
5140 it to HTTP/1.1 may sometimes help. Note that the Host field is
5141 mandatory in HTTP/1.1, and as a trick, it is possible to pass it
5142 after "\r\n" following the version string.
5143
5144 By default, server health checks only consist in trying to establish a TCP
5145 connection. When "option httpchk" is specified, a complete HTTP request is
5146 sent once the TCP connection is established, and responses 2xx and 3xx are
5147 considered valid, while all other ones indicate a server failure, including
5148 the lack of any response.
5149
5150 The port and interval are specified in the server configuration.
5151
5152 This option does not necessarily require an HTTP backend, it also works with
5153 plain TCP backends. This is particularly useful to check simple scripts bound
5154 to some dedicated ports using the inetd daemon.
5155
5156 Examples :
5157 # Relay HTTPS traffic to Apache instance and check service availability
5158 # using HTTP request "OPTIONS * HTTP/1.1" on port 80.
5159 backend https_relay
5160 mode tcp
5161 option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
5162 server apache1 192.168.1.1:443 check port 80
5163
Simon Hormanafc47ee2013-11-25 10:46:35 +09005164 See also : "option ssl-hello-chk", "option smtpchk", "option mysql-check",
5165 "option pgsql-check", "http-check" and the "check", "port" and
5166 "inter" server options.
Willy Tarreaud63335a2010-02-26 12:56:52 +01005167
5168
Willy Tarreauc27debf2008-01-06 08:57:02 +01005169option httpclose
5170no option httpclose
5171 Enable or disable passive HTTP connection closing
5172 May be used in sections : defaults | frontend | listen | backend
5173 yes | yes | yes | yes
5174 Arguments : none
5175
Willy Tarreau70dffda2014-01-30 03:07:23 +01005176 By default HAProxy operates in keep-alive mode with regards to persistent
5177 connections: for each connection it processes each request and response, and
5178 leaves the connection idle on both sides between the end of a response and
5179 the start of a new request. This mode may be changed by several options such
Cyril Bonté653dcd62014-02-20 00:13:15 +01005180 as "option http-server-close", "option forceclose", "option httpclose" or
Willy Tarreau70dffda2014-01-30 03:07:23 +01005181 "option http-tunnel".
5182
5183 If "option httpclose" is set, HAProxy will work in HTTP tunnel mode and check
5184 if a "Connection: close" header is already set in each direction, and will
5185 add one if missing. Each end should react to this by actively closing the TCP
5186 connection after each transfer, thus resulting in a switch to the HTTP close
5187 mode. Any "Connection" header different from "close" will also be removed.
5188 Note that this option is deprecated since what it does is very cheap but not
5189 reliable. Using "option http-server-close" or "option forceclose" is strongly
5190 recommended instead.
Willy Tarreauc27debf2008-01-06 08:57:02 +01005191
5192 It seldom happens that some servers incorrectly ignore this header and do not
Jamie Gloudonaaa21002012-08-25 00:18:33 -04005193 close the connection even though they reply "Connection: close". For this
Willy Tarreau0dfdf192010-01-05 11:33:11 +01005194 reason, they are not compatible with older HTTP 1.0 browsers. If this happens
5195 it is possible to use the "option forceclose" which actively closes the
5196 request connection once the server responds. Option "forceclose" also
5197 releases the server connection earlier because it does not have to wait for
5198 the client to acknowledge it.
Willy Tarreauc27debf2008-01-06 08:57:02 +01005199
5200 This option may be set both in a frontend and in a backend. It is enabled if
5201 at least one of the frontend or backend holding a connection has it enabled.
Cyril Bonté653dcd62014-02-20 00:13:15 +01005202 It disables and replaces any previous "option http-server-close",
5203 "option forceclose", "option http-keep-alive" or "option http-tunnel". Please
Willy Tarreau70dffda2014-01-30 03:07:23 +01005204 check section 4 ("Proxies") to see how this option combines with others when
5205 frontend and backend options differ.
Willy Tarreauc27debf2008-01-06 08:57:02 +01005206
5207 If this option has been enabled in a "defaults" section, it can be disabled
5208 in a specific instance by prepending the "no" keyword before it.
5209
Patrick Mezard9ec2ec42010-06-12 17:02:45 +02005210 See also : "option forceclose", "option http-server-close" and
5211 "1.1. The HTTP transaction model".
Willy Tarreauc27debf2008-01-06 08:57:02 +01005212
5213
Emeric Brun3a058f32009-06-30 18:26:00 +02005214option httplog [ clf ]
Willy Tarreauc27debf2008-01-06 08:57:02 +01005215 Enable logging of HTTP request, session state and timers
5216 May be used in sections : defaults | frontend | listen | backend
5217 yes | yes | yes | yes
Emeric Brun3a058f32009-06-30 18:26:00 +02005218 Arguments :
5219 clf if the "clf" argument is added, then the output format will be
5220 the CLF format instead of HAProxy's default HTTP format. You can
5221 use this when you need to feed HAProxy's logs through a specific
5222 log analyser which only support the CLF format and which is not
5223 extensible.
Willy Tarreauc27debf2008-01-06 08:57:02 +01005224
5225 By default, the log output format is very poor, as it only contains the
5226 source and destination addresses, and the instance name. By specifying
5227 "option httplog", each log line turns into a much richer format including,
5228 but not limited to, the HTTP request, the connection timers, the session
5229 status, the connections numbers, the captured headers and cookies, the
5230 frontend, backend and server name, and of course the source address and
5231 ports.
5232
5233 This option may be set either in the frontend or the backend.
5234
PiBa-NLbd556bf2014-12-11 21:31:54 +01005235 Specifying only "option httplog" will automatically clear the 'clf' mode
5236 if it was set by default.
Emeric Brun3a058f32009-06-30 18:26:00 +02005237
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005238 See also : section 8 about logging.
Willy Tarreauc27debf2008-01-06 08:57:02 +01005239
Willy Tarreau55165fe2009-05-10 12:02:55 +02005240
5241option http_proxy
5242no option http_proxy
5243 Enable or disable plain HTTP proxy mode
5244 May be used in sections : defaults | frontend | listen | backend
5245 yes | yes | yes | yes
5246 Arguments : none
5247
5248 It sometimes happens that people need a pure HTTP proxy which understands
5249 basic proxy requests without caching nor any fancy feature. In this case,
5250 it may be worth setting up an HAProxy instance with the "option http_proxy"
5251 set. In this mode, no server is declared, and the connection is forwarded to
5252 the IP address and port found in the URL after the "http://" scheme.
5253
5254 No host address resolution is performed, so this only works when pure IP
5255 addresses are passed. Since this option's usage perimeter is rather limited,
5256 it will probably be used only by experts who know they need exactly it. Last,
5257 if the clients are susceptible of sending keep-alive requests, it will be
Cyril Bonté2409e682010-12-14 22:47:51 +01005258 needed to add "option httpclose" to ensure that all requests will correctly
Willy Tarreau55165fe2009-05-10 12:02:55 +02005259 be analyzed.
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
5264 Example :
5265 # this backend understands HTTP proxy requests and forwards them directly.
5266 backend direct_forward
5267 option httpclose
5268 option http_proxy
5269
5270 See also : "option httpclose"
5271
Willy Tarreau211ad242009-10-03 21:45:07 +02005272
Jamie Gloudon801a0a32012-08-25 00:18:33 -04005273option independent-streams
5274no option independent-streams
5275 Enable or disable independent timeout processing for both directions
Willy Tarreauf27b5ea2009-10-03 22:01:18 +02005276 May be used in sections : defaults | frontend | listen | backend
5277 yes | yes | yes | yes
5278 Arguments : none
5279
5280 By default, when data is sent over a socket, both the write timeout and the
5281 read timeout for that socket are refreshed, because we consider that there is
5282 activity on that socket, and we have no other means of guessing if we should
5283 receive data or not.
5284
5285 While this default behaviour is desirable for almost all applications, there
5286 exists a situation where it is desirable to disable it, and only refresh the
5287 read timeout if there are incoming data. This happens on sessions with large
5288 timeouts and low amounts of exchanged data such as telnet session. If the
5289 server suddenly disappears, the output data accumulates in the system's
5290 socket buffers, both timeouts are correctly refreshed, and there is no way
5291 to know the server does not receive them, so we don't timeout. However, when
5292 the underlying protocol always echoes sent data, it would be enough by itself
5293 to detect the issue using the read timeout. Note that this problem does not
5294 happen with more verbose protocols because data won't accumulate long in the
5295 socket buffers.
5296
5297 When this option is set on the frontend, it will disable read timeout updates
5298 on data sent to the client. There probably is little use of this case. When
5299 the option is set on the backend, it will disable read timeout updates on
5300 data sent to the server. Doing so will typically break large HTTP posts from
5301 slow lines, so use it with caution.
5302
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005303 Note: older versions used to call this setting "option independent-streams"
Jamie Gloudon801a0a32012-08-25 00:18:33 -04005304 with a spelling mistake. This spelling is still supported but
5305 deprecated.
5306
Willy Tarreauce887fd2012-05-12 12:50:00 +02005307 See also : "timeout client", "timeout server" and "timeout tunnel"
Willy Tarreauf27b5ea2009-10-03 22:01:18 +02005308
5309
Gabor Lekenyb4c81e42010-09-29 18:17:05 +02005310option ldap-check
5311 Use LDAPv3 health checks for server testing
5312 May be used in sections : defaults | frontend | listen | backend
5313 yes | no | yes | yes
5314 Arguments : none
5315
5316 It is possible to test that the server correctly talks LDAPv3 instead of just
5317 testing that it accepts the TCP connection. When this option is set, an
5318 LDAPv3 anonymous simple bind message is sent to the server, and the response
5319 is analyzed to find an LDAPv3 bind response message.
5320
5321 The server is considered valid only when the LDAP response contains success
5322 resultCode (http://tools.ietf.org/html/rfc4511#section-4.1.9).
5323
5324 Logging of bind requests is server dependent see your documentation how to
5325 configure it.
5326
5327 Example :
5328 option ldap-check
5329
5330 See also : "option httpchk"
5331
5332
Simon Horman98637e52014-06-20 12:30:16 +09005333option external-check
5334 Use external processes for server health checks
5335 May be used in sections : defaults | frontend | listen | backend
5336 yes | no | yes | yes
5337
5338 It is possible to test the health of a server using an external command.
5339 This is achieved by running the executable set using "external-check
5340 command".
5341
5342 Requires the "external-check" global to be set.
5343
5344 See also : "external-check", "external-check command", "external-check path"
5345
5346
Willy Tarreau211ad242009-10-03 21:45:07 +02005347option log-health-checks
5348no option log-health-checks
Willy Tarreaubef1b322014-05-13 21:01:39 +02005349 Enable or disable logging of health checks status updates
Willy Tarreau211ad242009-10-03 21:45:07 +02005350 May be used in sections : defaults | frontend | listen | backend
5351 yes | no | yes | yes
5352 Arguments : none
5353
Willy Tarreaubef1b322014-05-13 21:01:39 +02005354 By default, failed health check are logged if server is UP and successful
5355 health checks are logged if server is DOWN, so the amount of additional
5356 information is limited.
Willy Tarreau211ad242009-10-03 21:45:07 +02005357
Willy Tarreaubef1b322014-05-13 21:01:39 +02005358 When this option is enabled, any change of the health check status or to
5359 the server's health will be logged, so that it becomes possible to know
5360 that a server was failing occasional checks before crashing, or exactly when
5361 it failed to respond a valid HTTP status, then when the port started to
5362 reject connections, then when the server stopped responding at all.
5363
5364 Note that status changes not caused by health checks (eg: enable/disable on
5365 the CLI) are intentionally not logged by this option.
Willy Tarreau211ad242009-10-03 21:45:07 +02005366
Willy Tarreaubef1b322014-05-13 21:01:39 +02005367 See also: "option httpchk", "option ldap-check", "option mysql-check",
5368 "option pgsql-check", "option redis-check", "option smtpchk",
5369 "option tcp-check", "log" and section 8 about logging.
Willy Tarreau211ad242009-10-03 21:45:07 +02005370
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02005371
5372option log-separate-errors
5373no option log-separate-errors
5374 Change log level for non-completely successful connections
5375 May be used in sections : defaults | frontend | listen | backend
5376 yes | yes | yes | no
5377 Arguments : none
5378
5379 Sometimes looking for errors in logs is not easy. This option makes haproxy
5380 raise the level of logs containing potentially interesting information such
5381 as errors, timeouts, retries, redispatches, or HTTP status codes 5xx. The
5382 level changes from "info" to "err". This makes it possible to log them
5383 separately to a different file with most syslog daemons. Be careful not to
5384 remove them from the original file, otherwise you would lose ordering which
5385 provides very important information.
5386
5387 Using this option, large sites dealing with several thousand connections per
5388 second may log normal traffic to a rotating buffer and only archive smaller
5389 error logs.
5390
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005391 See also : "log", "dontlognull", "dontlog-normal" and section 8 about
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +02005392 logging.
5393
Willy Tarreauc27debf2008-01-06 08:57:02 +01005394
5395option logasap
5396no option logasap
5397 Enable or disable early logging of HTTP requests
5398 May be used in sections : defaults | frontend | listen | backend
5399 yes | yes | yes | no
5400 Arguments : none
5401
5402 By default, HTTP requests are logged upon termination so that the total
5403 transfer time and the number of bytes appear in the logs. When large objects
5404 are being transferred, it may take a while before the request appears in the
5405 logs. Using "option logasap", the request gets logged as soon as the server
5406 sends the complete headers. The only missing information in the logs will be
5407 the total number of bytes which will indicate everything except the amount
5408 of data transferred, and the total time which will not take the transfer
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01005409 time into account. In such a situation, it's a good practice to capture the
Willy Tarreauc27debf2008-01-06 08:57:02 +01005410 "Content-Length" response header so that the logs at least indicate how many
5411 bytes are expected to be transferred.
5412
Willy Tarreaucc6c8912009-02-22 10:53:55 +01005413 Examples :
5414 listen http_proxy 0.0.0.0:80
5415 mode http
5416 option httplog
5417 option logasap
5418 log 192.168.2.200 local3
5419
5420 >>> Feb 6 12:14:14 localhost \
5421 haproxy[14389]: 10.0.1.2:33317 [06/Feb/2009:12:14:14.655] http-in \
5422 static/srv1 9/10/7/14/+30 200 +243 - - ---- 3/1/1/1/0 1/0 \
5423 "GET /image.iso HTTP/1.0"
5424
Willy Tarreauc57f0e22009-05-10 13:12:33 +02005425 See also : "option httplog", "capture response header", and section 8 about
Willy Tarreauc27debf2008-01-06 08:57:02 +01005426 logging.
5427
5428
Nenad Merdanovic6639a7c2014-05-30 14:26:32 +02005429option mysql-check [ user <username> [ post-41 ] ]
Hervé COMMOWICK8776f1b2010-10-18 15:58:36 +02005430 Use MySQL health checks for server testing
Hervé COMMOWICK698ae002010-01-12 09:25:13 +01005431 May be used in sections : defaults | frontend | listen | backend
5432 yes | no | yes | yes
Hervé COMMOWICK8776f1b2010-10-18 15:58:36 +02005433 Arguments :
Cyril Bonté108cf6e2012-04-21 23:30:29 +02005434 <username> This is the username which will be used when connecting to MySQL
5435 server.
Nenad Merdanovic6639a7c2014-05-30 14:26:32 +02005436 post-41 Send post v4.1 client compatible checks
Hervé COMMOWICK8776f1b2010-10-18 15:58:36 +02005437
5438 If you specify a username, the check consists of sending two MySQL packet,
5439 one Client Authentication packet, and one QUIT packet, to correctly close
5440 MySQL session. We then parse the MySQL Handshake Initialisation packet and/or
5441 Error packet. It is a basic but useful test which does not produce error nor
5442 aborted connect on the server. However, it requires adding an authorization
5443 in the MySQL table, like this :
5444
5445 USE mysql;
5446 INSERT INTO user (Host,User) values ('<ip_of_haproxy>','<username>');
5447 FLUSH PRIVILEGES;
5448
5449 If you don't specify a username (it is deprecated and not recommended), the
5450 check only consists in parsing the Mysql Handshake Initialisation packet or
5451 Error packet, we don't send anything in this mode. It was reported that it
5452 can generate lockout if check is too frequent and/or if there is not enough
5453 traffic. In fact, you need in this case to check MySQL "max_connect_errors"
5454 value as if a connection is established successfully within fewer than MySQL
5455 "max_connect_errors" attempts after a previous connection was interrupted,
5456 the error count for the host is cleared to zero. If HAProxy's server get
5457 blocked, the "FLUSH HOSTS" statement is the only way to unblock it.
5458
5459 Remember that this does not check database presence nor database consistency.
5460 To do this, you can use an external check with xinetd for example.
Hervé COMMOWICK698ae002010-01-12 09:25:13 +01005461
Hervé COMMOWICK212f7782011-06-10 14:05:59 +02005462 The check requires MySQL >=3.22, for older version, please use TCP check.
Hervé COMMOWICK698ae002010-01-12 09:25:13 +01005463
5464 Most often, an incoming MySQL server needs to see the client's IP address for
5465 various purposes, including IP privilege matching and connection logging.
5466 When possible, it is often wise to masquerade the client's IP address when
5467 connecting to the server using the "usesrc" argument of the "source" keyword,
5468 which requires the cttproxy feature to be compiled in, and the MySQL server
5469 to route the client via the machine hosting haproxy.
5470
5471 See also: "option httpchk"
5472
5473
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005474option nolinger
5475no option nolinger
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01005476 Enable or disable immediate session resource cleaning after close
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005477 May be used in sections: defaults | frontend | listen | backend
5478 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005479 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005480
5481 When clients or servers abort connections in a dirty way (eg: they are
5482 physically disconnected), the session timeouts triggers and the session is
5483 closed. But it will remain in FIN_WAIT1 state for some time in the system,
5484 using some resources and possibly limiting the ability to establish newer
5485 connections.
5486
5487 When this happens, it is possible to activate "option nolinger" which forces
5488 the system to immediately remove any socket's pending data on close. Thus,
5489 the session is instantly purged from the system's tables. This usually has
5490 side effects such as increased number of TCP resets due to old retransmits
5491 getting immediately rejected. Some firewalls may sometimes complain about
5492 this too.
5493
5494 For this reason, it is not recommended to use this option when not absolutely
5495 needed. You know that you need it when you have thousands of FIN_WAIT1
5496 sessions on your system (TIME_WAIT ones do not count).
5497
5498 This option may be used both on frontends and backends, depending on the side
5499 where it is required. Use it on the frontend for clients, and on the backend
5500 for servers.
5501
5502 If this option has been enabled in a "defaults" section, it can be disabled
5503 in a specific instance by prepending the "no" keyword before it.
5504
5505
Willy Tarreau55165fe2009-05-10 12:02:55 +02005506option originalto [ except <network> ] [ header <name> ]
5507 Enable insertion of the X-Original-To header to requests sent to servers
5508 May be used in sections : defaults | frontend | listen | backend
5509 yes | yes | yes | yes
5510 Arguments :
5511 <network> is an optional argument used to disable this option for sources
5512 matching <network>
5513 <name> an optional argument to specify a different "X-Original-To"
5514 header name.
5515
5516 Since HAProxy can work in transparent mode, every request from a client can
5517 be redirected to the proxy and HAProxy itself can proxy every request to a
5518 complex SQUID environment and the destination host from SO_ORIGINAL_DST will
5519 be lost. This is annoying when you want access rules based on destination ip
5520 addresses. To solve this problem, a new HTTP header "X-Original-To" may be
5521 added by HAProxy to all requests sent to the server. This header contains a
5522 value representing the original destination IP address. Since this must be
5523 configured to always use the last occurrence of this header only. Note that
5524 only the last occurrence of the header must be used, since it is really
5525 possible that the client has already brought one.
5526
5527 The keyword "header" may be used to supply a different header name to replace
5528 the default "X-Original-To". This can be useful where you might already
5529 have a "X-Original-To" header from a different application, and you need
5530 preserve it. Also if your backend server doesn't use the "X-Original-To"
5531 header and requires different one.
5532
5533 Sometimes, a same HAProxy instance may be shared between a direct client
5534 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
5535 used to decrypt HTTPS traffic). It is possible to disable the addition of the
5536 header for a known source address or network by adding the "except" keyword
5537 followed by the network address. In this case, any source IP matching the
5538 network will not cause an addition of this header. Most common uses are with
5539 private networks or 127.0.0.1.
5540
5541 This option may be specified either in the frontend or in the backend. If at
5542 least one of them uses it, the header will be added. Note that the backend's
5543 setting of the header subargument takes precedence over the frontend's if
5544 both are defined.
5545
Willy Tarreau55165fe2009-05-10 12:02:55 +02005546 Examples :
5547 # Original Destination address
5548 frontend www
5549 mode http
5550 option originalto except 127.0.0.1
5551
5552 # Those servers want the IP Address in X-Client-Dst
5553 backend www
5554 mode http
5555 option originalto header X-Client-Dst
5556
Willy Tarreau87cf5142011-08-19 22:57:24 +02005557 See also : "option httpclose", "option http-server-close",
5558 "option forceclose"
Willy Tarreau55165fe2009-05-10 12:02:55 +02005559
5560
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005561option persist
5562no option persist
5563 Enable or disable forced persistence on down servers
5564 May be used in sections: defaults | frontend | listen | backend
5565 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01005566 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005567
5568 When an HTTP request reaches a backend with a cookie which references a dead
5569 server, by default it is redispatched to another server. It is possible to
5570 force the request to be sent to the dead server first using "option persist"
5571 if absolutely needed. A common use case is when servers are under extreme
5572 load and spend their time flapping. In this case, the users would still be
5573 directed to the server they opened the session on, in the hope they would be
5574 correctly served. It is recommended to use "option redispatch" in conjunction
5575 with this option so that in the event it would not be possible to connect to
5576 the server at all (server definitely dead), the client would finally be
5577 redirected to another valid server.
5578
5579 If this option has been enabled in a "defaults" section, it can be disabled
5580 in a specific instance by prepending the "no" keyword before it.
5581
Willy Tarreau4de91492010-01-22 19:10:05 +01005582 See also : "option redispatch", "retries", "force-persist"
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005583
5584
Willy Tarreau0c122822013-12-15 18:49:01 +01005585option pgsql-check [ user <username> ]
5586 Use PostgreSQL health checks for server testing
5587 May be used in sections : defaults | frontend | listen | backend
5588 yes | no | yes | yes
5589 Arguments :
5590 <username> This is the username which will be used when connecting to
5591 PostgreSQL server.
5592
5593 The check sends a PostgreSQL StartupMessage and waits for either
5594 Authentication request or ErrorResponse message. It is a basic but useful
5595 test which does not produce error nor aborted connect on the server.
5596 This check is identical with the "mysql-check".
5597
5598 See also: "option httpchk"
5599
5600
Willy Tarreau9420b122013-12-15 18:58:25 +01005601option prefer-last-server
5602no option prefer-last-server
5603 Allow multiple load balanced requests to remain on the same server
5604 May be used in sections: defaults | frontend | listen | backend
5605 yes | no | yes | yes
5606 Arguments : none
5607
5608 When the load balancing algorithm in use is not deterministic, and a previous
5609 request was sent to a server to which haproxy still holds a connection, it is
5610 sometimes desirable that subsequent requests on a same session go to the same
5611 server as much as possible. Note that this is different from persistence, as
5612 we only indicate a preference which haproxy tries to apply without any form
5613 of warranty. The real use is for keep-alive connections sent to servers. When
5614 this option is used, haproxy will try to reuse the same connection that is
5615 attached to the server instead of rebalancing to another server, causing a
5616 close of the connection. This can make sense for static file servers. It does
Willy Tarreau068621e2013-12-23 15:11:25 +01005617 not make much sense to use this in combination with hashing algorithms. Note,
5618 haproxy already automatically tries to stick to a server which sends a 401 or
5619 to a proxy which sends a 407 (authentication required). This is mandatory for
5620 use with the broken NTLM authentication challenge, and significantly helps in
5621 troubleshooting some faulty applications. Option prefer-last-server might be
5622 desirable in these environments as well, to avoid redistributing the traffic
5623 after every other response.
Willy Tarreau9420b122013-12-15 18:58:25 +01005624
5625 If this option has been enabled in a "defaults" section, it can be disabled
5626 in a specific instance by prepending the "no" keyword before it.
5627
5628 See also: "option http-keep-alive"
5629
5630
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005631option redispatch
Joseph Lynch726ab712015-05-11 23:25:34 -07005632option redispatch <interval>
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005633no option redispatch
5634 Enable or disable session redistribution in case of connection failure
5635 May be used in sections: defaults | frontend | listen | backend
5636 yes | no | yes | yes
Joseph Lynch726ab712015-05-11 23:25:34 -07005637 Arguments :
5638 <interval> The optional integer value that controls how often redispatches
5639 occur when retrying connections. Positive value P indicates a
5640 redispatch is desired on every Pth retry, and negative value
5641 N indicate a redispath is desired on the Nth retry prior to the
5642 last retry. For example, the default of -1 preserves the
5643 historical behaviour of redispatching on the last retry, a
5644 positive value of 1 would indicate a redispatch on every retry,
5645 and a positive value of 3 would indicate a redispatch on every
5646 third retry. You can disable redispatches with a value of 0.
5647
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005648
5649 In HTTP mode, if a server designated by a cookie is down, clients may
5650 definitely stick to it because they cannot flush the cookie, so they will not
5651 be able to access the service anymore.
5652
5653 Specifying "option redispatch" will allow the proxy to break their
5654 persistence and redistribute them to a working server.
5655
Joseph Lynch726ab712015-05-11 23:25:34 -07005656 It also allows to retry connections to another server in case of multiple
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005657 connection failures. Of course, it requires having "retries" set to a nonzero
5658 value.
Willy Tarreaud72758d2010-01-12 10:42:19 +01005659
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005660 This form is the preferred form, which replaces both the "redispatch" and
5661 "redisp" keywords.
5662
5663 If this option has been enabled in a "defaults" section, it can be disabled
5664 in a specific instance by prepending the "no" keyword before it.
5665
Willy Tarreau4de91492010-01-22 19:10:05 +01005666 See also : "redispatch", "retries", "force-persist"
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005667
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005668
Hervé COMMOWICKec032d62011-08-05 16:23:48 +02005669option redis-check
5670 Use redis health checks for server testing
5671 May be used in sections : defaults | frontend | listen | backend
5672 yes | no | yes | yes
5673 Arguments : none
5674
5675 It is possible to test that the server correctly talks REDIS protocol instead
5676 of just testing that it accepts the TCP connection. When this option is set,
5677 a PING redis command is sent to the server, and the response is analyzed to
5678 find the "+PONG" response message.
5679
5680 Example :
5681 option redis-check
5682
5683 See also : "option httpchk"
5684
5685
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005686option smtpchk
5687option smtpchk <hello> <domain>
5688 Use SMTP health checks for server testing
5689 May be used in sections : defaults | frontend | listen | backend
5690 yes | no | yes | yes
Willy Tarreaud72758d2010-01-12 10:42:19 +01005691 Arguments :
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005692 <hello> is an optional argument. It is the "hello" command to use. It can
5693 be either "HELO" (for SMTP) or "EHLO" (for ESTMP). All other
5694 values will be turned into the default command ("HELO").
5695
5696 <domain> is the domain name to present to the server. It may only be
5697 specified (and is mandatory) if the hello command has been
5698 specified. By default, "localhost" is used.
5699
5700 When "option smtpchk" is set, the health checks will consist in TCP
5701 connections followed by an SMTP command. By default, this command is
5702 "HELO localhost". The server's return code is analyzed and only return codes
5703 starting with a "2" will be considered as valid. All other responses,
5704 including a lack of response will constitute an error and will indicate a
5705 dead server.
5706
5707 This test is meant to be used with SMTP servers or relays. Depending on the
5708 request, it is possible that some servers do not log each connection attempt,
5709 so you may want to experiment to improve the behaviour. Using telnet on port
5710 25 is often easier than adjusting the configuration.
5711
5712 Most often, an incoming SMTP server needs to see the client's IP address for
5713 various purposes, including spam filtering, anti-spoofing and logging. When
5714 possible, it is often wise to masquerade the client's IP address when
5715 connecting to the server using the "usesrc" argument of the "source" keyword,
5716 which requires the cttproxy feature to be compiled in.
5717
5718 Example :
5719 option smtpchk HELO mydomain.org
5720
5721 See also : "option httpchk", "source"
5722
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01005723
Krzysztof Piotr Oledzkiaeebf9b2009-10-04 15:43:17 +02005724option socket-stats
5725no option socket-stats
5726
5727 Enable or disable collecting & providing separate statistics for each socket.
5728 May be used in sections : defaults | frontend | listen | backend
5729 yes | yes | yes | no
5730
5731 Arguments : none
5732
5733
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005734option splice-auto
5735no option splice-auto
5736 Enable or disable automatic kernel acceleration on sockets in both directions
5737 May be used in sections : defaults | frontend | listen | backend
5738 yes | yes | yes | yes
5739 Arguments : none
5740
5741 When this option is enabled either on a frontend or on a backend, haproxy
5742 will automatically evaluate the opportunity to use kernel tcp splicing to
5743 forward data between the client and the server, in either direction. Haproxy
5744 uses heuristics to estimate if kernel splicing might improve performance or
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01005745 not. Both directions are handled independently. Note that the heuristics used
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005746 are not much aggressive in order to limit excessive use of splicing. This
5747 option requires splicing to be enabled at compile time, and may be globally
5748 disabled with the global option "nosplice". Since splice uses pipes, using it
5749 requires that there are enough spare pipes.
5750
5751 Important note: kernel-based TCP splicing is a Linux-specific feature which
5752 first appeared in kernel 2.6.25. It offers kernel-based acceleration to
5753 transfer data between sockets without copying these data to user-space, thus
5754 providing noticeable performance gains and CPU cycles savings. Since many
5755 early implementations are buggy, corrupt data and/or are inefficient, this
5756 feature is not enabled by default, and it should be used with extreme care.
5757 While it is not possible to detect the correctness of an implementation,
5758 2.6.29 is the first version offering a properly working implementation. In
5759 case of doubt, splicing may be globally disabled using the global "nosplice"
5760 keyword.
5761
5762 Example :
5763 option splice-auto
5764
5765 If this option has been enabled in a "defaults" section, it can be disabled
5766 in a specific instance by prepending the "no" keyword before it.
5767
5768 See also : "option splice-request", "option splice-response", and global
5769 options "nosplice" and "maxpipes"
5770
5771
5772option splice-request
5773no option splice-request
5774 Enable or disable automatic kernel acceleration on sockets for requests
5775 May be used in sections : defaults | frontend | listen | backend
5776 yes | yes | yes | yes
5777 Arguments : none
5778
5779 When this option is enabled either on a frontend or on a backend, haproxy
Jamie Gloudonaaa21002012-08-25 00:18:33 -04005780 will use kernel tcp splicing whenever possible to forward data going from
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005781 the client to the server. It might still use the recv/send scheme if there
5782 are no spare pipes left. This option requires splicing to be enabled at
5783 compile time, and may be globally disabled with the global option "nosplice".
5784 Since splice uses pipes, using it requires that there are enough spare pipes.
5785
5786 Important note: see "option splice-auto" for usage limitations.
5787
5788 Example :
5789 option splice-request
5790
5791 If this option has been enabled in a "defaults" section, it can be disabled
5792 in a specific instance by prepending the "no" keyword before it.
5793
5794 See also : "option splice-auto", "option splice-response", and global options
5795 "nosplice" and "maxpipes"
5796
5797
5798option splice-response
5799no option splice-response
5800 Enable or disable automatic kernel acceleration on sockets for responses
5801 May be used in sections : defaults | frontend | listen | backend
5802 yes | yes | yes | yes
5803 Arguments : none
5804
5805 When this option is enabled either on a frontend or on a backend, haproxy
Jamie Gloudonaaa21002012-08-25 00:18:33 -04005806 will use kernel tcp splicing whenever possible to forward data going from
Willy Tarreauff4f82d2009-02-06 11:28:13 +01005807 the server to the client. It might still use the recv/send scheme if there
5808 are no spare pipes left. This option requires splicing to be enabled at
5809 compile time, and may be globally disabled with the global option "nosplice".
5810 Since splice uses pipes, using it requires that there are enough spare pipes.
5811
5812 Important note: see "option splice-auto" for usage limitations.
5813
5814 Example :
5815 option splice-response
5816
5817 If this option has been enabled in a "defaults" section, it can be disabled
5818 in a specific instance by prepending the "no" keyword before it.
5819
5820 See also : "option splice-auto", "option splice-request", and global options
5821 "nosplice" and "maxpipes"
5822
5823
Willy Tarreaubf1f8162007-12-28 17:42:56 +01005824option srvtcpka
5825no option srvtcpka
5826 Enable or disable the sending of TCP keepalive packets on the server side
5827 May be used in sections : defaults | frontend | listen | backend
5828 yes | no | yes | yes
5829 Arguments : none
5830
5831 When there is a firewall or any session-aware component between a client and
5832 a server, and when the protocol involves very long sessions with long idle
5833 periods (eg: remote desktops), there is a risk that one of the intermediate
5834 components decides to expire a session which has remained idle for too long.
5835
5836 Enabling socket-level TCP keep-alives makes the system regularly send packets
5837 to the other end of the connection, leaving it active. The delay between
5838 keep-alive probes is controlled by the system only and depends both on the
5839 operating system and its tuning parameters.
5840
5841 It is important to understand that keep-alive packets are neither emitted nor
5842 received at the application level. It is only the network stacks which sees
5843 them. For this reason, even if one side of the proxy already uses keep-alives
5844 to maintain its connection alive, those keep-alive packets will not be
5845 forwarded to the other side of the proxy.
5846
5847 Please note that this has nothing to do with HTTP keep-alive.
5848
5849 Using option "srvtcpka" enables the emission of TCP keep-alive probes on the
5850 server side of a connection, which should help when session expirations are
5851 noticed between HAProxy and a server.
5852
5853 If this option has been enabled in a "defaults" section, it can be disabled
5854 in a specific instance by prepending the "no" keyword before it.
5855
5856 See also : "option clitcpka", "option tcpka"
5857
5858
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005859option ssl-hello-chk
5860 Use SSLv3 client hello health checks for server testing
5861 May be used in sections : defaults | frontend | listen | backend
5862 yes | no | yes | yes
5863 Arguments : none
5864
5865 When some SSL-based protocols are relayed in TCP mode through HAProxy, it is
5866 possible to test that the server correctly talks SSL instead of just testing
5867 that it accepts the TCP connection. When "option ssl-hello-chk" is set, pure
5868 SSLv3 client hello messages are sent once the connection is established to
5869 the server, and the response is analyzed to find an SSL server hello message.
5870 The server is considered valid only when the response contains this server
5871 hello message.
5872
5873 All servers tested till there correctly reply to SSLv3 client hello messages,
5874 and most servers tested do not even log the requests containing only hello
5875 messages, which is appreciable.
5876
Willy Tarreau763a95b2012-10-04 23:15:39 +02005877 Note that this check works even when SSL support was not built into haproxy
5878 because it forges the SSL message. When SSL support is available, it is best
5879 to use native SSL health checks instead of this one.
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005880
Willy Tarreau763a95b2012-10-04 23:15:39 +02005881 See also: "option httpchk", "check-ssl"
5882
Willy Tarreaua453bdd2008-01-08 19:50:52 +01005883
Willy Tarreaued179852013-12-16 01:07:00 +01005884option tcp-check
5885 Perform health checks using tcp-check send/expect sequences
5886 May be used in sections: defaults | frontend | listen | backend
5887 yes | no | yes | yes
5888
5889 This health check method is intended to be combined with "tcp-check" command
5890 lists in order to support send/expect types of health check sequences.
5891
5892 TCP checks currently support 4 modes of operations :
5893 - no "tcp-check" directive : the health check only consists in a connection
5894 attempt, which remains the default mode.
5895
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005896 - "tcp-check send" or "tcp-check send-binary" only is mentioned : this is
Willy Tarreaued179852013-12-16 01:07:00 +01005897 used to send a string along with a connection opening. With some
5898 protocols, it helps sending a "QUIT" message for example that prevents
5899 the server from logging a connection error for each health check. The
5900 check result will still be based on the ability to open the connection
5901 only.
5902
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005903 - "tcp-check expect" only is mentioned : this is used to test a banner.
Willy Tarreaued179852013-12-16 01:07:00 +01005904 The connection is opened and haproxy waits for the server to present some
5905 contents which must validate some rules. The check result will be based
5906 on the matching between the contents and the rules. This is suited for
5907 POP, IMAP, SMTP, FTP, SSH, TELNET.
5908
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005909 - both "tcp-check send" and "tcp-check expect" are mentioned : this is
Willy Tarreaued179852013-12-16 01:07:00 +01005910 used to test a hello-type protocol. Haproxy sends a message, the server
5911 responds and its response is analysed. the check result will be based on
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005912 the matching between the response contents and the rules. This is often
Willy Tarreaued179852013-12-16 01:07:00 +01005913 suited for protocols which require a binding or a request/response model.
5914 LDAP, MySQL, Redis and SSL are example of such protocols, though they
5915 already all have their dedicated checks with a deeper understanding of
5916 the respective protocols.
5917 In this mode, many questions may be sent and many answers may be
5918 analysed.
5919
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005920 A fifth mode can be used to insert comments in different steps of the
5921 script.
5922
5923 For each tcp-check rule you create, you can add a "comment" directive,
5924 followed by a string. This string will be reported in the log and stderr
5925 in debug mode. It is useful to make user-friendly error reporting.
5926 The "comment" is of course optional.
5927
5928
Willy Tarreaued179852013-12-16 01:07:00 +01005929 Examples :
5930 # perform a POP check (analyse only server's banner)
5931 option tcp-check
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005932 tcp-check expect string +OK\ POP3\ ready comment POP\ protocol
Willy Tarreaued179852013-12-16 01:07:00 +01005933
5934 # perform an IMAP check (analyse only server's banner)
5935 option tcp-check
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005936 tcp-check expect string *\ OK\ IMAP4\ ready comment IMAP\ protocol
Willy Tarreaued179852013-12-16 01:07:00 +01005937
5938 # look for the redis master server after ensuring it speaks well
5939 # redis protocol, then it exits properly.
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03005940 # (send a command then analyse the response 3 times)
Willy Tarreaued179852013-12-16 01:07:00 +01005941 option tcp-check
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005942 tcp-check comment PING\ phase
Willy Tarreaued179852013-12-16 01:07:00 +01005943 tcp-check send PING\r\n
Baptiste Assmanna3322992015-08-04 10:12:18 +02005944 tcp-check expect string +PONG
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005945 tcp-check comment role\ check
Willy Tarreaued179852013-12-16 01:07:00 +01005946 tcp-check send info\ replication\r\n
5947 tcp-check expect string role:master
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005948 tcp-check comment QUIT\ phase
Willy Tarreaued179852013-12-16 01:07:00 +01005949 tcp-check send QUIT\r\n
5950 tcp-check expect string +OK
5951
5952 forge a HTTP request, then analyse the response
5953 (send many headers before analyzing)
5954 option tcp-check
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005955 tcp-check comment forge\ and\ send\ HTTP\ request
Willy Tarreaued179852013-12-16 01:07:00 +01005956 tcp-check send HEAD\ /\ HTTP/1.1\r\n
5957 tcp-check send Host:\ www.mydomain.com\r\n
5958 tcp-check send User-Agent:\ HAProxy\ tcpcheck\r\n
5959 tcp-check send \r\n
Baptiste Assmannd60a9e52015-04-25 16:27:23 +02005960 tcp-check expect rstring HTTP/1\..\ (2..|3..) comment check\ HTTP\ response
Willy Tarreaued179852013-12-16 01:07:00 +01005961
5962
5963 See also : "tcp-check expect", "tcp-check send"
5964
5965
Willy Tarreau9ea05a72009-06-14 12:07:01 +02005966option tcp-smart-accept
5967no option tcp-smart-accept
5968 Enable or disable the saving of one ACK packet during the accept sequence
5969 May be used in sections : defaults | frontend | listen | backend
5970 yes | yes | yes | no
5971 Arguments : none
5972
5973 When an HTTP connection request comes in, the system acknowledges it on
5974 behalf of HAProxy, then the client immediately sends its request, and the
5975 system acknowledges it too while it is notifying HAProxy about the new
5976 connection. HAProxy then reads the request and responds. This means that we
5977 have one TCP ACK sent by the system for nothing, because the request could
5978 very well be acknowledged by HAProxy when it sends its response.
5979
5980 For this reason, in HTTP mode, HAProxy automatically asks the system to avoid
5981 sending this useless ACK on platforms which support it (currently at least
5982 Linux). It must not cause any problem, because the system will send it anyway
5983 after 40 ms if the response takes more time than expected to come.
5984
5985 During complex network debugging sessions, it may be desirable to disable
5986 this optimization because delayed ACKs can make troubleshooting more complex
5987 when trying to identify where packets are delayed. It is then possible to
5988 fall back to normal behaviour by specifying "no option tcp-smart-accept".
5989
5990 It is also possible to force it for non-HTTP proxies by simply specifying
5991 "option tcp-smart-accept". For instance, it can make sense with some services
5992 such as SMTP where the server speaks first.
5993
5994 It is recommended to avoid forcing this option in a defaults section. In case
5995 of doubt, consider setting it back to automatic values by prepending the
5996 "default" keyword before it, or disabling it using the "no" keyword.
5997
Willy Tarreaud88edf22009-06-14 15:48:17 +02005998 See also : "option tcp-smart-connect"
5999
6000
6001option tcp-smart-connect
6002no option tcp-smart-connect
6003 Enable or disable the saving of one ACK packet during the connect sequence
6004 May be used in sections : defaults | frontend | listen | backend
6005 yes | no | yes | yes
6006 Arguments : none
6007
6008 On certain systems (at least Linux), HAProxy can ask the kernel not to
6009 immediately send an empty ACK upon a connection request, but to directly
6010 send the buffer request instead. This saves one packet on the network and
6011 thus boosts performance. It can also be useful for some servers, because they
6012 immediately get the request along with the incoming connection.
6013
6014 This feature is enabled when "option tcp-smart-connect" is set in a backend.
6015 It is not enabled by default because it makes network troubleshooting more
6016 complex.
6017
6018 It only makes sense to enable it with protocols where the client speaks first
6019 such as HTTP. In other situations, if there is no data to send in place of
6020 the ACK, a normal ACK is sent.
6021
6022 If this option has been enabled in a "defaults" section, it can be disabled
6023 in a specific instance by prepending the "no" keyword before it.
6024
6025 See also : "option tcp-smart-accept"
6026
Willy Tarreau9ea05a72009-06-14 12:07:01 +02006027
Willy Tarreaubf1f8162007-12-28 17:42:56 +01006028option tcpka
6029 Enable or disable the sending of TCP keepalive packets on both sides
6030 May be used in sections : defaults | frontend | listen | backend
6031 yes | yes | yes | yes
6032 Arguments : none
6033
6034 When there is a firewall or any session-aware component between a client and
6035 a server, and when the protocol involves very long sessions with long idle
6036 periods (eg: remote desktops), there is a risk that one of the intermediate
6037 components decides to expire a session which has remained idle for too long.
6038
6039 Enabling socket-level TCP keep-alives makes the system regularly send packets
6040 to the other end of the connection, leaving it active. The delay between
6041 keep-alive probes is controlled by the system only and depends both on the
6042 operating system and its tuning parameters.
6043
6044 It is important to understand that keep-alive packets are neither emitted nor
6045 received at the application level. It is only the network stacks which sees
6046 them. For this reason, even if one side of the proxy already uses keep-alives
6047 to maintain its connection alive, those keep-alive packets will not be
6048 forwarded to the other side of the proxy.
6049
6050 Please note that this has nothing to do with HTTP keep-alive.
6051
6052 Using option "tcpka" enables the emission of TCP keep-alive probes on both
6053 the client and server sides of a connection. Note that this is meaningful
6054 only in "defaults" or "listen" sections. If this option is used in a
6055 frontend, only the client side will get keep-alives, and if this option is
6056 used in a backend, only the server side will get keep-alives. For this
6057 reason, it is strongly recommended to explicitly use "option clitcpka" and
6058 "option srvtcpka" when the configuration is split between frontends and
6059 backends.
6060
6061 See also : "option clitcpka", "option srvtcpka"
6062
Willy Tarreau844e3c52008-01-11 16:28:18 +01006063
6064option tcplog
6065 Enable advanced logging of TCP connections with session state and timers
6066 May be used in sections : defaults | frontend | listen | backend
6067 yes | yes | yes | yes
6068 Arguments : none
6069
6070 By default, the log output format is very poor, as it only contains the
6071 source and destination addresses, and the instance name. By specifying
6072 "option tcplog", each log line turns into a much richer format including, but
6073 not limited to, the connection timers, the session status, the connections
6074 numbers, the frontend, backend and server name, and of course the source
6075 address and ports. This option is useful for pure TCP proxies in order to
6076 find which of the client or server disconnects or times out. For normal HTTP
6077 proxies, it's better to use "option httplog" which is even more complete.
6078
6079 This option may be set either in the frontend or the backend.
6080
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006081 See also : "option httplog", and section 8 about logging.
Willy Tarreau844e3c52008-01-11 16:28:18 +01006082
6083
Willy Tarreau844e3c52008-01-11 16:28:18 +01006084option transparent
6085no option transparent
6086 Enable client-side transparent proxying
6087 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau4b1f8592008-12-23 23:13:55 +01006088 yes | no | yes | yes
Willy Tarreau844e3c52008-01-11 16:28:18 +01006089 Arguments : none
6090
6091 This option was introduced in order to provide layer 7 persistence to layer 3
6092 load balancers. The idea is to use the OS's ability to redirect an incoming
6093 connection for a remote address to a local process (here HAProxy), and let
6094 this process know what address was initially requested. When this option is
6095 used, sessions without cookies will be forwarded to the original destination
6096 IP address of the incoming request (which should match that of another
6097 equipment), while requests with cookies will still be forwarded to the
6098 appropriate server.
6099
6100 Note that contrary to a common belief, this option does NOT make HAProxy
6101 present the client's IP to the server when establishing the connection.
6102
Willy Tarreaua1146052011-03-01 09:51:54 +01006103 See also: the "usesrc" argument of the "source" keyword, and the
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006104 "transparent" option of the "bind" keyword.
Willy Tarreau844e3c52008-01-11 16:28:18 +01006105
Willy Tarreaubf1f8162007-12-28 17:42:56 +01006106
Simon Horman98637e52014-06-20 12:30:16 +09006107external-check command <command>
6108 Executable to run when performing an external-check
6109 May be used in sections : defaults | frontend | listen | backend
6110 yes | no | yes | yes
6111
6112 Arguments :
6113 <command> is the external command to run
6114
Simon Horman98637e52014-06-20 12:30:16 +09006115 The arguments passed to the to the command are:
6116
Cyril Bonté777be862014-12-02 21:21:35 +01006117 <proxy_address> <proxy_port> <server_address> <server_port>
Simon Horman98637e52014-06-20 12:30:16 +09006118
Cyril Bonté777be862014-12-02 21:21:35 +01006119 The <proxy_address> and <proxy_port> are derived from the first listener
6120 that is either IPv4, IPv6 or a UNIX socket. In the case of a UNIX socket
6121 listener the proxy_address will be the path of the socket and the
6122 <proxy_port> will be the string "NOT_USED". In a backend section, it's not
6123 possible to determine a listener, and both <proxy_address> and <proxy_port>
6124 will have the string value "NOT_USED".
Simon Horman98637e52014-06-20 12:30:16 +09006125
Cyril Bonté72cda2a2014-12-27 22:28:39 +01006126 Some values are also provided through environment variables.
6127
6128 Environment variables :
6129 HAPROXY_PROXY_ADDR The first bind address if available (or empty if not
6130 applicable, for example in a "backend" section).
6131
6132 HAPROXY_PROXY_ID The backend id.
6133
6134 HAPROXY_PROXY_NAME The backend name.
6135
6136 HAPROXY_PROXY_PORT The first bind port if available (or empty if not
6137 applicable, for example in a "backend" section or
6138 for a UNIX socket).
6139
6140 HAPROXY_SERVER_ADDR The server address.
6141
6142 HAPROXY_SERVER_CURCONN The current number of connections on the server.
6143
6144 HAPROXY_SERVER_ID The server id.
6145
6146 HAPROXY_SERVER_MAXCONN The server max connections.
6147
6148 HAPROXY_SERVER_NAME The server name.
6149
6150 HAPROXY_SERVER_PORT The server port if available (or empty for a UNIX
6151 socket).
6152
6153 PATH The PATH environment variable used when executing
6154 the command may be set using "external-check path".
6155
Simon Horman98637e52014-06-20 12:30:16 +09006156 If the command executed and exits with a zero status then the check is
6157 considered to have passed, otherwise the check is considered to have
6158 failed.
6159
6160 Example :
6161 external-check command /bin/true
6162
6163 See also : "external-check", "option external-check", "external-check path"
6164
6165
6166external-check path <path>
6167 The value of the PATH environment variable used when running an external-check
6168 May be used in sections : defaults | frontend | listen | backend
6169 yes | no | yes | yes
6170
6171 Arguments :
6172 <path> is the path used when executing external command to run
6173
6174 The default path is "".
6175
6176 Example :
6177 external-check path "/usr/bin:/bin"
6178
6179 See also : "external-check", "option external-check",
6180 "external-check command"
6181
6182
Emeric Brun647caf12009-06-30 17:57:00 +02006183persist rdp-cookie
Hervé COMMOWICKa3eb39c2011-08-05 18:48:51 +02006184persist rdp-cookie(<name>)
Emeric Brun647caf12009-06-30 17:57:00 +02006185 Enable RDP cookie-based persistence
6186 May be used in sections : defaults | frontend | listen | backend
6187 yes | no | yes | yes
6188 Arguments :
6189 <name> is the optional name of the RDP cookie to check. If omitted, the
Willy Tarreau61e28f22010-05-16 22:31:05 +02006190 default cookie name "msts" will be used. There currently is no
6191 valid reason to change this name.
Emeric Brun647caf12009-06-30 17:57:00 +02006192
6193 This statement enables persistence based on an RDP cookie. The RDP cookie
6194 contains all information required to find the server in the list of known
6195 servers. So when this option is set in the backend, the request is analysed
6196 and if an RDP cookie is found, it is decoded. If it matches a known server
6197 which is still UP (or if "option persist" is set), then the connection is
6198 forwarded to this server.
6199
6200 Note that this only makes sense in a TCP backend, but for this to work, the
6201 frontend must have waited long enough to ensure that an RDP cookie is present
6202 in the request buffer. This is the same requirement as with the "rdp-cookie"
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01006203 load-balancing method. Thus it is highly recommended to put all statements in
Emeric Brun647caf12009-06-30 17:57:00 +02006204 a single "listen" section.
6205
Willy Tarreau61e28f22010-05-16 22:31:05 +02006206 Also, it is important to understand that the terminal server will emit this
6207 RDP cookie only if it is configured for "token redirection mode", which means
6208 that the "IP address redirection" option is disabled.
6209
Emeric Brun647caf12009-06-30 17:57:00 +02006210 Example :
6211 listen tse-farm
6212 bind :3389
6213 # wait up to 5s for an RDP cookie in the request
6214 tcp-request inspect-delay 5s
6215 tcp-request content accept if RDP_COOKIE
6216 # apply RDP cookie persistence
6217 persist rdp-cookie
6218 # if server is unknown, let's balance on the same cookie.
Cyril Bontédc4d9032012-04-08 21:57:39 +02006219 # alternatively, "balance leastconn" may be useful too.
Emeric Brun647caf12009-06-30 17:57:00 +02006220 balance rdp-cookie
6221 server srv1 1.1.1.1:3389
6222 server srv2 1.1.1.2:3389
6223
Simon Hormanab814e02011-06-24 14:50:20 +09006224 See also : "balance rdp-cookie", "tcp-request", the "req_rdp_cookie" ACL and
6225 the rdp_cookie pattern fetch function.
Emeric Brun647caf12009-06-30 17:57:00 +02006226
6227
Willy Tarreau3a7d2072009-03-05 23:48:25 +01006228rate-limit sessions <rate>
6229 Set a limit on the number of new sessions accepted per second on a frontend
6230 May be used in sections : defaults | frontend | listen | backend
6231 yes | yes | yes | no
6232 Arguments :
6233 <rate> The <rate> parameter is an integer designating the maximum number
6234 of new sessions per second to accept on the frontend.
6235
6236 When the frontend reaches the specified number of new sessions per second, it
6237 stops accepting new connections until the rate drops below the limit again.
6238 During this time, the pending sessions will be kept in the socket's backlog
6239 (in system buffers) and haproxy will not even be aware that sessions are
6240 pending. When applying very low limit on a highly loaded service, it may make
6241 sense to increase the socket's backlog using the "backlog" keyword.
6242
6243 This feature is particularly efficient at blocking connection-based attacks
6244 or service abuse on fragile servers. Since the session rate is measured every
6245 millisecond, it is extremely accurate. Also, the limit applies immediately,
6246 no delay is needed at all to detect the threshold.
6247
6248 Example : limit the connection rate on SMTP to 10 per second max
6249 listen smtp
6250 mode tcp
6251 bind :25
6252 rate-limit sessions 10
6253 server 127.0.0.1:1025
6254
Willy Tarreaua17c2d92011-07-25 08:16:20 +02006255 Note : when the maximum rate is reached, the frontend's status is not changed
6256 but its sockets appear as "WAITING" in the statistics if the
6257 "socket-stats" option is enabled.
Willy Tarreau3a7d2072009-03-05 23:48:25 +01006258
6259 See also : the "backlog" keyword and the "fe_sess_rate" ACL criterion.
6260
6261
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006262redirect location <loc> [code <code>] <option> [{if | unless} <condition>]
6263redirect prefix <pfx> [code <code>] <option> [{if | unless} <condition>]
6264redirect scheme <sch> [code <code>] <option> [{if | unless} <condition>]
Willy Tarreaub463dfb2008-06-07 23:08:56 +02006265 Return an HTTP redirection if/unless a condition is matched
6266 May be used in sections : defaults | frontend | listen | backend
6267 no | yes | yes | yes
6268
6269 If/unless the condition is matched, the HTTP request will lead to a redirect
Willy Tarreauf285f542010-01-03 20:03:03 +01006270 response. If no condition is specified, the redirect applies unconditionally.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02006271
Willy Tarreau0140f252008-11-19 21:07:09 +01006272 Arguments :
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006273 <loc> With "redirect location", the exact value in <loc> is placed into
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01006274 the HTTP "Location" header. When used in an "http-request" rule,
6275 <loc> value follows the log-format rules and can include some
6276 dynamic values (see Custom Log Format in section 8.2.4).
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006277
6278 <pfx> With "redirect prefix", the "Location" header is built from the
6279 concatenation of <pfx> and the complete URI path, including the
6280 query string, unless the "drop-query" option is specified (see
6281 below). As a special case, if <pfx> equals exactly "/", then
6282 nothing is inserted before the original URI. It allows one to
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01006283 redirect to the same URL (for instance, to insert a cookie). When
6284 used in an "http-request" rule, <pfx> value follows the log-format
6285 rules and can include some dynamic values (see Custom Log Format
6286 in section 8.2.4).
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006287
6288 <sch> With "redirect scheme", then the "Location" header is built by
6289 concatenating <sch> with "://" then the first occurrence of the
6290 "Host" header, and then the URI path, including the query string
6291 unless the "drop-query" option is specified (see below). If no
6292 path is found or if the path is "*", then "/" is used instead. If
6293 no "Host" header is found, then an empty host component will be
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03006294 returned, which most recent browsers interpret as redirecting to
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006295 the same host. This directive is mostly used to redirect HTTP to
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01006296 HTTPS. When used in an "http-request" rule, <sch> value follows
6297 the log-format rules and can include some dynamic values (see
6298 Custom Log Format in section 8.2.4).
Willy Tarreau0140f252008-11-19 21:07:09 +01006299
6300 <code> The code is optional. It indicates which type of HTTP redirection
Willy Tarreaub67fdc42013-03-29 19:28:11 +01006301 is desired. Only codes 301, 302, 303, 307 and 308 are supported,
6302 with 302 used by default if no code is specified. 301 means
6303 "Moved permanently", and a browser may cache the Location. 302
Baptiste Assmannea849c02015-08-03 11:42:50 +02006304 means "Moved temporarily" and means that the browser should not
Willy Tarreaub67fdc42013-03-29 19:28:11 +01006305 cache the redirection. 303 is equivalent to 302 except that the
6306 browser will fetch the location with a GET method. 307 is just
6307 like 302 but makes it clear that the same method must be reused.
6308 Likewise, 308 replaces 301 if the same method must be used.
Willy Tarreau0140f252008-11-19 21:07:09 +01006309
6310 <option> There are several options which can be specified to adjust the
6311 expected behaviour of a redirection :
6312
6313 - "drop-query"
6314 When this keyword is used in a prefix-based redirection, then the
6315 location will be set without any possible query-string, which is useful
6316 for directing users to a non-secure page for instance. It has no effect
6317 with a location-type redirect.
6318
Willy Tarreau81e3b4f2010-01-10 00:42:19 +01006319 - "append-slash"
6320 This keyword may be used in conjunction with "drop-query" to redirect
6321 users who use a URL not ending with a '/' to the same one with the '/'.
6322 It can be useful to ensure that search engines will only see one URL.
6323 For this, a return code 301 is preferred.
6324
Willy Tarreau0140f252008-11-19 21:07:09 +01006325 - "set-cookie NAME[=value]"
6326 A "Set-Cookie" header will be added with NAME (and optionally "=value")
6327 to the response. This is sometimes used to indicate that a user has
6328 been seen, for instance to protect against some types of DoS. No other
6329 cookie option is added, so the cookie will be a session cookie. Note
6330 that for a browser, a sole cookie name without an equal sign is
6331 different from a cookie with an equal sign.
6332
6333 - "clear-cookie NAME[=]"
6334 A "Set-Cookie" header will be added with NAME (and optionally "="), but
6335 with the "Max-Age" attribute set to zero. This will tell the browser to
6336 delete this cookie. It is useful for instance on logout pages. It is
6337 important to note that clearing the cookie "NAME" will not remove a
6338 cookie set with "NAME=value". You have to clear the cookie "NAME=" for
6339 that, because the browser makes the difference.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02006340
6341 Example: move the login URL only to HTTPS.
6342 acl clear dst_port 80
6343 acl secure dst_port 8080
6344 acl login_page url_beg /login
Willy Tarreau0140f252008-11-19 21:07:09 +01006345 acl logout url_beg /logout
Willy Tarreau79da4692008-11-19 20:03:04 +01006346 acl uid_given url_reg /login?userid=[^&]+
Willy Tarreau0140f252008-11-19 21:07:09 +01006347 acl cookie_set hdr_sub(cookie) SEEN=1
6348
6349 redirect prefix https://mysite.com set-cookie SEEN=1 if !cookie_set
Willy Tarreau79da4692008-11-19 20:03:04 +01006350 redirect prefix https://mysite.com if login_page !secure
6351 redirect prefix http://mysite.com drop-query if login_page !uid_given
6352 redirect location http://mysite.com/ if !login_page secure
Willy Tarreau0140f252008-11-19 21:07:09 +01006353 redirect location / clear-cookie USERID= if logout
Willy Tarreaub463dfb2008-06-07 23:08:56 +02006354
Willy Tarreau81e3b4f2010-01-10 00:42:19 +01006355 Example: send redirects for request for articles without a '/'.
6356 acl missing_slash path_reg ^/article/[^/]*$
6357 redirect code 301 prefix / drop-query append-slash if missing_slash
6358
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006359 Example: redirect all HTTP traffic to HTTPS when SSL is handled by haproxy.
David BERARDe7153042012-11-03 00:11:31 +01006360 redirect scheme https if !{ ssl_fc }
Willy Tarreau2e1dca82012-09-12 08:43:15 +02006361
Thierry FOURNIERd18cd0f2013-11-29 12:15:45 +01006362 Example: append 'www.' prefix in front of all hosts not having it
6363 http-request redirect code 301 location www.%[hdr(host)]%[req.uri] \
6364 unless { hdr_beg(host) -i www }
6365
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006366 See section 7 about ACL usage.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02006367
6368
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01006369redisp (deprecated)
6370redispatch (deprecated)
6371 Enable or disable session redistribution in case of connection failure
6372 May be used in sections: defaults | frontend | listen | backend
6373 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006374 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01006375
6376 In HTTP mode, if a server designated by a cookie is down, clients may
6377 definitely stick to it because they cannot flush the cookie, so they will not
6378 be able to access the service anymore.
6379
6380 Specifying "redispatch" will allow the proxy to break their persistence and
6381 redistribute them to a working server.
6382
6383 It also allows to retry last connection to another server in case of multiple
6384 connection failures. Of course, it requires having "retries" set to a nonzero
6385 value.
Willy Tarreaud72758d2010-01-12 10:42:19 +01006386
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01006387 This form is deprecated, do not use it in any new configuration, use the new
6388 "option redispatch" instead.
6389
6390 See also : "option redispatch"
6391
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006392
Willy Tarreau8abd4cd2010-01-31 14:30:44 +01006393reqadd <string> [{if | unless} <cond>]
Willy Tarreau303c0352008-01-17 19:01:39 +01006394 Add a header at the end of the HTTP request
6395 May be used in sections : defaults | frontend | listen | backend
6396 no | yes | yes | yes
6397 Arguments :
6398 <string> is the complete line to be added. Any space or known delimiter
6399 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006400 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006401
Willy Tarreau8abd4cd2010-01-31 14:30:44 +01006402 <cond> is an optional matching condition built from ACLs. It makes it
6403 possible to ignore this rule when other conditions are not met.
6404
Willy Tarreau303c0352008-01-17 19:01:39 +01006405 A new line consisting in <string> followed by a line feed will be added after
6406 the last header of an HTTP request.
6407
6408 Header transformations only apply to traffic which passes through HAProxy,
6409 and not to traffic generated by HAProxy, such as health-checks or error
6410 responses.
6411
Willy Tarreau8abd4cd2010-01-31 14:30:44 +01006412 Example : add "X-Proto: SSL" to requests coming via port 81
6413 acl is-ssl dst_port 81
6414 reqadd X-Proto:\ SSL if is-ssl
6415
6416 See also: "rspadd", section 6 about HTTP header manipulation, and section 7
6417 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006418
6419
Willy Tarreau5321c422010-01-28 20:35:13 +01006420reqallow <search> [{if | unless} <cond>]
6421reqiallow <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006422 Definitely allow an HTTP request if a line matches a regular expression
6423 May be used in sections : defaults | frontend | listen | backend
6424 no | yes | yes | yes
6425 Arguments :
6426 <search> is the regular expression applied to HTTP headers and to the
6427 request line. This is an extended regular expression. Parenthesis
6428 grouping is supported and no preliminary backslash is required.
6429 Any space or known delimiter must be escaped using a backslash
6430 ('\'). The pattern applies to a full line at a time. The
6431 "reqallow" keyword strictly matches case while "reqiallow"
6432 ignores case.
6433
Willy Tarreau5321c422010-01-28 20:35:13 +01006434 <cond> is an optional matching condition built from ACLs. It makes it
6435 possible to ignore this rule when other conditions are not met.
6436
Willy Tarreau303c0352008-01-17 19:01:39 +01006437 A request containing any line which matches extended regular expression
6438 <search> will mark the request as allowed, even if any later test would
6439 result in a deny. The test applies both to the request line and to request
6440 headers. Keep in mind that URLs in request line are case-sensitive while
Willy Tarreaud72758d2010-01-12 10:42:19 +01006441 header names are not.
Willy Tarreau303c0352008-01-17 19:01:39 +01006442
6443 It is easier, faster and more powerful to use ACLs to write access policies.
6444 Reqdeny, reqallow and reqpass should be avoided in new designs.
6445
6446 Example :
6447 # allow www.* but refuse *.local
6448 reqiallow ^Host:\ www\.
6449 reqideny ^Host:\ .*\.local
6450
Willy Tarreau5321c422010-01-28 20:35:13 +01006451 See also: "reqdeny", "block", section 6 about HTTP header manipulation, and
6452 section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006453
6454
Willy Tarreau5321c422010-01-28 20:35:13 +01006455reqdel <search> [{if | unless} <cond>]
6456reqidel <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006457 Delete all headers matching a regular expression in an HTTP request
6458 May be used in sections : defaults | frontend | listen | backend
6459 no | yes | yes | yes
6460 Arguments :
6461 <search> is the regular expression applied to HTTP headers and to the
6462 request line. This is an extended regular expression. Parenthesis
6463 grouping is supported and no preliminary backslash is required.
6464 Any space or known delimiter must be escaped using a backslash
6465 ('\'). The pattern applies to a full line at a time. The "reqdel"
6466 keyword strictly matches case while "reqidel" ignores case.
6467
Willy Tarreau5321c422010-01-28 20:35:13 +01006468 <cond> is an optional matching condition built from ACLs. It makes it
6469 possible to ignore this rule when other conditions are not met.
6470
Willy Tarreau303c0352008-01-17 19:01:39 +01006471 Any header line matching extended regular expression <search> in the request
6472 will be completely deleted. Most common use of this is to remove unwanted
6473 and/or dangerous headers or cookies from a request before passing it to the
6474 next servers.
6475
6476 Header transformations only apply to traffic which passes through HAProxy,
6477 and not to traffic generated by HAProxy, such as health-checks or error
6478 responses. Keep in mind that header names are not case-sensitive.
6479
6480 Example :
6481 # remove X-Forwarded-For header and SERVER cookie
6482 reqidel ^X-Forwarded-For:.*
6483 reqidel ^Cookie:.*SERVER=
6484
Willy Tarreau5321c422010-01-28 20:35:13 +01006485 See also: "reqadd", "reqrep", "rspdel", section 6 about HTTP header
6486 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006487
6488
Willy Tarreau5321c422010-01-28 20:35:13 +01006489reqdeny <search> [{if | unless} <cond>]
6490reqideny <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006491 Deny an HTTP request if a line matches a regular expression
6492 May be used in sections : defaults | frontend | listen | backend
6493 no | yes | yes | yes
6494 Arguments :
6495 <search> is the regular expression applied to HTTP headers and to the
6496 request line. This is an extended regular expression. Parenthesis
6497 grouping is supported and no preliminary backslash is required.
6498 Any space or known delimiter must be escaped using a backslash
6499 ('\'). The pattern applies to a full line at a time. The
6500 "reqdeny" keyword strictly matches case while "reqideny" ignores
6501 case.
6502
Willy Tarreau5321c422010-01-28 20:35:13 +01006503 <cond> is an optional matching condition built from ACLs. It makes it
6504 possible to ignore this rule when other conditions are not met.
6505
Willy Tarreau303c0352008-01-17 19:01:39 +01006506 A request containing any line which matches extended regular expression
6507 <search> will mark the request as denied, even if any later test would
6508 result in an allow. The test applies both to the request line and to request
6509 headers. Keep in mind that URLs in request line are case-sensitive while
Willy Tarreaud72758d2010-01-12 10:42:19 +01006510 header names are not.
Willy Tarreau303c0352008-01-17 19:01:39 +01006511
Willy Tarreauced27012008-01-17 20:35:34 +01006512 A denied request will generate an "HTTP 403 forbidden" response once the
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01006513 complete request has been parsed. This is consistent with what is practiced
Willy Tarreaud72758d2010-01-12 10:42:19 +01006514 using ACLs.
Willy Tarreauced27012008-01-17 20:35:34 +01006515
Willy Tarreau303c0352008-01-17 19:01:39 +01006516 It is easier, faster and more powerful to use ACLs to write access policies.
6517 Reqdeny, reqallow and reqpass should be avoided in new designs.
6518
6519 Example :
6520 # refuse *.local, then allow www.*
6521 reqideny ^Host:\ .*\.local
6522 reqiallow ^Host:\ www\.
6523
Willy Tarreau5321c422010-01-28 20:35:13 +01006524 See also: "reqallow", "rspdeny", "block", section 6 about HTTP header
6525 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006526
6527
Willy Tarreau5321c422010-01-28 20:35:13 +01006528reqpass <search> [{if | unless} <cond>]
6529reqipass <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006530 Ignore any HTTP request line matching a regular expression in next rules
6531 May be used in sections : defaults | frontend | listen | backend
6532 no | yes | yes | yes
6533 Arguments :
6534 <search> is the regular expression applied to HTTP headers and to the
6535 request line. This is an extended regular expression. Parenthesis
6536 grouping is supported and no preliminary backslash is required.
6537 Any space or known delimiter must be escaped using a backslash
6538 ('\'). The pattern applies to a full line at a time. The
6539 "reqpass" keyword strictly matches case while "reqipass" ignores
6540 case.
6541
Willy Tarreau5321c422010-01-28 20:35:13 +01006542 <cond> is an optional matching condition built from ACLs. It makes it
6543 possible to ignore this rule when other conditions are not met.
6544
Willy Tarreau303c0352008-01-17 19:01:39 +01006545 A request containing any line which matches extended regular expression
6546 <search> will skip next rules, without assigning any deny or allow verdict.
6547 The test applies both to the request line and to request headers. Keep in
6548 mind that URLs in request line are case-sensitive while header names are not.
6549
6550 It is easier, faster and more powerful to use ACLs to write access policies.
6551 Reqdeny, reqallow and reqpass should be avoided in new designs.
6552
6553 Example :
6554 # refuse *.local, then allow www.*, but ignore "www.private.local"
6555 reqipass ^Host:\ www.private\.local
6556 reqideny ^Host:\ .*\.local
6557 reqiallow ^Host:\ www\.
6558
Willy Tarreau5321c422010-01-28 20:35:13 +01006559 See also: "reqallow", "reqdeny", "block", section 6 about HTTP header
6560 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006561
6562
Willy Tarreau5321c422010-01-28 20:35:13 +01006563reqrep <search> <string> [{if | unless} <cond>]
6564reqirep <search> <string> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006565 Replace a regular expression with a string in an HTTP request line
6566 May be used in sections : defaults | frontend | listen | backend
6567 no | yes | yes | yes
6568 Arguments :
6569 <search> is the regular expression applied to HTTP headers and to the
6570 request line. This is an extended regular expression. Parenthesis
6571 grouping is supported and no preliminary backslash is required.
6572 Any space or known delimiter must be escaped using a backslash
6573 ('\'). The pattern applies to a full line at a time. The "reqrep"
6574 keyword strictly matches case while "reqirep" ignores case.
6575
6576 <string> is the complete line to be added. Any space or known delimiter
6577 must be escaped using a backslash ('\'). References to matched
6578 pattern groups are possible using the common \N form, with N
6579 being a single digit between 0 and 9. Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006580 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006581
Willy Tarreau5321c422010-01-28 20:35:13 +01006582 <cond> is an optional matching condition built from ACLs. It makes it
6583 possible to ignore this rule when other conditions are not met.
6584
Willy Tarreau303c0352008-01-17 19:01:39 +01006585 Any line matching extended regular expression <search> in the request (both
6586 the request line and header lines) will be completely replaced with <string>.
6587 Most common use of this is to rewrite URLs or domain names in "Host" headers.
6588
6589 Header transformations only apply to traffic which passes through HAProxy,
6590 and not to traffic generated by HAProxy, such as health-checks or error
6591 responses. Note that for increased readability, it is suggested to add enough
6592 spaces between the request and the response. Keep in mind that URLs in
6593 request line are case-sensitive while header names are not.
6594
6595 Example :
6596 # replace "/static/" with "/" at the beginning of any request path.
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04006597 reqrep ^([^\ :]*)\ /static/(.*) \1\ /\2
Willy Tarreau303c0352008-01-17 19:01:39 +01006598 # replace "www.mydomain.com" with "www" in the host name.
6599 reqirep ^Host:\ www.mydomain.com Host:\ www
6600
Dmitry Sivachenkof6f4f7b2012-10-21 18:10:25 +04006601 See also: "reqadd", "reqdel", "rsprep", "tune.bufsize", section 6 about
6602 HTTP header manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006603
6604
Willy Tarreau5321c422010-01-28 20:35:13 +01006605reqtarpit <search> [{if | unless} <cond>]
6606reqitarpit <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006607 Tarpit an HTTP request containing a line matching a regular expression
6608 May be used in sections : defaults | frontend | listen | backend
6609 no | yes | yes | yes
6610 Arguments :
6611 <search> is the regular expression applied to HTTP headers and to the
6612 request line. This is an extended regular expression. Parenthesis
6613 grouping is supported and no preliminary backslash is required.
6614 Any space or known delimiter must be escaped using a backslash
6615 ('\'). The pattern applies to a full line at a time. The
6616 "reqtarpit" keyword strictly matches case while "reqitarpit"
6617 ignores case.
6618
Willy Tarreau5321c422010-01-28 20:35:13 +01006619 <cond> is an optional matching condition built from ACLs. It makes it
6620 possible to ignore this rule when other conditions are not met.
6621
Willy Tarreau303c0352008-01-17 19:01:39 +01006622 A request containing any line which matches extended regular expression
6623 <search> will be tarpitted, which means that it will connect to nowhere, will
Willy Tarreauced27012008-01-17 20:35:34 +01006624 be kept open for a pre-defined time, then will return an HTTP error 500 so
6625 that the attacker does not suspect it has been tarpitted. The status 500 will
6626 be reported in the logs, but the completion flags will indicate "PT". The
Willy Tarreau303c0352008-01-17 19:01:39 +01006627 delay is defined by "timeout tarpit", or "timeout connect" if the former is
6628 not set.
6629
6630 The goal of the tarpit is to slow down robots attacking servers with
6631 identifiable requests. Many robots limit their outgoing number of connections
6632 and stay connected waiting for a reply which can take several minutes to
6633 come. Depending on the environment and attack, it may be particularly
6634 efficient at reducing the load on the network and firewalls.
6635
Willy Tarreau5321c422010-01-28 20:35:13 +01006636 Examples :
Willy Tarreau303c0352008-01-17 19:01:39 +01006637 # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but
6638 # block all others.
6639 reqipass ^User-Agent:\.*(Mozilla|MSIE)
6640 reqitarpit ^User-Agent:
6641
Willy Tarreau5321c422010-01-28 20:35:13 +01006642 # block bad guys
6643 acl badguys src 10.1.0.3 172.16.13.20/28
6644 reqitarpit . if badguys
6645
6646 See also: "reqallow", "reqdeny", "reqpass", section 6 about HTTP header
6647 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006648
6649
Willy Tarreaue5c5ce92008-06-20 17:27:19 +02006650retries <value>
6651 Set the number of retries to perform on a server after a connection failure
6652 May be used in sections: defaults | frontend | listen | backend
6653 yes | no | yes | yes
6654 Arguments :
6655 <value> is the number of times a connection attempt should be retried on
6656 a server when a connection either is refused or times out. The
6657 default value is 3.
6658
6659 It is important to understand that this value applies to the number of
6660 connection attempts, not full requests. When a connection has effectively
6661 been established to a server, there will be no more retry.
6662
6663 In order to avoid immediate reconnections to a server which is restarting,
Joseph Lynch726ab712015-05-11 23:25:34 -07006664 a turn-around timer of min("timeout connect", one second) is applied before
6665 a retry occurs.
Willy Tarreaue5c5ce92008-06-20 17:27:19 +02006666
6667 When "option redispatch" is set, the last retry may be performed on another
6668 server even if a cookie references a different server.
6669
6670 See also : "option redispatch"
6671
6672
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006673rspadd <string> [{if | unless} <cond>]
Willy Tarreau303c0352008-01-17 19:01:39 +01006674 Add a header at the end of the HTTP response
6675 May be used in sections : defaults | frontend | listen | backend
6676 no | yes | yes | yes
6677 Arguments :
6678 <string> is the complete line to be added. Any space or known delimiter
6679 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006680 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006681
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006682 <cond> is an optional matching condition built from ACLs. It makes it
6683 possible to ignore this rule when other conditions are not met.
6684
Willy Tarreau303c0352008-01-17 19:01:39 +01006685 A new line consisting in <string> followed by a line feed will be added after
6686 the last header of an HTTP response.
6687
6688 Header transformations only apply to traffic which passes through HAProxy,
6689 and not to traffic generated by HAProxy, such as health-checks or error
6690 responses.
6691
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006692 See also: "reqadd", section 6 about HTTP header manipulation, and section 7
6693 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006694
6695
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006696rspdel <search> [{if | unless} <cond>]
6697rspidel <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006698 Delete all headers matching a regular expression in an HTTP response
6699 May be used in sections : defaults | frontend | listen | backend
6700 no | yes | yes | yes
6701 Arguments :
6702 <search> is the regular expression applied to HTTP headers and to the
6703 response line. This is an extended regular expression, so
6704 parenthesis grouping is supported and no preliminary backslash
6705 is required. Any space or known delimiter must be escaped using
6706 a backslash ('\'). The pattern applies to a full line at a time.
6707 The "rspdel" keyword strictly matches case while "rspidel"
6708 ignores case.
6709
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006710 <cond> is an optional matching condition built from ACLs. It makes it
6711 possible to ignore this rule when other conditions are not met.
6712
Willy Tarreau303c0352008-01-17 19:01:39 +01006713 Any header line matching extended regular expression <search> in the response
6714 will be completely deleted. Most common use of this is to remove unwanted
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02006715 and/or sensitive headers or cookies from a response before passing it to the
Willy Tarreau303c0352008-01-17 19:01:39 +01006716 client.
6717
6718 Header transformations only apply to traffic which passes through HAProxy,
6719 and not to traffic generated by HAProxy, such as health-checks or error
6720 responses. Keep in mind that header names are not case-sensitive.
6721
6722 Example :
6723 # remove the Server header from responses
Willy Tarreau5e80e022013-05-25 08:31:25 +02006724 rspidel ^Server:.*
Willy Tarreau303c0352008-01-17 19:01:39 +01006725
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006726 See also: "rspadd", "rsprep", "reqdel", section 6 about HTTP header
6727 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006728
6729
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006730rspdeny <search> [{if | unless} <cond>]
6731rspideny <search> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006732 Block an HTTP response if a line matches a regular expression
6733 May be used in sections : defaults | frontend | listen | backend
6734 no | yes | yes | yes
6735 Arguments :
6736 <search> is the regular expression applied to HTTP headers and to the
6737 response line. This is an extended regular expression, so
6738 parenthesis grouping is supported and no preliminary backslash
6739 is required. Any space or known delimiter must be escaped using
6740 a backslash ('\'). The pattern applies to a full line at a time.
6741 The "rspdeny" keyword strictly matches case while "rspideny"
6742 ignores case.
6743
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006744 <cond> is an optional matching condition built from ACLs. It makes it
6745 possible to ignore this rule when other conditions are not met.
6746
Willy Tarreau303c0352008-01-17 19:01:39 +01006747 A response containing any line which matches extended regular expression
6748 <search> will mark the request as denied. The test applies both to the
6749 response line and to response headers. Keep in mind that header names are not
6750 case-sensitive.
6751
6752 Main use of this keyword is to prevent sensitive information leak and to
Willy Tarreauced27012008-01-17 20:35:34 +01006753 block the response before it reaches the client. If a response is denied, it
6754 will be replaced with an HTTP 502 error so that the client never retrieves
6755 any sensitive data.
Willy Tarreau303c0352008-01-17 19:01:39 +01006756
6757 It is easier, faster and more powerful to use ACLs to write access policies.
6758 Rspdeny should be avoided in new designs.
6759
6760 Example :
6761 # Ensure that no content type matching ms-word will leak
6762 rspideny ^Content-type:\.*/ms-word
6763
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006764 See also: "reqdeny", "acl", "block", section 6 about HTTP header manipulation
6765 and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006766
6767
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006768rsprep <search> <string> [{if | unless} <cond>]
6769rspirep <search> <string> [{if | unless} <cond>] (ignore case)
Willy Tarreau303c0352008-01-17 19:01:39 +01006770 Replace a regular expression with a string in an HTTP response line
6771 May be used in sections : defaults | frontend | listen | backend
6772 no | yes | yes | yes
6773 Arguments :
6774 <search> is the regular expression applied to HTTP headers and to the
6775 response line. This is an extended regular expression, so
6776 parenthesis grouping is supported and no preliminary backslash
6777 is required. Any space or known delimiter must be escaped using
6778 a backslash ('\'). The pattern applies to a full line at a time.
6779 The "rsprep" keyword strictly matches case while "rspirep"
6780 ignores case.
6781
6782 <string> is the complete line to be added. Any space or known delimiter
6783 must be escaped using a backslash ('\'). References to matched
6784 pattern groups are possible using the common \N form, with N
6785 being a single digit between 0 and 9. Please refer to section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006786 6 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01006787
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006788 <cond> is an optional matching condition built from ACLs. It makes it
6789 possible to ignore this rule when other conditions are not met.
6790
Willy Tarreau303c0352008-01-17 19:01:39 +01006791 Any line matching extended regular expression <search> in the response (both
6792 the response line and header lines) will be completely replaced with
6793 <string>. Most common use of this is to rewrite Location headers.
6794
6795 Header transformations only apply to traffic which passes through HAProxy,
6796 and not to traffic generated by HAProxy, such as health-checks or error
6797 responses. Note that for increased readability, it is suggested to add enough
6798 spaces between the request and the response. Keep in mind that header names
6799 are not case-sensitive.
6800
6801 Example :
6802 # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com"
6803 rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com
6804
Willy Tarreaufdb563c2010-01-31 15:43:27 +01006805 See also: "rspadd", "rspdel", "reqrep", section 6 about HTTP header
6806 manipulation, and section 7 about ACLs.
Willy Tarreau303c0352008-01-17 19:01:39 +01006807
6808
David du Colombier486df472011-03-17 10:40:26 +01006809server <name> <address>[:[port]] [param*]
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006810 Declare a server in a backend
6811 May be used in sections : defaults | frontend | listen | backend
6812 no | no | yes | yes
6813 Arguments :
6814 <name> is the internal name assigned to this server. This name will
Cyril Bonté941a0c62012-10-15 19:44:24 +02006815 appear in logs and alerts. If "http-send-name-header" is
Mark Lamourinec2247f02012-01-04 13:02:01 -05006816 set, it will be added to the request header sent to the server.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006817
David du Colombier486df472011-03-17 10:40:26 +01006818 <address> is the IPv4 or IPv6 address of the server. Alternatively, a
6819 resolvable hostname is supported, but this name will be resolved
6820 during start-up. Address "0.0.0.0" or "*" has a special meaning.
6821 It indicates that the connection will be forwarded to the same IP
Willy Tarreaud669a4f2010-07-13 14:49:50 +02006822 address as the one from the client connection. This is useful in
6823 transparent proxy architectures where the client's connection is
6824 intercepted and haproxy must forward to the original destination
6825 address. This is more or less what the "transparent" keyword does
6826 except that with a server it's possible to limit concurrency and
Willy Tarreau24709282013-03-10 21:32:12 +01006827 to report statistics. Optionally, an address family prefix may be
6828 used before the address to force the family regardless of the
6829 address format, which can be useful to specify a path to a unix
6830 socket with no slash ('/'). Currently supported prefixes are :
6831 - 'ipv4@' -> address is always IPv4
6832 - 'ipv6@' -> address is always IPv6
6833 - 'unix@' -> address is a path to a local unix socket
Willy Tarreauccfccef2014-05-10 01:49:15 +02006834 - 'abns@' -> address is in abstract namespace (Linux only)
William Lallemandb2f07452015-05-12 14:27:13 +02006835 You may want to reference some environment variables in the
6836 address parameter, see section 2.3 about environment
6837 variables.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006838
Willy Tarreaub6205fd2012-09-24 12:27:33 +02006839 <port> is an optional port specification. If set, all connections will
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006840 be sent to this port. If unset, the same port the client
6841 connected to will be used. The port may also be prefixed by a "+"
6842 or a "-". In this case, the server's port will be determined by
6843 adding this value to the client's port.
6844
6845 <param*> is a list of parameters for this server. The "server" keywords
6846 accepts an important number of options and has a complete section
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006847 dedicated to it. Please refer to section 5 for more details.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006848
6849 Examples :
6850 server first 10.1.1.1:1080 cookie first check inter 1000
6851 server second 10.1.1.2:1080 cookie second check inter 1000
Willy Tarreau24709282013-03-10 21:32:12 +01006852 server transp ipv4@
William Lallemandb2f07452015-05-12 14:27:13 +02006853 server backup "${SRV_BACKUP}:1080" backup
6854 server www1_dc1 "${LAN_DC1}.101:80"
6855 server www1_dc2 "${LAN_DC2}.101:80"
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006856
Mark Lamourinec2247f02012-01-04 13:02:01 -05006857 See also: "default-server", "http-send-name-header" and section 5 about
6858 server options
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006859
6860
6861source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
Willy Tarreaubce70882009-09-07 11:51:47 +02006862source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | hdr_ip(<hdr>[,<occ>]) } ]
Willy Tarreaud53f96b2009-02-04 18:46:54 +01006863source <addr>[:<port>] [interface <name>]
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006864 Set the source address for outgoing connections
6865 May be used in sections : defaults | frontend | listen | backend
6866 yes | no | yes | yes
6867 Arguments :
6868 <addr> is the IPv4 address HAProxy will bind to before connecting to a
6869 server. This address is also used as a source for health checks.
Willy Tarreau24709282013-03-10 21:32:12 +01006870
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006871 The default value of 0.0.0.0 means that the system will select
Willy Tarreau24709282013-03-10 21:32:12 +01006872 the most appropriate address to reach its destination. Optionally
6873 an address family prefix may be used before the address to force
6874 the family regardless of the address format, which can be useful
6875 to specify a path to a unix socket with no slash ('/'). Currently
6876 supported prefixes are :
6877 - 'ipv4@' -> address is always IPv4
6878 - 'ipv6@' -> address is always IPv6
6879 - 'unix@' -> address is a path to a local unix socket
Willy Tarreauccfccef2014-05-10 01:49:15 +02006880 - 'abns@' -> address is in abstract namespace (Linux only)
William Lallemandb2f07452015-05-12 14:27:13 +02006881 You may want to reference some environment variables in the address
6882 parameter, see section 2.3 about environment variables.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006883
6884 <port> is an optional port. It is normally not needed but may be useful
6885 in some very specific contexts. The default value of zero means
Willy Tarreauc6f4ce82009-06-10 11:09:37 +02006886 the system will select a free port. Note that port ranges are not
6887 supported in the backend. If you want to force port ranges, you
6888 have to specify them on each "server" line.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006889
6890 <addr2> is the IP address to present to the server when connections are
6891 forwarded in full transparent proxy mode. This is currently only
6892 supported on some patched Linux kernels. When this address is
6893 specified, clients connecting to the server will be presented
6894 with this address, while health checks will still use the address
6895 <addr>.
6896
6897 <port2> is the optional port to present to the server when connections
6898 are forwarded in full transparent proxy mode (see <addr2> above).
6899 The default value of zero means the system will select a free
6900 port.
6901
Willy Tarreaubce70882009-09-07 11:51:47 +02006902 <hdr> is the name of a HTTP header in which to fetch the IP to bind to.
6903 This is the name of a comma-separated header list which can
6904 contain multiple IP addresses. By default, the last occurrence is
6905 used. This is designed to work with the X-Forwarded-For header
Baptiste Assmannea3e73b2013-02-02 23:47:49 +01006906 and to automatically bind to the client's IP address as seen
Willy Tarreaubce70882009-09-07 11:51:47 +02006907 by previous proxy, typically Stunnel. In order to use another
6908 occurrence from the last one, please see the <occ> parameter
6909 below. When the header (or occurrence) is not found, no binding
6910 is performed so that the proxy's default IP address is used. Also
6911 keep in mind that the header name is case insensitive, as for any
6912 HTTP header.
6913
6914 <occ> is the occurrence number of a value to be used in a multi-value
6915 header. This is to be used in conjunction with "hdr_ip(<hdr>)",
Jamie Gloudonaaa21002012-08-25 00:18:33 -04006916 in order to specify which occurrence to use for the source IP
Willy Tarreaubce70882009-09-07 11:51:47 +02006917 address. Positive values indicate a position from the first
6918 occurrence, 1 being the first one. Negative values indicate
6919 positions relative to the last one, -1 being the last one. This
6920 is helpful for situations where an X-Forwarded-For header is set
6921 at the entry point of an infrastructure and must be used several
6922 proxy layers away. When this value is not specified, -1 is
6923 assumed. Passing a zero here disables the feature.
6924
Willy Tarreaud53f96b2009-02-04 18:46:54 +01006925 <name> is an optional interface name to which to bind to for outgoing
6926 traffic. On systems supporting this features (currently, only
6927 Linux), this allows one to bind all traffic to the server to
6928 this interface even if it is not the one the system would select
6929 based on routing tables. This should be used with extreme care.
6930 Note that using this option requires root privileges.
6931
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006932 The "source" keyword is useful in complex environments where a specific
6933 address only is allowed to connect to the servers. It may be needed when a
6934 private address must be used through a public gateway for instance, and it is
6935 known that the system cannot determine the adequate source address by itself.
6936
6937 An extension which is available on certain patched Linux kernels may be used
6938 through the "usesrc" optional keyword. It makes it possible to connect to the
6939 servers with an IP address which does not belong to the system itself. This
6940 is called "full transparent proxy mode". For this to work, the destination
6941 servers have to route their traffic back to this address through the machine
6942 running HAProxy, and IP forwarding must generally be enabled on this machine.
6943
6944 In this "full transparent proxy" mode, it is possible to force a specific IP
6945 address to be presented to the servers. This is not much used in fact. A more
6946 common use is to tell HAProxy to present the client's IP address. For this,
6947 there are two methods :
6948
6949 - present the client's IP and port addresses. This is the most transparent
6950 mode, but it can cause problems when IP connection tracking is enabled on
6951 the machine, because a same connection may be seen twice with different
6952 states. However, this solution presents the huge advantage of not
6953 limiting the system to the 64k outgoing address+port couples, because all
6954 of the client ranges may be used.
6955
6956 - present only the client's IP address and select a spare port. This
6957 solution is still quite elegant but slightly less transparent (downstream
6958 firewalls logs will not match upstream's). It also presents the downside
6959 of limiting the number of concurrent connections to the usual 64k ports.
6960 However, since the upstream and downstream ports are different, local IP
6961 connection tracking on the machine will not be upset by the reuse of the
6962 same session.
6963
6964 Note that depending on the transparent proxy technology used, it may be
6965 required to force the source address. In fact, cttproxy version 2 requires an
6966 IP address in <addr> above, and does not support setting of "0.0.0.0" as the
6967 IP address because it creates NAT entries which much match the exact outgoing
6968 address. Tproxy version 4 and some other kernel patches which work in pure
6969 forwarding mode generally will not have this limitation.
6970
6971 This option sets the default source for all servers in the backend. It may
6972 also be specified in a "defaults" section. Finer source address specification
6973 is possible at the server level using the "source" server option. Refer to
Willy Tarreauc57f0e22009-05-10 13:12:33 +02006974 section 5 for more information.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006975
Baptiste Assmann91bd3372015-07-17 21:59:42 +02006976 In order to work, "usesrc" requires root privileges.
6977
Willy Tarreaueabeafa2008-01-16 16:17:06 +01006978 Examples :
6979 backend private
6980 # Connect to the servers using our 192.168.1.200 source address
6981 source 192.168.1.200
6982
6983 backend transparent_ssl1
6984 # Connect to the SSL farm from the client's source address
6985 source 192.168.1.200 usesrc clientip
6986
6987 backend transparent_ssl2
6988 # Connect to the SSL farm from the client's source address and port
6989 # not recommended if IP conntrack is present on the local machine.
6990 source 192.168.1.200 usesrc client
6991
6992 backend transparent_ssl3
6993 # Connect to the SSL farm from the client's source address. It
6994 # is more conntrack-friendly.
6995 source 192.168.1.200 usesrc clientip
6996
6997 backend transparent_smtp
6998 # Connect to the SMTP farm from the client's source address/port
6999 # with Tproxy version 4.
7000 source 0.0.0.0 usesrc clientip
7001
Willy Tarreaubce70882009-09-07 11:51:47 +02007002 backend transparent_http
7003 # Connect to the servers using the client's IP as seen by previous
7004 # proxy.
7005 source 0.0.0.0 usesrc hdr_ip(x-forwarded-for,-1)
7006
Willy Tarreauc57f0e22009-05-10 13:12:33 +02007007 See also : the "source" server option in section 5, the Tproxy patches for
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007008 the Linux kernel on www.balabit.com, the "bind" keyword.
7009
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01007010
Willy Tarreau844e3c52008-01-11 16:28:18 +01007011srvtimeout <timeout> (deprecated)
7012 Set the maximum inactivity time on the server side.
7013 May be used in sections : defaults | frontend | listen | backend
7014 yes | no | yes | yes
7015 Arguments :
7016 <timeout> is the timeout value specified in milliseconds by default, but
7017 can be in any other unit if the number is suffixed by the unit,
7018 as explained at the top of this document.
7019
7020 The inactivity timeout applies when the server is expected to acknowledge or
7021 send data. In HTTP mode, this timeout is particularly important to consider
7022 during the first phase of the server's response, when it has to send the
7023 headers, as it directly represents the server's processing time for the
7024 request. To find out what value to put there, it's often good to start with
7025 what would be considered as unacceptable response times, then check the logs
7026 to observe the response time distribution, and adjust the value accordingly.
7027
7028 The value is specified in milliseconds by default, but can be in any other
7029 unit if the number is suffixed by the unit, as specified at the top of this
7030 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
7031 recommended that the client timeout remains equal to the server timeout in
7032 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01007033 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01007034 packet losses by specifying timeouts that are slightly above multiples of 3
Willy Tarreaud72758d2010-01-12 10:42:19 +01007035 seconds (eg: 4 or 5 seconds minimum).
Willy Tarreau844e3c52008-01-11 16:28:18 +01007036
7037 This parameter is specific to backends, but can be specified once for all in
7038 "defaults" sections. This is in fact one of the easiest solutions not to
7039 forget about it. An unspecified timeout results in an infinite timeout, which
7040 is not recommended. Such a usage is accepted and works but reports a warning
7041 during startup because it may results in accumulation of expired sessions in
7042 the system if the system's timeouts are not configured either.
7043
7044 This parameter is provided for compatibility but is currently deprecated.
7045 Please use "timeout server" instead.
7046
Willy Tarreauce887fd2012-05-12 12:50:00 +02007047 See also : "timeout server", "timeout tunnel", "timeout client" and
7048 "clitimeout".
Willy Tarreau844e3c52008-01-11 16:28:18 +01007049
7050
Cyril Bonté66c327d2010-10-12 00:14:37 +02007051stats admin { if | unless } <cond>
7052 Enable statistics admin level if/unless a condition is matched
7053 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007054 no | yes | yes | yes
Cyril Bonté66c327d2010-10-12 00:14:37 +02007055
7056 This statement enables the statistics admin level if/unless a condition is
7057 matched.
7058
7059 The admin level allows to enable/disable servers from the web interface. By
7060 default, statistics page is read-only for security reasons.
7061
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007062 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7063 unless you know what you do : memory is not shared between the
7064 processes, which can result in random behaviours.
7065
Cyril Bonté23b39d92011-02-10 22:54:44 +01007066 Currently, the POST request is limited to the buffer size minus the reserved
7067 buffer space, which means that if the list of servers is too long, the
7068 request won't be processed. It is recommended to alter few servers at a
7069 time.
Cyril Bonté66c327d2010-10-12 00:14:37 +02007070
7071 Example :
7072 # statistics admin level only for localhost
7073 backend stats_localhost
7074 stats enable
7075 stats admin if LOCALHOST
7076
7077 Example :
7078 # statistics admin level always enabled because of the authentication
7079 backend stats_auth
7080 stats enable
7081 stats auth admin:AdMiN123
7082 stats admin if TRUE
7083
7084 Example :
7085 # statistics admin level depends on the authenticated user
7086 userlist stats-auth
7087 group admin users admin
7088 user admin insecure-password AdMiN123
7089 group readonly users haproxy
7090 user haproxy insecure-password haproxy
7091
7092 backend stats_auth
7093 stats enable
7094 acl AUTH http_auth(stats-auth)
7095 acl AUTH_ADMIN http_auth_group(stats-auth) admin
7096 stats http-request auth unless AUTH
7097 stats admin if AUTH_ADMIN
7098
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007099 See also : "stats enable", "stats auth", "stats http-request", "nbproc",
7100 "bind-process", section 3.4 about userlists and section 7 about
7101 ACL usage.
Cyril Bonté66c327d2010-10-12 00:14:37 +02007102
7103
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007104stats auth <user>:<passwd>
7105 Enable statistics with authentication and grant access to an account
7106 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007107 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007108 Arguments :
7109 <user> is a user name to grant access to
7110
7111 <passwd> is the cleartext password associated to this user
7112
7113 This statement enables statistics with default settings, and restricts access
7114 to declared users only. It may be repeated as many times as necessary to
7115 allow as many users as desired. When a user tries to access the statistics
7116 without a valid account, a "401 Forbidden" response will be returned so that
7117 the browser asks the user to provide a valid user and password. The real
7118 which will be returned to the browser is configurable using "stats realm".
7119
7120 Since the authentication method is HTTP Basic Authentication, the passwords
7121 circulate in cleartext on the network. Thus, it was decided that the
7122 configuration file would also use cleartext passwords to remind the users
Willy Tarreau3c92c5f2011-08-28 09:45:47 +02007123 that those ones should not be sensitive and not shared with any other account.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007124
7125 It is also possible to reduce the scope of the proxies which appear in the
7126 report using "stats scope".
7127
7128 Though this statement alone is enough to enable statistics reporting, it is
7129 recommended to set all other settings in order to avoid relying on default
7130 unobvious parameters.
7131
7132 Example :
7133 # public access (limited to this backend only)
7134 backend public_www
7135 server srv1 192.168.0.1:80
7136 stats enable
7137 stats hide-version
7138 stats scope .
7139 stats uri /admin?stats
7140 stats realm Haproxy\ Statistics
7141 stats auth admin1:AdMiN123
7142 stats auth admin2:AdMiN321
7143
7144 # internal monitoring access (unlimited)
7145 backend private_monitoring
7146 stats enable
7147 stats uri /admin?stats
7148 stats refresh 5s
7149
7150 See also : "stats enable", "stats realm", "stats scope", "stats uri"
7151
7152
7153stats enable
7154 Enable statistics reporting with default settings
7155 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007156 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007157 Arguments : none
7158
7159 This statement enables statistics reporting with default settings defined
7160 at build time. Unless stated otherwise, these settings are used :
7161 - stats uri : /haproxy?stats
7162 - stats realm : "HAProxy Statistics"
7163 - stats auth : no authentication
7164 - stats scope : no restriction
7165
7166 Though this statement alone is enough to enable statistics reporting, it is
7167 recommended to set all other settings in order to avoid relying on default
7168 unobvious parameters.
7169
7170 Example :
7171 # public access (limited to this backend only)
7172 backend public_www
7173 server srv1 192.168.0.1:80
7174 stats enable
7175 stats hide-version
7176 stats scope .
7177 stats uri /admin?stats
7178 stats realm Haproxy\ Statistics
7179 stats auth admin1:AdMiN123
7180 stats auth admin2:AdMiN321
7181
7182 # internal monitoring access (unlimited)
7183 backend private_monitoring
7184 stats enable
7185 stats uri /admin?stats
7186 stats refresh 5s
7187
7188 See also : "stats auth", "stats realm", "stats uri"
7189
7190
Willy Tarreaud63335a2010-02-26 12:56:52 +01007191stats hide-version
7192 Enable statistics and hide HAProxy version reporting
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02007193 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007194 yes | yes | yes | yes
Willy Tarreaud63335a2010-02-26 12:56:52 +01007195 Arguments : none
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02007196
Willy Tarreaud63335a2010-02-26 12:56:52 +01007197 By default, the stats page reports some useful status information along with
7198 the statistics. Among them is HAProxy's version. However, it is generally
7199 considered dangerous to report precise version to anyone, as it can help them
7200 target known weaknesses with specific attacks. The "stats hide-version"
7201 statement removes the version from the statistics report. This is recommended
7202 for public sites or any site with a weak login/password.
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02007203
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +02007204 Though this statement alone is enough to enable statistics reporting, it is
7205 recommended to set all other settings in order to avoid relying on default
7206 unobvious parameters.
7207
Willy Tarreaud63335a2010-02-26 12:56:52 +01007208 Example :
7209 # public access (limited to this backend only)
7210 backend public_www
7211 server srv1 192.168.0.1:80
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +02007212 stats enable
Willy Tarreaud63335a2010-02-26 12:56:52 +01007213 stats hide-version
7214 stats scope .
7215 stats uri /admin?stats
7216 stats realm Haproxy\ Statistics
7217 stats auth admin1:AdMiN123
7218 stats auth admin2:AdMiN321
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02007219
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02007220 # internal monitoring access (unlimited)
7221 backend private_monitoring
7222 stats enable
Willy Tarreaud63335a2010-02-26 12:56:52 +01007223 stats uri /admin?stats
7224 stats refresh 5s
Krzysztof Piotr Oledzki15514c22010-01-04 16:03:09 +01007225
Willy Tarreaud63335a2010-02-26 12:56:52 +01007226 See also : "stats auth", "stats enable", "stats realm", "stats uri"
Willy Tarreau1d45b7c2009-08-16 10:29:18 +02007227
Willy Tarreau983e01e2010-01-11 18:42:06 +01007228
Cyril Bonté2be1b3f2010-09-30 23:46:30 +02007229stats http-request { allow | deny | auth [realm <realm>] }
7230 [ { if | unless } <condition> ]
7231 Access control for statistics
7232
7233 May be used in sections: defaults | frontend | listen | backend
7234 no | no | yes | yes
7235
7236 As "http-request", these set of options allow to fine control access to
7237 statistics. Each option may be followed by if/unless and acl.
7238 First option with matched condition (or option without condition) is final.
7239 For "deny" a 403 error will be returned, for "allow" normal processing is
7240 performed, for "auth" a 401/407 error code is returned so the client
7241 should be asked to enter a username and password.
7242
7243 There is no fixed limit to the number of http-request statements per
7244 instance.
7245
7246 See also : "http-request", section 3.4 about userlists and section 7
7247 about ACL usage.
7248
7249
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007250stats realm <realm>
7251 Enable statistics and set authentication realm
7252 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007253 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007254 Arguments :
7255 <realm> is the name of the HTTP Basic Authentication realm reported to
7256 the browser. The browser uses it to display it in the pop-up
7257 inviting the user to enter a valid username and password.
7258
7259 The realm is read as a single word, so any spaces in it should be escaped
7260 using a backslash ('\').
7261
7262 This statement is useful only in conjunction with "stats auth" since it is
7263 only related to authentication.
7264
7265 Though this statement alone is enough to enable statistics reporting, it is
7266 recommended to set all other settings in order to avoid relying on default
7267 unobvious parameters.
7268
7269 Example :
7270 # public access (limited to this backend only)
7271 backend public_www
7272 server srv1 192.168.0.1:80
7273 stats enable
7274 stats hide-version
7275 stats scope .
7276 stats uri /admin?stats
7277 stats realm Haproxy\ Statistics
7278 stats auth admin1:AdMiN123
7279 stats auth admin2:AdMiN321
7280
7281 # internal monitoring access (unlimited)
7282 backend private_monitoring
7283 stats enable
7284 stats uri /admin?stats
7285 stats refresh 5s
7286
7287 See also : "stats auth", "stats enable", "stats uri"
7288
7289
7290stats refresh <delay>
7291 Enable statistics with automatic refresh
7292 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007293 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007294 Arguments :
7295 <delay> is the suggested refresh delay, specified in seconds, which will
7296 be returned to the browser consulting the report page. While the
7297 browser is free to apply any delay, it will generally respect it
7298 and refresh the page this every seconds. The refresh interval may
7299 be specified in any other non-default time unit, by suffixing the
7300 unit after the value, as explained at the top of this document.
7301
7302 This statement is useful on monitoring displays with a permanent page
7303 reporting the load balancer's activity. When set, the HTML report page will
7304 include a link "refresh"/"stop refresh" so that the user can select whether
7305 he wants automatic refresh of the page or not.
7306
7307 Though this statement alone is enough to enable statistics reporting, it is
7308 recommended to set all other settings in order to avoid relying on default
7309 unobvious parameters.
7310
7311 Example :
7312 # public access (limited to this backend only)
7313 backend public_www
7314 server srv1 192.168.0.1:80
7315 stats enable
7316 stats hide-version
7317 stats scope .
7318 stats uri /admin?stats
7319 stats realm Haproxy\ Statistics
7320 stats auth admin1:AdMiN123
7321 stats auth admin2:AdMiN321
7322
7323 # internal monitoring access (unlimited)
7324 backend private_monitoring
7325 stats enable
7326 stats uri /admin?stats
7327 stats refresh 5s
7328
7329 See also : "stats auth", "stats enable", "stats realm", "stats uri"
7330
7331
7332stats scope { <name> | "." }
7333 Enable statistics and limit access scope
7334 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007335 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007336 Arguments :
7337 <name> is the name of a listen, frontend or backend section to be
7338 reported. The special name "." (a single dot) designates the
7339 section in which the statement appears.
7340
7341 When this statement is specified, only the sections enumerated with this
7342 statement will appear in the report. All other ones will be hidden. This
7343 statement may appear as many times as needed if multiple sections need to be
7344 reported. Please note that the name checking is performed as simple string
7345 comparisons, and that it is never checked that a give section name really
7346 exists.
7347
7348 Though this statement alone is enough to enable statistics reporting, it is
7349 recommended to set all other settings in order to avoid relying on default
7350 unobvious parameters.
7351
7352 Example :
7353 # public access (limited to this backend only)
7354 backend public_www
7355 server srv1 192.168.0.1:80
7356 stats enable
7357 stats hide-version
7358 stats scope .
7359 stats uri /admin?stats
7360 stats realm Haproxy\ Statistics
7361 stats auth admin1:AdMiN123
7362 stats auth admin2:AdMiN321
7363
7364 # internal monitoring access (unlimited)
7365 backend private_monitoring
7366 stats enable
7367 stats uri /admin?stats
7368 stats refresh 5s
7369
7370 See also : "stats auth", "stats enable", "stats realm", "stats uri"
7371
Willy Tarreaud63335a2010-02-26 12:56:52 +01007372
Willy Tarreauc9705a12010-07-27 20:05:50 +02007373stats show-desc [ <desc> ]
Willy Tarreaud63335a2010-02-26 12:56:52 +01007374 Enable reporting of a description on the statistics page.
7375 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007376 yes | yes | yes | yes
Willy Tarreaud63335a2010-02-26 12:56:52 +01007377
Willy Tarreauc9705a12010-07-27 20:05:50 +02007378 <desc> is an optional description to be reported. If unspecified, the
Willy Tarreaud63335a2010-02-26 12:56:52 +01007379 description from global section is automatically used instead.
7380
7381 This statement is useful for users that offer shared services to their
7382 customers, where node or description should be different for each customer.
7383
7384 Though this statement alone is enough to enable statistics reporting, it is
7385 recommended to set all other settings in order to avoid relying on default
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04007386 unobvious parameters. By default description is not shown.
Willy Tarreaud63335a2010-02-26 12:56:52 +01007387
7388 Example :
7389 # internal monitoring access (unlimited)
7390 backend private_monitoring
7391 stats enable
7392 stats show-desc Master node for Europe, Asia, Africa
7393 stats uri /admin?stats
7394 stats refresh 5s
7395
7396 See also: "show-node", "stats enable", "stats uri" and "description" in
7397 global section.
7398
7399
7400stats show-legends
Willy Tarreaued2119c2014-04-24 22:10:39 +02007401 Enable reporting additional information on the statistics page
7402 May be used in sections : defaults | frontend | listen | backend
7403 yes | yes | yes | yes
7404 Arguments : none
7405
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03007406 Enable reporting additional information on the statistics page :
Willy Tarreaud63335a2010-02-26 12:56:52 +01007407 - cap: capabilities (proxy)
7408 - mode: one of tcp, http or health (proxy)
7409 - id: SNMP ID (proxy, socket, server)
7410 - IP (socket, server)
7411 - cookie (backend, server)
7412
7413 Though this statement alone is enough to enable statistics reporting, it is
7414 recommended to set all other settings in order to avoid relying on default
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04007415 unobvious parameters. Default behaviour is not to show this information.
Willy Tarreaud63335a2010-02-26 12:56:52 +01007416
7417 See also: "stats enable", "stats uri".
7418
7419
7420stats show-node [ <name> ]
7421 Enable reporting of a host name on the statistics page.
7422 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007423 yes | yes | yes | yes
Willy Tarreaud63335a2010-02-26 12:56:52 +01007424 Arguments:
7425 <name> is an optional name to be reported. If unspecified, the
7426 node name from global section is automatically used instead.
7427
7428 This statement is useful for users that offer shared services to their
7429 customers, where node or description might be different on a stats page
Dmitry Sivachenko7823de32012-05-16 14:00:26 +04007430 provided for each customer. Default behaviour is not to show host name.
Willy Tarreaud63335a2010-02-26 12:56:52 +01007431
7432 Though this statement alone is enough to enable statistics reporting, it is
7433 recommended to set all other settings in order to avoid relying on default
7434 unobvious parameters.
7435
7436 Example:
7437 # internal monitoring access (unlimited)
7438 backend private_monitoring
7439 stats enable
7440 stats show-node Europe-1
7441 stats uri /admin?stats
7442 stats refresh 5s
7443
7444 See also: "show-desc", "stats enable", "stats uri", and "node" in global
7445 section.
7446
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007447
7448stats uri <prefix>
7449 Enable statistics and define the URI prefix to access them
7450 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaued2119c2014-04-24 22:10:39 +02007451 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007452 Arguments :
7453 <prefix> is the prefix of any URI which will be redirected to stats. This
7454 prefix may contain a question mark ('?') to indicate part of a
7455 query string.
7456
7457 The statistics URI is intercepted on the relayed traffic, so it appears as a
7458 page within the normal application. It is strongly advised to ensure that the
7459 selected URI will never appear in the application, otherwise it will never be
7460 possible to reach it in the application.
7461
7462 The default URI compiled in haproxy is "/haproxy?stats", but this may be
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01007463 changed at build time, so it's better to always explicitly specify it here.
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007464 It is generally a good idea to include a question mark in the URI so that
7465 intermediate proxies refrain from caching the results. Also, since any string
7466 beginning with the prefix will be accepted as a stats request, the question
7467 mark helps ensuring that no valid URI will begin with the same words.
7468
7469 It is sometimes very convenient to use "/" as the URI prefix, and put that
7470 statement in a "listen" instance of its own. That makes it easy to dedicate
7471 an address or a port to statistics only.
7472
7473 Though this statement alone is enough to enable statistics reporting, it is
7474 recommended to set all other settings in order to avoid relying on default
7475 unobvious parameters.
7476
7477 Example :
7478 # public access (limited to this backend only)
7479 backend public_www
7480 server srv1 192.168.0.1:80
7481 stats enable
7482 stats hide-version
7483 stats scope .
7484 stats uri /admin?stats
7485 stats realm Haproxy\ Statistics
7486 stats auth admin1:AdMiN123
7487 stats auth admin2:AdMiN321
7488
7489 # internal monitoring access (unlimited)
7490 backend private_monitoring
7491 stats enable
7492 stats uri /admin?stats
7493 stats refresh 5s
7494
7495 See also : "stats auth", "stats enable", "stats realm"
7496
7497
Willy Tarreaud63335a2010-02-26 12:56:52 +01007498stick match <pattern> [table <table>] [{if | unless} <cond>]
7499 Define a request pattern matching condition to stick a user to a server
Willy Tarreaueabeafa2008-01-16 16:17:06 +01007500 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaud63335a2010-02-26 12:56:52 +01007501 no | no | yes | yes
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007502
7503 Arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007504 <pattern> is a sample expression rule as described in section 7.3. It
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007505 describes what elements of the incoming request or connection
7506 will be analysed in the hope to find a matching entry in a
7507 stickiness table. This rule is mandatory.
7508
7509 <table> is an optional stickiness table name. If unspecified, the same
7510 backend's table is used. A stickiness table is declared using
7511 the "stick-table" statement.
7512
7513 <cond> is an optional matching condition. It makes it possible to match
7514 on a certain criterion only when other conditions are met (or
7515 not met). For instance, it could be used to match on a source IP
7516 address except when a request passes through a known proxy, in
7517 which case we'd match on a header containing that IP address.
7518
7519 Some protocols or applications require complex stickiness rules and cannot
7520 always simply rely on cookies nor hashing. The "stick match" statement
7521 describes a rule to extract the stickiness criterion from an incoming request
7522 or connection. See section 7 for a complete list of possible patterns and
7523 transformation rules.
7524
7525 The table has to be declared using the "stick-table" statement. It must be of
7526 a type compatible with the pattern. By default it is the one which is present
7527 in the same backend. It is possible to share a table with other backends by
7528 referencing it using the "table" keyword. If another table is referenced,
7529 the server's ID inside the backends are used. By default, all server IDs
7530 start at 1 in each backend, so the server ordering is enough. But in case of
7531 doubt, it is highly recommended to force server IDs using their "id" setting.
7532
7533 It is possible to restrict the conditions where a "stick match" statement
7534 will apply, using "if" or "unless" followed by a condition. See section 7 for
7535 ACL based conditions.
7536
7537 There is no limit on the number of "stick match" statements. The first that
7538 applies and matches will cause the request to be directed to the same server
7539 as was used for the request which created the entry. That way, multiple
7540 matches can be used as fallbacks.
7541
7542 The stick rules are checked after the persistence cookies, so they will not
7543 affect stickiness if a cookie has already been used to select a server. That
7544 way, it becomes very easy to insert cookies and match on IP addresses in
7545 order to maintain stickiness between HTTP and HTTPS.
7546
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007547 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7548 unless you know what you do : memory is not shared between the
7549 processes, which can result in random behaviours.
7550
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007551 Example :
7552 # forward SMTP users to the same server they just used for POP in the
7553 # last 30 minutes
7554 backend pop
7555 mode tcp
7556 balance roundrobin
7557 stick store-request src
7558 stick-table type ip size 200k expire 30m
7559 server s1 192.168.1.1:110
7560 server s2 192.168.1.1:110
7561
7562 backend smtp
7563 mode tcp
7564 balance roundrobin
7565 stick match src table pop
7566 server s1 192.168.1.1:25
7567 server s2 192.168.1.1:25
7568
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007569 See also : "stick-table", "stick on", "nbproc", "bind-process" and section 7
Willy Tarreaube722a22014-06-13 16:31:59 +02007570 about ACLs and samples fetching.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007571
7572
7573stick on <pattern> [table <table>] [{if | unless} <condition>]
7574 Define a request pattern to associate a user to a server
7575 May be used in sections : defaults | frontend | listen | backend
7576 no | no | yes | yes
7577
7578 Note : This form is exactly equivalent to "stick match" followed by
7579 "stick store-request", all with the same arguments. Please refer
7580 to both keywords for details. It is only provided as a convenience
7581 for writing more maintainable configurations.
7582
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007583 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7584 unless you know what you do : memory is not shared between the
7585 processes, which can result in random behaviours.
7586
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007587 Examples :
7588 # The following form ...
Willy Tarreauec579d82010-02-26 19:15:04 +01007589 stick on src table pop if !localhost
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007590
7591 # ...is strictly equivalent to this one :
7592 stick match src table pop if !localhost
7593 stick store-request src table pop if !localhost
7594
7595
7596 # Use cookie persistence for HTTP, and stick on source address for HTTPS as
7597 # well as HTTP without cookie. Share the same table between both accesses.
7598 backend http
7599 mode http
7600 balance roundrobin
7601 stick on src table https
7602 cookie SRV insert indirect nocache
7603 server s1 192.168.1.1:80 cookie s1
7604 server s2 192.168.1.1:80 cookie s2
7605
7606 backend https
7607 mode tcp
7608 balance roundrobin
7609 stick-table type ip size 200k expire 30m
7610 stick on src
7611 server s1 192.168.1.1:443
7612 server s2 192.168.1.1:443
7613
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007614 See also : "stick match", "stick store-request", "nbproc" and "bind-process".
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007615
7616
7617stick store-request <pattern> [table <table>] [{if | unless} <condition>]
7618 Define a request pattern used to create an entry in a stickiness table
7619 May be used in sections : defaults | frontend | listen | backend
7620 no | no | yes | yes
7621
7622 Arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007623 <pattern> is a sample expression rule as described in section 7.3. It
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007624 describes what elements of the incoming request or connection
7625 will be analysed, extracted and stored in the table once a
7626 server is selected.
7627
7628 <table> is an optional stickiness table name. If unspecified, the same
7629 backend's table is used. A stickiness table is declared using
7630 the "stick-table" statement.
7631
7632 <cond> is an optional storage condition. It makes it possible to store
7633 certain criteria only when some conditions are met (or not met).
7634 For instance, it could be used to store the source IP address
7635 except when the request passes through a known proxy, in which
7636 case we'd store a converted form of a header containing that IP
7637 address.
7638
7639 Some protocols or applications require complex stickiness rules and cannot
7640 always simply rely on cookies nor hashing. The "stick store-request" statement
7641 describes a rule to decide what to extract from the request and when to do
7642 it, in order to store it into a stickiness table for further requests to
7643 match it using the "stick match" statement. Obviously the extracted part must
7644 make sense and have a chance to be matched in a further request. Storing a
7645 client's IP address for instance often makes sense. Storing an ID found in a
7646 URL parameter also makes sense. Storing a source port will almost never make
7647 any sense because it will be randomly matched. See section 7 for a complete
7648 list of possible patterns and transformation rules.
7649
7650 The table has to be declared using the "stick-table" statement. It must be of
7651 a type compatible with the pattern. By default it is the one which is present
7652 in the same backend. It is possible to share a table with other backends by
7653 referencing it using the "table" keyword. If another table is referenced,
7654 the server's ID inside the backends are used. By default, all server IDs
7655 start at 1 in each backend, so the server ordering is enough. But in case of
7656 doubt, it is highly recommended to force server IDs using their "id" setting.
7657
7658 It is possible to restrict the conditions where a "stick store-request"
7659 statement will apply, using "if" or "unless" followed by a condition. This
7660 condition will be evaluated while parsing the request, so any criteria can be
7661 used. See section 7 for ACL based conditions.
7662
7663 There is no limit on the number of "stick store-request" statements, but
7664 there is a limit of 8 simultaneous stores per request or response. This
7665 makes it possible to store up to 8 criteria, all extracted from either the
7666 request or the response, regardless of the number of rules. Only the 8 first
7667 ones which match will be kept. Using this, it is possible to feed multiple
7668 tables at once in the hope to increase the chance to recognize a user on
Willy Tarreau9667a802013-12-09 12:52:13 +01007669 another protocol or access method. Using multiple store-request rules with
7670 the same table is possible and may be used to find the best criterion to rely
7671 on, by arranging the rules by decreasing preference order. Only the first
7672 extracted criterion for a given table will be stored. All subsequent store-
7673 request rules referencing the same table will be skipped and their ACLs will
7674 not be evaluated.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007675
7676 The "store-request" rules are evaluated once the server connection has been
7677 established, so that the table will contain the real server that processed
7678 the request.
7679
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007680 Note : Consider not using this feature in multi-process mode (nbproc > 1)
7681 unless you know what you do : memory is not shared between the
7682 processes, which can result in random behaviours.
7683
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007684 Example :
7685 # forward SMTP users to the same server they just used for POP in the
7686 # last 30 minutes
7687 backend pop
7688 mode tcp
7689 balance roundrobin
7690 stick store-request src
7691 stick-table type ip size 200k expire 30m
7692 server s1 192.168.1.1:110
7693 server s2 192.168.1.1:110
7694
7695 backend smtp
7696 mode tcp
7697 balance roundrobin
7698 stick match src table pop
7699 server s1 192.168.1.1:25
7700 server s2 192.168.1.1:25
7701
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007702 See also : "stick-table", "stick on", "nbproc", "bind-process" and section 7
Willy Tarreaube722a22014-06-13 16:31:59 +02007703 about ACLs and sample fetching.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007704
7705
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007706stick-table type {ip | integer | string [len <length>] | binary [len <length>]}
Emeric Brunf099e792010-09-27 12:05:28 +02007707 size <size> [expire <expire>] [nopurge] [peers <peersect>]
7708 [store <data_type>]*
Godbach64cef792013-12-04 16:08:22 +08007709 Configure the stickiness table for the current section
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007710 May be used in sections : defaults | frontend | listen | backend
Willy Tarreauc00cdc22010-06-06 16:48:26 +02007711 no | yes | yes | yes
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007712
7713 Arguments :
7714 ip a table declared with "type ip" will only store IPv4 addresses.
7715 This form is very compact (about 50 bytes per entry) and allows
7716 very fast entry lookup and stores with almost no overhead. This
7717 is mainly used to store client source IP addresses.
7718
David du Colombier9a6d3c92011-03-17 10:40:24 +01007719 ipv6 a table declared with "type ipv6" will only store IPv6 addresses.
7720 This form is very compact (about 60 bytes per entry) and allows
7721 very fast entry lookup and stores with almost no overhead. This
7722 is mainly used to store client source IP addresses.
7723
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007724 integer a table declared with "type integer" will store 32bit integers
7725 which can represent a client identifier found in a request for
7726 instance.
7727
7728 string a table declared with "type string" will store substrings of up
7729 to <len> characters. If the string provided by the pattern
7730 extractor is larger than <len>, it will be truncated before
7731 being stored. During matching, at most <len> characters will be
7732 compared between the string in the table and the extracted
7733 pattern. When not specified, the string is automatically limited
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007734 to 32 characters.
7735
7736 binary a table declared with "type binary" will store binary blocks
7737 of <len> bytes. If the block provided by the pattern
7738 extractor is larger than <len>, it will be truncated before
Willy Tarreaube722a22014-06-13 16:31:59 +02007739 being stored. If the block provided by the sample expression
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007740 is shorter than <len>, it will be padded by 0. When not
7741 specified, the block is automatically limited to 32 bytes.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007742
7743 <length> is the maximum number of characters that will be stored in a
Emeric Brun7c6b82e2010-09-24 16:34:28 +02007744 "string" type table (See type "string" above). Or the number
7745 of bytes of the block in "binary" type table. Be careful when
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007746 changing this parameter as memory usage will proportionally
7747 increase.
7748
7749 <size> is the maximum number of entries that can fit in the table. This
Cyril Bonté78caf842010-03-10 22:41:43 +01007750 value directly impacts memory usage. Count approximately
7751 50 bytes per entry, plus the size of a string if any. The size
7752 supports suffixes "k", "m", "g" for 2^10, 2^20 and 2^30 factors.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007753
7754 [nopurge] indicates that we refuse to purge older entries when the table
7755 is full. When not specified and the table is full when haproxy
7756 wants to store an entry in it, it will flush a few of the oldest
7757 entries in order to release some space for the new ones. This is
7758 most often the desired behaviour. In some specific cases, it
7759 be desirable to refuse new entries instead of purging the older
7760 ones. That may be the case when the amount of data to store is
7761 far above the hardware limits and we prefer not to offer access
7762 to new clients than to reject the ones already connected. When
7763 using this parameter, be sure to properly set the "expire"
7764 parameter (see below).
7765
Emeric Brunf099e792010-09-27 12:05:28 +02007766 <peersect> is the name of the peers section to use for replication. Entries
7767 which associate keys to server IDs are kept synchronized with
7768 the remote peers declared in this section. All entries are also
7769 automatically learned from the local peer (old process) during a
7770 soft restart.
7771
Willy Tarreau1abc6732015-05-01 19:21:02 +02007772 NOTE : each peers section may be referenced only by tables
7773 belonging to the same unique process.
Cyril Bonté02ff8ef2010-12-14 22:48:49 +01007774
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007775 <expire> defines the maximum duration of an entry in the table since it
7776 was last created, refreshed or matched. The expiration delay is
7777 defined using the standard time format, similarly as the various
7778 timeouts. The maximum duration is slightly above 24 days. See
7779 section 2.2 for more information. If this delay is not specified,
Cyril Bontédc4d9032012-04-08 21:57:39 +02007780 the session won't automatically expire, but older entries will
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007781 be removed once full. Be sure not to use the "nopurge" parameter
7782 if not expiration delay is specified.
7783
Willy Tarreau08d5f982010-06-06 13:34:54 +02007784 <data_type> is used to store additional information in the stick-table. This
7785 may be used by ACLs in order to control various criteria related
7786 to the activity of the client matching the stick-table. For each
7787 item specified here, the size of each entry will be inflated so
Willy Tarreauc9705a12010-07-27 20:05:50 +02007788 that the additional data can fit. Several data types may be
7789 stored with an entry. Multiple data types may be specified after
7790 the "store" keyword, as a comma-separated list. Alternatively,
7791 it is possible to repeat the "store" keyword followed by one or
7792 several data types. Except for the "server_id" type which is
7793 automatically detected and enabled, all data types must be
7794 explicitly declared to be stored. If an ACL references a data
7795 type which is not stored, the ACL will simply not match. Some
7796 data types require an argument which must be passed just after
7797 the type between parenthesis. See below for the supported data
7798 types and their arguments.
7799
7800 The data types that can be stored with an entry are the following :
7801 - server_id : this is an integer which holds the numeric ID of the server a
7802 request was assigned to. It is used by the "stick match", "stick store",
7803 and "stick on" rules. It is automatically enabled when referenced.
7804
7805 - gpc0 : first General Purpose Counter. It is a positive 32-bit integer
7806 integer which may be used for anything. Most of the time it will be used
7807 to put a special tag on some entries, for instance to note that a
7808 specific behaviour was detected and must be known for future matches.
7809
Willy Tarreauba2ffd12013-05-29 15:54:14 +02007810 - gpc0_rate(<period>) : increment rate of the first General Purpose Counter
7811 over a period. It is a positive 32-bit integer integer which may be used
7812 for anything. Just like <gpc0>, it counts events, but instead of keeping
7813 a cumulative count, it maintains the rate at which the counter is
7814 incremented. Most of the time it will be used to measure the frequency of
7815 occurrence of certain events (eg: requests to a specific URL).
7816
Willy Tarreauc9705a12010-07-27 20:05:50 +02007817 - conn_cnt : Connection Count. It is a positive 32-bit integer which counts
7818 the absolute number of connections received from clients which matched
7819 this entry. It does not mean the connections were accepted, just that
7820 they were received.
7821
7822 - conn_cur : Current Connections. It is a positive 32-bit integer which
7823 stores the concurrent connection counts for the entry. It is incremented
7824 once an incoming connection matches the entry, and decremented once the
7825 connection leaves. That way it is possible to know at any time the exact
7826 number of concurrent connections for an entry.
7827
7828 - conn_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7829 integer parameter <period> which indicates in milliseconds the length
7830 of the period over which the average is measured. It reports the average
7831 incoming connection rate over that period, in connections per period. The
7832 result is an integer which can be matched using ACLs.
7833
7834 - sess_cnt : Session Count. It is a positive 32-bit integer which counts
7835 the absolute number of sessions received from clients which matched this
7836 entry. A session is a connection that was accepted by the layer 4 rules.
7837
7838 - sess_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7839 integer parameter <period> which indicates in milliseconds the length
7840 of the period over which the average is measured. It reports the average
7841 incoming session rate over that period, in sessions per period. The
7842 result is an integer which can be matched using ACLs.
7843
7844 - http_req_cnt : HTTP request Count. It is a positive 32-bit integer which
7845 counts the absolute number of HTTP requests received from clients which
7846 matched this entry. It does not matter whether they are valid requests or
7847 not. Note that this is different from sessions when keep-alive is used on
7848 the client side.
7849
7850 - http_req_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7851 integer parameter <period> which indicates in milliseconds the length
7852 of the period over which the average is measured. It reports the average
7853 HTTP request rate over that period, in requests per period. The result is
7854 an integer which can be matched using ACLs. It does not matter whether
7855 they are valid requests or not. Note that this is different from sessions
7856 when keep-alive is used on the client side.
7857
7858 - http_err_cnt : HTTP Error Count. It is a positive 32-bit integer which
7859 counts the absolute number of HTTP requests errors induced by clients
7860 which matched this entry. Errors are counted on invalid and truncated
7861 requests, as well as on denied or tarpitted requests, and on failed
7862 authentications. If the server responds with 4xx, then the request is
7863 also counted as an error since it's an error triggered by the client
7864 (eg: vulnerability scan).
7865
7866 - http_err_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7867 integer parameter <period> which indicates in milliseconds the length
7868 of the period over which the average is measured. It reports the average
7869 HTTP request error rate over that period, in requests per period (see
7870 http_err_cnt above for what is accounted as an error). The result is an
7871 integer which can be matched using ACLs.
7872
7873 - bytes_in_cnt : client to server byte count. It is a positive 64-bit
7874 integer which counts the cumulated amount of bytes received from clients
7875 which matched this entry. Headers are included in the count. This may be
7876 used to limit abuse of upload features on photo or video servers.
7877
7878 - bytes_in_rate(<period>) : frequency counter (takes 12 bytes). It takes an
7879 integer parameter <period> which indicates in milliseconds the length
7880 of the period over which the average is measured. It reports the average
7881 incoming bytes rate over that period, in bytes per period. It may be used
7882 to detect users which upload too much and too fast. Warning: with large
7883 uploads, it is possible that the amount of uploaded data will be counted
7884 once upon termination, thus causing spikes in the average transfer speed
7885 instead of having a smooth one. This may partially be smoothed with
7886 "option contstats" though this is not perfect yet. Use of byte_in_cnt is
7887 recommended for better fairness.
7888
7889 - bytes_out_cnt : server to client byte count. It is a positive 64-bit
7890 integer which counts the cumulated amount of bytes sent to clients which
7891 matched this entry. Headers are included in the count. This may be used
7892 to limit abuse of bots sucking the whole site.
7893
7894 - bytes_out_rate(<period>) : frequency counter (takes 12 bytes). It takes
7895 an integer parameter <period> which indicates in milliseconds the length
7896 of the period over which the average is measured. It reports the average
7897 outgoing bytes rate over that period, in bytes per period. It may be used
7898 to detect users which download too much and too fast. Warning: with large
7899 transfers, it is possible that the amount of transferred data will be
7900 counted once upon termination, thus causing spikes in the average
7901 transfer speed instead of having a smooth one. This may partially be
7902 smoothed with "option contstats" though this is not perfect yet. Use of
7903 byte_out_cnt is recommended for better fairness.
Willy Tarreau08d5f982010-06-06 13:34:54 +02007904
Willy Tarreauc00cdc22010-06-06 16:48:26 +02007905 There is only one stick-table per proxy. At the moment of writing this doc,
7906 it does not seem useful to have multiple tables per proxy. If this happens
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007907 to be required, simply create a dummy backend with a stick-table in it and
7908 reference it.
7909
7910 It is important to understand that stickiness based on learning information
7911 has some limitations, including the fact that all learned associations are
7912 lost upon restart. In general it can be good as a complement but not always
7913 as an exclusive stickiness.
7914
Willy Tarreauc9705a12010-07-27 20:05:50 +02007915 Last, memory requirements may be important when storing many data types.
7916 Indeed, storing all indicators above at once in each entry requires 116 bytes
7917 per entry, or 116 MB for a 1-million entries table. This is definitely not
7918 something that can be ignored.
7919
7920 Example:
7921 # Keep track of counters of up to 1 million IP addresses over 5 minutes
7922 # and store a general purpose counter and the average connection rate
7923 # computed over a sliding window of 30 seconds.
7924 stick-table type ip size 1m expire 5m store gpc0,conn_rate(30s)
7925
7926 See also : "stick match", "stick on", "stick store-request", section 2.2
David du Colombiera13d1b92011-03-17 10:40:22 +01007927 about time format and section 7 about ACLs.
Willy Tarreaub937b7e2010-01-12 15:27:54 +01007928
7929
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007930stick store-response <pattern> [table <table>] [{if | unless} <condition>]
7931 Define a request pattern used to create an entry in a stickiness table
7932 May be used in sections : defaults | frontend | listen | backend
7933 no | no | yes | yes
7934
7935 Arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02007936 <pattern> is a sample expression rule as described in section 7.3. It
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007937 describes what elements of the response or connection will
7938 be analysed, extracted and stored in the table once a
7939 server is selected.
7940
7941 <table> is an optional stickiness table name. If unspecified, the same
7942 backend's table is used. A stickiness table is declared using
7943 the "stick-table" statement.
7944
7945 <cond> is an optional storage condition. It makes it possible to store
7946 certain criteria only when some conditions are met (or not met).
7947 For instance, it could be used to store the SSL session ID only
7948 when the response is a SSL server hello.
7949
7950 Some protocols or applications require complex stickiness rules and cannot
7951 always simply rely on cookies nor hashing. The "stick store-response"
7952 statement describes a rule to decide what to extract from the response and
7953 when to do it, in order to store it into a stickiness table for further
7954 requests to match it using the "stick match" statement. Obviously the
7955 extracted part must make sense and have a chance to be matched in a further
Cyril Bonté108cf6e2012-04-21 23:30:29 +02007956 request. Storing an ID found in a header of a response makes sense.
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007957 See section 7 for a complete list of possible patterns and transformation
7958 rules.
7959
7960 The table has to be declared using the "stick-table" statement. It must be of
7961 a type compatible with the pattern. By default it is the one which is present
7962 in the same backend. It is possible to share a table with other backends by
7963 referencing it using the "table" keyword. If another table is referenced,
7964 the server's ID inside the backends are used. By default, all server IDs
7965 start at 1 in each backend, so the server ordering is enough. But in case of
7966 doubt, it is highly recommended to force server IDs using their "id" setting.
7967
7968 It is possible to restrict the conditions where a "stick store-response"
7969 statement will apply, using "if" or "unless" followed by a condition. This
7970 condition will be evaluated while parsing the response, so any criteria can
7971 be used. See section 7 for ACL based conditions.
7972
7973 There is no limit on the number of "stick store-response" statements, but
7974 there is a limit of 8 simultaneous stores per request or response. This
7975 makes it possible to store up to 8 criteria, all extracted from either the
7976 request or the response, regardless of the number of rules. Only the 8 first
7977 ones which match will be kept. Using this, it is possible to feed multiple
7978 tables at once in the hope to increase the chance to recognize a user on
Willy Tarreau9667a802013-12-09 12:52:13 +01007979 another protocol or access method. Using multiple store-response rules with
7980 the same table is possible and may be used to find the best criterion to rely
7981 on, by arranging the rules by decreasing preference order. Only the first
7982 extracted criterion for a given table will be stored. All subsequent store-
7983 response rules referencing the same table will be skipped and their ACLs will
7984 not be evaluated. However, even if a store-request rule references a table, a
7985 store-response rule may also use the same table. This means that each table
7986 may learn exactly one element from the request and one element from the
7987 response at once.
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007988
7989 The table will contain the real server that processed the request.
7990
7991 Example :
7992 # Learn SSL session ID from both request and response and create affinity.
7993 backend https
7994 mode tcp
7995 balance roundrobin
Cyril Bontédc4d9032012-04-08 21:57:39 +02007996 # maximum SSL session ID length is 32 bytes.
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007997 stick-table type binary len 32 size 30k expire 30m
Cyril Bonté108cf6e2012-04-21 23:30:29 +02007998
Emeric Brun6a1cefa2010-09-24 18:15:17 +02007999 acl clienthello req_ssl_hello_type 1
8000 acl serverhello rep_ssl_hello_type 2
8001
8002 # use tcp content accepts to detects ssl client and server hello.
8003 tcp-request inspect-delay 5s
8004 tcp-request content accept if clienthello
8005
8006 # no timeout on response inspect delay by default.
8007 tcp-response content accept if serverhello
Cyril Bonté108cf6e2012-04-21 23:30:29 +02008008
Emeric Brun6a1cefa2010-09-24 18:15:17 +02008009 # SSL session ID (SSLID) may be present on a client or server hello.
8010 # Its length is coded on 1 byte at offset 43 and its value starts
8011 # at offset 44.
8012
8013 # Match and learn on request if client hello.
8014 stick on payload_lv(43,1) if clienthello
8015
8016 # Learn on response if server hello.
8017 stick store-response payload_lv(43,1) if serverhello
Cyril Bontédc4d9032012-04-08 21:57:39 +02008018
Emeric Brun6a1cefa2010-09-24 18:15:17 +02008019 server s1 192.168.1.1:443
8020 server s2 192.168.1.1:443
8021
8022 See also : "stick-table", "stick on", and section 7 about ACLs and pattern
8023 extraction.
8024
8025
Willy Tarreau938c7fe2014-04-25 14:21:39 +02008026tcp-check connect [params*]
8027 Opens a new connection
8028 May be used in sections: defaults | frontend | listen | backend
8029 no | no | yes | yes
8030
8031 When an application lies on more than a single TCP port or when HAProxy
8032 load-balance many services in a single backend, it makes sense to probe all
8033 the services individually before considering a server as operational.
8034
8035 When there are no TCP port configured on the server line neither server port
8036 directive, then the 'tcp-check connect port <port>' must be the first step
8037 of the sequence.
8038
8039 In a tcp-check ruleset a 'connect' is required, it is also mandatory to start
8040 the ruleset with a 'connect' rule. Purpose is to ensure admin know what they
8041 do.
8042
8043 Parameters :
8044 They are optional and can be used to describe how HAProxy should open and
8045 use the TCP connection.
8046
8047 port if not set, check port or server port is used.
8048 It tells HAProxy where to open the connection to.
8049 <port> must be a valid TCP port source integer, from 1 to 65535.
8050
8051 send-proxy send a PROXY protocol string
8052
8053 ssl opens a ciphered connection
8054
8055 Examples:
8056 # check HTTP and HTTPs services on a server.
8057 # first open port 80 thanks to server line port directive, then
8058 # tcp-check opens port 443, ciphered and run a request on it:
8059 option tcp-check
8060 tcp-check connect
8061 tcp-check send GET\ /\ HTTP/1.0\r\n
8062 tcp-check send Host:\ haproxy.1wt.eu\r\n
8063 tcp-check send \r\n
8064 tcp-check expect rstring (2..|3..)
8065 tcp-check connect port 443 ssl
8066 tcp-check send GET\ /\ HTTP/1.0\r\n
8067 tcp-check send Host:\ haproxy.1wt.eu\r\n
8068 tcp-check send \r\n
8069 tcp-check expect rstring (2..|3..)
8070 server www 10.0.0.1 check port 80
8071
8072 # check both POP and IMAP from a single server:
8073 option tcp-check
8074 tcp-check connect port 110
8075 tcp-check expect string +OK\ POP3\ ready
8076 tcp-check connect port 143
8077 tcp-check expect string *\ OK\ IMAP4\ ready
8078 server mail 10.0.0.1 check
8079
8080 See also : "option tcp-check", "tcp-check send", "tcp-check expect"
8081
8082
8083tcp-check expect [!] <match> <pattern>
8084 Specify data to be collected and analysed during a generic health check
8085 May be used in sections: defaults | frontend | listen | backend
8086 no | no | yes | yes
8087
8088 Arguments :
8089 <match> is a keyword indicating how to look for a specific pattern in the
8090 response. The keyword may be one of "string", "rstring" or
8091 binary.
8092 The keyword may be preceded by an exclamation mark ("!") to negate
8093 the match. Spaces are allowed between the exclamation mark and the
8094 keyword. See below for more details on the supported keywords.
8095
8096 <pattern> is the pattern to look for. It may be a string or a regular
8097 expression. If the pattern contains spaces, they must be escaped
8098 with the usual backslash ('\').
8099 If the match is set to binary, then the pattern must be passed as
8100 a serie of hexadecimal digits in an even number. Each sequence of
8101 two digits will represent a byte. The hexadecimal digits may be
8102 used upper or lower case.
8103
8104
8105 The available matches are intentionally similar to their http-check cousins :
8106
8107 string <string> : test the exact string matches in the response buffer.
8108 A health check response will be considered valid if the
8109 response's buffer contains this exact string. If the
8110 "string" keyword is prefixed with "!", then the response
8111 will be considered invalid if the body contains this
8112 string. This can be used to look for a mandatory pattern
8113 in a protocol response, or to detect a failure when a
8114 specific error appears in a protocol banner.
8115
8116 rstring <regex> : test a regular expression on the response buffer.
8117 A health check response will be considered valid if the
8118 response's buffer matches this expression. If the
8119 "rstring" keyword is prefixed with "!", then the response
8120 will be considered invalid if the body matches the
8121 expression.
8122
8123 binary <hexstring> : test the exact string in its hexadecimal form matches
8124 in the response buffer. A health check response will
8125 be considered valid if the response's buffer contains
8126 this exact hexadecimal string.
8127 Purpose is to match data on binary protocols.
8128
8129 It is important to note that the responses will be limited to a certain size
8130 defined by the global "tune.chksize" option, which defaults to 16384 bytes.
8131 Thus, too large responses may not contain the mandatory pattern when using
8132 "string", "rstring" or binary. If a large response is absolutely required, it
8133 is possible to change the default max size by setting the global variable.
8134 However, it is worth keeping in mind that parsing very large responses can
8135 waste some CPU cycles, especially when regular expressions are used, and that
8136 it is always better to focus the checks on smaller resources. Also, in its
8137 current state, the check will not find any string nor regex past a null
8138 character in the response. Similarly it is not possible to request matching
8139 the null character.
8140
8141 Examples :
8142 # perform a POP check
8143 option tcp-check
8144 tcp-check expect string +OK\ POP3\ ready
8145
8146 # perform an IMAP check
8147 option tcp-check
8148 tcp-check expect string *\ OK\ IMAP4\ ready
8149
8150 # look for the redis master server
8151 option tcp-check
8152 tcp-check send PING\r\n
Baptiste Assmanna3322992015-08-04 10:12:18 +02008153 tcp-check expect string +PONG
Willy Tarreau938c7fe2014-04-25 14:21:39 +02008154 tcp-check send info\ replication\r\n
8155 tcp-check expect string role:master
8156 tcp-check send QUIT\r\n
8157 tcp-check expect string +OK
8158
8159
8160 See also : "option tcp-check", "tcp-check connect", "tcp-check send",
8161 "tcp-check send-binary", "http-check expect", tune.chksize
8162
8163
8164tcp-check send <data>
8165 Specify a string to be sent as a question during a generic health check
8166 May be used in sections: defaults | frontend | listen | backend
8167 no | no | yes | yes
8168
8169 <data> : the data to be sent as a question during a generic health check
8170 session. For now, <data> must be a string.
8171
8172 Examples :
8173 # look for the redis master server
8174 option tcp-check
8175 tcp-check send info\ replication\r\n
8176 tcp-check expect string role:master
8177
8178 See also : "option tcp-check", "tcp-check connect", "tcp-check expect",
8179 "tcp-check send-binary", tune.chksize
8180
8181
8182tcp-check send-binary <hexastring>
8183 Specify an hexa digits string to be sent as a binary question during a raw
8184 tcp health check
8185 May be used in sections: defaults | frontend | listen | backend
8186 no | no | yes | yes
8187
8188 <data> : the data to be sent as a question during a generic health check
8189 session. For now, <data> must be a string.
8190 <hexastring> : test the exact string in its hexadecimal form matches in the
8191 response buffer. A health check response will be considered
8192 valid if the response's buffer contains this exact
8193 hexadecimal string.
8194 Purpose is to send binary data to ask on binary protocols.
8195
8196 Examples :
8197 # redis check in binary
8198 option tcp-check
8199 tcp-check send-binary 50494e470d0a # PING\r\n
8200 tcp-check expect binary 2b504F4e47 # +PONG
8201
8202
8203 See also : "option tcp-check", "tcp-check connect", "tcp-check expect",
8204 "tcp-check send", tune.chksize
8205
8206
Willy Tarreaue9656522010-08-17 15:40:09 +02008207tcp-request connection <action> [{if | unless} <condition>]
8208 Perform an action on an incoming connection depending on a layer 4 condition
Willy Tarreau1a687942010-05-23 22:40:30 +02008209 May be used in sections : defaults | frontend | listen | backend
8210 no | yes | yes | no
Willy Tarreaue9656522010-08-17 15:40:09 +02008211 Arguments :
8212 <action> defines the action to perform if the condition applies. Valid
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008213 actions include : "accept", "reject", "track-sc0", "track-sc1",
8214 "track-sc2", and "expect-proxy". See below for more details.
Willy Tarreau1a687942010-05-23 22:40:30 +02008215
Willy Tarreaue9656522010-08-17 15:40:09 +02008216 <condition> is a standard layer4-only ACL-based condition (see section 7).
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008217
8218 Immediately after acceptance of a new incoming connection, it is possible to
8219 evaluate some conditions to decide whether this connection must be accepted
Willy Tarreaue9656522010-08-17 15:40:09 +02008220 or dropped or have its counters tracked. Those conditions cannot make use of
8221 any data contents because the connection has not been read from yet, and the
8222 buffers are not yet allocated. This is used to selectively and very quickly
8223 accept or drop connections from various sources with a very low overhead. If
8224 some contents need to be inspected in order to take the decision, the
8225 "tcp-request content" statements must be used instead.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008226
Willy Tarreaue9656522010-08-17 15:40:09 +02008227 The "tcp-request connection" rules are evaluated in their exact declaration
8228 order. If no rule matches or if there is no rule, the default action is to
8229 accept the incoming connection. There is no specific limit to the number of
8230 rules which may be inserted.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008231
Willy Tarreaua9083d02015-05-08 15:27:59 +02008232 Four types of actions are supported :
Willy Tarreaue9656522010-08-17 15:40:09 +02008233 - accept :
8234 accepts the connection if the condition is true (when used with "if")
8235 or false (when used with "unless"). The first such rule executed ends
8236 the rules evaluation.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008237
Willy Tarreaue9656522010-08-17 15:40:09 +02008238 - reject :
8239 rejects the connection if the condition is true (when used with "if")
8240 or false (when used with "unless"). The first such rule executed ends
8241 the rules evaluation. Rejected connections do not even become a
8242 session, which is why they are accounted separately for in the stats,
8243 as "denied connections". They are not considered for the session
8244 rate-limit and are not logged either. The reason is that these rules
8245 should only be used to filter extremely high connection rates such as
8246 the ones encountered during a massive DDoS attack. Under these extreme
8247 conditions, the simple action of logging each event would make the
8248 system collapse and would considerably lower the filtering capacity. If
8249 logging is absolutely desired, then "tcp-request content" rules should
8250 be used instead.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008251
Willy Tarreau4f0d9192013-06-11 20:40:55 +02008252 - expect-proxy layer4 :
8253 configures the client-facing connection to receive a PROXY protocol
8254 header before any byte is read from the socket. This is equivalent to
8255 having the "accept-proxy" keyword on the "bind" line, except that using
8256 the TCP rule allows the PROXY protocol to be accepted only for certain
8257 IP address ranges using an ACL. This is convenient when multiple layers
8258 of load balancers are passed through by traffic coming from public
8259 hosts.
8260
Willy Tarreau18bf01e2014-06-13 16:18:52 +02008261 - capture <sample> len <length> :
8262 This only applies to "tcp-request content" rules. It captures sample
8263 expression <sample> from the request buffer, and converts it to a
8264 string of at most <len> characters. The resulting string is stored into
8265 the next request "capture" slot, so it will possibly appear next to
8266 some captured HTTP headers. It will then automatically appear in the
8267 logs, and it will be possible to extract it using sample fetch rules to
8268 feed it into headers or anything. The length should be limited given
8269 that this size will be allocated for each capture during the whole
Willy Tarreaua9083d02015-05-08 15:27:59 +02008270 session life. Please check section 7.3 (Fetching samples) and "capture
8271 request header" for more information.
Willy Tarreau18bf01e2014-06-13 16:18:52 +02008272
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008273 - { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>] :
Willy Tarreaue9656522010-08-17 15:40:09 +02008274 enables tracking of sticky counters from current connection. These
Willy Tarreau09448f72014-06-25 18:12:15 +02008275 rules do not stop evaluation and do not change default action. 3 sets
Willy Tarreaue9656522010-08-17 15:40:09 +02008276 of counters may be simultaneously tracked by the same connection. The
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008277 first "track-sc0" rule executed enables tracking of the counters of the
8278 specified table as the first set. The first "track-sc1" rule executed
Willy Tarreaue9656522010-08-17 15:40:09 +02008279 enables tracking of the counters of the specified table as the second
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008280 set. The first "track-sc2" rule executed enables tracking of the
8281 counters of the specified table as the third set. It is a recommended
8282 practice to use the first set of counters for the per-frontend counters
8283 and the second set for the per-backend ones. But this is just a
8284 guideline, all may be used everywhere.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008285
Willy Tarreaue9656522010-08-17 15:40:09 +02008286 These actions take one or two arguments :
Willy Tarreaube722a22014-06-13 16:31:59 +02008287 <key> is mandatory, and is a sample expression rule as described
Willy Tarreau74ca5042013-06-11 23:12:07 +02008288 in section 7.3. It describes what elements of the incoming
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008289 request or connection will be analysed, extracted, combined,
8290 and used to select which table entry to update the counters.
8291 Note that "tcp-request connection" cannot use content-based
8292 fetches.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008293
Willy Tarreaue9656522010-08-17 15:40:09 +02008294 <table> is an optional table to be used instead of the default one,
8295 which is the stick-table declared in the current proxy. All
8296 the counters for the matches and updates for the key will
8297 then be performed in that table until the session ends.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008298
Willy Tarreaue9656522010-08-17 15:40:09 +02008299 Once a "track-sc*" rule is executed, the key is looked up in the table
8300 and if it is not found, an entry is allocated for it. Then a pointer to
8301 that entry is kept during all the session's life, and this entry's
8302 counters are updated as often as possible, every time the session's
8303 counters are updated, and also systematically when the session ends.
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008304 Counters are only updated for events that happen after the tracking has
8305 been started. For example, connection counters will not be updated when
8306 tracking layer 7 information, since the connection event happens before
8307 layer7 information is extracted.
8308
Willy Tarreaue9656522010-08-17 15:40:09 +02008309 If the entry tracks concurrent connection counters, one connection is
8310 counted for as long as the entry is tracked, and the entry will not
8311 expire during that time. Tracking counters also provides a performance
8312 advantage over just checking the keys, because only one table lookup is
8313 performed for all ACL checks that make use of it.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008314
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008315 - sc-set-gpt0(<sc-id>) <int>:
8316 This action sets the GPT0 tag according to the sticky counter designated
8317 by <sc-id> and the value of <int>. The expected result is a boolean. If
8318 an error occurs, this action silently fails and the actions evaluation
8319 continues.
8320
Willy Tarreaue9656522010-08-17 15:40:09 +02008321 Note that the "if/unless" condition is optional. If no condition is set on
8322 the action, it is simply performed unconditionally. That can be useful for
8323 "track-sc*" actions as well as for changing the default action to a reject.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008324
Willy Tarreaue9656522010-08-17 15:40:09 +02008325 Example: accept all connections from white-listed hosts, reject too fast
8326 connection without counting them, and track accepted connections.
8327 This results in connection rate being capped from abusive sources.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008328
Willy Tarreaue9656522010-08-17 15:40:09 +02008329 tcp-request connection accept if { src -f /etc/haproxy/whitelist.lst }
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008330 tcp-request connection reject if { src_conn_rate gt 10 }
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008331 tcp-request connection track-sc0 src
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008332
Willy Tarreaue9656522010-08-17 15:40:09 +02008333 Example: accept all connections from white-listed hosts, count all other
8334 connections and reject too fast ones. This results in abusive ones
8335 being blocked as long as they don't slow down.
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008336
Willy Tarreaue9656522010-08-17 15:40:09 +02008337 tcp-request connection accept if { src -f /etc/haproxy/whitelist.lst }
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008338 tcp-request connection track-sc0 src
8339 tcp-request connection reject if { sc0_conn_rate gt 10 }
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008340
Willy Tarreau4f0d9192013-06-11 20:40:55 +02008341 Example: enable the PROXY protocol for traffic coming from all known proxies.
8342
8343 tcp-request connection expect-proxy layer4 if { src -f proxies.lst }
8344
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008345 See section 7 about ACL usage.
8346
Willy Tarreaue9656522010-08-17 15:40:09 +02008347 See also : "tcp-request content", "stick-table"
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008348
8349
Willy Tarreaue9656522010-08-17 15:40:09 +02008350tcp-request content <action> [{if | unless} <condition>]
8351 Perform an action on a new session depending on a layer 4-7 condition
Willy Tarreau62644772008-07-16 18:36:06 +02008352 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaufb356202010-08-03 14:02:05 +02008353 no | yes | yes | yes
Willy Tarreaue9656522010-08-17 15:40:09 +02008354 Arguments :
8355 <action> defines the action to perform if the condition applies. Valid
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008356 actions include : "accept", "reject", "track-sc0", "track-sc1",
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008357 "track-sc2", "sc-set-gpt0", "capture" and "lua". See
8358 "tcp-request connection" above for their signification.
Willy Tarreau62644772008-07-16 18:36:06 +02008359
Willy Tarreaue9656522010-08-17 15:40:09 +02008360 <condition> is a standard layer 4-7 ACL-based condition (see section 7).
Willy Tarreau62644772008-07-16 18:36:06 +02008361
Willy Tarreaue9656522010-08-17 15:40:09 +02008362 A request's contents can be analysed at an early stage of request processing
8363 called "TCP content inspection". During this stage, ACL-based rules are
8364 evaluated every time the request contents are updated, until either an
8365 "accept" or a "reject" rule matches, or the TCP request inspection delay
8366 expires with no matching rule.
Willy Tarreau62644772008-07-16 18:36:06 +02008367
Willy Tarreaue9656522010-08-17 15:40:09 +02008368 The first difference between these rules and "tcp-request connection" rules
8369 is that "tcp-request content" rules can make use of contents to take a
8370 decision. Most often, these decisions will consider a protocol recognition or
8371 validity. The second difference is that content-based rules can be used in
Willy Tarreauf3338342014-01-28 21:40:28 +01008372 both frontends and backends. In case of HTTP keep-alive with the client, all
8373 tcp-request content rules are evaluated again, so haproxy keeps a record of
8374 what sticky counters were assigned by a "tcp-request connection" versus a
8375 "tcp-request content" rule, and flushes all the content-related ones after
8376 processing an HTTP request, so that they may be evaluated again by the rules
8377 being evaluated again for the next request. This is of particular importance
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008378 when the rule tracks some L7 information or when it is conditioned by an
Willy Tarreauf3338342014-01-28 21:40:28 +01008379 L7-based ACL, since tracking may change between requests.
Willy Tarreau62644772008-07-16 18:36:06 +02008380
Willy Tarreaue9656522010-08-17 15:40:09 +02008381 Content-based rules are evaluated in their exact declaration order. If no
8382 rule matches or if there is no rule, the default action is to accept the
8383 contents. There is no specific limit to the number of rules which may be
8384 inserted.
Willy Tarreau62644772008-07-16 18:36:06 +02008385
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008386 Several types of actions are supported :
Willy Tarreau18bf01e2014-06-13 16:18:52 +02008387 - accept : the request is accepted
8388 - reject : the request is rejected and the connection is closed
8389 - capture : the specified sample expression is captured
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008390 - { track-sc0 | track-sc1 | track-sc2 } <key> [table <table>]
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008391 - set-gpt0(<sc-id>) <int>
Thierry FOURNIER69717b42015-06-04 12:23:41 +02008392 - lua <function>
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02008393 - set-var(<var-name>) <expr>
Willy Tarreau62644772008-07-16 18:36:06 +02008394
Willy Tarreaue9656522010-08-17 15:40:09 +02008395 They have the same meaning as their counter-parts in "tcp-request connection"
8396 so please refer to that section for a complete description.
Willy Tarreau62644772008-07-16 18:36:06 +02008397
Willy Tarreauf3338342014-01-28 21:40:28 +01008398 While there is nothing mandatory about it, it is recommended to use the
8399 track-sc0 in "tcp-request connection" rules, track-sc1 for "tcp-request
8400 content" rules in the frontend, and track-sc2 for "tcp-request content"
8401 rules in the backend, because that makes the configuration more readable
8402 and easier to troubleshoot, but this is just a guideline and all counters
8403 may be used everywhere.
Willy Tarreau62644772008-07-16 18:36:06 +02008404
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01008405 Note that the "if/unless" condition is optional. If no condition is set on
Willy Tarreaue9656522010-08-17 15:40:09 +02008406 the action, it is simply performed unconditionally. That can be useful for
8407 "track-sc*" actions as well as for changing the default action to a reject.
Willy Tarreau62644772008-07-16 18:36:06 +02008408
Willy Tarreaue9656522010-08-17 15:40:09 +02008409 It is perfectly possible to match layer 7 contents with "tcp-request content"
Willy Tarreauc0239e02012-04-16 14:42:55 +02008410 rules, since HTTP-specific ACL matches are able to preliminarily parse the
8411 contents of a buffer before extracting the required data. If the buffered
8412 contents do not parse as a valid HTTP message, then the ACL does not match.
8413 The parser which is involved there is exactly the same as for all other HTTP
Willy Tarreauf3338342014-01-28 21:40:28 +01008414 processing, so there is no risk of parsing something differently. In an HTTP
8415 backend connected to from an HTTP frontend, it is guaranteed that HTTP
8416 contents will always be immediately present when the rule is evaluated first.
Willy Tarreau62644772008-07-16 18:36:06 +02008417
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008418 Tracking layer7 information is also possible provided that the information
Willy Tarreau4d54c7c2014-09-16 15:48:15 +02008419 are present when the rule is processed. The rule processing engine is able to
8420 wait until the inspect delay expires when the data to be tracked is not yet
8421 available.
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008422
Thierry FOURNIER90da1912015-03-05 11:17:06 +01008423 The "lua" keyword is followed by a Lua function name. It is used to run a Lua
8424 function if the action is executed. The single parameter is the name of the
8425 function to run. The prototype of the function is documented in the API
8426 documentation.
8427
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02008428 The "set-var" is used to set the content of a variable. The variable is
8429 declared inline.
8430
8431 <var-name> The name of the variable starts by an indication about its scope.
8432 The allowed scopes are:
8433 "sess" : the variable is shared with all the session,
8434 "txn" : the variable is shared with all the transaction
8435 (request and response)
8436 "req" : the variable is shared only during the request
8437 processing
8438 "res" : the variable is shared only during the response
8439 processing.
8440 This prefix is followed by a name. The separator is a '.'.
8441 The name may only contain characters 'a-z', 'A-Z', '0-9' and '_'.
8442
8443 <expr> Is a standard HAProxy expression formed by a sample-fetch
8444 followed by some converters.
8445
8446 Example:
8447
8448 tcp-request content set-var(sess.my_var) src
8449
Willy Tarreau62644772008-07-16 18:36:06 +02008450 Example:
Willy Tarreaue9656522010-08-17 15:40:09 +02008451 # Accept HTTP requests containing a Host header saying "example.com"
8452 # and reject everything else.
8453 acl is_host_com hdr(Host) -i example.com
8454 tcp-request inspect-delay 30s
Willy Tarreauc0239e02012-04-16 14:42:55 +02008455 tcp-request content accept if is_host_com
Willy Tarreaue9656522010-08-17 15:40:09 +02008456 tcp-request content reject
8457
8458 Example:
Willy Tarreau62644772008-07-16 18:36:06 +02008459 # reject SMTP connection if client speaks first
8460 tcp-request inspect-delay 30s
8461 acl content_present req_len gt 0
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008462 tcp-request content reject if content_present
Willy Tarreau62644772008-07-16 18:36:06 +02008463
8464 # Forward HTTPS connection only if client speaks
8465 tcp-request inspect-delay 30s
8466 acl content_present req_len gt 0
Willy Tarreau68c03ab2010-08-06 15:08:45 +02008467 tcp-request content accept if content_present
Willy Tarreaue9656522010-08-17 15:40:09 +02008468 tcp-request content reject
8469
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008470 Example:
8471 # Track the last IP from X-Forwarded-For
8472 tcp-request inspect-delay 10s
Willy Tarreau4d54c7c2014-09-16 15:48:15 +02008473 tcp-request content track-sc0 hdr(x-forwarded-for,-1)
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008474
8475 Example:
8476 # track request counts per "base" (concatenation of Host+URL)
8477 tcp-request inspect-delay 10s
Willy Tarreau4d54c7c2014-09-16 15:48:15 +02008478 tcp-request content track-sc0 base table req-rate
Willy Tarreau5d5b5d82012-12-09 12:00:04 +01008479
Willy Tarreaue9656522010-08-17 15:40:09 +02008480 Example: track per-frontend and per-backend counters, block abusers at the
8481 frontend when the backend detects abuse.
8482
8483 frontend http
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008484 # Use General Purpose Couter 0 in SC0 as a global abuse counter
Willy Tarreaue9656522010-08-17 15:40:09 +02008485 # protecting all our sites
8486 stick-table type ip size 1m expire 5m store gpc0
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008487 tcp-request connection track-sc0 src
8488 tcp-request connection reject if { sc0_get_gpc0 gt 0 }
Willy Tarreaue9656522010-08-17 15:40:09 +02008489 ...
8490 use_backend http_dynamic if { path_end .php }
8491
8492 backend http_dynamic
8493 # if a source makes too fast requests to this dynamic site (tracked
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008494 # by SC1), block it globally in the frontend.
Willy Tarreaue9656522010-08-17 15:40:09 +02008495 stick-table type ip size 1m expire 5m store http_req_rate(10s)
Willy Tarreaube4a3ef2013-06-17 15:04:07 +02008496 acl click_too_fast sc1_http_req_rate gt 10
8497 acl mark_as_abuser sc0_inc_gpc0 gt 0
8498 tcp-request content track-sc1 src
Willy Tarreaue9656522010-08-17 15:40:09 +02008499 tcp-request content reject if click_too_fast mark_as_abuser
Willy Tarreau62644772008-07-16 18:36:06 +02008500
Willy Tarreauc57f0e22009-05-10 13:12:33 +02008501 See section 7 about ACL usage.
Willy Tarreau62644772008-07-16 18:36:06 +02008502
Willy Tarreaue9656522010-08-17 15:40:09 +02008503 See also : "tcp-request connection", "tcp-request inspect-delay"
Willy Tarreau62644772008-07-16 18:36:06 +02008504
8505
8506tcp-request inspect-delay <timeout>
8507 Set the maximum allowed time to wait for data during content inspection
8508 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaufb356202010-08-03 14:02:05 +02008509 no | yes | yes | yes
Willy Tarreau62644772008-07-16 18:36:06 +02008510 Arguments :
8511 <timeout> is the timeout value specified in milliseconds by default, but
8512 can be in any other unit if the number is suffixed by the unit,
8513 as explained at the top of this document.
8514
8515 People using haproxy primarily as a TCP relay are often worried about the
8516 risk of passing any type of protocol to a server without any analysis. In
8517 order to be able to analyze the request contents, we must first withhold
8518 the data then analyze them. This statement simply enables withholding of
8519 data for at most the specified amount of time.
8520
Willy Tarreaufb356202010-08-03 14:02:05 +02008521 TCP content inspection applies very early when a connection reaches a
8522 frontend, then very early when the connection is forwarded to a backend. This
8523 means that a connection may experience a first delay in the frontend and a
8524 second delay in the backend if both have tcp-request rules.
8525
Willy Tarreau62644772008-07-16 18:36:06 +02008526 Note that when performing content inspection, haproxy will evaluate the whole
8527 rules for every new chunk which gets in, taking into account the fact that
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01008528 those data are partial. If no rule matches before the aforementioned delay,
Willy Tarreau62644772008-07-16 18:36:06 +02008529 a last check is performed upon expiration, this time considering that the
Willy Tarreaud869b242009-03-15 14:43:58 +01008530 contents are definitive. If no delay is set, haproxy will not wait at all
8531 and will immediately apply a verdict based on the available information.
8532 Obviously this is unlikely to be very useful and might even be racy, so such
8533 setups are not recommended.
Willy Tarreau62644772008-07-16 18:36:06 +02008534
8535 As soon as a rule matches, the request is released and continues as usual. If
8536 the timeout is reached and no rule matches, the default policy will be to let
8537 it pass through unaffected.
8538
8539 For most protocols, it is enough to set it to a few seconds, as most clients
8540 send the full request immediately upon connection. Add 3 or more seconds to
8541 cover TCP retransmits but that's all. For some protocols, it may make sense
Willy Tarreaud72758d2010-01-12 10:42:19 +01008542 to use large values, for instance to ensure that the client never talks
Willy Tarreau62644772008-07-16 18:36:06 +02008543 before the server (eg: SMTP), or to wait for a client to talk before passing
8544 data to the server (eg: SSL). Note that the client timeout must cover at
Willy Tarreaub824b002010-09-29 16:36:16 +02008545 least the inspection delay, otherwise it will expire first. If the client
8546 closes the connection or if the buffer is full, the delay immediately expires
8547 since the contents will not be able to change anymore.
Willy Tarreau62644772008-07-16 18:36:06 +02008548
Willy Tarreau55165fe2009-05-10 12:02:55 +02008549 See also : "tcp-request content accept", "tcp-request content reject",
Willy Tarreau62644772008-07-16 18:36:06 +02008550 "timeout client".
8551
8552
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008553tcp-response content <action> [{if | unless} <condition>]
8554 Perform an action on a session response depending on a layer 4-7 condition
8555 May be used in sections : defaults | frontend | listen | backend
8556 no | no | yes | yes
8557 Arguments :
8558 <action> defines the action to perform if the condition applies. Valid
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008559 actions include : "accept", "close", "reject", "lua", and
8560 "sc-set-gpt0".
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008561
8562 <condition> is a standard layer 4-7 ACL-based condition (see section 7).
8563
8564 Response contents can be analysed at an early stage of response processing
8565 called "TCP content inspection". During this stage, ACL-based rules are
8566 evaluated every time the response contents are updated, until either an
Willy Tarreaucc1e04b2013-09-11 23:20:29 +02008567 "accept", "close" or a "reject" rule matches, or a TCP response inspection
8568 delay is set and expires with no matching rule.
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008569
8570 Most often, these decisions will consider a protocol recognition or validity.
8571
8572 Content-based rules are evaluated in their exact declaration order. If no
8573 rule matches or if there is no rule, the default action is to accept the
8574 contents. There is no specific limit to the number of rules which may be
8575 inserted.
8576
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008577 Several types of actions are supported :
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008578 - accept :
8579 accepts the response if the condition is true (when used with "if")
8580 or false (when used with "unless"). The first such rule executed ends
8581 the rules evaluation.
8582
Willy Tarreaucc1e04b2013-09-11 23:20:29 +02008583 - close :
8584 immediately closes the connection with the server if the condition is
8585 true (when used with "if"), or false (when used with "unless"). The
8586 first such rule executed ends the rules evaluation. The main purpose of
8587 this action is to force a connection to be finished between a client
8588 and a server after an exchange when the application protocol expects
8589 some long time outs to elapse first. The goal is to eliminate idle
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03008590 connections which take significant resources on servers with certain
Willy Tarreaucc1e04b2013-09-11 23:20:29 +02008591 protocols.
8592
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008593 - reject :
8594 rejects the response if the condition is true (when used with "if")
8595 or false (when used with "unless"). The first such rule executed ends
Jamie Gloudonaaa21002012-08-25 00:18:33 -04008596 the rules evaluation. Rejected session are immediately closed.
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008597
Thierry FOURNIER69717b42015-06-04 12:23:41 +02008598 - lua <function>
8599 Executes Lua.
8600
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02008601 - set-var(<var-name>) <expr>
8602 Sets a variable.
8603
Thierry FOURNIER236657b2015-08-19 08:25:14 +02008604 - sc-set-gpt0(<sc-id>) <int> :
8605 This action sets the GPT0 tag according to the sticky counter designated
8606 by <sc-id> and the value of <int>. The expected result is a boolean. If
8607 an error occurs, this action silently fails and the actions evaluation
8608 continues.
8609
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008610 Note that the "if/unless" condition is optional. If no condition is set on
8611 the action, it is simply performed unconditionally. That can be useful for
8612 for changing the default action to a reject.
8613
Jamie Gloudonaaa21002012-08-25 00:18:33 -04008614 It is perfectly possible to match layer 7 contents with "tcp-response
8615 content" rules, but then it is important to ensure that a full response has
8616 been buffered, otherwise no contents will match. In order to achieve this,
8617 the best solution involves detecting the HTTP protocol during the inspection
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008618 period.
8619
Thierry FOURNIER90da1912015-03-05 11:17:06 +01008620 The "lua" keyword is followed by a Lua function name. It is used to run a Lua
8621 function if the action is executed. The single parameter is the name of the
8622 function to run. The prototype of the function is documented in the API
8623 documentation.
8624
Thierry FOURNIER4834bc72015-06-06 19:29:07 +02008625 The "set-var" is used to set the content of a variable. The variable is
8626 declared inline.
8627
8628 <var-name> The name of the variable starts by an indication about its scope.
8629 The allowed scopes are:
8630 "sess" : the variable is shared with all the session,
8631 "txn" : the variable is shared with all the transaction
8632 (request and response)
8633 "req" : the variable is shared only during the request
8634 processing
8635 "res" : the variable is shared only during the response
8636 processing.
8637 This prefix is followed by a name. The separator is a '.'.
8638 The name may only contain characters 'a-z', 'A-Z', '0-9' and '_'.
8639
8640 <expr> Is a standard HAProxy expression formed by a sample-fetch
8641 followed by some converters.
8642
8643 Example:
8644
8645 tcp-request content set-var(sess.my_var) src
8646
Emeric Brun0a3b67f2010-09-24 15:34:53 +02008647 See section 7 about ACL usage.
8648
8649 See also : "tcp-request content", "tcp-response inspect-delay"
8650
8651
8652tcp-response inspect-delay <timeout>
8653 Set the maximum allowed time to wait for a response during content inspection
8654 May be used in sections : defaults | frontend | listen | backend
8655 no | no | yes | yes
8656 Arguments :
8657 <timeout> is the timeout value specified in milliseconds by default, but
8658 can be in any other unit if the number is suffixed by the unit,
8659 as explained at the top of this document.
8660
8661 See also : "tcp-response content", "tcp-request inspect-delay".
8662
8663
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008664timeout check <timeout>
8665 Set additional check timeout, but only after a connection has been already
8666 established.
8667
8668 May be used in sections: defaults | frontend | listen | backend
8669 yes | no | yes | yes
8670 Arguments:
8671 <timeout> is the timeout value specified in milliseconds by default, but
8672 can be in any other unit if the number is suffixed by the unit,
8673 as explained at the top of this document.
8674
8675 If set, haproxy uses min("timeout connect", "inter") as a connect timeout
8676 for check and "timeout check" as an additional read timeout. The "min" is
8677 used so that people running with *very* long "timeout connect" (eg. those
8678 who needed this due to the queue or tarpit) do not slow down their checks.
Willy Tarreaud7550a22010-02-10 05:10:19 +01008679 (Please also note that there is no valid reason to have such long connect
8680 timeouts, because "timeout queue" and "timeout tarpit" can always be used to
8681 avoid that).
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008682
8683 If "timeout check" is not set haproxy uses "inter" for complete check
8684 timeout (connect + read) exactly like all <1.3.15 version.
8685
8686 In most cases check request is much simpler and faster to handle than normal
8687 requests and people may want to kick out laggy servers so this timeout should
Willy Tarreau41a340d2008-01-22 12:25:31 +01008688 be smaller than "timeout server".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008689
8690 This parameter is specific to backends, but can be specified once for all in
8691 "defaults" sections. This is in fact one of the easiest solutions not to
8692 forget about it.
8693
Willy Tarreau41a340d2008-01-22 12:25:31 +01008694 See also: "timeout connect", "timeout queue", "timeout server",
8695 "timeout tarpit".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008696
8697
Willy Tarreau0ba27502007-12-24 16:55:16 +01008698timeout client <timeout>
8699timeout clitimeout <timeout> (deprecated)
8700 Set the maximum inactivity time on the client side.
8701 May be used in sections : defaults | frontend | listen | backend
8702 yes | yes | yes | no
8703 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01008704 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01008705 can be in any other unit if the number is suffixed by the unit,
8706 as explained at the top of this document.
8707
8708 The inactivity timeout applies when the client is expected to acknowledge or
8709 send data. In HTTP mode, this timeout is particularly important to consider
8710 during the first phase, when the client sends the request, and during the
8711 response while it is reading data sent by the server. The value is specified
8712 in milliseconds by default, but can be in any other unit if the number is
8713 suffixed by the unit, as specified at the top of this document. In TCP mode
8714 (and to a lesser extent, in HTTP mode), it is highly recommended that the
8715 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01008716 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01008717 losses by specifying timeouts that are slightly above multiples of 3 seconds
Willy Tarreauce887fd2012-05-12 12:50:00 +02008718 (eg: 4 or 5 seconds). If some long-lived sessions are mixed with short-lived
8719 sessions (eg: WebSocket and HTTP), it's worth considering "timeout tunnel",
Willy Tarreau05cdd962014-05-10 14:30:07 +02008720 which overrides "timeout client" and "timeout server" for tunnels, as well as
8721 "timeout client-fin" for half-closed connections.
Willy Tarreau0ba27502007-12-24 16:55:16 +01008722
8723 This parameter is specific to frontends, but can be specified once for all in
8724 "defaults" sections. This is in fact one of the easiest solutions not to
8725 forget about it. An unspecified timeout results in an infinite timeout, which
8726 is not recommended. Such a usage is accepted and works but reports a warning
8727 during startup because it may results in accumulation of expired sessions in
8728 the system if the system's timeouts are not configured either.
8729
8730 This parameter replaces the old, deprecated "clitimeout". It is recommended
8731 to use it to write new configurations. The form "timeout clitimeout" is
8732 provided only by backwards compatibility but its use is strongly discouraged.
8733
Willy Tarreauce887fd2012-05-12 12:50:00 +02008734 See also : "clitimeout", "timeout server", "timeout tunnel".
Willy Tarreau0ba27502007-12-24 16:55:16 +01008735
8736
Willy Tarreau05cdd962014-05-10 14:30:07 +02008737timeout client-fin <timeout>
8738 Set the inactivity timeout on the client side for half-closed connections.
8739 May be used in sections : defaults | frontend | listen | backend
8740 yes | yes | yes | no
8741 Arguments :
8742 <timeout> is the timeout value specified in milliseconds by default, but
8743 can be in any other unit if the number is suffixed by the unit,
8744 as explained at the top of this document.
8745
8746 The inactivity timeout applies when the client is expected to acknowledge or
8747 send data while one direction is already shut down. This timeout is different
8748 from "timeout client" in that it only applies to connections which are closed
8749 in one direction. This is particularly useful to avoid keeping connections in
8750 FIN_WAIT state for too long when clients do not disconnect cleanly. This
8751 problem is particularly common long connections such as RDP or WebSocket.
8752 Note that this timeout can override "timeout tunnel" when a connection shuts
8753 down in one direction.
8754
8755 This parameter is specific to frontends, but can be specified once for all in
8756 "defaults" sections. By default it is not set, so half-closed connections
8757 will use the other timeouts (timeout.client or timeout.tunnel).
8758
8759 See also : "timeout client", "timeout server-fin", and "timeout tunnel".
8760
8761
Willy Tarreau0ba27502007-12-24 16:55:16 +01008762timeout connect <timeout>
8763timeout contimeout <timeout> (deprecated)
8764 Set the maximum time to wait for a connection attempt to a server to succeed.
8765 May be used in sections : defaults | frontend | listen | backend
8766 yes | no | yes | yes
8767 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01008768 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01008769 can be in any other unit if the number is suffixed by the unit,
8770 as explained at the top of this document.
8771
8772 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01008773 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreaud72758d2010-01-12 10:42:19 +01008774 cover one or several TCP packet losses by specifying timeouts that are
Willy Tarreau0ba27502007-12-24 16:55:16 +01008775 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01008776 connect timeout also presets both queue and tarpit timeouts to the same value
8777 if these have not been specified.
Willy Tarreau0ba27502007-12-24 16:55:16 +01008778
8779 This parameter is specific to backends, but can be specified once for all in
8780 "defaults" sections. This is in fact one of the easiest solutions not to
8781 forget about it. An unspecified timeout results in an infinite timeout, which
8782 is not recommended. Such a usage is accepted and works but reports a warning
8783 during startup because it may results in accumulation of failed sessions in
8784 the system if the system's timeouts are not configured either.
8785
8786 This parameter replaces the old, deprecated "contimeout". It is recommended
8787 to use it to write new configurations. The form "timeout contimeout" is
8788 provided only by backwards compatibility but its use is strongly discouraged.
8789
Willy Tarreau41a340d2008-01-22 12:25:31 +01008790 See also: "timeout check", "timeout queue", "timeout server", "contimeout",
8791 "timeout tarpit".
Willy Tarreau0ba27502007-12-24 16:55:16 +01008792
8793
Willy Tarreaub16a5742010-01-10 14:46:16 +01008794timeout http-keep-alive <timeout>
8795 Set the maximum allowed time to wait for a new HTTP request to appear
8796 May be used in sections : defaults | frontend | listen | backend
8797 yes | yes | yes | yes
8798 Arguments :
8799 <timeout> is the timeout value specified in milliseconds by default, but
8800 can be in any other unit if the number is suffixed by the unit,
8801 as explained at the top of this document.
8802
8803 By default, the time to wait for a new request in case of keep-alive is set
8804 by "timeout http-request". However this is not always convenient because some
8805 people want very short keep-alive timeouts in order to release connections
8806 faster, and others prefer to have larger ones but still have short timeouts
8807 once the request has started to present itself.
8808
8809 The "http-keep-alive" timeout covers these needs. It will define how long to
8810 wait for a new HTTP request to start coming after a response was sent. Once
8811 the first byte of request has been seen, the "http-request" timeout is used
8812 to wait for the complete request to come. Note that empty lines prior to a
8813 new request do not refresh the timeout and are not counted as a new request.
8814
8815 There is also another difference between the two timeouts : when a connection
8816 expires during timeout http-keep-alive, no error is returned, the connection
8817 just closes. If the connection expires in "http-request" while waiting for a
8818 connection to complete, a HTTP 408 error is returned.
8819
8820 In general it is optimal to set this value to a few tens to hundreds of
8821 milliseconds, to allow users to fetch all objects of a page at once but
8822 without waiting for further clicks. Also, if set to a very small value (eg:
8823 1 millisecond) it will probably only accept pipelined requests but not the
8824 non-pipelined ones. It may be a nice trade-off for very large sites running
Patrick Mézard2382ad62010-05-09 10:43:32 +02008825 with tens to hundreds of thousands of clients.
Willy Tarreaub16a5742010-01-10 14:46:16 +01008826
8827 If this parameter is not set, the "http-request" timeout applies, and if both
8828 are not set, "timeout client" still applies at the lower level. It should be
8829 set in the frontend to take effect, unless the frontend is in TCP mode, in
8830 which case the HTTP backend's timeout will be used.
8831
8832 See also : "timeout http-request", "timeout client".
8833
8834
Willy Tarreau036fae02008-01-06 13:24:40 +01008835timeout http-request <timeout>
8836 Set the maximum allowed time to wait for a complete HTTP request
8837 May be used in sections : defaults | frontend | listen | backend
Willy Tarreaucd7afc02009-07-12 10:03:17 +02008838 yes | yes | yes | yes
Willy Tarreau036fae02008-01-06 13:24:40 +01008839 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01008840 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau036fae02008-01-06 13:24:40 +01008841 can be in any other unit if the number is suffixed by the unit,
8842 as explained at the top of this document.
8843
8844 In order to offer DoS protection, it may be required to lower the maximum
8845 accepted time to receive a complete HTTP request without affecting the client
8846 timeout. This helps protecting against established connections on which
8847 nothing is sent. The client timeout cannot offer a good protection against
8848 this abuse because it is an inactivity timeout, which means that if the
8849 attacker sends one character every now and then, the timeout will not
8850 trigger. With the HTTP request timeout, no matter what speed the client
Willy Tarreau2705a612014-05-23 17:38:34 +02008851 types, the request will be aborted if it does not complete in time. When the
8852 timeout expires, an HTTP 408 response is sent to the client to inform it
8853 about the problem, and the connection is closed. The logs will report
8854 termination codes "cR". Some recent browsers are having problems with this
8855 standard, well-documented behaviour, so it might be needed to hide the 408
Willy Tarreau0f228a02015-05-01 15:37:53 +02008856 code using "option http-ignore-probes" or "errorfile 408 /dev/null". See
8857 more details in the explanations of the "cR" termination code in section 8.5.
Willy Tarreau036fae02008-01-06 13:24:40 +01008858
8859 Note that this timeout only applies to the header part of the request, and
8860 not to any data. As soon as the empty line is received, this timeout is not
Willy Tarreaub16a5742010-01-10 14:46:16 +01008861 used anymore. It is used again on keep-alive connections to wait for a second
8862 request if "timeout http-keep-alive" is not set.
Willy Tarreau036fae02008-01-06 13:24:40 +01008863
8864 Generally it is enough to set it to a few seconds, as most clients send the
8865 full request immediately upon connection. Add 3 or more seconds to cover TCP
8866 retransmits but that's all. Setting it to very low values (eg: 50 ms) will
8867 generally work on local networks as long as there are no packet losses. This
8868 will prevent people from sending bare HTTP requests using telnet.
8869
8870 If this parameter is not set, the client timeout still applies between each
Willy Tarreaucd7afc02009-07-12 10:03:17 +02008871 chunk of the incoming request. It should be set in the frontend to take
8872 effect, unless the frontend is in TCP mode, in which case the HTTP backend's
8873 timeout will be used.
Willy Tarreau036fae02008-01-06 13:24:40 +01008874
Willy Tarreau0f228a02015-05-01 15:37:53 +02008875 See also : "errorfile", "http-ignore-probes", "timeout http-keep-alive", and
8876 "timeout client".
Willy Tarreau036fae02008-01-06 13:24:40 +01008877
Willy Tarreau844e3c52008-01-11 16:28:18 +01008878
8879timeout queue <timeout>
8880 Set the maximum time to wait in the queue for a connection slot to be free
8881 May be used in sections : defaults | frontend | listen | backend
8882 yes | no | yes | yes
8883 Arguments :
8884 <timeout> is the timeout value specified in milliseconds by default, but
8885 can be in any other unit if the number is suffixed by the unit,
8886 as explained at the top of this document.
8887
8888 When a server's maxconn is reached, connections are left pending in a queue
8889 which may be server-specific or global to the backend. In order not to wait
8890 indefinitely, a timeout is applied to requests pending in the queue. If the
8891 timeout is reached, it is considered that the request will almost never be
8892 served, so it is dropped and a 503 error is returned to the client.
8893
8894 The "timeout queue" statement allows to fix the maximum time for a request to
8895 be left pending in a queue. If unspecified, the same value as the backend's
8896 connection timeout ("timeout connect") is used, for backwards compatibility
8897 with older versions with no "timeout queue" parameter.
8898
8899 See also : "timeout connect", "contimeout".
8900
8901
8902timeout server <timeout>
8903timeout srvtimeout <timeout> (deprecated)
8904 Set the maximum inactivity time on the server side.
8905 May be used in sections : defaults | frontend | listen | backend
8906 yes | no | yes | yes
8907 Arguments :
8908 <timeout> is the timeout value specified in milliseconds by default, but
8909 can be in any other unit if the number is suffixed by the unit,
8910 as explained at the top of this document.
8911
8912 The inactivity timeout applies when the server is expected to acknowledge or
8913 send data. In HTTP mode, this timeout is particularly important to consider
8914 during the first phase of the server's response, when it has to send the
8915 headers, as it directly represents the server's processing time for the
8916 request. To find out what value to put there, it's often good to start with
8917 what would be considered as unacceptable response times, then check the logs
8918 to observe the response time distribution, and adjust the value accordingly.
8919
8920 The value is specified in milliseconds by default, but can be in any other
8921 unit if the number is suffixed by the unit, as specified at the top of this
8922 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
8923 recommended that the client timeout remains equal to the server timeout in
8924 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01008925 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01008926 packet losses by specifying timeouts that are slightly above multiples of 3
Willy Tarreauce887fd2012-05-12 12:50:00 +02008927 seconds (eg: 4 or 5 seconds minimum). If some long-lived sessions are mixed
8928 with short-lived sessions (eg: WebSocket and HTTP), it's worth considering
8929 "timeout tunnel", which overrides "timeout client" and "timeout server" for
8930 tunnels.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008931
8932 This parameter is specific to backends, but can be specified once for all in
8933 "defaults" sections. This is in fact one of the easiest solutions not to
8934 forget about it. An unspecified timeout results in an infinite timeout, which
8935 is not recommended. Such a usage is accepted and works but reports a warning
8936 during startup because it may results in accumulation of expired sessions in
8937 the system if the system's timeouts are not configured either.
8938
8939 This parameter replaces the old, deprecated "srvtimeout". It is recommended
8940 to use it to write new configurations. The form "timeout srvtimeout" is
8941 provided only by backwards compatibility but its use is strongly discouraged.
8942
Willy Tarreauce887fd2012-05-12 12:50:00 +02008943 See also : "srvtimeout", "timeout client" and "timeout tunnel".
Willy Tarreau844e3c52008-01-11 16:28:18 +01008944
Willy Tarreau05cdd962014-05-10 14:30:07 +02008945
8946timeout server-fin <timeout>
8947 Set the inactivity timeout on the server side for half-closed connections.
8948 May be used in sections : defaults | frontend | listen | backend
8949 yes | no | yes | yes
8950 Arguments :
8951 <timeout> is the timeout value specified in milliseconds by default, but
8952 can be in any other unit if the number is suffixed by the unit,
8953 as explained at the top of this document.
8954
8955 The inactivity timeout applies when the server is expected to acknowledge or
8956 send data while one direction is already shut down. This timeout is different
8957 from "timeout server" in that it only applies to connections which are closed
8958 in one direction. This is particularly useful to avoid keeping connections in
8959 FIN_WAIT state for too long when a remote server does not disconnect cleanly.
8960 This problem is particularly common long connections such as RDP or WebSocket.
8961 Note that this timeout can override "timeout tunnel" when a connection shuts
8962 down in one direction. This setting was provided for completeness, but in most
8963 situations, it should not be needed.
8964
8965 This parameter is specific to backends, but can be specified once for all in
8966 "defaults" sections. By default it is not set, so half-closed connections
8967 will use the other timeouts (timeout.server or timeout.tunnel).
8968
8969 See also : "timeout client-fin", "timeout server", and "timeout tunnel".
8970
Willy Tarreau844e3c52008-01-11 16:28:18 +01008971
8972timeout tarpit <timeout>
Cyril Bonté78caf842010-03-10 22:41:43 +01008973 Set the duration for which tarpitted connections will be maintained
Willy Tarreau844e3c52008-01-11 16:28:18 +01008974 May be used in sections : defaults | frontend | listen | backend
8975 yes | yes | yes | yes
8976 Arguments :
8977 <timeout> is the tarpit duration specified in milliseconds by default, but
8978 can be in any other unit if the number is suffixed by the unit,
8979 as explained at the top of this document.
8980
8981 When a connection is tarpitted using "reqtarpit", it is maintained open with
8982 no activity for a certain amount of time, then closed. "timeout tarpit"
8983 defines how long it will be maintained open.
8984
8985 The value is specified in milliseconds by default, but can be in any other
8986 unit if the number is suffixed by the unit, as specified at the top of this
8987 document. If unspecified, the same value as the backend's connection timeout
8988 ("timeout connect") is used, for backwards compatibility with older versions
Cyril Bonté78caf842010-03-10 22:41:43 +01008989 with no "timeout tarpit" parameter.
Willy Tarreau844e3c52008-01-11 16:28:18 +01008990
8991 See also : "timeout connect", "contimeout".
8992
8993
Willy Tarreauce887fd2012-05-12 12:50:00 +02008994timeout tunnel <timeout>
8995 Set the maximum inactivity time on the client and server side for tunnels.
8996 May be used in sections : defaults | frontend | listen | backend
8997 yes | no | yes | yes
8998 Arguments :
8999 <timeout> is the timeout value specified in milliseconds by default, but
9000 can be in any other unit if the number is suffixed by the unit,
9001 as explained at the top of this document.
9002
Jamie Gloudonaaa21002012-08-25 00:18:33 -04009003 The tunnel timeout applies when a bidirectional connection is established
Willy Tarreauce887fd2012-05-12 12:50:00 +02009004 between a client and a server, and the connection remains inactive in both
9005 directions. This timeout supersedes both the client and server timeouts once
9006 the connection becomes a tunnel. In TCP, this timeout is used as soon as no
9007 analyser remains attached to either connection (eg: tcp content rules are
9008 accepted). In HTTP, this timeout is used when a connection is upgraded (eg:
9009 when switching to the WebSocket protocol, or forwarding a CONNECT request
9010 to a proxy), or after the first response when no keepalive/close option is
9011 specified.
9012
Willy Tarreau05cdd962014-05-10 14:30:07 +02009013 Since this timeout is usually used in conjunction with long-lived connections,
9014 it usually is a good idea to also set "timeout client-fin" to handle the
9015 situation where a client suddenly disappears from the net and does not
9016 acknowledge a close, or sends a shutdown and does not acknowledge pending
9017 data anymore. This can happen in lossy networks where firewalls are present,
9018 and is detected by the presence of large amounts of sessions in a FIN_WAIT
9019 state.
9020
Willy Tarreauce887fd2012-05-12 12:50:00 +02009021 The value is specified in milliseconds by default, but can be in any other
9022 unit if the number is suffixed by the unit, as specified at the top of this
9023 document. Whatever the expected normal idle time, it is a good practice to
9024 cover at least one or several TCP packet losses by specifying timeouts that
9025 are slightly above multiples of 3 seconds (eg: 4 or 5 seconds minimum).
9026
9027 This parameter is specific to backends, but can be specified once for all in
9028 "defaults" sections. This is in fact one of the easiest solutions not to
9029 forget about it.
9030
9031 Example :
9032 defaults http
9033 option http-server-close
9034 timeout connect 5s
9035 timeout client 30s
Willy Tarreau05cdd962014-05-10 14:30:07 +02009036 timeout client-fin 30s
Willy Tarreauce887fd2012-05-12 12:50:00 +02009037 timeout server 30s
9038 timeout tunnel 1h # timeout to use with WebSocket and CONNECT
9039
Willy Tarreau05cdd962014-05-10 14:30:07 +02009040 See also : "timeout client", "timeout client-fin", "timeout server".
Willy Tarreauce887fd2012-05-12 12:50:00 +02009041
9042
Willy Tarreau844e3c52008-01-11 16:28:18 +01009043transparent (deprecated)
9044 Enable client-side transparent proxying
9045 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau4b1f8592008-12-23 23:13:55 +01009046 yes | no | yes | yes
Willy Tarreau844e3c52008-01-11 16:28:18 +01009047 Arguments : none
9048
9049 This keyword was introduced in order to provide layer 7 persistence to layer
9050 3 load balancers. The idea is to use the OS's ability to redirect an incoming
9051 connection for a remote address to a local process (here HAProxy), and let
9052 this process know what address was initially requested. When this option is
9053 used, sessions without cookies will be forwarded to the original destination
9054 IP address of the incoming request (which should match that of another
9055 equipment), while requests with cookies will still be forwarded to the
9056 appropriate server.
9057
9058 The "transparent" keyword is deprecated, use "option transparent" instead.
9059
9060 Note that contrary to a common belief, this option does NOT make HAProxy
9061 present the client's IP to the server when establishing the connection.
9062
Willy Tarreau844e3c52008-01-11 16:28:18 +01009063 See also: "option transparent"
9064
William Lallemanda73203e2012-03-12 12:48:57 +01009065unique-id-format <string>
9066 Generate a unique ID for each request.
9067 May be used in sections : defaults | frontend | listen | backend
9068 yes | yes | yes | no
9069 Arguments :
9070 <string> is a log-format string.
9071
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009072 This keyword creates a ID for each request using the custom log format. A
9073 unique ID is useful to trace a request passing through many components of
9074 a complex infrastructure. The newly created ID may also be logged using the
9075 %ID tag the log-format string.
William Lallemanda73203e2012-03-12 12:48:57 +01009076
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009077 The format should be composed from elements that are guaranteed to be
9078 unique when combined together. For instance, if multiple haproxy instances
9079 are involved, it might be important to include the node name. It is often
9080 needed to log the incoming connection's source and destination addresses
9081 and ports. Note that since multiple requests may be performed over the same
9082 connection, including a request counter may help differentiate them.
9083 Similarly, a timestamp may protect against a rollover of the counter.
9084 Logging the process ID will avoid collisions after a service restart.
William Lallemanda73203e2012-03-12 12:48:57 +01009085
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009086 It is recommended to use hexadecimal notation for many fields since it
9087 makes them more compact and saves space in logs.
William Lallemanda73203e2012-03-12 12:48:57 +01009088
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009089 Example:
William Lallemanda73203e2012-03-12 12:48:57 +01009090
Julien Vehentf21be322014-03-07 08:27:34 -05009091 unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
William Lallemanda73203e2012-03-12 12:48:57 +01009092
9093 will generate:
9094
9095 7F000001:8296_7F00001E:1F90_4F7B0A69_0003:790A
9096
9097 See also: "unique-id-header"
9098
9099unique-id-header <name>
9100 Add a unique ID header in the HTTP request.
9101 May be used in sections : defaults | frontend | listen | backend
9102 yes | yes | yes | no
9103 Arguments :
9104 <name> is the name of the header.
9105
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009106 Add a unique-id header in the HTTP request sent to the server, using the
9107 unique-id-format. It can't work if the unique-id-format doesn't exist.
William Lallemanda73203e2012-03-12 12:48:57 +01009108
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009109 Example:
William Lallemanda73203e2012-03-12 12:48:57 +01009110
Julien Vehentf21be322014-03-07 08:27:34 -05009111 unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
William Lallemanda73203e2012-03-12 12:48:57 +01009112 unique-id-header X-Unique-ID
9113
9114 will generate:
9115
9116 X-Unique-ID: 7F000001:8296_7F00001E:1F90_4F7B0A69_0003:790A
9117
9118 See also: "unique-id-format"
Willy Tarreau844e3c52008-01-11 16:28:18 +01009119
Willy Tarreauf51658d2014-04-23 01:21:56 +02009120use_backend <backend> [{if | unless} <condition>]
Willy Tarreau1d0dfb12009-07-07 15:10:31 +02009121 Switch to a specific backend if/unless an ACL-based condition is matched.
Willy Tarreau844e3c52008-01-11 16:28:18 +01009122 May be used in sections : defaults | frontend | listen | backend
9123 no | yes | yes | no
9124 Arguments :
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01009125 <backend> is the name of a valid backend or "listen" section, or a
9126 "log-format" string resolving to a backend name.
Willy Tarreau844e3c52008-01-11 16:28:18 +01009127
Willy Tarreauf51658d2014-04-23 01:21:56 +02009128 <condition> is a condition composed of ACLs, as described in section 7. If
9129 it is omitted, the rule is unconditionally applied.
Willy Tarreau844e3c52008-01-11 16:28:18 +01009130
9131 When doing content-switching, connections arrive on a frontend and are then
9132 dispatched to various backends depending on a number of conditions. The
9133 relation between the conditions and the backends is described with the
Willy Tarreau1d0dfb12009-07-07 15:10:31 +02009134 "use_backend" keyword. While it is normally used with HTTP processing, it can
9135 also be used in pure TCP, either without content using stateless ACLs (eg:
9136 source address validation) or combined with a "tcp-request" rule to wait for
9137 some payload.
Willy Tarreau844e3c52008-01-11 16:28:18 +01009138
9139 There may be as many "use_backend" rules as desired. All of these rules are
9140 evaluated in their declaration order, and the first one which matches will
9141 assign the backend.
9142
9143 In the first form, the backend will be used if the condition is met. In the
9144 second form, the backend will be used if the condition is not met. If no
9145 condition is valid, the backend defined with "default_backend" will be used.
9146 If no default backend is defined, either the servers in the same section are
9147 used (in case of a "listen" section) or, in case of a frontend, no server is
9148 used and a 503 service unavailable response is returned.
9149
Willy Tarreau51aecc72009-07-12 09:47:04 +02009150 Note that it is possible to switch from a TCP frontend to an HTTP backend. In
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +01009151 this case, either the frontend has already checked that the protocol is HTTP,
Willy Tarreau51aecc72009-07-12 09:47:04 +02009152 and backend processing will immediately follow, or the backend will wait for
9153 a complete HTTP request to get in. This feature is useful when a frontend
9154 must decode several protocols on a unique port, one of them being HTTP.
9155
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01009156 When <backend> is a simple name, it is resolved at configuration time, and an
9157 error is reported if the specified backend does not exist. If <backend> is
9158 a log-format string instead, no check may be done at configuration time, so
9159 the backend name is resolved dynamically at run time. If the resulting
9160 backend name does not correspond to any valid backend, no other rule is
9161 evaluated, and the default_backend directive is applied instead. Note that
9162 when using dynamic backend names, it is highly recommended to use a prefix
9163 that no other backend uses in order to ensure that an unauthorized backend
9164 cannot be forced from the request.
9165
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009166 It is worth mentioning that "use_backend" rules with an explicit name are
Bertrand Jacquin702d44f2013-11-19 11:43:06 +01009167 used to detect the association between frontends and backends to compute the
9168 backend's "fullconn" setting. This cannot be done for dynamic names.
9169
9170 See also: "default_backend", "tcp-request", "fullconn", "log-format", and
9171 section 7 about ACLs.
Willy Tarreaud72758d2010-01-12 10:42:19 +01009172
Willy Tarreau036fae02008-01-06 13:24:40 +01009173
Willy Tarreau4a5cade2012-04-05 21:09:48 +02009174use-server <server> if <condition>
9175use-server <server> unless <condition>
9176 Only use a specific server if/unless an ACL-based condition is matched.
9177 May be used in sections : defaults | frontend | listen | backend
9178 no | no | yes | yes
9179 Arguments :
Cyril Bonté108cf6e2012-04-21 23:30:29 +02009180 <server> is the name of a valid server in the same backend section.
Willy Tarreau4a5cade2012-04-05 21:09:48 +02009181
9182 <condition> is a condition composed of ACLs, as described in section 7.
9183
9184 By default, connections which arrive to a backend are load-balanced across
9185 the available servers according to the configured algorithm, unless a
9186 persistence mechanism such as a cookie is used and found in the request.
9187
9188 Sometimes it is desirable to forward a particular request to a specific
9189 server without having to declare a dedicated backend for this server. This
9190 can be achieved using the "use-server" rules. These rules are evaluated after
9191 the "redirect" rules and before evaluating cookies, and they have precedence
9192 on them. There may be as many "use-server" rules as desired. All of these
9193 rules are evaluated in their declaration order, and the first one which
9194 matches will assign the server.
9195
9196 If a rule designates a server which is down, and "option persist" is not used
9197 and no force-persist rule was validated, it is ignored and evaluation goes on
9198 with the next rules until one matches.
9199
9200 In the first form, the server will be used if the condition is met. In the
9201 second form, the server will be used if the condition is not met. If no
9202 condition is valid, the processing continues and the server will be assigned
9203 according to other persistence mechanisms.
9204
9205 Note that even if a rule is matched, cookie processing is still performed but
9206 does not assign the server. This allows prefixed cookies to have their prefix
9207 stripped.
9208
9209 The "use-server" statement works both in HTTP and TCP mode. This makes it
9210 suitable for use with content-based inspection. For instance, a server could
9211 be selected in a farm according to the TLS SNI field. And if these servers
9212 have their weight set to zero, they will not be used for other traffic.
9213
9214 Example :
9215 # intercept incoming TLS requests based on the SNI field
9216 use-server www if { req_ssl_sni -i www.example.com }
9217 server www 192.168.0.1:443 weight 0
9218 use-server mail if { req_ssl_sni -i mail.example.com }
9219 server mail 192.168.0.1:587 weight 0
9220 use-server imap if { req_ssl_sni -i imap.example.com }
9221 server mail 192.168.0.1:993 weight 0
9222 # all the rest is forwarded to this server
9223 server default 192.168.0.2:443 check
9224
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009225 See also: "use_backend", section 5 about server and section 7 about ACLs.
Willy Tarreau4a5cade2012-04-05 21:09:48 +02009226
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009227
92285. Bind and Server options
9229--------------------------
9230
9231The "bind", "server" and "default-server" keywords support a number of settings
9232depending on some build options and on the system HAProxy was built on. These
9233settings generally each consist in one word sometimes followed by a value,
9234written on the same line as the "bind" or "server" line. All these options are
9235described in this section.
9236
9237
92385.1. Bind options
9239-----------------
9240
9241The "bind" keyword supports a certain number of settings which are all passed
9242as arguments on the same line. The order in which those arguments appear makes
9243no importance, provided that they appear after the bind address. All of these
9244parameters are optional. Some of them consist in a single words (booleans),
9245while other ones expect a value after them. In this case, the value must be
9246provided immediately after the setting name.
9247
9248The currently supported settings are the following ones.
9249
9250accept-proxy
9251 Enforces the use of the PROXY protocol over any connection accepted by any of
Willy Tarreau77992672014-06-14 11:06:17 +02009252 the sockets declared on the same line. Versions 1 and 2 of the PROXY protocol
9253 are supported and correctly detected. The PROXY protocol dictates the layer
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009254 3/4 addresses of the incoming connection to be used everywhere an address is
9255 used, with the only exception of "tcp-request connection" rules which will
9256 only see the real connection address. Logs will reflect the addresses
9257 indicated in the protocol, unless it is violated, in which case the real
9258 address will still be used. This keyword combined with support from external
9259 components can be used as an efficient and reliable alternative to the
9260 X-Forwarded-For mechanism which is not always reliable and not even always
Willy Tarreau4f0d9192013-06-11 20:40:55 +02009261 usable. See also "tcp-request connection expect-proxy" for a finer-grained
9262 setting of which client is allowed to use the protocol.
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009263
Willy Tarreauab861d32013-04-02 02:30:41 +02009264alpn <protocols>
9265 This enables the TLS ALPN extension and advertises the specified protocol
9266 list as supported on top of ALPN. The protocol list consists in a comma-
9267 delimited list of protocol names, for instance: "http/1.1,http/1.0" (without
9268 quotes). This requires that the SSL library is build with support for TLS
9269 extensions enabled (check with haproxy -vv). The ALPN extension replaces the
9270 initial NPN extension.
9271
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009272backlog <backlog>
9273 Sets the socket's backlog to this value. If unspecified, the frontend's
9274 backlog is used instead, which generally defaults to the maxconn value.
9275
Emeric Brun7fb34422012-09-28 15:26:15 +02009276ecdhe <named curve>
9277 This setting is only available when support for OpenSSL was built in. It sets
Emeric Brun6924ef82013-03-06 14:08:53 +01009278 the named curve (RFC 4492) used to generate ECDH ephemeral keys. By default,
9279 used named curve is prime256v1.
Emeric Brun7fb34422012-09-28 15:26:15 +02009280
Emeric Brunfd33a262012-10-11 16:28:27 +02009281ca-file <cafile>
Emeric Brun1a073b42012-09-28 17:07:34 +02009282 This setting is only available when support for OpenSSL was built in. It
9283 designates a PEM file from which to load CA certificates used to verify
9284 client's certificate.
9285
Emeric Brunb6dc9342012-09-28 17:55:37 +02009286ca-ignore-err [all|<errorID>,...]
9287 This setting is only available when support for OpenSSL was built in.
9288 Sets a comma separated list of errorIDs to ignore during verify at depth > 0.
9289 If set to 'all', all errors are ignored. SSL handshake is not aborted if an
9290 error is ignored.
9291
Christopher Faulet31af49d2015-06-09 17:29:50 +02009292ca-sign-file <cafile>
9293 This setting is only available when support for OpenSSL was built in. It
9294 designates a PEM file containing both the CA certificate and the CA private
9295 key used to create and sign server's certificates. This is a mandatory
9296 setting when the dynamic generation of certificates is enabled. See
9297 'generate-certificates' for details.
9298
9299ca-sign-passphrase <passphrase>
9300 This setting is only available when support for OpenSSL was built in. It is
9301 the CA private key passphrase. This setting is optional and used only when
9302 the dynamic generation of certificates is enabled. See
9303 'generate-certificates' for details.
9304
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009305ciphers <ciphers>
9306 This setting is only available when support for OpenSSL was built in. It sets
9307 the string describing the list of cipher algorithms ("cipher suite") that are
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009308 negotiated during the SSL/TLS handshake. The format of the string is defined
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009309 in "man 1 ciphers" from OpenSSL man pages, and can be for instance a string
9310 such as "AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH" (without quotes).
9311
Emeric Brunfd33a262012-10-11 16:28:27 +02009312crl-file <crlfile>
Emeric Brun1a073b42012-09-28 17:07:34 +02009313 This setting is only available when support for OpenSSL was built in. It
9314 designates a PEM file from which to load certificate revocation list used
9315 to verify client's certificate.
9316
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009317crt <cert>
Alex Davies0fbf0162013-03-02 16:04:50 +00009318 This setting is only available when support for OpenSSL was built in. It
9319 designates a PEM file containing both the required certificates and any
9320 associated private keys. This file can be built by concatenating multiple
9321 PEM files into one (e.g. cat cert.pem key.pem > combined.pem). If your CA
9322 requires an intermediate certificate, this can also be concatenated into this
9323 file.
9324
9325 If the OpenSSL used supports Diffie-Hellman, parameters present in this file
9326 are loaded.
9327
9328 If a directory name is used instead of a PEM file, then all files found in
Cyril Bonté3180f7b2015-01-25 00:16:08 +01009329 that directory will be loaded in alphabetic order unless their name ends with
Janusz Dziemidowicz2c701b52015-03-07 23:03:59 +01009330 '.issuer', '.ocsp' or '.sctl' (reserved extensions). This directive may be
9331 specified multiple times in order to load certificates from multiple files or
9332 directories. The certificates will be presented to clients who provide a
9333 valid TLS Server Name Indication field matching one of their CN or alt
9334 subjects. Wildcards are supported, where a wildcard character '*' is used
9335 instead of the first hostname component (eg: *.example.org matches
9336 www.example.org but not www.sub.example.org).
Alex Davies0fbf0162013-03-02 16:04:50 +00009337
9338 If no SNI is provided by the client or if the SSL library does not support
9339 TLS extensions, or if the client provides an SNI hostname which does not
9340 match any certificate, then the first loaded certificate will be presented.
9341 This means that when loading certificates from a directory, it is highly
Cyril Bonté3180f7b2015-01-25 00:16:08 +01009342 recommended to load the default one first as a file or to ensure that it will
9343 always be the first one in the directory.
Alex Davies0fbf0162013-03-02 16:04:50 +00009344
Emeric Brune032bfa2012-09-28 13:01:45 +02009345 Note that the same cert may be loaded multiple times without side effects.
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009346
Alex Davies0fbf0162013-03-02 16:04:50 +00009347 Some CAs (such as Godaddy) offer a drop down list of server types that do not
9348 include HAProxy when obtaining a certificate. If this happens be sure to
Godbach8bf60a12014-04-21 21:42:41 +08009349 choose a webserver that the CA believes requires an intermediate CA (for
Alex Davies0fbf0162013-03-02 16:04:50 +00009350 Godaddy, selection Apache Tomcat will get the correct bundle, but many
9351 others, e.g. nginx, result in a wrong bundle that will not work for some
9352 clients).
9353
Emeric Brun4147b2e2014-06-16 18:36:30 +02009354 For each PEM file, haproxy checks for the presence of file at the same path
9355 suffixed by ".ocsp". If such file is found, support for the TLS Certificate
9356 Status Request extension (also known as "OCSP stapling") is automatically
9357 enabled. The content of this file is optional. If not empty, it must contain
9358 a valid OCSP Response in DER format. In order to be valid an OCSP Response
9359 must comply with the following rules: it has to indicate a good status,
9360 it has to be a single response for the certificate of the PEM file, and it
9361 has to be valid at the moment of addition. If these rules are not respected
9362 the OCSP Response is ignored and a warning is emitted. In order to identify
9363 which certificate an OCSP Response applies to, the issuer's certificate is
9364 necessary. If the issuer's certificate is not found in the PEM file, it will
9365 be loaded from a file at the same path as the PEM file suffixed by ".issuer"
9366 if it exists otherwise it will fail with an error.
9367
Janusz Dziemidowicz2c701b52015-03-07 23:03:59 +01009368 For each PEM file, haproxy also checks for the presence of file at the same
9369 path suffixed by ".sctl". If such file is found, support for Certificate
9370 Transparency (RFC6962) TLS extension is enabled. The file must contain a
9371 valid Signed Certificate Timestamp List, as described in RFC. File is parsed
9372 to check basic syntax, but no signatures are verified.
9373
Emeric Brunb6dc9342012-09-28 17:55:37 +02009374crt-ignore-err <errors>
Alex Davies0fbf0162013-03-02 16:04:50 +00009375 This setting is only available when support for OpenSSL was built in. Sets a
9376 comma separated list of errorIDs to ignore during verify at depth == 0. If
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009377 set to 'all', all errors are ignored. SSL handshake is not aborted if an error
Alex Davies0fbf0162013-03-02 16:04:50 +00009378 is ignored.
Emeric Brunb6dc9342012-09-28 17:55:37 +02009379
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01009380crt-list <file>
9381 This setting is only available when support for OpenSSL was built in. It
Emmanuel Hocdet7c41a1b2013-05-07 20:20:06 +02009382 designates a list of PEM file with an optional list of SNI filter per
9383 certificate, with the following format for each line :
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01009384
Emmanuel Hocdet7c41a1b2013-05-07 20:20:06 +02009385 <crtfile> [[!]<snifilter> ...]
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01009386
Emmanuel Hocdet7c41a1b2013-05-07 20:20:06 +02009387 Wildcards are supported in the SNI filter. Negative filter are also supported,
9388 only useful in combination with a wildcard filter to exclude a particular SNI.
9389 The certificates will be presented to clients who provide a valid TLS Server
9390 Name Indication field matching one of the SNI filters. If no SNI filter is
9391 specified, the CN and alt subjects are used. This directive may be specified
9392 multiple times. See the "crt" option for more information. The default
9393 certificate is still needed to meet OpenSSL expectations. If it is not used,
9394 the 'strict-sni' option may be used.
Emmanuel Hocdetfe616562013-01-22 15:31:15 +01009395
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009396defer-accept
9397 Is an optional keyword which is supported only on certain Linux kernels. It
9398 states that a connection will only be accepted once some data arrive on it,
9399 or at worst after the first retransmit. This should be used only on protocols
9400 for which the client talks first (eg: HTTP). It can slightly improve
9401 performance by ensuring that most of the request is already available when
9402 the connection is accepted. On the other hand, it will not be able to detect
9403 connections which don't talk. It is important to note that this option is
9404 broken in all kernels up to 2.6.31, as the connection is never accepted until
9405 the client talks. This can cause issues with front firewalls which would see
9406 an established connection while the proxy will only see it in SYN_RECV. This
9407 option is only supported on TCPv4/TCPv6 sockets and ignored by other ones.
9408
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009409force-sslv3
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009410 This option enforces use of SSLv3 only on SSL connections instantiated from
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009411 this listener. SSLv3 is generally less expensive than the TLS counterparts
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009412 for high connection rates. This option is also available on global statement
9413 "ssl-default-bind-options". See also "no-tlsv*" and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009414
9415force-tlsv10
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009416 This option enforces use of TLSv1.0 only on SSL connections instantiated from
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009417 this listener. This option is also available on global statement
9418 "ssl-default-bind-options". See also "no-tlsv*" and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009419
9420force-tlsv11
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009421 This option enforces use of TLSv1.1 only on SSL connections instantiated from
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009422 this listener. This option is also available on global statement
9423 "ssl-default-bind-options". See also "no-tlsv*", and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009424
9425force-tlsv12
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009426 This option enforces use of TLSv1.2 only on SSL connections instantiated from
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009427 this listener. This option is also available on global statement
9428 "ssl-default-bind-options". See also "no-tlsv*", and "no-sslv3".
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009429
Christopher Faulet31af49d2015-06-09 17:29:50 +02009430generate-certificates
9431 This setting is only available when support for OpenSSL was built in. It
9432 enables the dynamic SSL certificates generation. A CA certificate and its
9433 private key are necessary (see 'ca-sign-file'). When HAProxy is configured as
9434 a transparent forward proxy, SSL requests generate errors because of a common
9435 name mismatch on the certificate presented to the client. With this option
9436 enabled, HAProxy will try to forge a certificate using the SNI hostname
9437 indicated by the client. This is done only if no certificate matches the SNI
9438 hostname (see 'crt-list'). If an error occurs, the default certificate is
9439 used, else the 'strict-sni' option is set.
9440 It can also be used when HAProxy is configured as a reverse proxy to ease the
9441 deployment of an architecture with many backends.
9442
9443 Creating a SSL certificate is an expensive operation, so a LRU cache is used
9444 to store forged certificates (see 'tune.ssl.ssl-ctx-cache-size'). It
9445 increases the HAProxy's memroy footprint to reduce latency when the same
9446 certificate is used many times.
9447
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009448gid <gid>
9449 Sets the group of the UNIX sockets to the designated system gid. It can also
9450 be set by default in the global section's "unix-bind" statement. Note that
9451 some platforms simply ignore this. This setting is equivalent to the "group"
9452 setting except that the group ID is used instead of its name. This setting is
9453 ignored by non UNIX sockets.
9454
9455group <group>
9456 Sets the group of the UNIX sockets to the designated system group. It can
9457 also be set by default in the global section's "unix-bind" statement. Note
9458 that some platforms simply ignore this. This setting is equivalent to the
9459 "gid" setting except that the group name is used instead of its gid. This
9460 setting is ignored by non UNIX sockets.
9461
9462id <id>
9463 Fixes the socket ID. By default, socket IDs are automatically assigned, but
9464 sometimes it is more convenient to fix them to ease monitoring. This value
9465 must be strictly positive and unique within the listener/frontend. This
9466 option can only be used when defining only a single socket.
9467
9468interface <interface>
Lukas Tribusfce2e962013-02-12 22:13:19 +01009469 Restricts the socket to a specific interface. When specified, only packets
9470 received from that particular interface are processed by the socket. This is
9471 currently only supported on Linux. The interface must be a primary system
9472 interface, not an aliased interface. It is also possible to bind multiple
9473 frontends to the same address if they are bound to different interfaces. Note
9474 that binding to a network interface requires root privileges. This parameter
9475 is only compatible with TCPv4/TCPv6 sockets.
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009476
Willy Tarreauabb175f2012-09-24 12:43:26 +02009477level <level>
9478 This setting is used with the stats sockets only to restrict the nature of
9479 the commands that can be issued on the socket. It is ignored by other
9480 sockets. <level> can be one of :
9481 - "user" is the least privileged level ; only non-sensitive stats can be
9482 read, and no change is allowed. It would make sense on systems where it
9483 is not easy to restrict access to the socket.
9484 - "operator" is the default level and fits most common uses. All data can
9485 be read, and only non-sensitive changes are permitted (eg: clear max
9486 counters).
9487 - "admin" should be used with care, as everything is permitted (eg: clear
9488 all counters).
9489
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009490maxconn <maxconn>
9491 Limits the sockets to this number of concurrent connections. Extraneous
9492 connections will remain in the system's backlog until a connection is
9493 released. If unspecified, the limit will be the same as the frontend's
9494 maxconn. Note that in case of port ranges or multiple addresses, the same
9495 value will be applied to each socket. This setting enables different
9496 limitations on expensive sockets, for instance SSL entries which may easily
9497 eat all memory.
9498
9499mode <mode>
9500 Sets the octal mode used to define access permissions on the UNIX socket. It
9501 can also be set by default in the global section's "unix-bind" statement.
9502 Note that some platforms simply ignore this. This setting is ignored by non
9503 UNIX sockets.
9504
9505mss <maxseg>
9506 Sets the TCP Maximum Segment Size (MSS) value to be advertised on incoming
9507 connections. This can be used to force a lower MSS for certain specific
9508 ports, for instance for connections passing through a VPN. Note that this
9509 relies on a kernel feature which is theoretically supported under Linux but
9510 was buggy in all versions prior to 2.6.28. It may or may not work on other
9511 operating systems. It may also not change the advertised value but change the
9512 effective size of outgoing segments. The commonly advertised value for TCPv4
9513 over Ethernet networks is 1460 = 1500(MTU) - 40(IP+TCP). If this value is
9514 positive, it will be used as the advertised MSS. If it is negative, it will
9515 indicate by how much to reduce the incoming connection's advertised MSS for
9516 outgoing segments. This parameter is only compatible with TCP v4/v6 sockets.
9517
9518name <name>
9519 Sets an optional name for these sockets, which will be reported on the stats
9520 page.
9521
9522nice <nice>
9523 Sets the 'niceness' of connections initiated from the socket. Value must be
9524 in the range -1024..1024 inclusive, and defaults to zero. Positive values
9525 means that such connections are more friendly to others and easily offer
9526 their place in the scheduler. On the opposite, negative values mean that
9527 connections want to run with a higher priority than others. The difference
9528 only happens under high loads when the system is close to saturation.
9529 Negative values are appropriate for low-latency or administration services,
9530 and high values are generally recommended for CPU intensive tasks such as SSL
9531 processing or bulk transfers which are less sensible to latency. For example,
9532 it may make sense to use a positive value for an SMTP socket and a negative
9533 one for an RDP socket.
9534
Emeric Brun9b3009b2012-10-05 11:55:06 +02009535no-sslv3
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009536 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009537 disables support for SSLv3 on any sockets instantiated from the listener when
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009538 SSL is supported. Note that SSLv2 is forced disabled in the code and cannot
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009539 be enabled using any configuration option. This option is also available on
9540 global statement "ssl-default-bind-options". See also "force-tls*",
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009541 and "force-sslv3".
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009542
Emeric Brun90ad8722012-10-02 14:00:59 +02009543no-tls-tickets
9544 This setting is only available when support for OpenSSL was built in. It
9545 disables the stateless session resumption (RFC 5077 TLS Ticket
9546 extension) and force to use stateful session resumption. Stateless
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009547 session resumption is more expensive in CPU usage. This option is also
9548 available on global statement "ssl-default-bind-options".
Emeric Brun90ad8722012-10-02 14:00:59 +02009549
Emeric Brun9b3009b2012-10-05 11:55:06 +02009550no-tlsv10
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009551 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009552 disables support for TLSv1.0 on any sockets instantiated from the listener
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009553 when SSL is supported. Note that SSLv2 is forced disabled in the code and
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009554 cannot be enabled using any configuration option. This option is also
9555 available on global statement "ssl-default-bind-options". See also
9556 "force-tlsv*", and "force-sslv3".
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009557
Emeric Brun9b3009b2012-10-05 11:55:06 +02009558no-tlsv11
Emeric Brunf5da4932012-09-28 19:42:54 +02009559 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009560 disables support for TLSv1.1 on any sockets instantiated from the listener
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009561 when SSL is supported. Note that SSLv2 is forced disabled in the code and
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009562 cannot be enabled using any configuration option. This option is also
9563 available on global statement "ssl-default-bind-options". See also
9564 "force-tlsv*", and "force-sslv3".
Emeric Brunf5da4932012-09-28 19:42:54 +02009565
Emeric Brun9b3009b2012-10-05 11:55:06 +02009566no-tlsv12
Emeric Brunf5da4932012-09-28 19:42:54 +02009567 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009568 disables support for TLSv1.2 on any sockets instantiated from the listener
Emeric Brun2cb7ae52012-10-05 14:14:21 +02009569 when SSL is supported. Note that SSLv2 is forced disabled in the code and
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009570 cannot be enabled using any configuration option. This option is also
9571 available on global statement "ssl-default-bind-options". See also
9572 "force-tlsv*", and "force-sslv3".
Emeric Brunf5da4932012-09-28 19:42:54 +02009573
Willy Tarreau6c9a3d52012-10-18 18:57:14 +02009574npn <protocols>
9575 This enables the NPN TLS extension and advertises the specified protocol list
9576 as supported on top of NPN. The protocol list consists in a comma-delimited
9577 list of protocol names, for instance: "http/1.1,http/1.0" (without quotes).
9578 This requires that the SSL library is build with support for TLS extensions
Willy Tarreauab861d32013-04-02 02:30:41 +02009579 enabled (check with haproxy -vv). Note that the NPN extension has been
9580 replaced with the ALPN extension (see the "alpn" keyword).
Willy Tarreau6c9a3d52012-10-18 18:57:14 +02009581
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02009582process [ all | odd | even | <number 1-64>[-<number 1-64>] ]
9583 This restricts the list of processes on which this listener is allowed to
9584 run. It does not enforce any process but eliminates those which do not match.
9585 If the frontend uses a "bind-process" setting, the intersection between the
9586 two is applied. If in the end the listener is not allowed to run on any
9587 remaining process, a warning is emitted, and the listener will either run on
9588 the first process of the listener if a single process was specified, or on
9589 all of its processes if multiple processes were specified. For the unlikely
Willy Tarreauae302532014-05-07 19:22:24 +02009590 case where several ranges are needed, this directive may be repeated. The
9591 main purpose of this directive is to be used with the stats sockets and have
9592 one different socket per process. The second purpose is to have multiple bind
9593 lines sharing the same IP:port but not the same process in a listener, so
9594 that the system can distribute the incoming connections into multiple queues
9595 and allow a smoother inter-process load balancing. Currently Linux 3.9 and
9596 above is known for supporting this. See also "bind-process" and "nbproc".
Willy Tarreau6ae1ba62014-05-07 19:01:58 +02009597
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009598ssl
9599 This setting is only available when support for OpenSSL was built in. It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009600 enables SSL deciphering on connections instantiated from this listener. A
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009601 certificate is necessary (see "crt" above). All contents in the buffers will
9602 appear in clear text, so that ACLs and HTTP processing will only have access
9603 to deciphered contents.
9604
Emmanuel Hocdet65623372013-01-24 17:17:15 +01009605strict-sni
9606 This setting is only available when support for OpenSSL was built in. The
9607 SSL/TLS negotiation is allow only if the client provided an SNI which match
9608 a certificate. The default certificate is not used.
9609 See the "crt" option for more information.
9610
Willy Tarreau2af207a2015-02-04 00:45:58 +01009611tcp-ut <delay>
9612 Sets the TCP User Timeout for all incoming connections instanciated from this
9613 listening socket. This option is available on Linux since version 2.6.37. It
9614 allows haproxy to configure a timeout for sockets which contain data not
9615 receiving an acknoledgement for the configured delay. This is especially
9616 useful on long-lived connections experiencing long idle periods such as
9617 remote terminals or database connection pools, where the client and server
9618 timeouts must remain high to allow a long period of idle, but where it is
9619 important to detect that the client has disappeared in order to release all
9620 resources associated with its connection (and the server's session). The
9621 argument is a delay expressed in milliseconds by default. This only works
9622 for regular TCP connections, and is ignored for other protocols.
9623
Willy Tarreau1c862c52012-10-05 16:21:00 +02009624tfo
Lukas Tribus0defb902013-02-13 23:35:39 +01009625 Is an optional keyword which is supported only on Linux kernels >= 3.7. It
Willy Tarreau1c862c52012-10-05 16:21:00 +02009626 enables TCP Fast Open on the listening socket, which means that clients which
9627 support this feature will be able to send a request and receive a response
9628 during the 3-way handshake starting from second connection, thus saving one
9629 round-trip after the first connection. This only makes sense with protocols
9630 that use high connection rates and where each round trip matters. This can
9631 possibly cause issues with many firewalls which do not accept data on SYN
9632 packets, so this option should only be enabled once well tested. This option
Lukas Tribus0999f762013-04-02 16:43:24 +02009633 is only supported on TCPv4/TCPv6 sockets and ignored by other ones. You may
9634 need to build HAProxy with USE_TFO=1 if your libc doesn't define
9635 TCP_FASTOPEN.
Willy Tarreau1c862c52012-10-05 16:21:00 +02009636
Nenad Merdanovic188ad3e2015-02-27 19:56:50 +01009637tls-ticket-keys <keyfile>
9638 Sets the TLS ticket keys file to load the keys from. The keys need to be 48
9639 bytes long, encoded with base64 (ex. openssl rand -base64 48). Number of keys
9640 is specified by the TLS_TICKETS_NO build option (default 3) and at least as
9641 many keys need to be present in the file. Last TLS_TICKETS_NO keys will be
9642 used for decryption and the penultimate one for encryption. This enables easy
9643 key rotation by just appending new key to the file and reloading the process.
9644 Keys must be periodically rotated (ex. every 12h) or Perfect Forward Secrecy
9645 is compromised. It is also a good idea to keep the keys off any permanent
9646 storage such as hard drives (hint: use tmpfs and don't swap those files).
9647 Lifetime hint can be changed using tune.ssl.timeout.
9648
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009649transparent
9650 Is an optional keyword which is supported only on certain Linux kernels. It
9651 indicates that the addresses will be bound even if they do not belong to the
9652 local machine, and that packets targeting any of these addresses will be
9653 intercepted just as if the addresses were locally configured. This normally
9654 requires that IP forwarding is enabled. Caution! do not use this with the
9655 default address '*', as it would redirect any traffic for the specified port.
9656 This keyword is available only when HAProxy is built with USE_LINUX_TPROXY=1.
9657 This parameter is only compatible with TCPv4 and TCPv6 sockets, depending on
9658 kernel version. Some distribution kernels include backports of the feature,
9659 so check for support with your vendor.
9660
Willy Tarreau77e3af92012-11-24 15:07:23 +01009661v4v6
9662 Is an optional keyword which is supported only on most recent systems
9663 including Linux kernels >= 2.4.21. It is used to bind a socket to both IPv4
9664 and IPv6 when it uses the default address. Doing so is sometimes necessary
9665 on systems which bind to IPv6 only by default. It has no effect on non-IPv6
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009666 sockets, and is overridden by the "v6only" option.
Willy Tarreau77e3af92012-11-24 15:07:23 +01009667
Willy Tarreau9b6700f2012-11-24 11:55:28 +01009668v6only
9669 Is an optional keyword which is supported only on most recent systems
9670 including Linux kernels >= 2.4.21. It is used to bind a socket to IPv6 only
9671 when it uses the default address. Doing so is sometimes preferred to doing it
Willy Tarreau77e3af92012-11-24 15:07:23 +01009672 system-wide as it is per-listener. It has no effect on non-IPv6 sockets and
9673 has precedence over the "v4v6" option.
Willy Tarreau9b6700f2012-11-24 11:55:28 +01009674
Willy Tarreaub6205fd2012-09-24 12:27:33 +02009675uid <uid>
9676 Sets the owner of the UNIX sockets to the designated system uid. It can also
9677 be set by default in the global section's "unix-bind" statement. Note that
9678 some platforms simply ignore this. This setting is equivalent to the "user"
9679 setting except that the user numeric ID is used instead of its name. This
9680 setting is ignored by non UNIX sockets.
9681
9682user <user>
9683 Sets the owner of the UNIX sockets to the designated system user. It can also
9684 be set by default in the global section's "unix-bind" statement. Note that
9685 some platforms simply ignore this. This setting is equivalent to the "uid"
9686 setting except that the user name is used instead of its uid. This setting is
9687 ignored by non UNIX sockets.
9688
Emeric Brun1a073b42012-09-28 17:07:34 +02009689verify [none|optional|required]
9690 This setting is only available when support for OpenSSL was built in. If set
9691 to 'none', client certificate is not requested. This is the default. In other
9692 cases, a client certificate is requested. If the client does not provide a
9693 certificate after the request and if 'verify' is set to 'required', then the
9694 handshake is aborted, while it would have succeeded if set to 'optional'. The
Emeric Brunfd33a262012-10-11 16:28:27 +02009695 certificate provided by the client is always verified using CAs from
9696 'ca-file' and optional CRLs from 'crl-file'. On verify failure the handshake
9697 is aborted, regardless of the 'verify' option, unless the error code exactly
9698 matches one of those listed with 'ca-ignore-err' or 'crt-ignore-err'.
Willy Tarreau4a5cade2012-04-05 21:09:48 +02009699
Willy Tarreaub6205fd2012-09-24 12:27:33 +020097005.2. Server and default-server options
Cyril Bontéf0c60612010-02-06 14:44:47 +01009701------------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02009702
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01009703The "server" and "default-server" keywords support a certain number of settings
9704which are all passed as arguments on the server line. The order in which those
9705arguments appear does not count, and they are all optional. Some of those
9706settings are single words (booleans) while others expect one or several values
9707after them. In this case, the values must immediately follow the setting name.
9708Except default-server, all those settings must be specified after the server's
9709address if they are used:
Willy Tarreau6a06a402007-07-15 20:15:28 +02009710
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009711 server <name> <address>[:port] [settings ...]
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +01009712 default-server [settings ...]
Willy Tarreau6a06a402007-07-15 20:15:28 +02009713
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009714The currently supported settings are the following ones.
Willy Tarreau0ba27502007-12-24 16:55:16 +01009715
Willy Tarreauceb4ac92012-04-28 00:41:46 +02009716addr <ipv4|ipv6>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009717 Using the "addr" parameter, it becomes possible to use a different IP address
9718 to send health-checks. On some servers, it may be desirable to dedicate an IP
9719 address to specific component able to perform complex tests which are more
9720 suitable to health-checks than the application. This parameter is ignored if
9721 the "check" parameter is not set. See also the "port" parameter.
Willy Tarreau6a06a402007-07-15 20:15:28 +02009722
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009723 Supported in default-server: No
9724
Simon Hormand60d6912013-11-25 10:46:36 +09009725agent-check
9726 Enable an auxiliary agent check which is run independently of a regular
Willy Tarreau81f5d942013-12-09 20:51:51 +01009727 health check. An agent health check is performed by making a TCP connection
9728 to the port set by the "agent-port" parameter and reading an ASCII string.
9729 The string is made of a series of words delimited by spaces, tabs or commas
9730 in any order, optionally terminated by '\r' and/or '\n', each consisting of :
Simon Hormand60d6912013-11-25 10:46:36 +09009731
Willy Tarreau81f5d942013-12-09 20:51:51 +01009732 - An ASCII representation of a positive integer percentage, e.g. "75%".
Simon Hormand60d6912013-11-25 10:46:36 +09009733 Values in this format will set the weight proportional to the initial
Willy Tarreauc5af3a62014-10-07 15:27:33 +02009734 weight of a server as configured when haproxy starts. Note that a zero
9735 weight is reported on the stats page as "DRAIN" since it has the same
9736 effect on the server (it's removed from the LB farm).
Simon Hormand60d6912013-11-25 10:46:36 +09009737
Willy Tarreau81f5d942013-12-09 20:51:51 +01009738 - The word "ready". This will turn the server's administrative state to the
9739 READY mode, thus cancelling any DRAIN or MAINT state
Simon Hormand60d6912013-11-25 10:46:36 +09009740
Willy Tarreau81f5d942013-12-09 20:51:51 +01009741 - The word "drain". This will turn the server's administrative state to the
9742 DRAIN mode, thus it will not accept any new connections other than those
9743 that are accepted via persistence.
Simon Hormand60d6912013-11-25 10:46:36 +09009744
Willy Tarreau81f5d942013-12-09 20:51:51 +01009745 - The word "maint". This will turn the server's administrative state to the
9746 MAINT mode, thus it will not accept any new connections at all, and health
9747 checks will be stopped.
Simon Hormand60d6912013-11-25 10:46:36 +09009748
Willy Tarreau81f5d942013-12-09 20:51:51 +01009749 - The words "down", "failed", or "stopped", optionally followed by a
9750 description string after a sharp ('#'). All of these mark the server's
9751 operating state as DOWN, but since the word itself is reported on the stats
9752 page, the difference allows an administrator to know if the situation was
9753 expected or not : the service may intentionally be stopped, may appear up
9754 but fail some validity tests, or may be seen as down (eg: missing process,
9755 or port not responding).
Simon Hormand60d6912013-11-25 10:46:36 +09009756
Willy Tarreau81f5d942013-12-09 20:51:51 +01009757 - The word "up" sets back the server's operating state as UP if health checks
9758 also report that the service is accessible.
Simon Hormand60d6912013-11-25 10:46:36 +09009759
Willy Tarreau81f5d942013-12-09 20:51:51 +01009760 Parameters which are not advertised by the agent are not changed. For
9761 example, an agent might be designed to monitor CPU usage and only report a
9762 relative weight and never interact with the operating status. Similarly, an
9763 agent could be designed as an end-user interface with 3 radio buttons
9764 allowing an administrator to change only the administrative state. However,
9765 it is important to consider that only the agent may revert its own actions,
9766 so if a server is set to DRAIN mode or to DOWN state using the agent, the
9767 agent must implement the other equivalent actions to bring the service into
9768 operations again.
Simon Hormand60d6912013-11-25 10:46:36 +09009769
Simon Horman2f1f9552013-11-25 10:46:37 +09009770 Failure to connect to the agent is not considered an error as connectivity
9771 is tested by the regular health check which is enabled by the "check"
Willy Tarreau81f5d942013-12-09 20:51:51 +01009772 parameter. Warning though, it is not a good idea to stop an agent after it
9773 reports "down", since only an agent reporting "up" will be able to turn the
9774 server up again. Note that the CLI on the Unix stats socket is also able to
9775 force an agent's result in order to workaround a bogus agent if needed.
Simon Horman2f1f9552013-11-25 10:46:37 +09009776
Willy Tarreau81f5d942013-12-09 20:51:51 +01009777 Requires the "agent-port" parameter to be set. See also the "agent-inter"
9778 parameter.
Simon Hormand60d6912013-11-25 10:46:36 +09009779
9780 Supported in default-server: No
9781
9782agent-inter <delay>
9783 The "agent-inter" parameter sets the interval between two agent checks
9784 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
9785
9786 Just as with every other time-based parameter, it may be entered in any
9787 other explicit unit among { us, ms, s, m, h, d }. The "agent-inter"
9788 parameter also serves as a timeout for agent checks "timeout check" is
9789 not set. In order to reduce "resonance" effects when multiple servers are
9790 hosted on the same hardware, the agent and health checks of all servers
9791 are started with a small time offset between them. It is also possible to
9792 add some random noise in the agent and health checks interval using the
9793 global "spread-checks" keyword. This makes sense for instance when a lot
9794 of backends use the same servers.
9795
9796 See also the "agent-check" and "agent-port" parameters.
9797
9798 Supported in default-server: Yes
9799
9800agent-port <port>
9801 The "agent-port" parameter sets the TCP port used for agent checks.
9802
9803 See also the "agent-check" and "agent-inter" parameters.
9804
9805 Supported in default-server: Yes
9806
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009807backup
9808 When "backup" is present on a server line, the server is only used in load
9809 balancing when all other non-backup servers are unavailable. Requests coming
9810 with a persistence cookie referencing the server will always be served
9811 though. By default, only the first operational backup server is used, unless
9812 the "allbackups" option is set in the backend. See also the "allbackups"
9813 option.
Willy Tarreau6a06a402007-07-15 20:15:28 +02009814
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009815 Supported in default-server: No
9816
Emeric Brunef42d922012-10-11 16:11:36 +02009817ca-file <cafile>
9818 This setting is only available when support for OpenSSL was built in. It
9819 designates a PEM file from which to load CA certificates used to verify
9820 server's certificate.
9821
9822 Supported in default-server: No
9823
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009824check
9825 This option enables health checks on the server. By default, a server is
Patrick Mézardb7aeec62012-01-22 16:01:22 +01009826 always considered available. If "check" is set, the server is available when
9827 accepting periodic TCP connections, to ensure that it is really able to serve
9828 requests. The default address and port to send the tests to are those of the
9829 server, and the default source is the same as the one defined in the
9830 backend. It is possible to change the address using the "addr" parameter, the
9831 port using the "port" parameter, the source address using the "source"
9832 address, and the interval and timers using the "inter", "rise" and "fall"
Simon Hormanafc47ee2013-11-25 10:46:35 +09009833 parameters. The request method is define in the backend using the "httpchk",
9834 "smtpchk", "mysql-check", "pgsql-check" and "ssl-hello-chk" options. Please
9835 refer to those options and parameters for more information.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009836
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009837 Supported in default-server: No
9838
Willy Tarreau6c16adc2012-10-05 00:04:16 +02009839check-send-proxy
9840 This option forces emission of a PROXY protocol line with outgoing health
9841 checks, regardless of whether the server uses send-proxy or not for the
9842 normal traffic. By default, the PROXY protocol is enabled for health checks
9843 if it is already enabled for normal traffic and if no "port" nor "addr"
9844 directive is present. However, if such a directive is present, the
9845 "check-send-proxy" option needs to be used to force the use of the
9846 protocol. See also the "send-proxy" option for more information.
9847
9848 Supported in default-server: No
9849
Willy Tarreau763a95b2012-10-04 23:15:39 +02009850check-ssl
9851 This option forces encryption of all health checks over SSL, regardless of
9852 whether the server uses SSL or not for the normal traffic. This is generally
9853 used when an explicit "port" or "addr" directive is specified and SSL health
9854 checks are not inherited. It is important to understand that this option
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009855 inserts an SSL transport layer below the checks, so that a simple TCP connect
Willy Tarreau763a95b2012-10-04 23:15:39 +02009856 check becomes an SSL connect, which replaces the old ssl-hello-chk. The most
9857 common use is to send HTTPS checks by combining "httpchk" with SSL checks.
9858 All SSL settings are common to health checks and traffic (eg: ciphers).
9859 See the "ssl" option for more information.
9860
9861 Supported in default-server: No
9862
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009863ciphers <ciphers>
9864 This option sets the string describing the list of cipher algorithms that is
Jarno Huuskonen0e82b922014-04-12 18:22:19 +03009865 is negotiated during the SSL/TLS handshake with the server. The format of the
Willy Tarreaua0ee1d02012-09-10 09:01:23 +02009866 string is defined in "man 1 ciphers". When SSL is used to communicate with
9867 servers on the local network, it is common to see a weaker set of algorithms
9868 than what is used over the internet. Doing so reduces CPU usage on both the
9869 server and haproxy while still keeping it compatible with deployed software.
9870 Some algorithms such as RC4-SHA1 are reasonably cheap. If no security at all
9871 is needed and just connectivity, using DES can be appropriate.
9872
Willy Tarreau763a95b2012-10-04 23:15:39 +02009873 Supported in default-server: No
9874
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009875cookie <value>
9876 The "cookie" parameter sets the cookie value assigned to the server to
9877 <value>. This value will be checked in incoming requests, and the first
9878 operational server possessing the same value will be selected. In return, in
9879 cookie insertion or rewrite modes, this value will be assigned to the cookie
9880 sent to the client. There is nothing wrong in having several servers sharing
9881 the same cookie value, and it is in fact somewhat common between normal and
9882 backup servers. See also the "cookie" keyword in backend section.
9883
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009884 Supported in default-server: No
9885
Emeric Brunef42d922012-10-11 16:11:36 +02009886crl-file <crlfile>
9887 This setting is only available when support for OpenSSL was built in. It
9888 designates a PEM file from which to load certificate revocation list used
9889 to verify server's certificate.
9890
9891 Supported in default-server: No
9892
Emeric Bruna7aa3092012-10-26 12:58:00 +02009893crt <cert>
9894 This setting is only available when support for OpenSSL was built in.
9895 It designates a PEM file from which to load both a certificate and the
9896 associated private key. This file can be built by concatenating both PEM
9897 files into one. This certificate will be sent if the server send a client
9898 certificate request.
9899
9900 Supported in default-server: No
9901
Willy Tarreau96839092010-03-29 10:02:24 +02009902disabled
9903 The "disabled" keyword starts the server in the "disabled" state. That means
9904 that it is marked down in maintenance mode, and no connection other than the
9905 ones allowed by persist mode will reach it. It is very well suited to setup
9906 new servers, because normal traffic will never reach them, while it is still
9907 possible to test the service by making use of the force-persist mechanism.
9908
9909 Supported in default-server: No
9910
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009911error-limit <count>
Willy Tarreau983e01e2010-01-11 18:42:06 +01009912 If health observing is enabled, the "error-limit" parameter specifies the
9913 number of consecutive errors that triggers event selected by the "on-error"
9914 option. By default it is set to 10 consecutive errors.
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009915
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009916 Supported in default-server: Yes
9917
9918 See also the "check", "error-limit" and "on-error".
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +01009919
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009920fall <count>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009921 The "fall" parameter states that a server will be considered as dead after
9922 <count> consecutive unsuccessful health checks. This value defaults to 3 if
9923 unspecified. See also the "check", "inter" and "rise" parameters.
9924
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009925 Supported in default-server: Yes
9926
Emeric Brun8694b9a2012-10-05 14:39:07 +02009927force-sslv3
9928 This option enforces use of SSLv3 only when SSL is used to communicate with
9929 the server. SSLv3 is generally less expensive than the TLS counterparts for
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009930 high connection rates. This option is also available on global statement
9931 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009932
9933 Supported in default-server: No
9934
9935force-tlsv10
9936 This option enforces use of TLSv1.0 only when SSL is used to communicate with
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009937 the server. This option is also available on global statement
9938 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009939
9940 Supported in default-server: No
9941
9942force-tlsv11
9943 This option enforces use of TLSv1.1 only when SSL is used to communicate with
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009944 the server. This option is also available on global statement
9945 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009946
9947 Supported in default-server: No
9948
9949force-tlsv12
9950 This option enforces use of TLSv1.2 only when SSL is used to communicate with
Emeric Brun2c86cbf2014-10-30 15:56:50 +01009951 the server. This option is also available on global statement
9952 "ssl-default-server-options". See also "no-tlsv*", "no-sslv3".
Emeric Brun8694b9a2012-10-05 14:39:07 +02009953
9954 Supported in default-server: No
9955
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009956id <value>
Willy Tarreau53fb4ae2009-10-04 23:04:08 +02009957 Set a persistent ID for the server. This ID must be positive and unique for
9958 the proxy. An unused ID will automatically be assigned if unset. The first
9959 assigned value will be 1. This ID is currently only returned in statistics.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009960
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009961 Supported in default-server: No
9962
9963inter <delay>
9964fastinter <delay>
9965downinter <delay>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009966 The "inter" parameter sets the interval between two consecutive health checks
9967 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
9968 It is also possible to use "fastinter" and "downinter" to optimize delays
9969 between checks depending on the server state :
9970
9971 Server state | Interval used
9972 ---------------------------------+-----------------------------------------
9973 UP 100% (non-transitional) | "inter"
9974 ---------------------------------+-----------------------------------------
9975 Transitionally UP (going down), |
9976 Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise.
9977 or yet unchecked. |
9978 ---------------------------------+-----------------------------------------
9979 DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise.
9980 ---------------------------------+-----------------------------------------
Willy Tarreaud72758d2010-01-12 10:42:19 +01009981
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009982 Just as with every other time-based parameter, they can be entered in any
9983 other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also
9984 serves as a timeout for health checks sent to servers if "timeout check" is
9985 not set. In order to reduce "resonance" effects when multiple servers are
Simon Hormand60d6912013-11-25 10:46:36 +09009986 hosted on the same hardware, the agent and health checks of all servers
9987 are started with a small time offset between them. It is also possible to
9988 add some random noise in the agent and health checks interval using the
9989 global "spread-checks" keyword. This makes sense for instance when a lot
9990 of backends use the same servers.
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009991
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +01009992 Supported in default-server: Yes
9993
9994maxconn <maxconn>
Willy Tarreauc57f0e22009-05-10 13:12:33 +02009995 The "maxconn" parameter specifies the maximal number of concurrent
9996 connections that will be sent to this server. If the number of incoming
9997 concurrent requests goes higher than this value, they will be queued, waiting
9998 for a connection to be released. This parameter is very important as it can
9999 save fragile servers from going down under extreme loads. If a "minconn"
10000 parameter is specified, the limit becomes dynamic. The default value is "0"
10001 which means unlimited. See also the "minconn" and "maxqueue" parameters, and
10002 the backend's "fullconn" keyword.
10003
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010004 Supported in default-server: Yes
10005
10006maxqueue <maxqueue>
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010007 The "maxqueue" parameter specifies the maximal number of connections which
10008 will wait in the queue for this server. If this limit is reached, next
10009 requests will be redispatched to other servers instead of indefinitely
10010 waiting to be served. This will break persistence but may allow people to
10011 quickly re-log in when the server they try to connect to is dying. The
10012 default value is "0" which means the queue is unlimited. See also the
10013 "maxconn" and "minconn" parameters.
10014
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010015 Supported in default-server: Yes
10016
10017minconn <minconn>
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010018 When the "minconn" parameter is set, the maxconn limit becomes a dynamic
10019 limit following the backend's load. The server will always accept at least
10020 <minconn> connections, never more than <maxconn>, and the limit will be on
10021 the ramp between both values when the backend has less than <fullconn>
10022 concurrent connections. This makes it possible to limit the load on the
10023 server during normal loads, but push it further for important loads without
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010010024 overloading the server during exceptional loads. See also the "maxconn"
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010025 and "maxqueue" parameters, as well as the "fullconn" backend keyword.
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010010026
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010027 Supported in default-server: Yes
10028
Willy Tarreau2a3fb1c2015-02-05 16:47:07 +010010029no-ssl-reuse
10030 This option disables SSL session reuse when SSL is used to communicate with
10031 the server. It will force the server to perform a full handshake for every
10032 new connection. It's probably only useful for benchmarking, troubleshooting,
10033 and for paranoid users.
10034
10035 Supported in default-server: No
10036
Emeric Brun9b3009b2012-10-05 11:55:06 +020010037no-sslv3
Willy Tarreaua0ee1d02012-09-10 09:01:23 +020010038 This option disables support for SSLv3 when SSL is used to communicate with
10039 the server. Note that SSLv2 is disabled in the code and cannot be enabled
Emeric Brun8694b9a2012-10-05 14:39:07 +020010040 using any configuration option. See also "force-sslv3", "force-tlsv*".
Willy Tarreaua0ee1d02012-09-10 09:01:23 +020010041
Willy Tarreau763a95b2012-10-04 23:15:39 +020010042 Supported in default-server: No
10043
Emeric Brunf9c5c472012-10-11 15:28:34 +020010044no-tls-tickets
10045 This setting is only available when support for OpenSSL was built in. It
10046 disables the stateless session resumption (RFC 5077 TLS Ticket
10047 extension) and force to use stateful session resumption. Stateless
Emeric Brun2c86cbf2014-10-30 15:56:50 +010010048 session resumption is more expensive in CPU usage for servers. This option
10049 is also available on global statement "ssl-default-server-options".
Emeric Brunf9c5c472012-10-11 15:28:34 +020010050
10051 Supported in default-server: No
10052
Emeric Brun9b3009b2012-10-05 11:55:06 +020010053no-tlsv10
Emeric Brun8694b9a2012-10-05 14:39:07 +020010054 This option disables support for TLSv1.0 when SSL is used to communicate with
Emeric Brunf5da4932012-09-28 19:42:54 +020010055 the server. Note that SSLv2 is disabled in the code and cannot be enabled
10056 using any configuration option. TLSv1 is more expensive than SSLv3 so it
Emeric Brun2c86cbf2014-10-30 15:56:50 +010010057 often makes sense to disable it when communicating with local servers. This
10058 option is also available on global statement "ssl-default-server-options".
10059 See also "force-sslv3", "force-tlsv*".
Emeric Brunf5da4932012-09-28 19:42:54 +020010060
Willy Tarreau763a95b2012-10-04 23:15:39 +020010061 Supported in default-server: No
10062
Emeric Brun9b3009b2012-10-05 11:55:06 +020010063no-tlsv11
Emeric Brun8694b9a2012-10-05 14:39:07 +020010064 This option disables support for TLSv1.1 when SSL is used to communicate with
Emeric Brunf5da4932012-09-28 19:42:54 +020010065 the server. Note that SSLv2 is disabled in the code and cannot be enabled
10066 using any configuration option. TLSv1 is more expensive than SSLv3 so it
Emeric Brun2c86cbf2014-10-30 15:56:50 +010010067 often makes sense to disable it when communicating with local servers. This
10068 option is also available on global statement "ssl-default-server-options".
10069 See also "force-sslv3", "force-tlsv*".
Emeric Brunf5da4932012-09-28 19:42:54 +020010070
Willy Tarreau763a95b2012-10-04 23:15:39 +020010071 Supported in default-server: No
10072
Emeric Brun9b3009b2012-10-05 11:55:06 +020010073no-tlsv12
Emeric Brun8694b9a2012-10-05 14:39:07 +020010074 This option disables support for TLSv1.2 when SSL is used to communicate with
Willy Tarreaua0ee1d02012-09-10 09:01:23 +020010075 the server. Note that SSLv2 is disabled in the code and cannot be enabled
10076 using any configuration option. TLSv1 is more expensive than SSLv3 so it
Emeric Brun2c86cbf2014-10-30 15:56:50 +010010077 often makes sense to disable it when communicating with local servers. This
10078 option is also available on global statement "ssl-default-server-options".
10079 See also "force-sslv3", "force-tlsv*".
Willy Tarreaua0ee1d02012-09-10 09:01:23 +020010080
Willy Tarreau763a95b2012-10-04 23:15:39 +020010081 Supported in default-server: No
10082
Simon Hormanfa461682011-06-25 09:39:49 +090010083non-stick
10084 Never add connections allocated to this sever to a stick-table.
10085 This may be used in conjunction with backup to ensure that
10086 stick-table persistence is disabled for backup servers.
10087
Willy Tarreau763a95b2012-10-04 23:15:39 +020010088 Supported in default-server: No
10089
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010010090observe <mode>
10091 This option enables health adjusting based on observing communication with
10092 the server. By default this functionality is disabled and enabling it also
10093 requires to enable health checks. There are two supported modes: "layer4" and
10094 "layer7". In layer4 mode, only successful/unsuccessful tcp connections are
10095 significant. In layer7, which is only allowed for http proxies, responses
10096 received from server are verified, like valid/wrong http code, unparsable
Willy Tarreau150d1462012-03-10 08:19:02 +010010097 headers, a timeout, etc. Valid status codes include 100 to 499, 501 and 505.
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010010098
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010099 Supported in default-server: No
10100
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010010101 See also the "check", "on-error" and "error-limit".
10102
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010103on-error <mode>
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010010104 Select what should happen when enough consecutive errors are detected.
10105 Currently, four modes are available:
10106 - fastinter: force fastinter
10107 - fail-check: simulate a failed check, also forces fastinter (default)
10108 - sudden-death: simulate a pre-fatal failed health check, one more failed
10109 check will mark a server down, forces fastinter
10110 - mark-down: mark the server immediately down and force fastinter
10111
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010112 Supported in default-server: Yes
10113
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +010010114 See also the "check", "observe" and "error-limit".
10115
Simon Hormane0d1bfb2011-06-21 14:34:58 +090010116on-marked-down <action>
10117 Modify what occurs when a server is marked down.
10118 Currently one action is available:
Justin Karnegeseb2c24a2012-05-24 15:28:52 -070010119 - shutdown-sessions: Shutdown peer sessions. When this setting is enabled,
10120 all connections to the server are immediately terminated when the server
10121 goes down. It might be used if the health check detects more complex cases
10122 than a simple connection status, and long timeouts would cause the service
10123 to remain unresponsive for too long a time. For instance, a health check
10124 might detect that a database is stuck and that there's no chance to reuse
10125 existing connections anymore. Connections killed this way are logged with
10126 a 'D' termination code (for "Down").
Simon Hormane0d1bfb2011-06-21 14:34:58 +090010127
10128 Actions are disabled by default
10129
10130 Supported in default-server: Yes
10131
Justin Karnegeseb2c24a2012-05-24 15:28:52 -070010132on-marked-up <action>
10133 Modify what occurs when a server is marked up.
10134 Currently one action is available:
10135 - shutdown-backup-sessions: Shutdown sessions on all backup servers. This is
10136 done only if the server is not in backup state and if it is not disabled
10137 (it must have an effective weight > 0). This can be used sometimes to force
10138 an active server to take all the traffic back after recovery when dealing
10139 with long sessions (eg: LDAP, SQL, ...). Doing this can cause more trouble
10140 than it tries to solve (eg: incomplete transactions), so use this feature
10141 with extreme care. Sessions killed because a server comes up are logged
10142 with an 'U' termination code (for "Up").
10143
10144 Actions are disabled by default
10145
10146 Supported in default-server: Yes
10147
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010148port <port>
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010149 Using the "port" parameter, it becomes possible to use a different port to
10150 send health-checks. On some servers, it may be desirable to dedicate a port
10151 to a specific component able to perform complex tests which are more suitable
10152 to health-checks than the application. It is common to run a simple script in
10153 inetd for instance. This parameter is ignored if the "check" parameter is not
10154 set. See also the "addr" parameter.
10155
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010156 Supported in default-server: Yes
10157
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010158redir <prefix>
10159 The "redir" parameter enables the redirection mode for all GET and HEAD
10160 requests addressing this server. This means that instead of having HAProxy
10161 forward the request to the server, it will send an "HTTP 302" response with
10162 the "Location" header composed of this prefix immediately followed by the
10163 requested URI beginning at the leading '/' of the path component. That means
10164 that no trailing slash should be used after <prefix>. All invalid requests
10165 will be rejected, and all non-GET or HEAD requests will be normally served by
10166 the server. Note that since the response is completely forged, no header
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010010167 mangling nor cookie insertion is possible in the response. However, cookies in
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010168 requests are still analysed, making this solution completely usable to direct
10169 users to a remote location in case of local disaster. Main use consists in
10170 increasing bandwidth for static servers by having the clients directly
10171 connect to them. Note: never use a relative location here, it would cause a
10172 loop between the client and HAProxy!
10173
10174 Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check
10175
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010176 Supported in default-server: No
10177
10178rise <count>
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010179 The "rise" parameter states that a server will be considered as operational
10180 after <count> consecutive successful health checks. This value defaults to 2
10181 if unspecified. See also the "check", "inter" and "fall" parameters.
10182
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010183 Supported in default-server: Yes
10184
Baptiste Assmann1fa66662015-04-14 00:28:47 +020010185resolve-prefer <family>
10186 When DNS resolution is enabled for a server and multiple IP addresses from
10187 different families are returned, HAProxy will prefer using an IP address
10188 from the family mentioned in the "resolve-prefer" parameter.
10189 Available families: "ipv4" and "ipv6"
10190
Baptiste Assmannc4aabae2015-08-04 22:43:06 +020010191 Default value: ipv6
10192
10193 Supported in default-server: Yes
Baptiste Assmann1fa66662015-04-14 00:28:47 +020010194
10195 Example: server s1 app1.domain.com:80 resolvers mydns resolve-prefer ipv6
10196
10197resolvers <id>
10198 Points to an existing "resolvers" section to resolve current server's
10199 hostname.
10200
10201 Example: server s1 app1.domain.com:80 resolvers mydns
10202
10203 See also chapter 5.3
10204
Willy Tarreau5ab04ec2011-03-20 10:32:26 +010010205send-proxy
10206 The "send-proxy" parameter enforces use of the PROXY protocol over any
10207 connection established to this server. The PROXY protocol informs the other
10208 end about the layer 3/4 addresses of the incoming connection, so that it can
10209 know the client's address or the public address it accessed to, whatever the
10210 upper layer protocol. For connections accepted by an "accept-proxy" listener,
10211 the advertised address will be used. Only TCPv4 and TCPv6 address families
10212 are supported. Other families such as Unix sockets, will report an UNKNOWN
10213 family. Servers using this option can fully be chained to another instance of
10214 haproxy listening with an "accept-proxy" setting. This setting must not be
Willy Tarreau6c16adc2012-10-05 00:04:16 +020010215 used if the server isn't aware of the protocol. When health checks are sent
10216 to the server, the PROXY protocol is automatically used when this option is
10217 set, unless there is an explicit "port" or "addr" directive, in which case an
10218 explicit "check-send-proxy" directive would also be needed to use the PROXY
10219 protocol. See also the "accept-proxy" option of the "bind" keyword.
Willy Tarreau5ab04ec2011-03-20 10:32:26 +010010220
10221 Supported in default-server: No
10222
David Safb76832014-05-08 23:42:08 -040010223send-proxy-v2
10224 The "send-proxy-v2" parameter enforces use of the PROXY protocol version 2
10225 over any connection established to this server. The PROXY protocol informs
10226 the other end about the layer 3/4 addresses of the incoming connection, so
10227 that it can know the client's address or the public address it accessed to,
10228 whatever the upper layer protocol. This setting must not be used if the
10229 server isn't aware of this version of the protocol. See also the "send-proxy"
10230 option of the "bind" keyword.
10231
10232 Supported in default-server: No
10233
10234send-proxy-v2-ssl
10235 The "send-proxy-v2-ssl" parameter enforces use of the PROXY protocol version
10236 2 over any connection established to this server. The PROXY protocol informs
10237 the other end about the layer 3/4 addresses of the incoming connection, so
10238 that it can know the client's address or the public address it accessed to,
10239 whatever the upper layer protocol. In addition, the SSL information extension
10240 of the PROXY protocol is added to the PROXY protocol header. This setting
10241 must not be used if the server isn't aware of this version of the protocol.
10242 See also the "send-proxy-v2" option of the "bind" keyword.
10243
10244 Supported in default-server: No
10245
10246send-proxy-v2-ssl-cn
10247 The "send-proxy-v2-ssl" parameter enforces use of the PROXY protocol version
10248 2 over any connection established to this server. The PROXY protocol informs
10249 the other end about the layer 3/4 addresses of the incoming connection, so
10250 that it can know the client's address or the public address it accessed to,
10251 whatever the upper layer protocol. In addition, the SSL information extension
10252 of the PROXY protocol, along along with the Common Name from the subject of
10253 the client certificate (if any), is added to the PROXY protocol header. This
10254 setting must not be used if the server isn't aware of this version of the
10255 protocol. See also the "send-proxy-v2" option of the "bind" keyword.
10256
10257 Supported in default-server: No
10258
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010259slowstart <start_time_in_ms>
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010260 The "slowstart" parameter for a server accepts a value in milliseconds which
10261 indicates after how long a server which has just come back up will run at
10262 full speed. Just as with every other time-based parameter, it can be entered
10263 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
10264 linearly from 0 to 100% during this time. The limitation applies to two
10265 parameters :
10266
10267 - maxconn: the number of connections accepted by the server will grow from 1
10268 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
10269
10270 - weight: when the backend uses a dynamic weighted algorithm, the weight
10271 grows linearly from 1 to 100%. In this case, the weight is updated at every
10272 health-check. For this reason, it is important that the "inter" parameter
10273 is smaller than the "slowstart", in order to maximize the number of steps.
10274
10275 The slowstart never applies when haproxy starts, otherwise it would cause
10276 trouble to running servers. It only applies when a server has been previously
10277 seen as failed.
10278
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010279 Supported in default-server: Yes
10280
Willy Tarreau732eac42015-07-09 11:40:25 +020010281sni <expression>
10282 The "sni" parameter evaluates the sample fetch expression, converts it to a
10283 string and uses the result as the host name sent in the SNI TLS extension to
10284 the server. A typical use case is to send the SNI received from the client in
10285 a bridged HTTPS scenario, using the "ssl_fc_sni" sample fetch for the
10286 expression, though alternatives such as req.hdr(host) can also make sense.
10287
10288 Supported in default-server: no
10289
Willy Tarreauc6f4ce82009-06-10 11:09:37 +020010290source <addr>[:<pl>[-<ph>]] [usesrc { <addr2>[:<port2>] | client | clientip } ]
Willy Tarreaubce70882009-09-07 11:51:47 +020010291source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | hdr_ip(<hdr>[,<occ>]) } ]
Willy Tarreauc6f4ce82009-06-10 11:09:37 +020010292source <addr>[:<pl>[-<ph>]] [interface <name>] ...
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010293 The "source" parameter sets the source address which will be used when
10294 connecting to the server. It follows the exact same parameters and principle
10295 as the backend "source" keyword, except that it only applies to the server
10296 referencing it. Please consult the "source" keyword for details.
10297
Willy Tarreauc6f4ce82009-06-10 11:09:37 +020010298 Additionally, the "source" statement on a server line allows one to specify a
10299 source port range by indicating the lower and higher bounds delimited by a
10300 dash ('-'). Some operating systems might require a valid IP address when a
10301 source port range is specified. It is permitted to have the same IP/range for
10302 several servers. Doing so makes it possible to bypass the maximum of 64k
10303 total concurrent connections. The limit will then reach 64k connections per
10304 server.
10305
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010306 Supported in default-server: No
10307
Willy Tarreaua0ee1d02012-09-10 09:01:23 +020010308ssl
Willy Tarreau44f65392013-06-25 07:56:20 +020010309 This option enables SSL ciphering on outgoing connections to the server. It
10310 is critical to verify server certificates using "verify" when using SSL to
10311 connect to servers, otherwise the communication is prone to trivial man in
10312 the-middle attacks rendering SSL useless. When this option is used, health
10313 checks are automatically sent in SSL too unless there is a "port" or an
10314 "addr" directive indicating the check should be sent to a different location.
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030010315 See the "check-ssl" option to force SSL health checks.
Willy Tarreau763a95b2012-10-04 23:15:39 +020010316
10317 Supported in default-server: No
Willy Tarreaua0ee1d02012-09-10 09:01:23 +020010318
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010319track [<proxy>/]<server>
Willy Tarreau32091232014-05-16 13:52:00 +020010320 This option enables ability to set the current state of the server by tracking
10321 another one. It is possible to track a server which itself tracks another
10322 server, provided that at the end of the chain, a server has health checks
10323 enabled. If <proxy> is omitted the current one is used. If disable-on-404 is
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010324 used, it has to be enabled on both proxies.
10325
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010326 Supported in default-server: No
10327
Emeric Brunef42d922012-10-11 16:11:36 +020010328verify [none|required]
10329 This setting is only available when support for OpenSSL was built in. If set
Emeric Brun850efd52014-01-29 12:24:34 +010010330 to 'none', server certificate is not verified. In the other case, The
10331 certificate provided by the server is verified using CAs from 'ca-file'
10332 and optional CRLs from 'crl-file'. If 'ssl_server_verify' is not specified
10333 in global section, this is the default. On verify failure the handshake
Willy Tarreau44f65392013-06-25 07:56:20 +020010334 is aborted. It is critically important to verify server certificates when
10335 using SSL to connect to servers, otherwise the communication is prone to
10336 trivial man-in-the-middle attacks rendering SSL totally useless.
Emeric Brunef42d922012-10-11 16:11:36 +020010337
10338 Supported in default-server: No
10339
Evan Broderbe554312013-06-27 00:05:25 -070010340verifyhost <hostname>
10341 This setting is only available when support for OpenSSL was built in, and
10342 only takes effect if 'verify required' is also specified. When set, the
10343 hostnames in the subject and subjectAlternateNames of the certificate
10344 provided by the server are checked. If none of the hostnames in the
10345 certificate match the specified hostname, the handshake is aborted. The
10346 hostnames in the server-provided certificate may include wildcards.
10347
10348 Supported in default-server: No
10349
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010350weight <weight>
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010351 The "weight" parameter is used to adjust the server's weight relative to
10352 other servers. All servers will receive a load proportional to their weight
10353 relative to the sum of all weights, so the higher the weight, the higher the
Willy Tarreau6704d672009-06-15 10:56:05 +020010354 load. The default weight is 1, and the maximal value is 256. A value of 0
10355 means the server will not participate in load-balancing but will still accept
10356 persistent connections. If this parameter is used to distribute the load
10357 according to server's capacity, it is recommended to start with values which
10358 can both grow and shrink, for instance between 10 and 100 to leave enough
10359 room above and below for later adjustments.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010360
Krzysztof Piotr Oledzkic53601c2010-01-06 10:50:42 +010010361 Supported in default-server: Yes
10362
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010363
Cyril Bonté46175dd2015-07-02 22:45:32 +0200103645.3. Server IP address resolution using DNS
10365-------------------------------------------
Baptiste Assmann1fa66662015-04-14 00:28:47 +020010366
10367HAProxy allows using a host name to be resolved to find out what is the server
10368IP address. By default, HAProxy resolves the name when parsing the
10369configuration, at startup.
10370This is not sufficient in some cases, such as in Amazon where a server's IP
10371can change after a reboot or an ELB Virtual IP can change based on current
10372workload.
10373This chapter describes how HAProxy can be configured to process server's name
10374resolution at run time.
10375Whether run time server name resolution has been enable or not, HAProxy will
10376carry on doing the first resolution when parsing the configuration.
10377
10378
Cyril Bonté46175dd2015-07-02 22:45:32 +0200103795.3.1. Global overview
10380----------------------
Baptiste Assmann1fa66662015-04-14 00:28:47 +020010381
10382As we've seen in introduction, name resolution in HAProxy occurs at two
10383different steps of the process life:
10384
10385 1. when starting up, HAProxy parses the server line definition and matches a
10386 host name. It uses libc functions to get the host name resolved. This
10387 resolution relies on /etc/resolv.conf file.
10388
10389 2. at run time, when HAProxy gets prepared to run a health check on a server,
10390 it verifies if the current name resolution is still considered as valid.
10391 If not, it processes a new resolution, in parallel of the health check.
10392
10393A few other events can trigger a name resolution at run time:
10394 - when a server's health check ends up in a connection timeout: this may be
10395 because the server has a new IP address. So we need to trigger a name
10396 resolution to know this new IP.
10397
10398A few things important to notice:
10399 - all the name servers are queried in the mean time. HAProxy will process the
10400 first valid response.
10401
10402 - a resolution is considered as invalid (NX, timeout, refused), when all the
10403 servers return an error.
10404
10405
Cyril Bonté46175dd2015-07-02 22:45:32 +0200104065.3.2. The resolvers section
10407----------------------------
Baptiste Assmann1fa66662015-04-14 00:28:47 +020010408
10409This section is dedicated to host information related to name resolution in
10410HAProxy.
10411There can be as many as resolvers section as needed. Each section can contain
10412many name servers.
10413
10414resolvers <resolvers id>
10415 Creates a new name server list labelled <resolvers id>
10416
10417A resolvers section accept the following parameters:
10418
10419nameserver <id> <ip>:<port>
10420 DNS server description:
10421 <id> : label of the server, should be unique
10422 <ip> : IP address of the server
10423 <port> : port where the DNS service actually runs
10424
10425hold <status> <period>
10426 Defines <period> during which the last name resolution should be kept based
10427 on last resolution <status>
10428 <status> : last name resolution status. Only "valid" is accepted for now.
10429 <period> : interval between two successive name resolution when the last
10430 answer was in <status>. It follows the HAProxy time format.
10431 <period> is in milliseconds by default.
10432
10433 Default value is 10s for "valid".
10434
10435 Note: since the name resolution is triggered by the health checks, a new
10436 resolution is triggered after <period> modulo the <inter> parameter of
10437 the healch check.
10438
10439resolve_retries <nb>
10440 Defines the number <nb> of queries to send to resolve a server name before
10441 giving up.
10442 Default value: 3
10443
10444timeout <event> <time>
10445 Defines timeouts related to name resolution
10446 <event> : the event on which the <time> timeout period applies to.
10447 events available are:
10448 - retry: time between two DNS queries, when no response have
10449 been received.
10450 Default value: 1s
10451 <time> : time related to the event. It follows the HAProxy time format.
10452 <time> is expressed in milliseconds.
10453
10454Example of a resolvers section (with default values):
10455
10456 resolvers mydns
10457 nameserver dns1 10.0.0.1:53
10458 nameserver dns2 10.0.0.2:53
10459 resolve_retries 3
10460 timeout retry 1s
10461 hold valid 10s
10462
10463
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200104646. HTTP header manipulation
10465---------------------------
10466
10467In HTTP mode, it is possible to rewrite, add or delete some of the request and
10468response headers based on regular expressions. It is also possible to block a
10469request or a response if a particular header matches a regular expression,
10470which is enough to stop most elementary protocol attacks, and to protect
Willy Tarreau70dffda2014-01-30 03:07:23 +010010471against information leak from the internal network.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010472
Willy Tarreau70dffda2014-01-30 03:07:23 +010010473If HAProxy encounters an "Informational Response" (status code 1xx), it is able
10474to process all rsp* rules which can allow, deny, rewrite or delete a header,
10475but it will refuse to add a header to any such messages as this is not
10476HTTP-compliant. The reason for still processing headers in such responses is to
10477stop and/or fix any possible information leak which may happen, for instance
10478because another downstream equipment would unconditionally add a header, or if
10479a server name appears there. When such messages are seen, normal processing
10480still occurs on the next non-informational messages.
Willy Tarreau816b9792009-09-15 21:25:21 +020010481
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010482This section covers common usage of the following keywords, described in detail
10483in section 4.2 :
10484
10485 - reqadd <string>
10486 - reqallow <search>
10487 - reqiallow <search>
10488 - reqdel <search>
10489 - reqidel <search>
10490 - reqdeny <search>
10491 - reqideny <search>
10492 - reqpass <search>
10493 - reqipass <search>
10494 - reqrep <search> <replace>
10495 - reqirep <search> <replace>
10496 - reqtarpit <search>
10497 - reqitarpit <search>
10498 - rspadd <string>
10499 - rspdel <search>
10500 - rspidel <search>
10501 - rspdeny <search>
10502 - rspideny <search>
10503 - rsprep <search> <replace>
10504 - rspirep <search> <replace>
10505
10506With all these keywords, the same conventions are used. The <search> parameter
10507is a POSIX extended regular expression (regex) which supports grouping through
10508parenthesis (without the backslash). Spaces and other delimiters must be
10509prefixed with a backslash ('\') to avoid confusion with a field delimiter.
10510Other characters may be prefixed with a backslash to change their meaning :
10511
10512 \t for a tab
10513 \r for a carriage return (CR)
10514 \n for a new line (LF)
10515 \ to mark a space and differentiate it from a delimiter
10516 \# to mark a sharp and differentiate it from a comment
10517 \\ to use a backslash in a regex
10518 \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy)
10519 \xXX to write the ASCII hex code XX as in the C language
10520
10521The <replace> parameter contains the string to be used to replace the largest
10522portion of text matching the regex. It can make use of the special characters
10523above, and can reference a substring which is delimited by parenthesis in the
10524regex, by writing a backslash ('\') immediately followed by one digit from 0 to
105259 indicating the group position (0 designating the entire line). This practice
10526is very common to users of the "sed" program.
10527
10528The <string> parameter represents the string which will systematically be added
10529after the last header line. It can also use special character sequences above.
10530
10531Notes related to these keywords :
10532---------------------------------
10533 - these keywords are not always convenient to allow/deny based on header
10534 contents. It is strongly recommended to use ACLs with the "block" keyword
10535 instead, resulting in far more flexible and manageable rules.
10536
10537 - lines are always considered as a whole. It is not possible to reference
10538 a header name only or a value only. This is important because of the way
10539 headers are written (notably the number of spaces after the colon).
10540
10541 - the first line is always considered as a header, which makes it possible to
10542 rewrite or filter HTTP requests URIs or response codes, but in turn makes
10543 it harder to distinguish between headers and request line. The regex prefix
10544 ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix
10545 ^[^ \t:]*: matches any header name followed by a colon.
10546
10547 - for performances reasons, the number of characters added to a request or to
10548 a response is limited at build time to values between 1 and 4 kB. This
10549 should normally be far more than enough for most usages. If it is too short
10550 on occasional usages, it is possible to gain some space by removing some
10551 useless headers before adding new ones.
10552
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010010553 - keywords beginning with "reqi" and "rspi" are the same as their counterpart
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010554 without the 'i' letter except that they ignore case when matching patterns.
10555
10556 - when a request passes through a frontend then a backend, all req* rules
10557 from the frontend will be evaluated, then all req* rules from the backend
10558 will be evaluated. The reverse path is applied to responses.
10559
10560 - req* statements are applied after "block" statements, so that "block" is
10561 always the first one, but before "use_backend" in order to permit rewriting
Willy Tarreaud72758d2010-01-12 10:42:19 +010010562 before switching.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010563
10564
Willy Tarreau74ca5042013-06-11 23:12:07 +0200105657. Using ACLs and fetching samples
10566----------------------------------
10567
10568Haproxy is capable of extracting data from request or response streams, from
10569client or server information, from tables, environmental information etc...
10570The action of extracting such data is called fetching a sample. Once retrieved,
10571these samples may be used for various purposes such as a key to a stick-table,
10572but most common usages consist in matching them against predefined constant
10573data called patterns.
10574
10575
105767.1. ACL basics
10577---------------
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010578
10579The use of Access Control Lists (ACL) provides a flexible solution to perform
10580content switching and generally to take decisions based on content extracted
10581from the request, the response or any environmental status. The principle is
10582simple :
10583
Willy Tarreau74ca5042013-06-11 23:12:07 +020010584 - extract a data sample from a stream, table or the environment
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010585 - optionally apply some format conversion to the extracted sample
Willy Tarreau74ca5042013-06-11 23:12:07 +020010586 - apply one or multiple pattern matching methods on this sample
10587 - perform actions only when a pattern matches the sample
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010588
Willy Tarreau74ca5042013-06-11 23:12:07 +020010589The actions generally consist in blocking a request, selecting a backend, or
10590adding a header.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010591
10592In order to define a test, the "acl" keyword is used. The syntax is :
10593
Willy Tarreau74ca5042013-06-11 23:12:07 +020010594 acl <aclname> <criterion> [flags] [operator] [<value>] ...
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010595
10596This creates a new ACL <aclname> or completes an existing one with new tests.
10597Those tests apply to the portion of request/response specified in <criterion>
10598and may be adjusted with optional flags [flags]. Some criteria also support
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010599an operator which may be specified before the set of values. Optionally some
10600conversion operators may be applied to the sample, and they will be specified
10601as a comma-delimited list of keywords just after the first keyword. The values
10602are of the type supported by the criterion, and are separated by spaces.
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010603
10604ACL names must be formed from upper and lower case letters, digits, '-' (dash),
10605'_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive,
10606which means that "my_acl" and "My_Acl" are two different ACLs.
10607
10608There is no enforced limit to the number of ACLs. The unused ones do not affect
10609performance, they just consume a small amount of memory.
10610
Willy Tarreau74ca5042013-06-11 23:12:07 +020010611The criterion generally is the name of a sample fetch method, or one of its ACL
10612specific declinations. The default test method is implied by the output type of
10613this sample fetch method. The ACL declinations can describe alternate matching
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010614methods of a same sample fetch method. The sample fetch methods are the only
10615ones supporting a conversion.
Willy Tarreau74ca5042013-06-11 23:12:07 +020010616
10617Sample fetch methods return data which can be of the following types :
10618 - boolean
10619 - integer (signed or unsigned)
10620 - IPv4 or IPv6 address
10621 - string
10622 - data block
10623
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010624Converters transform any of these data into any of these. For example, some
10625converters might convert a string to a lower-case string while other ones
10626would turn a string to an IPv4 address, or apply a netmask to an IP address.
10627The resulting sample is of the type of the last converter applied to the list,
10628which defaults to the type of the sample fetch method.
10629
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010630Each sample or converter returns data of a specific type, specified with its
10631keyword in this documentation. When an ACL is declared using a standard sample
10632fetch method, certain types automatically involved a default matching method
10633which are summarized in the table below :
10634
10635 +---------------------+-----------------+
10636 | Sample or converter | Default |
10637 | output type | matching method |
10638 +---------------------+-----------------+
10639 | boolean | bool |
10640 +---------------------+-----------------+
10641 | integer | int |
10642 +---------------------+-----------------+
10643 | ip | ip |
10644 +---------------------+-----------------+
10645 | string | str |
10646 +---------------------+-----------------+
10647 | binary | none, use "-m" |
10648 +---------------------+-----------------+
10649
10650Note that in order to match a binary samples, it is mandatory to specify a
10651matching method, see below.
10652
Willy Tarreau74ca5042013-06-11 23:12:07 +020010653The ACL engine can match these types against patterns of the following types :
10654 - boolean
10655 - integer or integer range
10656 - IP address / network
10657 - string (exact, substring, suffix, prefix, subdir, domain)
10658 - regular expression
10659 - hex block
10660
Willy Tarreauc57f0e22009-05-10 13:12:33 +020010661The following ACL flags are currently supported :
10662
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010663 -i : ignore case during matching of all subsequent patterns.
10664 -f : load patterns from a file.
Willy Tarreau74ca5042013-06-11 23:12:07 +020010665 -m : use a specific pattern matching method
Thierry FOURNIERb7729c92014-02-11 16:24:41 +010010666 -n : forbid the DNS resolutions
Thierry FOURNIER9860c412014-01-29 14:23:29 +010010667 -M : load the file pointed by -f like a map file.
Thierry FOURNIER3534d882014-01-20 17:01:44 +010010668 -u : force the unique id of the ACL
Willy Tarreau6a06a402007-07-15 20:15:28 +020010669 -- : force end of flags. Useful when a string looks like one of the flags.
10670
Willy Tarreau74ca5042013-06-11 23:12:07 +020010671The "-f" flag is followed by the name of a file from which all lines will be
10672read as individual values. It is even possible to pass multiple "-f" arguments
10673if the patterns are to be loaded from multiple files. Empty lines as well as
10674lines beginning with a sharp ('#') will be ignored. All leading spaces and tabs
10675will be stripped. If it is absolutely necessary to insert a valid pattern
10676beginning with a sharp, just prefix it with a space so that it is not taken for
10677a comment. Depending on the data type and match method, haproxy may load the
10678lines into a binary tree, allowing very fast lookups. This is true for IPv4 and
10679exact string matching. In this case, duplicates will automatically be removed.
10680
Thierry FOURNIER9860c412014-01-29 14:23:29 +010010681The "-M" flag allows an ACL to use a map file. If this flag is set, the file is
10682parsed as two column file. The first column contains the patterns used by the
10683ACL, and the second column contain the samples. The sample can be used later by
10684a map. This can be useful in some rare cases where an ACL would just be used to
10685check for the existence of a pattern in a map before a mapping is applied.
10686
Thierry FOURNIER3534d882014-01-20 17:01:44 +010010687The "-u" flag forces the unique id of the ACL. This unique id is used with the
10688socket interface to identify ACL and dynamically change its values. Note that a
10689file is always identified by its name even if an id is set.
10690
Willy Tarreau74ca5042013-06-11 23:12:07 +020010691Also, note that the "-i" flag applies to subsequent entries and not to entries
10692loaded from files preceding it. For instance :
10693
10694 acl valid-ua hdr(user-agent) -f exact-ua.lst -i -f generic-ua.lst test
10695
10696In this example, each line of "exact-ua.lst" will be exactly matched against
10697the "user-agent" header of the request. Then each line of "generic-ua" will be
10698case-insensitively matched. Then the word "test" will be insensitively matched
10699as well.
10700
10701The "-m" flag is used to select a specific pattern matching method on the input
10702sample. All ACL-specific criteria imply a pattern matching method and generally
10703do not need this flag. However, this flag is useful with generic sample fetch
10704methods to describe how they're going to be matched against the patterns. This
10705is required for sample fetches which return data type for which there is no
10706obvious matching method (eg: string or binary). When "-m" is specified and
10707followed by a pattern matching method name, this method is used instead of the
10708default one for the criterion. This makes it possible to match contents in ways
10709that were not initially planned, or with sample fetch methods which return a
10710string. The matching method also affects the way the patterns are parsed.
10711
Thierry FOURNIERb7729c92014-02-11 16:24:41 +010010712The "-n" flag forbids the dns resolutions. It is used with the load of ip files.
10713By default, if the parser cannot parse ip address it considers that the parsed
10714string is maybe a domain name and try dns resolution. The flag "-n" disable this
10715resolution. It is useful for detecting malformed ip lists. Note that if the DNS
10716server is not reachable, the haproxy configuration parsing may last many minutes
10717waiting fir the timeout. During this time no error messages are displayed. The
10718flag "-n" disable this behavior. Note also that during the runtime, this
10719function is disabled for the dynamic acl modifications.
10720
Willy Tarreau74ca5042013-06-11 23:12:07 +020010721There are some restrictions however. Not all methods can be used with all
10722sample fetch methods. Also, if "-m" is used in conjunction with "-f", it must
10723be placed first. The pattern matching method must be one of the following :
Willy Tarreau5adeda12013-03-31 22:13:34 +020010724
10725 - "found" : only check if the requested sample could be found in the stream,
10726 but do not compare it against any pattern. It is recommended not
Willy Tarreau74ca5042013-06-11 23:12:07 +020010727 to pass any pattern to avoid confusion. This matching method is
10728 particularly useful to detect presence of certain contents such
10729 as headers, cookies, etc... even if they are empty and without
10730 comparing them to anything nor counting them.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010731
10732 - "bool" : check the value as a boolean. It can only be applied to fetches
10733 which return a boolean or integer value, and takes no pattern.
Willy Tarreau74ca5042013-06-11 23:12:07 +020010734 Value zero or false does not match, all other values do match.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010735
10736 - "int" : match the value as an integer. It can be used with integer and
Willy Tarreau74ca5042013-06-11 23:12:07 +020010737 boolean samples. Boolean false is integer 0, true is integer 1.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010738
10739 - "ip" : match the value as an IPv4 or IPv6 address. It is compatible
Willy Tarreau74ca5042013-06-11 23:12:07 +020010740 with IP address samples only, so it is implied and never needed.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010741
10742 - "bin" : match the contents against an hexadecimal string representing a
10743 binary sequence. This may be used with binary or string samples.
10744
10745 - "len" : match the sample's length as an integer. This may be used with
10746 binary or string samples.
10747
Willy Tarreau74ca5042013-06-11 23:12:07 +020010748 - "str" : exact match : match the contents against a string. This may be
10749 used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010750
Willy Tarreau74ca5042013-06-11 23:12:07 +020010751 - "sub" : substring match : check that the contents contain at least one of
10752 the provided string patterns. This may be used with binary or
10753 string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010754
Willy Tarreau74ca5042013-06-11 23:12:07 +020010755 - "reg" : regex match : match the contents against a list of regular
10756 expressions. This may be used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010757
Willy Tarreau74ca5042013-06-11 23:12:07 +020010758 - "beg" : prefix match : check that the contents begin like the provided
10759 string patterns. This may be used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010760
Willy Tarreau74ca5042013-06-11 23:12:07 +020010761 - "end" : suffix match : check that the contents end like the provided
10762 string patterns. This may be used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010763
Willy Tarreau74ca5042013-06-11 23:12:07 +020010764 - "dir" : subdir match : check that a slash-delimited portion of the
10765 contents exactly matches one of the provided string patterns.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010766 This may be used with binary or string samples.
10767
Willy Tarreau74ca5042013-06-11 23:12:07 +020010768 - "dom" : domain match : check that a dot-delimited portion of the contents
10769 exactly match one of the provided string patterns. This may be
10770 used with binary or string samples.
Willy Tarreau5adeda12013-03-31 22:13:34 +020010771
10772For example, to quickly detect the presence of cookie "JSESSIONID" in an HTTP
10773request, it is possible to do :
10774
10775 acl jsess_present cook(JSESSIONID) -m found
10776
10777In order to apply a regular expression on the 500 first bytes of data in the
10778buffer, one would use the following acl :
10779
10780 acl script_tag payload(0,500) -m reg -i <script>
10781
Willy Tarreaue6b11e42013-11-26 19:02:32 +010010782On systems where the regex library is much slower when using "-i", it is
10783possible to convert the sample to lowercase before matching, like this :
10784
10785 acl script_tag payload(0,500),lower -m reg <script>
10786
Willy Tarreau74ca5042013-06-11 23:12:07 +020010787All ACL-specific criteria imply a default matching method. Most often, these
10788criteria are composed by concatenating the name of the original sample fetch
10789method and the matching method. For example, "hdr_beg" applies the "beg" match
10790to samples retrieved using the "hdr" fetch method. Since all ACL-specific
10791criteria rely on a sample fetch method, it is always possible instead to use
10792the original sample fetch method and the explicit matching method using "-m".
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010793
Willy Tarreau74ca5042013-06-11 23:12:07 +020010794If an alternate match is specified using "-m" on an ACL-specific criterion,
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030010795the matching method is simply applied to the underlying sample fetch method.
10796For example, all ACLs below are exact equivalent :
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010797
Willy Tarreau74ca5042013-06-11 23:12:07 +020010798 acl short_form hdr_beg(host) www.
10799 acl alternate1 hdr_beg(host) -m beg www.
10800 acl alternate2 hdr_dom(host) -m beg www.
10801 acl alternate3 hdr(host) -m beg www.
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010802
Willy Tarreau2b5285d2010-05-09 23:45:24 +020010803
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010804The table below summarizes the compatibility matrix between sample or converter
10805types and the pattern types to fetch against. It indicates for each compatible
10806combination the name of the matching method to be used, surrounded with angle
10807brackets ">" and "<" when the method is the default one and will work by
10808default without "-m".
Willy Tarreau0ba27502007-12-24 16:55:16 +010010809
Willy Tarreau74ca5042013-06-11 23:12:07 +020010810 +-------------------------------------------------+
10811 | Input sample type |
10812 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010813 | pattern type | boolean | integer | ip | string | binary |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010814 +----------------------+---------+---------+---------+---------+---------+
10815 | none (presence only) | found | found | found | found | found |
10816 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010817 | none (boolean value) |> bool <| bool | | bool | |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010818 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010819 | integer (value) | int |> int <| int | int | |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010820 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010821 | integer (length) | len | len | len | len | len |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010822 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010823 | IP address | | |> ip <| ip | ip |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010824 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIER2a06e392014-05-11 15:49:55 +020010825 | exact string | str | str | str |> str <| str |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010826 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010827 | prefix | beg | beg | beg | beg | beg |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010828 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010829 | suffix | end | end | end | end | end |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010830 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010831 | substring | sub | sub | sub | sub | sub |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010832 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010833 | subdir | dir | dir | dir | dir | dir |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010834 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010835 | domain | dom | dom | dom | dom | dom |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010836 +----------------------+---------+---------+---------+---------+---------+
Thierry FOURNIERe3ded592013-12-06 15:36:54 +010010837 | regex | reg | reg | reg | reg | reg |
Willy Tarreau74ca5042013-06-11 23:12:07 +020010838 +----------------------+---------+---------+---------+---------+---------+
10839 | hex block | | | | bin | bin |
10840 +----------------------+---------+---------+---------+---------+---------+
Willy Tarreau6a06a402007-07-15 20:15:28 +020010841
10842
Willy Tarreau74ca5042013-06-11 23:12:07 +0200108437.1.1. Matching booleans
10844------------------------
10845
10846In order to match a boolean, no value is needed and all values are ignored.
10847Boolean matching is used by default for all fetch methods of type "boolean".
10848When boolean matching is used, the fetched value is returned as-is, which means
10849that a boolean "true" will always match and a boolean "false" will never match.
10850
10851Boolean matching may also be enforced using "-m bool" on fetch methods which
10852return an integer value. Then, integer value 0 is converted to the boolean
10853"false" and all other values are converted to "true".
10854
Willy Tarreau6a06a402007-07-15 20:15:28 +020010855
Willy Tarreau74ca5042013-06-11 23:12:07 +0200108567.1.2. Matching integers
10857------------------------
10858
10859Integer matching applies by default to integer fetch methods. It can also be
10860enforced on boolean fetches using "-m int". In this case, "false" is converted
10861to the integer 0, and "true" is converted to the integer 1.
10862
10863Integer matching also supports integer ranges and operators. Note that integer
10864matching only applies to positive values. A range is a value expressed with a
10865lower and an upper bound separated with a colon, both of which may be omitted.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010866
10867For instance, "1024:65535" is a valid range to represent a range of
10868unprivileged ports, and "1024:" would also work. "0:1023" is a valid
10869representation of privileged ports, and ":1023" would also work.
10870
Willy Tarreau62644772008-07-16 18:36:06 +020010871As a special case, some ACL functions support decimal numbers which are in fact
10872two integers separated by a dot. This is used with some version checks for
10873instance. All integer properties apply to those decimal numbers, including
10874ranges and operators.
10875
Willy Tarreau6a06a402007-07-15 20:15:28 +020010876For an easier usage, comparison operators are also supported. Note that using
Willy Tarreau0ba27502007-12-24 16:55:16 +010010877operators with ranges does not make much sense and is strongly discouraged.
10878Similarly, it does not make much sense to perform order comparisons with a set
10879of values.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010880
Willy Tarreau0ba27502007-12-24 16:55:16 +010010881Available operators for integer matching are :
Willy Tarreau6a06a402007-07-15 20:15:28 +020010882
10883 eq : true if the tested value equals at least one value
10884 ge : true if the tested value is greater than or equal to at least one value
10885 gt : true if the tested value is greater than at least one value
10886 le : true if the tested value is less than or equal to at least one value
10887 lt : true if the tested value is less than at least one value
10888
Willy Tarreau0ba27502007-12-24 16:55:16 +010010889For instance, the following ACL matches any negative Content-Length header :
Willy Tarreau6a06a402007-07-15 20:15:28 +020010890
10891 acl negative-length hdr_val(content-length) lt 0
10892
Willy Tarreau62644772008-07-16 18:36:06 +020010893This one matches SSL versions between 3.0 and 3.1 (inclusive) :
10894
10895 acl sslv3 req_ssl_ver 3:3.1
10896
Willy Tarreau6a06a402007-07-15 20:15:28 +020010897
Willy Tarreau74ca5042013-06-11 23:12:07 +0200108987.1.3. Matching strings
10899-----------------------
10900
10901String matching applies to string or binary fetch methods, and exists in 6
10902different forms :
10903
10904 - exact match (-m str) : the extracted string must exactly match the
10905 patterns ;
10906
10907 - substring match (-m sub) : the patterns are looked up inside the
10908 extracted string, and the ACL matches if any of them is found inside ;
10909
10910 - prefix match (-m beg) : the patterns are compared with the beginning of
10911 the extracted string, and the ACL matches if any of them matches.
10912
10913 - suffix match (-m end) : the patterns are compared with the end of the
10914 extracted string, and the ACL matches if any of them matches.
10915
10916 - subdir match (-m sub) : the patterns are looked up inside the extracted
10917 string, delimited with slashes ("/"), and the ACL matches if any of them
10918 matches.
10919
10920 - domain match (-m dom) : the patterns are looked up inside the extracted
10921 string, delimited with dots ("."), and the ACL matches if any of them
10922 matches.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010923
10924String matching applies to verbatim strings as they are passed, with the
10925exception of the backslash ("\") which makes it possible to escape some
10926characters such as the space. If the "-i" flag is passed before the first
10927string, then the matching will be performed ignoring the case. In order
10928to match the string "-i", either set it second, or pass the "--" flag
Willy Tarreau0ba27502007-12-24 16:55:16 +010010929before the first string. Same applies of course to match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +020010930
10931
Willy Tarreau74ca5042013-06-11 23:12:07 +0200109327.1.4. Matching regular expressions (regexes)
10933---------------------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +020010934
10935Just like with string matching, regex matching applies to verbatim strings as
10936they are passed, with the exception of the backslash ("\") which makes it
10937possible to escape some characters such as the space. If the "-i" flag is
10938passed before the first regex, then the matching will be performed ignoring
10939the case. In order to match the string "-i", either set it second, or pass
Willy Tarreau0ba27502007-12-24 16:55:16 +010010940the "--" flag before the first string. Same principle applies of course to
10941match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +020010942
10943
Willy Tarreau74ca5042013-06-11 23:12:07 +0200109447.1.5. Matching arbitrary data blocks
10945-------------------------------------
10946
10947It is possible to match some extracted samples against a binary block which may
10948not safely be represented as a string. For this, the patterns must be passed as
10949a series of hexadecimal digits in an even number, when the match method is set
10950to binary. Each sequence of two digits will represent a byte. The hexadecimal
10951digits may be used upper or lower case.
10952
10953Example :
10954 # match "Hello\n" in the input stream (\x48 \x65 \x6c \x6c \x6f \x0a)
10955 acl hello payload(0,6) -m bin 48656c6c6f0a
10956
10957
109587.1.6. Matching IPv4 and IPv6 addresses
10959---------------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +020010960
10961IPv4 addresses values can be specified either as plain addresses or with a
10962netmask appended, in which case the IPv4 address matches whenever it is
10963within the network. Plain addresses may also be replaced with a resolvable
Willy Tarreaud2a4aa22008-01-31 15:28:22 +010010964host name, but this practice is generally discouraged as it makes it more
Willy Tarreau0ba27502007-12-24 16:55:16 +010010965difficult to read and debug configurations. If hostnames are used, you should
10966at least ensure that they are present in /etc/hosts so that the configuration
10967does not depend on any random DNS match at the moment the configuration is
10968parsed.
Willy Tarreau6a06a402007-07-15 20:15:28 +020010969
Willy Tarreauceb4ac92012-04-28 00:41:46 +020010970IPv6 may be entered in their usual form, with or without a netmask appended.
10971Only bit counts are accepted for IPv6 netmasks. In order to avoid any risk of
10972trouble with randomly resolved IP addresses, host names are never allowed in
10973IPv6 patterns.
10974
10975HAProxy is also able to match IPv4 addresses with IPv6 addresses in the
10976following situations :
10977 - tested address is IPv4, pattern address is IPv4, the match applies
10978 in IPv4 using the supplied mask if any.
10979 - tested address is IPv6, pattern address is IPv6, the match applies
10980 in IPv6 using the supplied mask if any.
10981 - tested address is IPv6, pattern address is IPv4, the match applies in IPv4
10982 using the pattern's mask if the IPv6 address matches with 2002:IPV4::,
10983 ::IPV4 or ::ffff:IPV4, otherwise it fails.
10984 - tested address is IPv4, pattern address is IPv6, the IPv4 address is first
10985 converted to IPv6 by prefixing ::ffff: in front of it, then the match is
10986 applied in IPv6 using the supplied IPv6 mask.
10987
Willy Tarreau74ca5042013-06-11 23:12:07 +020010988
109897.2. Using ACLs to form conditions
10990----------------------------------
10991
10992Some actions are only performed upon a valid condition. A condition is a
10993combination of ACLs with operators. 3 operators are supported :
10994
10995 - AND (implicit)
10996 - OR (explicit with the "or" keyword or the "||" operator)
10997 - Negation with the exclamation mark ("!")
Willy Tarreau6a06a402007-07-15 20:15:28 +020010998
Willy Tarreau74ca5042013-06-11 23:12:07 +020010999A condition is formed as a disjunctive form:
Willy Tarreau6a06a402007-07-15 20:15:28 +020011000
Willy Tarreau74ca5042013-06-11 23:12:07 +020011001 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
Willy Tarreaubef91e72013-03-31 23:14:46 +020011002
Willy Tarreau74ca5042013-06-11 23:12:07 +020011003Such conditions are generally used after an "if" or "unless" statement,
11004indicating when the condition will trigger the action.
Willy Tarreaubef91e72013-03-31 23:14:46 +020011005
Willy Tarreau74ca5042013-06-11 23:12:07 +020011006For instance, to block HTTP requests to the "*" URL with methods other than
11007"OPTIONS", as well as POST requests without content-length, and GET or HEAD
11008requests with a content-length greater than 0, and finally every request which
11009is not either GET/HEAD/POST/OPTIONS !
11010
11011 acl missing_cl hdr_cnt(Content-length) eq 0
11012 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
11013 block if METH_GET HTTP_CONTENT
11014 block unless METH_GET or METH_POST or METH_OPTIONS
11015
11016To select a different backend for requests to static contents on the "www" site
11017and to every request on the "img", "video", "download" and "ftp" hosts :
11018
11019 acl url_static path_beg /static /images /img /css
11020 acl url_static path_end .gif .png .jpg .css .js
11021 acl host_www hdr_beg(host) -i www
11022 acl host_static hdr_beg(host) -i img. video. download. ftp.
11023
11024 # now use backend "static" for all static-only hosts, and for static urls
11025 # of host "www". Use backend "www" for the rest.
11026 use_backend static if host_static or host_www url_static
11027 use_backend www if host_www
11028
11029It is also possible to form rules using "anonymous ACLs". Those are unnamed ACL
11030expressions that are built on the fly without needing to be declared. They must
11031be enclosed between braces, with a space before and after each brace (because
11032the braces must be seen as independent words). Example :
11033
11034 The following rule :
11035
11036 acl missing_cl hdr_cnt(Content-length) eq 0
11037 block if METH_POST missing_cl
11038
11039 Can also be written that way :
11040
11041 block if METH_POST { hdr_cnt(Content-length) eq 0 }
11042
11043It is generally not recommended to use this construct because it's a lot easier
11044to leave errors in the configuration when written that way. However, for very
11045simple rules matching only one source IP address for instance, it can make more
11046sense to use them than to declare ACLs with random names. Another example of
11047good use is the following :
11048
11049 With named ACLs :
11050
11051 acl site_dead nbsrv(dynamic) lt 2
11052 acl site_dead nbsrv(static) lt 2
11053 monitor fail if site_dead
11054
11055 With anonymous ACLs :
11056
11057 monitor fail if { nbsrv(dynamic) lt 2 } || { nbsrv(static) lt 2 }
11058
11059See section 4.2 for detailed help on the "block" and "use_backend" keywords.
11060
11061
110627.3. Fetching samples
11063---------------------
11064
11065Historically, sample fetch methods were only used to retrieve data to match
11066against patterns using ACLs. With the arrival of stick-tables, a new class of
11067sample fetch methods was created, most often sharing the same syntax as their
11068ACL counterpart. These sample fetch methods are also known as "fetches". As
11069of now, ACLs and fetches have converged. All ACL fetch methods have been made
11070available as fetch methods, and ACLs may use any sample fetch method as well.
11071
11072This section details all available sample fetch methods and their output type.
11073Some sample fetch methods have deprecated aliases that are used to maintain
11074compatibility with existing configurations. They are then explicitly marked as
11075deprecated and should not be used in new setups.
11076
11077The ACL derivatives are also indicated when available, with their respective
11078matching methods. These ones all have a well defined default pattern matching
11079method, so it is never necessary (though allowed) to pass the "-m" option to
11080indicate how the sample will be matched using ACLs.
11081
11082As indicated in the sample type versus matching compatibility matrix above,
11083when using a generic sample fetch method in an ACL, the "-m" option is
11084mandatory unless the sample type is one of boolean, integer, IPv4 or IPv6. When
11085the same keyword exists as an ACL keyword and as a standard fetch method, the
11086ACL engine will automatically pick the ACL-only one by default.
11087
11088Some of these keywords support one or multiple mandatory arguments, and one or
11089multiple optional arguments. These arguments are strongly typed and are checked
11090when the configuration is parsed so that there is no risk of running with an
11091incorrect argument (eg: an unresolved backend name). Fetch function arguments
11092are passed between parenthesis and are delimited by commas. When an argument
11093is optional, it will be indicated below between square brackets ('[ ]'). When
11094all arguments are optional, the parenthesis may be omitted.
11095
11096Thus, the syntax of a standard sample fetch method is one of the following :
11097 - name
11098 - name(arg1)
11099 - name(arg1,arg2)
11100
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011101
111027.3.1. Converters
11103-----------------
11104
Willy Tarreaue6b11e42013-11-26 19:02:32 +010011105Sample fetch methods may be combined with transformations to be applied on top
11106of the fetched sample (also called "converters"). These combinations form what
11107is called "sample expressions" and the result is a "sample". Initially this
11108was only supported by "stick on" and "stick store-request" directives but this
11109has now be extended to all places where samples may be used (acls, log-format,
11110unique-id-format, add-header, ...).
11111
11112These transformations are enumerated as a series of specific keywords after the
11113sample fetch method. These keywords may equally be appended immediately after
11114the fetch keyword's argument, delimited by a comma. These keywords can also
11115support some arguments (eg: a netmask) which must be passed in parenthesis.
Willy Tarreau0ba27502007-12-24 16:55:16 +010011116
Willy Tarreau97707872015-01-27 15:12:13 +010011117A certain category of converters are bitwise and arithmetic operators which
11118support performing basic operations on integers. Some bitwise operations are
11119supported (and, or, xor, cpl) and some arithmetic operations are supported
11120(add, sub, mul, div, mod, neg). Some comparators are provided (odd, even, not,
11121bool) which make it possible to report a match without having to write an ACL.
11122
Willy Tarreau74ca5042013-06-11 23:12:07 +020011123The currently available list of transformation keywords include :
Willy Tarreau0ba27502007-12-24 16:55:16 +010011124
Willy Tarreau97707872015-01-27 15:12:13 +010011125add(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011126 Adds <value> to the input value of type signed integer, and returns the
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011127 result as a signed integer. <value> can be a numeric value or a variable
11128 name. The name of the variable starts by an indication about its scope. The
11129 allowed scopes are:
11130 "sess" : the variable is shared with all the session,
11131 "txn" : the variable is shared with all the transaction (request and
11132 response),
11133 "req" : the variable is shared only during the request processing,
11134 "res" : the variable is shared only during the response processing.
11135 This prefix is followed by a name. The separator is a '.'. The name may only
11136 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011137
11138and(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011139 Performs a bitwise "AND" between <value> and the input value of type signed
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011140 integer, and returns the result as an signed integer. <value> can be a
11141 numeric value or a variable name. The name of the variable starts by an
11142 indication about its scope. The allowed scopes are:
11143 "sess" : the variable is shared with all the session,
11144 "txn" : the variable is shared with all the transaction (request and
11145 response),
11146 "req" : the variable is shared only during the request processing,
11147 "res" : the variable is shared only during the response processing.
11148 This prefix is followed by a name. The separator is a '.'. The name may only
11149 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011150
Emeric Brun53d1a982014-04-30 18:21:37 +020011151base64
11152 Converts a binary input sample to a base64 string. It is used to log or
11153 transfer binary content in a way that can be reliably transferred (eg:
11154 an SSL ID can be copied in a header).
11155
Willy Tarreau97707872015-01-27 15:12:13 +010011156bool
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011157 Returns a boolean TRUE if the input value of type signed integer is
Willy Tarreau97707872015-01-27 15:12:13 +010011158 non-null, otherwise returns FALSE. Used in conjunction with and(), it can be
11159 used to report true/false for bit testing on input values (eg: verify the
11160 presence of a flag).
11161
Emeric Brun54c4ac82014-11-03 15:32:43 +010011162bytes(<offset>[,<length>])
11163 Extracts some bytes from an input binary sample. The result is a binary
11164 sample starting at an offset (in bytes) of the original sample and
11165 optionnaly truncated at the given length.
11166
Willy Tarreau97707872015-01-27 15:12:13 +010011167cpl
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011168 Takes the input value of type signed integer, applies a ones-complement
11169 (flips all bits) and returns the result as an signed integer.
Willy Tarreau97707872015-01-27 15:12:13 +010011170
Willy Tarreau80599772015-01-20 19:35:24 +010011171crc32([<avalanche>])
11172 Hashes a binary input sample into an unsigned 32-bit quantity using the CRC32
11173 hash function. Optionally, it is possible to apply a full avalanche hash
11174 function to the output if the optional <avalanche> argument equals 1. This
11175 converter uses the same functions as used by the various hash-based load
11176 balancing algorithms, so it will provide exactly the same results. It is
11177 provided for compatibility with other software which want a CRC32 to be
11178 computed on some input keys, so it follows the most common implementation as
11179 found in Ethernet, Gzip, PNG, etc... It is slower than the other algorithms
11180 but may provide a better or at least less predictable distribution. It must
11181 not be used for security purposes as a 32-bit hash is trivial to break. See
11182 also "djb2", "sdbm", "wt6" and the "hash-type" directive.
11183
David Carlier4542b102015-06-01 13:54:29 +020011184da-csv(<prop>[,<prop>*])
11185 Asks the DeviceAtlas converter to identify the User Agent string passed on
11186 input, and to emit a string made of the concatenation of the properties
11187 enumerated in argument, delimited by the separator defined by the global
11188 keyword "deviceatlas-property-separator", or by default the pipe character
11189 ('|'). There's a limit of 5 different properties imposed by the haproxy
11190 configuration language.
11191
11192 Example:
11193 frontend www
11194 bind *:8881
11195 default_backend servers
11196 http-request set-header X-DeviceAtlas-Data %[req.fhdr(User-Agent),da-csv(primaryHardwareType,osName,osVersion,browserName,browserVersion)]
11197
Thierry FOURNIER9687c772015-05-07 15:46:29 +020011198debug
11199 This converter is used as debug tool. It dumps on screen the content and the
11200 type of the input sample. The sample is returned as is on its output. This
11201 converter only exists when haproxy was built with debugging enabled.
11202
Willy Tarreau97707872015-01-27 15:12:13 +010011203div(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011204 Divides the input value of type signed integer by <value>, and returns the
11205 result as an signed integer. If <value> is null, the largest unsigned
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011206 integer is returned (typically 2^63-1). <value> can be a numeric value or a
11207 variable name. The name of the variable starts by an indication about it
11208 scope. The scope allowed are:
11209 "sess" : the variable is shared with all the session,
11210 "txn" : the variable is shared with all the transaction (request and
11211 response),
11212 "req" : the variable is shared only during the request processing,
11213 "res" : the variable is shared only during the response processing.
11214 This prefix is followed by a name. The separator is a '.'. The name may only
11215 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011216
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020011217djb2([<avalanche>])
11218 Hashes a binary input sample into an unsigned 32-bit quantity using the DJB2
11219 hash function. Optionally, it is possible to apply a full avalanche hash
11220 function to the output if the optional <avalanche> argument equals 1. This
11221 converter uses the same functions as used by the various hash-based load
11222 balancing algorithms, so it will provide exactly the same results. It is
11223 mostly intended for debugging, but can be used as a stick-table entry to
11224 collect rough statistics. It must not be used for security purposes as a
Willy Tarreau80599772015-01-20 19:35:24 +010011225 32-bit hash is trivial to break. See also "crc32", "sdbm", "wt6" and the
11226 "hash-type" directive.
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020011227
Willy Tarreau97707872015-01-27 15:12:13 +010011228even
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011229 Returns a boolean TRUE if the input value of type signed integer is even
Willy Tarreau97707872015-01-27 15:12:13 +010011230 otherwise returns FALSE. It is functionally equivalent to "not,and(1),bool".
11231
Emeric Brunf399b0d2014-11-03 17:07:03 +010011232field(<index>,<delimiters>)
11233 Extracts the substring at the given index considering given delimiters from
11234 an input string. Indexes start at 1 and delimiters are a string formatted
11235 list of chars.
11236
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011237hex
11238 Converts a binary input sample to an hex string containing two hex digits per
11239 input byte. It is used to log or transfer hex dumps of some binary input data
11240 in a way that can be reliably transferred (eg: an SSL ID can be copied in a
11241 header).
Thierry FOURNIER2f49d6d2014-03-12 15:01:52 +010011242
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011243http_date([<offset>])
11244 Converts an integer supposed to contain a date since epoch to a string
11245 representing this date in a format suitable for use in HTTP header fields. If
11246 an offset value is specified, then it is a number of seconds that is added to
11247 the date before the conversion is operated. This is particularly useful to
11248 emit Date header fields, Expires values in responses when combined with a
11249 positive offset, or Last-Modified values when the offset is negative.
Willy Tarreau74ca5042013-06-11 23:12:07 +020011250
Willy Tarreaud9f316a2014-07-10 14:03:38 +020011251in_table(<table>)
11252 Uses the string representation of the input sample to perform a look up in
11253 the specified table. If the key is not found in the table, a boolean false
11254 is returned. Otherwise a boolean true is returned. This can be used to verify
11255 the presence of a certain key in a table tracking some elements (eg: whether
11256 or not a source IP address or an Authorization header was already seen).
11257
Willy Tarreauffcb2e42014-07-10 16:29:08 +020011258ipmask(<mask>)
11259 Apply a mask to an IPv4 address, and use the result for lookups and storage.
11260 This can be used to make all hosts within a certain mask to share the same
11261 table entries and as such use the same server. The mask can be passed in
11262 dotted form (eg: 255.255.255.0) or in CIDR form (eg: 24).
11263
Thierry FOURNIER317e1c42014-08-12 10:20:47 +020011264json([<input-code>])
11265 Escapes the input string and produces an ASCII ouput string ready to use as a
11266 JSON string. The converter tries to decode the input string according to the
11267 <input-code> parameter. It can be "ascii", "utf8", "utf8s", "utf8"" or
11268 "utf8ps". The "ascii" decoder never fails. The "utf8" decoder detects 3 types
11269 of errors:
11270 - bad UTF-8 sequence (lone continuation byte, bad number of continuation
11271 bytes, ...)
11272 - invalid range (the decoded value is within a UTF-8 prohibited range),
11273 - code overlong (the value is encoded with more bytes than necessary).
11274
11275 The UTF-8 JSON encoding can produce a "too long value" error when the UTF-8
11276 character is greater than 0xffff because the JSON string escape specification
11277 only authorizes 4 hex digits for the value encoding. The UTF-8 decoder exists
11278 in 4 variants designated by a combination of two suffix letters : "p" for
11279 "permissive" and "s" for "silently ignore". The behaviors of the decoders
11280 are :
11281 - "ascii" : never fails ;
11282 - "utf8" : fails on any detected errors ;
11283 - "utf8s" : never fails, but removes characters corresponding to errors ;
11284 - "utf8p" : accepts and fixes the overlong errors, but fails on any other
11285 error ;
11286 - "utf8ps" : never fails, accepts and fixes the overlong errors, but removes
11287 characters corresponding to the other errors.
11288
11289 This converter is particularly useful for building properly escaped JSON for
11290 logging to servers which consume JSON-formated traffic logs.
11291
11292 Example:
11293 capture request header user-agent len 150
11294 capture request header Host len 15
11295 log-format {"ip":"%[src]","user-agent":"%[capture.req.hdr(1),json]"}
11296
11297 Input request from client 127.0.0.1:
11298 GET / HTTP/1.0
11299 User-Agent: Very "Ugly" UA 1/2
11300
11301 Output log:
11302 {"ip":"127.0.0.1","user-agent":"Very \"Ugly\" UA 1\/2"}
11303
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011304language(<value>[,<default>])
11305 Returns the value with the highest q-factor from a list as extracted from the
11306 "accept-language" header using "req.fhdr". Values with no q-factor have a
11307 q-factor of 1. Values with a q-factor of 0 are dropped. Only values which
11308 belong to the list of semi-colon delimited <values> will be considered. The
11309 argument <value> syntax is "lang[;lang[;lang[;...]]]". If no value matches the
11310 given list and a default value is provided, it is returned. Note that language
11311 names may have a variant after a dash ('-'). If this variant is present in the
11312 list, it will be matched, but if it is not, only the base language is checked.
11313 The match is case-sensitive, and the output string is always one of those
11314 provided in arguments. The ordering of arguments is meaningless, only the
11315 ordering of the values in the request counts, as the first value among
11316 multiple sharing the same q-factor is used.
Thierry FOURNIERad903512014-04-11 17:51:01 +020011317
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011318 Example :
Thierry FOURNIERad903512014-04-11 17:51:01 +020011319
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011320 # this configuration switches to the backend matching a
11321 # given language based on the request :
Thierry FOURNIERad903512014-04-11 17:51:01 +020011322
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011323 acl es req.fhdr(accept-language),language(es;fr;en) -m str es
11324 acl fr req.fhdr(accept-language),language(es;fr;en) -m str fr
11325 acl en req.fhdr(accept-language),language(es;fr;en) -m str en
11326 use_backend spanish if es
11327 use_backend french if fr
11328 use_backend english if en
11329 default_backend choose_your_language
Thierry FOURNIERad903512014-04-11 17:51:01 +020011330
Willy Tarreauffcb2e42014-07-10 16:29:08 +020011331lower
11332 Convert a string sample to lower case. This can only be placed after a string
11333 sample fetch function or after a transformation keyword returning a string
11334 type. The result is of type string.
11335
Willy Tarreau0dbfdba2014-07-10 16:37:47 +020011336ltime(<format>[,<offset>])
11337 Converts an integer supposed to contain a date since epoch to a string
11338 representing this date in local time using a format defined by the <format>
11339 string using strftime(3). The purpose is to allow any date format to be used
11340 in logs. An optional <offset> in seconds may be applied to the input date
11341 (positive or negative). See the strftime() man page for the format supported
11342 by your operating system. See also the utime converter.
11343
11344 Example :
11345
11346 # Emit two colons, one with the local time and another with ip:port
11347 # Eg: 20140710162350 127.0.0.1:57325
11348 log-format %[date,ltime(%Y%m%d%H%M%S)]\ %ci:%cp
11349
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011350map(<map_file>[,<default_value>])
11351map_<match_type>(<map_file>[,<default_value>])
11352map_<match_type>_<output_type>(<map_file>[,<default_value>])
11353 Search the input value from <map_file> using the <match_type> matching method,
11354 and return the associated value converted to the type <output_type>. If the
11355 input value cannot be found in the <map_file>, the converter returns the
11356 <default_value>. If the <default_value> is not set, the converter fails and
11357 acts as if no input value could be fetched. If the <match_type> is not set, it
11358 defaults to "str". Likewise, if the <output_type> is not set, it defaults to
11359 "str". For convenience, the "map" keyword is an alias for "map_str" and maps a
11360 string to another string.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011361
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011362 It is important to avoid overlapping between the keys : IP addresses and
11363 strings are stored in trees, so the first of the finest match will be used.
11364 Other keys are stored in lists, so the first matching occurrence will be used.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011365
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011366 The following array contains the list of all map functions avalaible sorted by
11367 input type, match type and output type.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011368
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011369 input type | match method | output type str | output type int | output type ip
11370 -----------+--------------+-----------------+-----------------+---------------
11371 str | str | map_str | map_str_int | map_str_ip
11372 -----------+--------------+-----------------+-----------------+---------------
Willy Tarreau787a4c02014-05-10 07:55:30 +020011373 str | beg | map_beg | map_beg_int | map_end_ip
11374 -----------+--------------+-----------------+-----------------+---------------
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011375 str | sub | map_sub | map_sub_int | map_sub_ip
11376 -----------+--------------+-----------------+-----------------+---------------
11377 str | dir | map_dir | map_dir_int | map_dir_ip
11378 -----------+--------------+-----------------+-----------------+---------------
11379 str | dom | map_dom | map_dom_int | map_dom_ip
11380 -----------+--------------+-----------------+-----------------+---------------
11381 str | end | map_end | map_end_int | map_end_ip
11382 -----------+--------------+-----------------+-----------------+---------------
11383 str | reg | map_reg | map_reg_int | map_reg_ip
11384 -----------+--------------+-----------------+-----------------+---------------
11385 int | int | map_int | map_int_int | map_int_ip
11386 -----------+--------------+-----------------+-----------------+---------------
11387 ip | ip | map_ip | map_ip_int | map_ip_ip
11388 -----------+--------------+-----------------+-----------------+---------------
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011389
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011390 The file contains one key + value per line. Lines which start with '#' are
11391 ignored, just like empty lines. Leading tabs and spaces are stripped. The key
11392 is then the first "word" (series of non-space/tabs characters), and the value
11393 is what follows this series of space/tab till the end of the line excluding
11394 trailing spaces/tabs.
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011395
Thierry FOURNIER060762e2014-04-23 13:29:15 +020011396 Example :
11397
11398 # this is a comment and is ignored
11399 2.22.246.0/23 United Kingdom \n
11400 <-><-----------><--><------------><---->
11401 | | | | `- trailing spaces ignored
11402 | | | `---------- value
11403 | | `-------------------- middle spaces ignored
11404 | `---------------------------- key
11405 `------------------------------------ leading spaces ignored
11406
Willy Tarreau97707872015-01-27 15:12:13 +010011407mod(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011408 Divides the input value of type signed integer by <value>, and returns the
11409 remainder as an signed integer. If <value> is null, then zero is returned.
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011410 <value> can be a numeric value or a variable name. The name of the variable
11411 starts by an indication about its scope. The allowed scopes are:
11412 "sess" : the variable is shared with all the session,
11413 "txn" : the variable is shared with all the transaction (request and
11414 response),
11415 "req" : the variable is shared only during the request processing,
11416 "res" : the variable is shared only during the response processing.
11417 This prefix is followed by a name. The separator is a '.'. The name may only
11418 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011419
11420mul(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011421 Multiplies the input value of type signed integer by <value>, and returns
Thierry FOURNIER00c005c2015-07-08 01:10:21 +020011422 the product as an signed integer. In case of overflow, the largest possible
11423 value for the sign is returned so that the operation doesn't wrap around.
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011424 <value> can be a numeric value or a variable name. The name of the variable
11425 starts by an indication about its scope. The allowed scopes are:
11426 "sess" : the variable is shared with all the session,
11427 "txn" : the variable is shared with all the transaction (request and
11428 response),
11429 "req" : the variable is shared only during the request processing,
11430 "res" : the variable is shared only during the response processing.
11431 This prefix is followed by a name. The separator is a '.'. The name may only
11432 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011433
11434neg
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011435 Takes the input value of type signed integer, computes the opposite value,
11436 and returns the remainder as an signed integer. 0 is identity. This operator
11437 is provided for reversed subtracts : in order to subtract the input from a
11438 constant, simply perform a "neg,add(value)".
Willy Tarreau97707872015-01-27 15:12:13 +010011439
11440not
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011441 Returns a boolean FALSE if the input value of type signed integer is
Willy Tarreau97707872015-01-27 15:12:13 +010011442 non-null, otherwise returns TRUE. Used in conjunction with and(), it can be
11443 used to report true/false for bit testing on input values (eg: verify the
11444 absence of a flag).
11445
11446odd
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011447 Returns a boolean TRUE if the input value of type signed integer is odd
Willy Tarreau97707872015-01-27 15:12:13 +010011448 otherwise returns FALSE. It is functionally equivalent to "and(1),bool".
11449
11450or(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011451 Performs a bitwise "OR" between <value> and the input value of type signed
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011452 integer, and returns the result as an signed integer. <value> can be a
11453 numeric value or a variable name. The name of the variable starts by an
11454 indication about its scope. The allowed scopes are:
11455 "sess" : the variable is shared with all the session,
11456 "txn" : the variable is shared with all the transaction (request and
11457 response),
11458 "req" : the variable is shared only during the request processing,
11459 "res" : the variable is shared only during the response processing.
11460 This prefix is followed by a name. The separator is a '.'. The name may only
11461 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011462
Willy Tarreauc4dc3502015-01-23 20:39:28 +010011463regsub(<regex>,<subst>[,<flags>])
Willy Tarreau7eda8492015-01-20 19:47:06 +010011464 Applies a regex-based substitution to the input string. It does the same
11465 operation as the well-known "sed" utility with "s/<regex>/<subst>/". By
11466 default it will replace in the input string the first occurrence of the
11467 largest part matching the regular expression <regex> with the substitution
11468 string <subst>. It is possible to replace all occurrences instead by adding
11469 the flag "g" in the third argument <flags>. It is also possible to make the
11470 regex case insensitive by adding the flag "i" in <flags>. Since <flags> is a
11471 string, it is made up from the concatenation of all desired flags. Thus if
11472 both "i" and "g" are desired, using "gi" or "ig" will have the same effect.
11473 It is important to note that due to the current limitations of the
11474 configuration parser, some characters such as closing parenthesis or comma
11475 are not possible to use in the arguments. The first use of this converter is
11476 to replace certain characters or sequence of characters with other ones.
11477
11478 Example :
11479
11480 # de-duplicate "/" in header "x-path".
11481 # input: x-path: /////a///b/c/xzxyz/
11482 # output: x-path: /a/b/c/xzxyz/
11483 http-request set-header x-path %[hdr(x-path),regsub(/+,/,g)]
11484
Thierry FOURNIER35ab2752015-05-28 13:22:03 +020011485capture-req(<id>)
11486 Capture the string entry in the request slot <id> and returns the entry as
11487 is. If the slot doesn't exist, the capture fails silently.
11488
11489 See also: "declare capture", "http-request capture",
11490 "http-response capture", "req.hdr.capture" and
11491 "res.hdr.capture" (sample fetches).
11492
11493capture-res(<id>)
11494 Capture the string entry in the response slot <id> and returns the entry as
11495 is. If the slot doesn't exist, the capture fails silently.
11496
11497 See also: "declare capture", "http-request capture",
11498 "http-response capture", "req.hdr.capture" and
11499 "res.hdr.capture" (sample fetches).
11500
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020011501sdbm([<avalanche>])
11502 Hashes a binary input sample into an unsigned 32-bit quantity using the SDBM
11503 hash function. Optionally, it is possible to apply a full avalanche hash
11504 function to the output if the optional <avalanche> argument equals 1. This
11505 converter uses the same functions as used by the various hash-based load
11506 balancing algorithms, so it will provide exactly the same results. It is
11507 mostly intended for debugging, but can be used as a stick-table entry to
11508 collect rough statistics. It must not be used for security purposes as a
Willy Tarreau80599772015-01-20 19:35:24 +010011509 32-bit hash is trivial to break. See also "crc32", "djb2", "wt6" and the
11510 "hash-type" directive.
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020011511
Thierry FOURNIER4834bc72015-06-06 19:29:07 +020011512set-var(<var name>)
11513 Sets a variable with the input content and return the content on the output as
11514 is. The variable keep the value and the associated input type. The name of the
11515 variable starts by an indication about it scope. The scope allowed are:
11516 "sess" : the variable is shared with all the session,
11517 "txn" : the variable is shared with all the transaction (request and
11518 response),
11519 "req" : the variable is shared only during the request processing,
11520 "res" : the variable is shared only during the response processing.
11521 This prefix is followed by a name. The separator is a '.'. The name may only
11522 contain characters 'a-z', 'A-Z', '0-9' and '_'.
11523
Willy Tarreau97707872015-01-27 15:12:13 +010011524sub(<value>)
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011525 Subtracts <value> from the input value of type signed integer, and returns
11526 the result as an signed integer. Note: in order to subtract the input from
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011527 a constant, simply perform a "neg,add(value)". <value> can be a numeric value
11528 or a variable name. The name of the variable starts by an indication about its
11529 scope. The allowed scopes are:
11530 "sess" : the variable is shared with all the session,
11531 "txn" : the variable is shared with all the transaction (request and
11532 response),
11533 "req" : the variable is shared only during the request processing,
11534 "res" : the variable is shared only during the response processing.
11535 This prefix is followed by a name. The separator is a '.'. The name may only
11536 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011537
Willy Tarreaud9f316a2014-07-10 14:03:38 +020011538table_bytes_in_rate(<table>)
11539 Uses the string representation of the input sample to perform a look up in
11540 the specified table. If the key is not found in the table, integer value zero
11541 is returned. Otherwise the converter returns the average client-to-server
11542 bytes rate associated with the input sample in the designated table, measured
11543 in amount of bytes over the period configured in the table. See also the
11544 sc_bytes_in_rate sample fetch keyword.
11545
11546
11547table_bytes_out_rate(<table>)
11548 Uses the string representation of the input sample to perform a look up in
11549 the specified table. If the key is not found in the table, integer value zero
11550 is returned. Otherwise the converter returns the average server-to-client
11551 bytes rate associated with the input sample in the designated table, measured
11552 in amount of bytes over the period configured in the table. See also the
11553 sc_bytes_out_rate sample fetch keyword.
11554
11555table_conn_cnt(<table>)
11556 Uses the string representation of the input sample to perform a look up in
11557 the specified table. If the key is not found in the table, integer value zero
11558 is returned. Otherwise the converter returns the cumulated amount of incoming
11559 connections associated with the input sample in the designated table. See
11560 also the sc_conn_cnt sample fetch keyword.
11561
11562table_conn_cur(<table>)
11563 Uses the string representation of the input sample to perform a look up in
11564 the specified table. If the key is not found in the table, integer value zero
11565 is returned. Otherwise the converter returns the current amount of concurrent
11566 tracked connections associated with the input sample in the designated table.
11567 See also the sc_conn_cur sample fetch keyword.
11568
11569table_conn_rate(<table>)
11570 Uses the string representation of the input sample to perform a look up in
11571 the specified table. If the key is not found in the table, integer value zero
11572 is returned. Otherwise the converter returns the average incoming connection
11573 rate associated with the input sample in the designated table. See also the
11574 sc_conn_rate sample fetch keyword.
11575
Thierry FOURNIER236657b2015-08-19 08:25:14 +020011576table_gpt0(<table>)
11577 Uses the string representation of the input sample to perform a look up in
11578 the specified table. If the key is not found in the table, boolean value zero
11579 is returned. Otherwise the converter returns the current value of the first
11580 general purpose tag associated with the input sample in the designated table.
11581 See also the sc_get_gpt0 sample fetch keyword.
11582
Willy Tarreaud9f316a2014-07-10 14:03:38 +020011583table_gpc0(<table>)
11584 Uses the string representation of the input sample to perform a look up in
11585 the specified table. If the key is not found in the table, integer value zero
11586 is returned. Otherwise the converter returns the current value of the first
11587 general purpose counter associated with the input sample in the designated
11588 table. See also the sc_get_gpc0 sample fetch keyword.
11589
11590table_gpc0_rate(<table>)
11591 Uses the string representation of the input sample to perform a look up in
11592 the specified table. If the key is not found in the table, integer value zero
11593 is returned. Otherwise the converter returns the frequency which the gpc0
11594 counter was incremented over the configured period in the table, associated
11595 with the input sample in the designated table. See also the sc_get_gpc0_rate
11596 sample fetch keyword.
11597
11598table_http_err_cnt(<table>)
11599 Uses the string representation of the input sample to perform a look up in
11600 the specified table. If the key is not found in the table, integer value zero
11601 is returned. Otherwise the converter returns the cumulated amount of HTTP
11602 errors associated with the input sample in the designated table. See also the
11603 sc_http_err_cnt sample fetch keyword.
11604
11605table_http_err_rate(<table>)
11606 Uses the string representation of the input sample to perform a look up in
11607 the specified table. If the key is not found in the table, integer value zero
11608 is returned. Otherwise the average rate of HTTP errors associated with the
11609 input sample in the designated table, measured in amount of errors over the
11610 period configured in the table. See also the sc_http_err_rate sample fetch
11611 keyword.
11612
11613table_http_req_cnt(<table>)
11614 Uses the string representation of the input sample to perform a look up in
11615 the specified table. If the key is not found in the table, integer value zero
11616 is returned. Otherwise the converter returns the cumulated amount of HTTP
11617 requests associated with the input sample in the designated table. See also
11618 the sc_http_req_cnt sample fetch keyword.
11619
11620table_http_req_rate(<table>)
11621 Uses the string representation of the input sample to perform a look up in
11622 the specified table. If the key is not found in the table, integer value zero
11623 is returned. Otherwise the average rate of HTTP requests associated with the
11624 input sample in the designated table, measured in amount of requests over the
11625 period configured in the table. See also the sc_http_req_rate sample fetch
11626 keyword.
11627
11628table_kbytes_in(<table>)
11629 Uses the string representation of the input sample to perform a look up in
11630 the specified table. If the key is not found in the table, integer value zero
11631 is returned. Otherwise the converter returns the cumulated amount of client-
11632 to-server data associated with the input sample in the designated table,
11633 measured in kilobytes. The test is currently performed on 32-bit integers,
11634 which limits values to 4 terabytes. See also the sc_kbytes_in sample fetch
11635 keyword.
11636
11637table_kbytes_out(<table>)
11638 Uses the string representation of the input sample to perform a look up in
11639 the specified table. If the key is not found in the table, integer value zero
11640 is returned. Otherwise the converter returns the cumulated amount of server-
11641 to-client data associated with the input sample in the designated table,
11642 measured in kilobytes. The test is currently performed on 32-bit integers,
11643 which limits values to 4 terabytes. See also the sc_kbytes_out sample fetch
11644 keyword.
11645
11646table_server_id(<table>)
11647 Uses the string representation of the input sample to perform a look up in
11648 the specified table. If the key is not found in the table, integer value zero
11649 is returned. Otherwise the converter returns the server ID associated with
11650 the input sample in the designated table. A server ID is associated to a
11651 sample by a "stick" rule when a connection to a server succeeds. A server ID
11652 zero means that no server is associated with this key.
11653
11654table_sess_cnt(<table>)
11655 Uses the string representation of the input sample to perform a look up in
11656 the specified table. If the key is not found in the table, integer value zero
11657 is returned. Otherwise the converter returns the cumulated amount of incoming
11658 sessions associated with the input sample in the designated table. Note that
11659 a session here refers to an incoming connection being accepted by the
11660 "tcp-request connection" rulesets. See also the sc_sess_cnt sample fetch
11661 keyword.
11662
11663table_sess_rate(<table>)
11664 Uses the string representation of the input sample to perform a look up in
11665 the specified table. If the key is not found in the table, integer value zero
11666 is returned. Otherwise the converter returns the average incoming session
11667 rate associated with the input sample in the designated table. Note that a
11668 session here refers to an incoming connection being accepted by the
11669 "tcp-request connection" rulesets. See also the sc_sess_rate sample fetch
11670 keyword.
11671
11672table_trackers(<table>)
11673 Uses the string representation of the input sample to perform a look up in
11674 the specified table. If the key is not found in the table, integer value zero
11675 is returned. Otherwise the converter returns the current amount of concurrent
11676 connections tracking the same key as the input sample in the designated
11677 table. It differs from table_conn_cur in that it does not rely on any stored
11678 information but on the table's reference count (the "use" value which is
11679 returned by "show table" on the CLI). This may sometimes be more suited for
11680 layer7 tracking. It can be used to tell a server how many concurrent
11681 connections there are from a given address for example. See also the
11682 sc_trackers sample fetch keyword.
11683
Willy Tarreauffcb2e42014-07-10 16:29:08 +020011684upper
11685 Convert a string sample to upper case. This can only be placed after a string
11686 sample fetch function or after a transformation keyword returning a string
11687 type. The result is of type string.
11688
Thierry FOURNIER82ff3c92015-05-07 15:46:20 +020011689url_dec
11690 Takes an url-encoded string provided as input and returns the decoded
11691 version as output. The input and the output are of type string.
11692
Willy Tarreau0dbfdba2014-07-10 16:37:47 +020011693utime(<format>[,<offset>])
11694 Converts an integer supposed to contain a date since epoch to a string
11695 representing this date in UTC time using a format defined by the <format>
11696 string using strftime(3). The purpose is to allow any date format to be used
11697 in logs. An optional <offset> in seconds may be applied to the input date
11698 (positive or negative). See the strftime() man page for the format supported
11699 by your operating system. See also the ltime converter.
11700
11701 Example :
11702
11703 # Emit two colons, one with the UTC time and another with ip:port
11704 # Eg: 20140710162350 127.0.0.1:57325
11705 log-format %[date,utime(%Y%m%d%H%M%S)]\ %ci:%cp
11706
Emeric Brunc9a0f6d2014-11-25 14:09:01 +010011707word(<index>,<delimiters>)
11708 Extracts the nth word considering given delimiters from an input string.
11709 Indexes start at 1 and delimiters are a string formatted list of chars.
11710
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020011711wt6([<avalanche>])
11712 Hashes a binary input sample into an unsigned 32-bit quantity using the WT6
11713 hash function. Optionally, it is possible to apply a full avalanche hash
11714 function to the output if the optional <avalanche> argument equals 1. This
11715 converter uses the same functions as used by the various hash-based load
11716 balancing algorithms, so it will provide exactly the same results. It is
11717 mostly intended for debugging, but can be used as a stick-table entry to
11718 collect rough statistics. It must not be used for security purposes as a
Willy Tarreau80599772015-01-20 19:35:24 +010011719 32-bit hash is trivial to break. See also "crc32", "djb2", "sdbm", and the
11720 "hash-type" directive.
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020011721
Willy Tarreau97707872015-01-27 15:12:13 +010011722xor(<value>)
11723 Performs a bitwise "XOR" (exclusive OR) between <value> and the input value
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011724 of type signed integer, and returns the result as an signed integer.
Thierry FOURNIER5d86fae2015-07-07 21:10:16 +020011725 <value> can be a numeric value or a variable name. The name of the variable
11726 starts by an indication about its scope. The allowed scopes are:
11727 "sess" : the variable is shared with all the session,
11728 "txn" : the variable is shared with all the transaction (request and
11729 response),
11730 "req" : the variable is shared only during the request processing,
11731 "res" : the variable is shared only during the response processing.
11732 This prefix is followed by a name. The separator is a '.'. The name may only
11733 contain characters 'a-z', 'A-Z', '0-9' and '_'.
Willy Tarreau97707872015-01-27 15:12:13 +010011734
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010011735
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200117367.3.2. Fetching samples from internal states
Willy Tarreau74ca5042013-06-11 23:12:07 +020011737--------------------------------------------
11738
11739A first set of sample fetch methods applies to internal information which does
11740not even relate to any client information. These ones are sometimes used with
11741"monitor-fail" directives to report an internal status to external watchers.
11742The sample fetch methods described in this section are usable anywhere.
11743
11744always_false : boolean
11745 Always returns the boolean "false" value. It may be used with ACLs as a
11746 temporary replacement for another one when adjusting configurations.
11747
11748always_true : boolean
11749 Always returns the boolean "true" value. It may be used with ACLs as a
11750 temporary replacement for another one when adjusting configurations.
11751
11752avg_queue([<backend>]) : integer
Willy Tarreaud63335a2010-02-26 12:56:52 +010011753 Returns the total number of queued connections of the designated backend
Willy Tarreau74ca5042013-06-11 23:12:07 +020011754 divided by the number of active servers. The current backend is used if no
11755 backend is specified. This is very similar to "queue" except that the size of
11756 the farm is considered, in order to give a more accurate measurement of the
11757 time it may take for a new connection to be processed. The main usage is with
11758 ACL to return a sorry page to new users when it becomes certain they will get
11759 a degraded service, or to pass to the backend servers in a header so that
11760 they decide to work in degraded mode or to disable some functions to speed up
11761 the processing a bit. Note that in the event there would not be any active
11762 server anymore, twice the number of queued connections would be considered as
11763 the measured value. This is a fair estimate, as we expect one server to get
11764 back soon anyway, but we still prefer to send new traffic to another backend
11765 if in better shape. See also the "queue", "be_conn", and "be_sess_rate"
11766 sample fetches.
Krzysztof Piotr Oledzki346f76d2010-01-12 21:59:30 +010011767
Willy Tarreau74ca5042013-06-11 23:12:07 +020011768be_conn([<backend>]) : integer
Willy Tarreaua36af912009-10-10 12:02:45 +020011769 Applies to the number of currently established connections on the backend,
11770 possibly including the connection being evaluated. If no backend name is
11771 specified, the current one is used. But it is also possible to check another
11772 backend. It can be used to use a specific farm when the nominal one is full.
11773 See also the "fe_conn", "queue" and "be_sess_rate" criteria.
Willy Tarreau6a06a402007-07-15 20:15:28 +020011774
Willy Tarreau74ca5042013-06-11 23:12:07 +020011775be_sess_rate([<backend>]) : integer
11776 Returns an integer value corresponding to the sessions creation rate on the
11777 backend, in number of new sessions per second. This is used with ACLs to
11778 switch to an alternate backend when an expensive or fragile one reaches too
11779 high a session rate, or to limit abuse of service (eg. prevent sucking of an
11780 online dictionary). It can also be useful to add this element to logs using a
11781 log-format directive.
Willy Tarreaud63335a2010-02-26 12:56:52 +010011782
11783 Example :
11784 # Redirect to an error page if the dictionary is requested too often
11785 backend dynamic
11786 mode http
11787 acl being_scanned be_sess_rate gt 100
11788 redirect location /denied.html if being_scanned
Willy Tarreau0ba27502007-12-24 16:55:16 +010011789
Thierry FOURNIERcc103292015-06-06 19:30:17 +020011790bin(<hexa>) : bin
11791 Returns a binary chain. The input is the hexadecimal representation
11792 of the string.
11793
11794bool(<bool>) : bool
11795 Returns a boolean value. <bool> can be 'true', 'false', '1' or '0'.
11796 'false' and '0' are the same. 'true' and '1' are the same.
11797
Willy Tarreau74ca5042013-06-11 23:12:07 +020011798connslots([<backend>]) : integer
11799 Returns an integer value corresponding to the number of connection slots
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011800 still available in the backend, by totaling the maximum amount of
Willy Tarreau74ca5042013-06-11 23:12:07 +020011801 connections on all servers and the maximum queue size. This is probably only
11802 used with ACLs.
Tait Clarridge7896d522012-12-05 21:39:31 -050011803
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011804 The basic idea here is to be able to measure the number of connection "slots"
Willy Tarreau55165fe2009-05-10 12:02:55 +020011805 still available (connection + queue), so that anything beyond that (intended
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011806 usage; see "use_backend" keyword) can be redirected to a different backend.
11807
Willy Tarreau55165fe2009-05-10 12:02:55 +020011808 'connslots' = number of available server connection slots, + number of
11809 available server queue slots.
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011810
Willy Tarreaua36af912009-10-10 12:02:45 +020011811 Note that while "fe_conn" may be used, "connslots" comes in especially
Willy Tarreau55165fe2009-05-10 12:02:55 +020011812 useful when you have a case of traffic going to one single ip, splitting into
Willy Tarreau74ca5042013-06-11 23:12:07 +020011813 multiple backends (perhaps using ACLs to do name-based load balancing) and
Willy Tarreau55165fe2009-05-10 12:02:55 +020011814 you want to be able to differentiate between different backends, and their
11815 available "connslots". Also, whereas "nbsrv" only measures servers that are
Willy Tarreau74ca5042013-06-11 23:12:07 +020011816 actually *down*, this fetch is more fine-grained and looks into the number of
Willy Tarreaua36af912009-10-10 12:02:45 +020011817 available connection slots as well. See also "queue" and "avg_queue".
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011818
Willy Tarreau55165fe2009-05-10 12:02:55 +020011819 OTHER CAVEATS AND NOTES: at this point in time, the code does not take care
11820 of dynamic connections. Also, if any of the server maxconn, or maxqueue is 0,
Willy Tarreau74ca5042013-06-11 23:12:07 +020011821 then this fetch clearly does not make sense, in which case the value returned
Willy Tarreau55165fe2009-05-10 12:02:55 +020011822 will be -1.
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +080011823
Willy Tarreau6236d3a2013-07-25 14:28:25 +020011824date([<offset>]) : integer
11825 Returns the current date as the epoch (number of seconds since 01/01/1970).
11826 If an offset value is specified, then it is a number of seconds that is added
11827 to the current date before returning the value. This is particularly useful
11828 to compute relative dates, as both positive and negative offsets are allowed.
Willy Tarreau276fae92013-07-25 14:36:01 +020011829 It is useful combined with the http_date converter.
11830
11831 Example :
11832
11833 # set an expires header to now+1 hour in every response
11834 http-response set-header Expires %[date(3600),http_date]
Willy Tarreau6236d3a2013-07-25 14:28:25 +020011835
Willy Tarreau595ec542013-06-12 21:34:28 +020011836env(<name>) : string
11837 Returns a string containing the value of environment variable <name>. As a
11838 reminder, environment variables are per-process and are sampled when the
11839 process starts. This can be useful to pass some information to a next hop
11840 server, or with ACLs to take specific action when the process is started a
11841 certain way.
11842
11843 Examples :
11844 # Pass the Via header to next hop with the local hostname in it
11845 http-request add-header Via 1.1\ %[env(HOSTNAME)]
11846
11847 # reject cookie-less requests when the STOP environment variable is set
11848 http-request deny if !{ cook(SESSIONID) -m found } { env(STOP) -m found }
11849
Willy Tarreau74ca5042013-06-11 23:12:07 +020011850fe_conn([<frontend>]) : integer
11851 Returns the number of currently established connections on the frontend,
Willy Tarreaud63335a2010-02-26 12:56:52 +010011852 possibly including the connection being evaluated. If no frontend name is
11853 specified, the current one is used. But it is also possible to check another
Willy Tarreau74ca5042013-06-11 23:12:07 +020011854 frontend. It can be used to return a sorry page before hard-blocking, or to
11855 use a specific backend to drain new requests when the farm is considered
11856 full. This is mostly used with ACLs but can also be used to pass some
11857 statistics to servers in HTTP headers. See also the "dst_conn", "be_conn",
11858 "fe_sess_rate" fetches.
Willy Tarreaua36af912009-10-10 12:02:45 +020011859
Willy Tarreau74ca5042013-06-11 23:12:07 +020011860fe_sess_rate([<frontend>]) : integer
11861 Returns an integer value corresponding to the sessions creation rate on the
11862 frontend, in number of new sessions per second. This is used with ACLs to
11863 limit the incoming session rate to an acceptable range in order to prevent
11864 abuse of service at the earliest moment, for example when combined with other
11865 layer 4 ACLs in order to force the clients to wait a bit for the rate to go
11866 down below the limit. It can also be useful to add this element to logs using
11867 a log-format directive. See also the "rate-limit sessions" directive for use
11868 in frontends.
Willy Tarreau079ff0a2009-03-05 21:34:28 +010011869
11870 Example :
11871 # This frontend limits incoming mails to 10/s with a max of 100
11872 # concurrent connections. We accept any connection below 10/s, and
11873 # force excess clients to wait for 100 ms. Since clients are limited to
11874 # 100 max, there cannot be more than 10 incoming mails per second.
11875 frontend mail
11876 bind :25
11877 mode tcp
11878 maxconn 100
11879 acl too_fast fe_sess_rate ge 10
11880 tcp-request inspect-delay 100ms
11881 tcp-request content accept if ! too_fast
11882 tcp-request content accept if WAIT_END
Willy Tarreaud72758d2010-01-12 10:42:19 +010011883
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +020011884int(<integer>) : signed integer
11885 Returns a signed integer.
11886
Thierry FOURNIERcc103292015-06-06 19:30:17 +020011887ipv4(<ipv4>) : ipv4
11888 Returns an ipv4.
11889
11890ipv6(<ipv6>) : ipv6
11891 Returns an ipv6.
11892
11893meth(<method>) : method
11894 Returns a method.
11895
Willy Tarreau0f30d262014-11-24 16:02:05 +010011896nbproc : integer
11897 Returns an integer value corresponding to the number of processes that were
11898 started (it equals the global "nbproc" setting). This is useful for logging
11899 and debugging purposes.
11900
Willy Tarreau74ca5042013-06-11 23:12:07 +020011901nbsrv([<backend>]) : integer
11902 Returns an integer value corresponding to the number of usable servers of
11903 either the current backend or the named backend. This is mostly used with
11904 ACLs but can also be useful when added to logs. This is normally used to
Willy Tarreaud63335a2010-02-26 12:56:52 +010011905 switch to an alternate backend when the number of servers is too low to
11906 to handle some load. It is useful to report a failure when combined with
11907 "monitor fail".
Willy Tarreau079ff0a2009-03-05 21:34:28 +010011908
Willy Tarreau0f30d262014-11-24 16:02:05 +010011909proc : integer
11910 Returns an integer value corresponding to the position of the process calling
11911 the function, between 1 and global.nbproc. This is useful for logging and
11912 debugging purposes.
11913
Willy Tarreau74ca5042013-06-11 23:12:07 +020011914queue([<backend>]) : integer
Willy Tarreaud63335a2010-02-26 12:56:52 +010011915 Returns the total number of queued connections of the designated backend,
11916 including all the connections in server queues. If no backend name is
11917 specified, the current one is used, but it is also possible to check another
Willy Tarreau74ca5042013-06-11 23:12:07 +020011918 one. This is useful with ACLs or to pass statistics to backend servers. This
11919 can be used to take actions when queuing goes above a known level, generally
11920 indicating a surge of traffic or a massive slowdown on the servers. One
11921 possible action could be to reject new users but still accept old ones. See
11922 also the "avg_queue", "be_conn", and "be_sess_rate" fetches.
11923
Willy Tarreau84310e22014-02-14 11:59:04 +010011924rand([<range>]) : integer
11925 Returns a random integer value within a range of <range> possible values,
11926 starting at zero. If the range is not specified, it defaults to 2^32, which
11927 gives numbers between 0 and 4294967295. It can be useful to pass some values
11928 needed to take some routing decisions for example, or just for debugging
11929 purposes. This random must not be used for security purposes.
11930
Willy Tarreau74ca5042013-06-11 23:12:07 +020011931srv_conn([<backend>/]<server>) : integer
11932 Returns an integer value corresponding to the number of currently established
11933 connections on the designated server, possibly including the connection being
11934 evaluated. If <backend> is omitted, then the server is looked up in the
11935 current backend. It can be used to use a specific farm when one server is
11936 full, or to inform the server about our view of the number of active
11937 connections with it. See also the "fe_conn", "be_conn" and "queue" fetch
11938 methods.
11939
11940srv_is_up([<backend>/]<server>) : boolean
11941 Returns true when the designated server is UP, and false when it is either
11942 DOWN or in maintenance mode. If <backend> is omitted, then the server is
11943 looked up in the current backend. It is mainly used to take action based on
11944 an external status reported via a health check (eg: a geographical site's
11945 availability). Another possible use which is more of a hack consists in
11946 using dummy servers as boolean variables that can be enabled or disabled from
11947 the CLI, so that rules depending on those ACLs can be tweaked in realtime.
11948
11949srv_sess_rate([<backend>/]<server>) : integer
11950 Returns an integer corresponding to the sessions creation rate on the
11951 designated server, in number of new sessions per second. If <backend> is
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030011952 omitted, then the server is looked up in the current backend. This is mostly
Willy Tarreau74ca5042013-06-11 23:12:07 +020011953 used with ACLs but can make sense with logs too. This is used to switch to an
11954 alternate backend when an expensive or fragile one reaches too high a session
11955 rate, or to limit abuse of service (eg. prevent latent requests from
11956 overloading servers).
11957
11958 Example :
11959 # Redirect to a separate back
11960 acl srv1_full srv_sess_rate(be1/srv1) gt 50
11961 acl srv2_full srv_sess_rate(be1/srv2) gt 50
11962 use_backend be2 if srv1_full or srv2_full
11963
Willy Tarreau0f30d262014-11-24 16:02:05 +010011964stopping : boolean
11965 Returns TRUE if the process calling the function is currently stopping. This
11966 can be useful for logging, or for relaxing certain checks or helping close
11967 certain connections upon graceful shutdown.
11968
Thierry FOURNIERcc103292015-06-06 19:30:17 +020011969str(<string>) : string
11970 Returns a string.
11971
Willy Tarreau74ca5042013-06-11 23:12:07 +020011972table_avl([<table>]) : integer
11973 Returns the total number of available entries in the current proxy's
11974 stick-table or in the designated stick-table. See also table_cnt.
11975
11976table_cnt([<table>]) : integer
11977 Returns the total number of entries currently in use in the current proxy's
11978 stick-table or in the designated stick-table. See also src_conn_cnt and
11979 table_avl for other entry counting methods.
11980
Thierry FOURNIER4834bc72015-06-06 19:29:07 +020011981var(<var-name>) : undefined
11982 Returns a variable with the stored type. If the variable is not set, the
11983 sample fetch fails. The name of the variable starts by an indication about its
11984 scope. The scope allowed are:
11985 "sess" : the variable is shared with all the session,
11986 "txn" : the variable is shared with all the transaction (request and
11987 response),
11988 "req" : the variable is shared only during the request processing,
11989 "res" : the variable is shared only during the response processing.
11990 This prefix is followed by a name. The separator is a '.'. The name may only
11991 contain characters 'a-z', 'A-Z', '0-9' and '_'.
11992
Willy Tarreau74ca5042013-06-11 23:12:07 +020011993
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200119947.3.3. Fetching samples at Layer 4
Willy Tarreau74ca5042013-06-11 23:12:07 +020011995----------------------------------
11996
11997The layer 4 usually describes just the transport layer which in haproxy is
11998closest to the connection, where no content is yet made available. The fetch
11999methods described here are usable as low as the "tcp-request connection" rule
12000sets unless they require some future information. Those generally include
12001TCP/IP addresses and ports, as well as elements from stick-tables related to
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012002the incoming connection. For retrieving a value from a sticky counters, the
12003counter number can be explicitly set as 0, 1, or 2 using the pre-defined
12004"sc0_", "sc1_", or "sc2_" prefix, or it can be specified as the first integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012005argument when using the "sc_" prefix. An optional table may be specified with
12006the "sc*" form, in which case the currently tracked key will be looked up into
12007this alternate table instead of the table currently being tracked.
Willy Tarreau74ca5042013-06-11 23:12:07 +020012008
12009be_id : integer
12010 Returns an integer containing the current backend's id. It can be used in
12011 frontends with responses to check which backend processed the request.
12012
12013dst : ip
12014 This is the destination IPv4 address of the connection on the client side,
12015 which is the address the client connected to. It can be useful when running
12016 in transparent mode. It is of type IP and works on both IPv4 and IPv6 tables.
12017 On IPv6 tables, IPv4 address is mapped to its IPv6 equivalent, according to
12018 RFC 4291.
12019
12020dst_conn : integer
12021 Returns an integer value corresponding to the number of currently established
12022 connections on the same socket including the one being evaluated. It is
12023 normally used with ACLs but can as well be used to pass the information to
12024 servers in an HTTP header or in logs. It can be used to either return a sorry
12025 page before hard-blocking, or to use a specific backend to drain new requests
12026 when the socket is considered saturated. This offers the ability to assign
12027 different limits to different listening ports or addresses. See also the
12028 "fe_conn" and "be_conn" fetches.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012029
Willy Tarreau74ca5042013-06-11 23:12:07 +020012030dst_port : integer
12031 Returns an integer value corresponding to the destination TCP port of the
12032 connection on the client side, which is the port the client connected to.
12033 This might be used when running in transparent mode, when assigning dynamic
12034 ports to some clients for a whole application session, to stick all users to
12035 a same server, or to pass the destination port information to a server using
12036 an HTTP header.
12037
12038fe_id : integer
12039 Returns an integer containing the current frontend's id. It can be used in
12040 backends to check from which backend it was called, or to stick all users
12041 coming via a same frontend to the same server.
12042
Cyril Bonté62ba8702014-04-22 23:52:25 +020012043sc_bytes_in_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012044sc0_bytes_in_rate([<table>]) : integer
12045sc1_bytes_in_rate([<table>]) : integer
12046sc2_bytes_in_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012047 Returns the average client-to-server bytes rate from the currently tracked
12048 counters, measured in amount of bytes over the period configured in the
12049 table. See also src_bytes_in_rate.
12050
Cyril Bonté62ba8702014-04-22 23:52:25 +020012051sc_bytes_out_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012052sc0_bytes_out_rate([<table>]) : integer
12053sc1_bytes_out_rate([<table>]) : integer
12054sc2_bytes_out_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012055 Returns the average server-to-client bytes rate from the currently tracked
12056 counters, measured in amount of bytes over the period configured in the
12057 table. See also src_bytes_out_rate.
12058
Cyril Bonté62ba8702014-04-22 23:52:25 +020012059sc_clr_gpc0(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012060sc0_clr_gpc0([<table>]) : integer
12061sc1_clr_gpc0([<table>]) : integer
12062sc2_clr_gpc0([<table>]) : integer
Willy Tarreauf73cd112011-08-13 01:45:16 +020012063 Clears the first General Purpose Counter associated to the currently tracked
12064 counters, and returns its previous value. Before the first invocation, the
Willy Tarreau869948b2013-01-04 14:14:57 +010012065 stored value is zero, so first invocation will always return zero. This is
12066 typically used as a second ACL in an expression in order to mark a connection
12067 when a first ACL was verified :
Willy Tarreauf73cd112011-08-13 01:45:16 +020012068
12069 # block if 5 consecutive requests continue to come faster than 10 sess
12070 # per second, and reset the counter as soon as the traffic slows down.
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020012071 acl abuse sc0_http_req_rate gt 10
12072 acl kill sc0_inc_gpc0 gt 5
12073 acl save sc0_clr_gpc0 ge 0
Willy Tarreauf73cd112011-08-13 01:45:16 +020012074 tcp-request connection accept if !abuse save
12075 tcp-request connection reject if abuse kill
12076
Cyril Bonté62ba8702014-04-22 23:52:25 +020012077sc_conn_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012078sc0_conn_cnt([<table>]) : integer
12079sc1_conn_cnt([<table>]) : integer
12080sc2_conn_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012081 Returns the cumulated number of incoming connections from currently tracked
12082 counters. See also src_conn_cnt.
12083
Cyril Bonté62ba8702014-04-22 23:52:25 +020012084sc_conn_cur(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012085sc0_conn_cur([<table>]) : integer
12086sc1_conn_cur([<table>]) : integer
12087sc2_conn_cur([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012088 Returns the current amount of concurrent connections tracking the same
12089 tracked counters. This number is automatically incremented when tracking
12090 begins and decremented when tracking stops. See also src_conn_cur.
12091
Cyril Bonté62ba8702014-04-22 23:52:25 +020012092sc_conn_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012093sc0_conn_rate([<table>]) : integer
12094sc1_conn_rate([<table>]) : integer
12095sc2_conn_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012096 Returns the average connection rate from the currently tracked counters,
12097 measured in amount of connections over the period configured in the table.
12098 See also src_conn_rate.
12099
Cyril Bonté62ba8702014-04-22 23:52:25 +020012100sc_get_gpc0(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012101sc0_get_gpc0([<table>]) : integer
12102sc1_get_gpc0([<table>]) : integer
12103sc2_get_gpc0([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012104 Returns the value of the first General Purpose Counter associated to the
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012105 currently tracked counters. See also src_get_gpc0 and sc/sc0/sc1/sc2_inc_gpc0.
Willy Tarreauba2ffd12013-05-29 15:54:14 +020012106
Thierry FOURNIER236657b2015-08-19 08:25:14 +020012107sc_get_gpt0(<ctr>[,<table>]) : integer
12108sc0_get_gpt0([<table>]) : integer
12109sc1_get_gpt0([<table>]) : integer
12110sc2_get_gpt0([<table>]) : integer
12111 Returns the value of the first General Purpose Tag associated to the
12112 currently tracked counters. See also src_get_gpt0.
12113
Cyril Bonté62ba8702014-04-22 23:52:25 +020012114sc_gpc0_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012115sc0_gpc0_rate([<table>]) : integer
12116sc1_gpc0_rate([<table>]) : integer
12117sc2_gpc0_rate([<table>]) : integer
Willy Tarreauba2ffd12013-05-29 15:54:14 +020012118 Returns the average increment rate of the first General Purpose Counter
12119 associated to the currently tracked counters. It reports the frequency
12120 which the gpc0 counter was incremented over the configured period. See also
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012121 src_gpc0_rate, sc/sc0/sc1/sc2_get_gpc0, and sc/sc0/sc1/sc2_inc_gpc0. Note
12122 that the "gpc0_rate" counter must be stored in the stick-table for a value to
12123 be returned, as "gpc0" only holds the event count.
Willy Tarreaue9656522010-08-17 15:40:09 +020012124
Cyril Bonté62ba8702014-04-22 23:52:25 +020012125sc_http_err_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012126sc0_http_err_cnt([<table>]) : integer
12127sc1_http_err_cnt([<table>]) : integer
12128sc2_http_err_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012129 Returns the cumulated number of HTTP errors from the currently tracked
12130 counters. This includes the both request errors and 4xx error responses.
12131 See also src_http_err_cnt.
12132
Cyril Bonté62ba8702014-04-22 23:52:25 +020012133sc_http_err_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012134sc0_http_err_rate([<table>]) : integer
12135sc1_http_err_rate([<table>]) : integer
12136sc2_http_err_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012137 Returns the average rate of HTTP errors from the currently tracked counters,
12138 measured in amount of errors over the period configured in the table. This
12139 includes the both request errors and 4xx error responses. See also
12140 src_http_err_rate.
12141
Cyril Bonté62ba8702014-04-22 23:52:25 +020012142sc_http_req_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012143sc0_http_req_cnt([<table>]) : integer
12144sc1_http_req_cnt([<table>]) : integer
12145sc2_http_req_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012146 Returns the cumulated number of HTTP requests from the currently tracked
12147 counters. This includes every started request, valid or not. See also
12148 src_http_req_cnt.
12149
Cyril Bonté62ba8702014-04-22 23:52:25 +020012150sc_http_req_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012151sc0_http_req_rate([<table>]) : integer
12152sc1_http_req_rate([<table>]) : integer
12153sc2_http_req_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012154 Returns the average rate of HTTP requests from the currently tracked
12155 counters, measured in amount of requests over the period configured in
12156 the table. This includes every started request, valid or not. See also
12157 src_http_req_rate.
12158
Cyril Bonté62ba8702014-04-22 23:52:25 +020012159sc_inc_gpc0(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012160sc0_inc_gpc0([<table>]) : integer
12161sc1_inc_gpc0([<table>]) : integer
12162sc2_inc_gpc0([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012163 Increments the first General Purpose Counter associated to the currently
Willy Tarreau869948b2013-01-04 14:14:57 +010012164 tracked counters, and returns its new value. Before the first invocation,
12165 the stored value is zero, so first invocation will increase it to 1 and will
12166 return 1. This is typically used as a second ACL in an expression in order
12167 to mark a connection when a first ACL was verified :
Willy Tarreaue9656522010-08-17 15:40:09 +020012168
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020012169 acl abuse sc0_http_req_rate gt 10
12170 acl kill sc0_inc_gpc0 gt 0
Willy Tarreaue9656522010-08-17 15:40:09 +020012171 tcp-request connection reject if abuse kill
12172
Cyril Bonté62ba8702014-04-22 23:52:25 +020012173sc_kbytes_in(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012174sc0_kbytes_in([<table>]) : integer
12175sc1_kbytes_in([<table>]) : integer
12176sc2_kbytes_in([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020012177 Returns the total amount of client-to-server data from the currently tracked
12178 counters, measured in kilobytes. The test is currently performed on 32-bit
12179 integers, which limits values to 4 terabytes. See also src_kbytes_in.
Willy Tarreaue9656522010-08-17 15:40:09 +020012180
Cyril Bonté62ba8702014-04-22 23:52:25 +020012181sc_kbytes_out(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012182sc0_kbytes_out([<table>]) : integer
12183sc1_kbytes_out([<table>]) : integer
12184sc2_kbytes_out([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020012185 Returns the total amount of server-to-client data from the currently tracked
12186 counters, measured in kilobytes. The test is currently performed on 32-bit
12187 integers, which limits values to 4 terabytes. See also src_kbytes_out.
Willy Tarreaue9656522010-08-17 15:40:09 +020012188
Cyril Bonté62ba8702014-04-22 23:52:25 +020012189sc_sess_cnt(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012190sc0_sess_cnt([<table>]) : integer
12191sc1_sess_cnt([<table>]) : integer
12192sc2_sess_cnt([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012193 Returns the cumulated number of incoming connections that were transformed
12194 into sessions, which means that they were accepted by a "tcp-request
12195 connection" rule, from the currently tracked counters. A backend may count
12196 more sessions than connections because each connection could result in many
Jamie Gloudonaaa21002012-08-25 00:18:33 -040012197 backend sessions if some HTTP keep-alive is performed over the connection
Willy Tarreaue9656522010-08-17 15:40:09 +020012198 with the client. See also src_sess_cnt.
12199
Cyril Bonté62ba8702014-04-22 23:52:25 +020012200sc_sess_rate(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012201sc0_sess_rate([<table>]) : integer
12202sc1_sess_rate([<table>]) : integer
12203sc2_sess_rate([<table>]) : integer
Willy Tarreaue9656522010-08-17 15:40:09 +020012204 Returns the average session rate from the currently tracked counters,
12205 measured in amount of sessions over the period configured in the table. A
12206 session is a connection that got past the early "tcp-request connection"
12207 rules. A backend may count more sessions than connections because each
12208 connection could result in many backend sessions if some HTTP keep-alive is
Jamie Gloudonaaa21002012-08-25 00:18:33 -040012209 performed over the connection with the client. See also src_sess_rate.
Willy Tarreaue9656522010-08-17 15:40:09 +020012210
Cyril Bonté62ba8702014-04-22 23:52:25 +020012211sc_tracked(<ctr>[,<table>]) : boolean
Willy Tarreau0f791d42013-07-23 19:56:43 +020012212sc0_tracked([<table>]) : boolean
12213sc1_tracked([<table>]) : boolean
12214sc2_tracked([<table>]) : boolean
Willy Tarreau6f1615f2013-06-03 15:15:22 +020012215 Returns true if the designated session counter is currently being tracked by
12216 the current session. This can be useful when deciding whether or not we want
12217 to set some values in a header passed to the server.
12218
Cyril Bonté62ba8702014-04-22 23:52:25 +020012219sc_trackers(<ctr>[,<table>]) : integer
Willy Tarreau0f791d42013-07-23 19:56:43 +020012220sc0_trackers([<table>]) : integer
12221sc1_trackers([<table>]) : integer
12222sc2_trackers([<table>]) : integer
Willy Tarreau2406db42012-12-09 12:16:43 +010012223 Returns the current amount of concurrent connections tracking the same
12224 tracked counters. This number is automatically incremented when tracking
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020012225 begins and decremented when tracking stops. It differs from sc0_conn_cur in
Willy Tarreau2406db42012-12-09 12:16:43 +010012226 that it does not rely on any stored information but on the table's reference
12227 count (the "use" value which is returned by "show table" on the CLI). This
Willy Tarreau74ca5042013-06-11 23:12:07 +020012228 may sometimes be more suited for layer7 tracking. It can be used to tell a
12229 server how many concurrent connections there are from a given address for
12230 example.
Willy Tarreau2406db42012-12-09 12:16:43 +010012231
Willy Tarreau74ca5042013-06-11 23:12:07 +020012232so_id : integer
12233 Returns an integer containing the current listening socket's id. It is useful
12234 in frontends involving many "bind" lines, or to stick all users coming via a
12235 same socket to the same server.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012236
Willy Tarreau74ca5042013-06-11 23:12:07 +020012237src : ip
12238 This is the source IPv4 address of the client of the session. It is of type
12239 IP and works on both IPv4 and IPv6 tables. On IPv6 tables, IPv4 addresses are
12240 mapped to their IPv6 equivalent, according to RFC 4291. Note that it is the
12241 TCP-level source address which is used, and not the address of a client
12242 behind a proxy. However if the "accept-proxy" bind directive is used, it can
12243 be the address of a client behind another PROXY-protocol compatible component
12244 for all rule sets except "tcp-request connection" which sees the real address.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012245
Thierry FOURNIERd5f624d2013-11-26 11:52:33 +010012246 Example:
12247 # add an HTTP header in requests with the originating address' country
12248 http-request set-header X-Country %[src,map_ip(geoip.lst)]
12249
Willy Tarreau74ca5042013-06-11 23:12:07 +020012250src_bytes_in_rate([<table>]) : integer
12251 Returns the average bytes rate from the incoming connection's source address
12252 in the current proxy's stick-table or in the designated stick-table, measured
12253 in amount of bytes over the period configured in the table. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012254 not found, zero is returned. See also sc/sc0/sc1/sc2_bytes_in_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012255
Willy Tarreau74ca5042013-06-11 23:12:07 +020012256src_bytes_out_rate([<table>]) : integer
12257 Returns the average bytes rate to the incoming connection's source address in
12258 the current proxy's stick-table or in the designated stick-table, measured in
Willy Tarreauc9705a12010-07-27 20:05:50 +020012259 amount of bytes over the period configured in the table. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012260 not found, zero is returned. See also sc/sc0/sc1/sc2_bytes_out_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012261
Willy Tarreau74ca5042013-06-11 23:12:07 +020012262src_clr_gpc0([<table>]) : integer
12263 Clears the first General Purpose Counter associated to the incoming
12264 connection's source address in the current proxy's stick-table or in the
12265 designated stick-table, and returns its previous value. If the address is not
12266 found, an entry is created and 0 is returned. This is typically used as a
12267 second ACL in an expression in order to mark a connection when a first ACL
12268 was verified :
Willy Tarreauf73cd112011-08-13 01:45:16 +020012269
12270 # block if 5 consecutive requests continue to come faster than 10 sess
12271 # per second, and reset the counter as soon as the traffic slows down.
12272 acl abuse src_http_req_rate gt 10
12273 acl kill src_inc_gpc0 gt 5
Willy Tarreau869948b2013-01-04 14:14:57 +010012274 acl save src_clr_gpc0 ge 0
Willy Tarreauf73cd112011-08-13 01:45:16 +020012275 tcp-request connection accept if !abuse save
12276 tcp-request connection reject if abuse kill
12277
Willy Tarreau74ca5042013-06-11 23:12:07 +020012278src_conn_cnt([<table>]) : integer
Willy Tarreauc9705a12010-07-27 20:05:50 +020012279 Returns the cumulated number of connections initiated from the current
Willy Tarreau74ca5042013-06-11 23:12:07 +020012280 incoming connection's source address in the current proxy's stick-table or in
Willy Tarreauc9705a12010-07-27 20:05:50 +020012281 the designated stick-table. If the address is not found, zero is returned.
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012282 See also sc/sc0/sc1/sc2_conn_cnt.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012283
Willy Tarreau74ca5042013-06-11 23:12:07 +020012284src_conn_cur([<table>]) : integer
Willy Tarreauc9705a12010-07-27 20:05:50 +020012285 Returns the current amount of concurrent connections initiated from the
Willy Tarreau74ca5042013-06-11 23:12:07 +020012286 current incoming connection's source address in the current proxy's
12287 stick-table or in the designated stick-table. If the address is not found,
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012288 zero is returned. See also sc/sc0/sc1/sc2_conn_cur.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012289
Willy Tarreau74ca5042013-06-11 23:12:07 +020012290src_conn_rate([<table>]) : integer
12291 Returns the average connection rate from the incoming connection's source
12292 address in the current proxy's stick-table or in the designated stick-table,
12293 measured in amount of connections over the period configured in the table. If
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012294 the address is not found, zero is returned. See also sc/sc0/sc1/sc2_conn_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012295
Willy Tarreau74ca5042013-06-11 23:12:07 +020012296src_get_gpc0([<table>]) : integer
Willy Tarreauc9705a12010-07-27 20:05:50 +020012297 Returns the value of the first General Purpose Counter associated to the
Willy Tarreau74ca5042013-06-11 23:12:07 +020012298 incoming connection's source address in the current proxy's stick-table or in
Willy Tarreauc9705a12010-07-27 20:05:50 +020012299 the designated stick-table. If the address is not found, zero is returned.
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012300 See also sc/sc0/sc1/sc2_get_gpc0 and src_inc_gpc0.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012301
Thierry FOURNIER236657b2015-08-19 08:25:14 +020012302src_get_gpt0([<table>]) : integer
12303 Returns the value of the first General Purpose Tag associated to the
12304 incoming connection's source address in the current proxy's stick-table or in
12305 the designated stick-table. If the address is not found, zero is returned.
12306 See also sc/sc0/sc1/sc2_get_gpt0.
12307
Willy Tarreau74ca5042013-06-11 23:12:07 +020012308src_gpc0_rate([<table>]) : integer
Willy Tarreauba2ffd12013-05-29 15:54:14 +020012309 Returns the average increment rate of the first General Purpose Counter
Willy Tarreau74ca5042013-06-11 23:12:07 +020012310 associated to the incoming connection's source address in the current proxy's
Willy Tarreauba2ffd12013-05-29 15:54:14 +020012311 stick-table or in the designated stick-table. It reports the frequency
12312 which the gpc0 counter was incremented over the configured period. See also
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012313 sc/sc0/sc1/sc2_gpc0_rate, src_get_gpc0, and sc/sc0/sc1/sc2_inc_gpc0. Note
12314 that the "gpc0_rate" counter must be stored in the stick-table for a value to
12315 be returned, as "gpc0" only holds the event count.
Willy Tarreauba2ffd12013-05-29 15:54:14 +020012316
Willy Tarreau74ca5042013-06-11 23:12:07 +020012317src_http_err_cnt([<table>]) : integer
12318 Returns the cumulated number of HTTP errors from the incoming connection's
12319 source address in the current proxy's stick-table or in the designated
Willy Tarreauc9705a12010-07-27 20:05:50 +020012320 stick-table. This includes the both request errors and 4xx error responses.
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012321 See also sc/sc0/sc1/sc2_http_err_cnt. If the address is not found, zero is
Willy Tarreau74ca5042013-06-11 23:12:07 +020012322 returned.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012323
Willy Tarreau74ca5042013-06-11 23:12:07 +020012324src_http_err_rate([<table>]) : integer
12325 Returns the average rate of HTTP errors from the incoming connection's source
12326 address in the current proxy's stick-table or in the designated stick-table,
12327 measured in amount of errors over the period configured in the table. This
12328 includes the both request errors and 4xx error responses. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012329 not found, zero is returned. See also sc/sc0/sc1/sc2_http_err_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012330
Willy Tarreau74ca5042013-06-11 23:12:07 +020012331src_http_req_cnt([<table>]) : integer
12332 Returns the cumulated number of HTTP requests from the incoming connection's
12333 source address in the current proxy's stick-table or in the designated stick-
12334 table. This includes every started request, valid or not. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012335 not found, zero is returned. See also sc/sc0/sc1/sc2_http_req_cnt.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012336
Willy Tarreau74ca5042013-06-11 23:12:07 +020012337src_http_req_rate([<table>]) : integer
12338 Returns the average rate of HTTP requests from the incoming connection's
12339 source address in the current proxy's stick-table or in the designated stick-
12340 table, measured in amount of requests over the period configured in the
Willy Tarreauc9705a12010-07-27 20:05:50 +020012341 table. This includes every started request, valid or not. If the address is
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012342 not found, zero is returned. See also sc/sc0/sc1/sc2_http_req_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012343
Willy Tarreau74ca5042013-06-11 23:12:07 +020012344src_inc_gpc0([<table>]) : integer
12345 Increments the first General Purpose Counter associated to the incoming
12346 connection's source address in the current proxy's stick-table or in the
12347 designated stick-table, and returns its new value. If the address is not
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020012348 found, an entry is created and 1 is returned. See also sc0/sc2/sc2_inc_gpc0.
Willy Tarreau74ca5042013-06-11 23:12:07 +020012349 This is typically used as a second ACL in an expression in order to mark a
12350 connection when a first ACL was verified :
Willy Tarreauc9705a12010-07-27 20:05:50 +020012351
12352 acl abuse src_http_req_rate gt 10
Willy Tarreau869948b2013-01-04 14:14:57 +010012353 acl kill src_inc_gpc0 gt 0
Willy Tarreaue9656522010-08-17 15:40:09 +020012354 tcp-request connection reject if abuse kill
Willy Tarreauc9705a12010-07-27 20:05:50 +020012355
Willy Tarreau74ca5042013-06-11 23:12:07 +020012356src_kbytes_in([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020012357 Returns the total amount of data received from the incoming connection's
12358 source address in the current proxy's stick-table or in the designated
12359 stick-table, measured in kilobytes. If the address is not found, zero is
12360 returned. The test is currently performed on 32-bit integers, which limits
12361 values to 4 terabytes. See also sc/sc0/sc1/sc2_kbytes_in.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012362
Willy Tarreau74ca5042013-06-11 23:12:07 +020012363src_kbytes_out([<table>]) : integer
Willy Tarreaua01b9742014-07-10 15:29:24 +020012364 Returns the total amount of data sent to the incoming connection's source
12365 address in the current proxy's stick-table or in the designated stick-table,
12366 measured in kilobytes. If the address is not found, zero is returned. The
12367 test is currently performed on 32-bit integers, which limits values to 4
12368 terabytes. See also sc/sc0/sc1/sc2_kbytes_out.
Willy Tarreaua975b8f2010-06-05 19:13:27 +020012369
Willy Tarreau74ca5042013-06-11 23:12:07 +020012370src_port : integer
12371 Returns an integer value corresponding to the TCP source port of the
12372 connection on the client side, which is the port the client connected from.
12373 Usage of this function is very limited as modern protocols do not care much
12374 about source ports nowadays.
Willy Tarreau079ff0a2009-03-05 21:34:28 +010012375
Willy Tarreau74ca5042013-06-11 23:12:07 +020012376src_sess_cnt([<table>]) : integer
12377 Returns the cumulated number of connections initiated from the incoming
Willy Tarreauc9705a12010-07-27 20:05:50 +020012378 connection's source IPv4 address in the current proxy's stick-table or in the
12379 designated stick-table, that were transformed into sessions, which means that
12380 they were accepted by "tcp-request" rules. If the address is not found, zero
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012381 is returned. See also sc/sc0/sc1/sc2_sess_cnt.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012382
Willy Tarreau74ca5042013-06-11 23:12:07 +020012383src_sess_rate([<table>]) : integer
12384 Returns the average session rate from the incoming connection's source
12385 address in the current proxy's stick-table or in the designated stick-table,
12386 measured in amount of sessions over the period configured in the table. A
12387 session is a connection that went past the early "tcp-request" rules. If the
Willy Tarreau4d4149c2013-07-23 19:33:46 +020012388 address is not found, zero is returned. See also sc/sc0/sc1/sc2_sess_rate.
Willy Tarreauc9705a12010-07-27 20:05:50 +020012389
Willy Tarreau74ca5042013-06-11 23:12:07 +020012390src_updt_conn_cnt([<table>]) : integer
12391 Creates or updates the entry associated to the incoming connection's source
12392 address in the current proxy's stick-table or in the designated stick-table.
12393 This table must be configured to store the "conn_cnt" data type, otherwise
12394 the match will be ignored. The current count is incremented by one, and the
12395 expiration timer refreshed. The updated count is returned, so this match
12396 can't return zero. This was used to reject service abusers based on their
12397 source address. Note: it is recommended to use the more complete "track-sc*"
12398 actions in "tcp-request" rules instead.
Willy Tarreaua975b8f2010-06-05 19:13:27 +020012399
12400 Example :
12401 # This frontend limits incoming SSH connections to 3 per 10 second for
12402 # each source address, and rejects excess connections until a 10 second
12403 # silence is observed. At most 20 addresses are tracked.
12404 listen ssh
12405 bind :22
12406 mode tcp
12407 maxconn 100
Willy Tarreauc9705a12010-07-27 20:05:50 +020012408 stick-table type ip size 20 expire 10s store conn_cnt
Willy Tarreau74ca5042013-06-11 23:12:07 +020012409 tcp-request content reject if { src_updt_conn_cnt gt 3 }
Willy Tarreaua975b8f2010-06-05 19:13:27 +020012410 server local 127.0.0.1:22
12411
Willy Tarreau74ca5042013-06-11 23:12:07 +020012412srv_id : integer
12413 Returns an integer containing the server's id when processing the response.
12414 While it's almost only used with ACLs, it may be used for logging or
12415 debugging.
Hervé COMMOWICKdaa824e2011-08-05 12:09:44 +020012416
Hervé COMMOWICK35ed8012010-12-15 14:04:51 +010012417
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200124187.3.4. Fetching samples at Layer 5
Willy Tarreau74ca5042013-06-11 23:12:07 +020012419----------------------------------
Willy Tarreau0b1cd942010-05-16 22:18:27 +020012420
Willy Tarreau74ca5042013-06-11 23:12:07 +020012421The layer 5 usually describes just the session layer which in haproxy is
12422closest to the session once all the connection handshakes are finished, but
12423when no content is yet made available. The fetch methods described here are
12424usable as low as the "tcp-request content" rule sets unless they require some
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030012425future information. Those generally include the results of SSL negotiations.
Willy Tarreauc735a072011-03-29 00:57:02 +020012426
Emeric Brun645ae792014-04-30 14:21:06 +020012427ssl_bc : boolean
12428 Returns true when the back connection was made via an SSL/TLS transport
12429 layer and is locally deciphered. This means the outgoing connection was made
12430 other a server with the "ssl" option.
12431
12432ssl_bc_alg_keysize : integer
12433 Returns the symmetric cipher key size supported in bits when the outgoing
12434 connection was made over an SSL/TLS transport layer.
12435
12436ssl_bc_cipher : string
12437 Returns the name of the used cipher when the outgoing connection was made
12438 over an SSL/TLS transport layer.
12439
12440ssl_bc_protocol : string
12441 Returns the name of the used protocol when the outgoing connection was made
12442 over an SSL/TLS transport layer.
12443
Emeric Brunb73a9b02014-04-30 18:49:19 +020012444ssl_bc_unique_id : binary
Emeric Brun645ae792014-04-30 14:21:06 +020012445 When the outgoing connection was made over an SSL/TLS transport layer,
Emeric Brunb73a9b02014-04-30 18:49:19 +020012446 returns the TLS unique ID as defined in RFC5929 section 3. The unique id
12447 can be encoded to base64 using the converter: "ssl_bc_unique_id,base64".
Emeric Brun645ae792014-04-30 14:21:06 +020012448
12449ssl_bc_session_id : binary
12450 Returns the SSL ID of the back connection when the outgoing connection was
12451 made over an SSL/TLS transport layer. It is useful to log if we want to know
12452 if session was reused or not.
12453
12454ssl_bc_use_keysize : integer
12455 Returns the symmetric cipher key size used in bits when the outgoing
12456 connection was made over an SSL/TLS transport layer.
12457
Willy Tarreau74ca5042013-06-11 23:12:07 +020012458ssl_c_ca_err : integer
12459 When the incoming connection was made over an SSL/TLS transport layer,
12460 returns the ID of the first error detected during verification of the client
12461 certificate at depth > 0, or 0 if no error was encountered during this
12462 verification process. Please refer to your SSL library's documentation to
12463 find the exhaustive list of error codes.
Willy Tarreauc735a072011-03-29 00:57:02 +020012464
Willy Tarreau74ca5042013-06-11 23:12:07 +020012465ssl_c_ca_err_depth : integer
12466 When the incoming connection was made over an SSL/TLS transport layer,
12467 returns the depth in the CA chain of the first error detected during the
12468 verification of the client certificate. If no error is encountered, 0 is
12469 returned.
Willy Tarreau0ba27502007-12-24 16:55:16 +010012470
Emeric Brun43e79582014-10-29 19:03:26 +010012471ssl_c_der : binary
12472 Returns the DER formatted certificate presented by the client when the
12473 incoming connection was made over an SSL/TLS transport layer. When used for
12474 an ACL, the value(s) to match against can be passed in hexadecimal form.
12475
Willy Tarreau74ca5042013-06-11 23:12:07 +020012476ssl_c_err : integer
12477 When the incoming connection was made over an SSL/TLS transport layer,
12478 returns the ID of the first error detected during verification at depth 0, or
12479 0 if no error was encountered during this verification process. Please refer
12480 to your SSL library's documentation to find the exhaustive list of error
12481 codes.
Willy Tarreau62644772008-07-16 18:36:06 +020012482
Willy Tarreau74ca5042013-06-11 23:12:07 +020012483ssl_c_i_dn([<entry>[,<occ>]]) : string
12484 When the incoming connection was made over an SSL/TLS transport layer,
12485 returns the full distinguished name of the issuer of the certificate
12486 presented by the client when no <entry> is specified, or the value of the
12487 first given entry found from the beginning of the DN. If a positive/negative
12488 occurrence number is specified as the optional second argument, it returns
12489 the value of the nth given entry value from the beginning/end of the DN.
12490 For instance, "ssl_c_i_dn(OU,2)" the second organization unit, and
12491 "ssl_c_i_dn(CN)" retrieves the common name.
Willy Tarreau62644772008-07-16 18:36:06 +020012492
Willy Tarreau74ca5042013-06-11 23:12:07 +020012493ssl_c_key_alg : string
12494 Returns the name of the algorithm used to generate the key of the certificate
12495 presented by the client when the incoming connection was made over an SSL/TLS
12496 transport layer.
Willy Tarreau62644772008-07-16 18:36:06 +020012497
Willy Tarreau74ca5042013-06-11 23:12:07 +020012498ssl_c_notafter : string
12499 Returns the end date presented by the client as a formatted string
12500 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
12501 transport layer.
Emeric Brunbede3d02009-06-30 17:54:00 +020012502
Willy Tarreau74ca5042013-06-11 23:12:07 +020012503ssl_c_notbefore : string
12504 Returns the start date presented by the client as a formatted string
12505 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
12506 transport layer.
Willy Tarreaub6672b52011-12-12 17:23:41 +010012507
Willy Tarreau74ca5042013-06-11 23:12:07 +020012508ssl_c_s_dn([<entry>[,<occ>]]) : string
12509 When the incoming connection was made over an SSL/TLS transport layer,
12510 returns the full distinguished name of the subject of the certificate
12511 presented by the client when no <entry> is specified, or the value of the
12512 first given entry found from the beginning of the DN. If a positive/negative
12513 occurrence number is specified as the optional second argument, it returns
12514 the value of the nth given entry value from the beginning/end of the DN.
12515 For instance, "ssl_c_s_dn(OU,2)" the second organization unit, and
12516 "ssl_c_s_dn(CN)" retrieves the common name.
Willy Tarreaub6672b52011-12-12 17:23:41 +010012517
Willy Tarreau74ca5042013-06-11 23:12:07 +020012518ssl_c_serial : binary
12519 Returns the serial of the certificate presented by the client when the
12520 incoming connection was made over an SSL/TLS transport layer. When used for
12521 an ACL, the value(s) to match against can be passed in hexadecimal form.
Emeric Brun2525b6b2012-10-18 15:59:43 +020012522
Willy Tarreau74ca5042013-06-11 23:12:07 +020012523ssl_c_sha1 : binary
12524 Returns the SHA-1 fingerprint of the certificate presented by the client when
12525 the incoming connection was made over an SSL/TLS transport layer. This can be
12526 used to stick a client to a server, or to pass this information to a server.
Willy Tarreau2d0caa32014-07-02 19:01:22 +020012527 Note that the output is binary, so if you want to pass that signature to the
12528 server, you need to encode it in hex or base64, such as in the example below:
12529
12530 http-request set-header X-SSL-Client-SHA1 %[ssl_c_sha1,hex]
Emeric Brun2525b6b2012-10-18 15:59:43 +020012531
Willy Tarreau74ca5042013-06-11 23:12:07 +020012532ssl_c_sig_alg : string
12533 Returns the name of the algorithm used to sign the certificate presented by
12534 the client when the incoming connection was made over an SSL/TLS transport
12535 layer.
Emeric Brun87855892012-10-17 17:39:35 +020012536
Willy Tarreau74ca5042013-06-11 23:12:07 +020012537ssl_c_used : boolean
12538 Returns true if current SSL session uses a client certificate even if current
12539 connection uses SSL session resumption. See also "ssl_fc_has_crt".
Emeric Brun7f56e742012-10-19 18:15:40 +020012540
Willy Tarreau74ca5042013-06-11 23:12:07 +020012541ssl_c_verify : integer
12542 Returns the verify result error ID when the incoming connection was made over
12543 an SSL/TLS transport layer, otherwise zero if no error is encountered. Please
12544 refer to your SSL library's documentation for an exhaustive list of error
12545 codes.
Emeric Brunce5ad802012-10-22 14:11:22 +020012546
Willy Tarreau74ca5042013-06-11 23:12:07 +020012547ssl_c_version : integer
12548 Returns the version of the certificate presented by the client when the
12549 incoming connection was made over an SSL/TLS transport layer.
Emeric Brunce5ad802012-10-22 14:11:22 +020012550
Emeric Brun43e79582014-10-29 19:03:26 +010012551ssl_f_der : binary
12552 Returns the DER formatted certificate presented by the frontend when the
12553 incoming connection was made over an SSL/TLS transport layer. When used for
12554 an ACL, the value(s) to match against can be passed in hexadecimal form.
12555
Willy Tarreau74ca5042013-06-11 23:12:07 +020012556ssl_f_i_dn([<entry>[,<occ>]]) : string
12557 When the incoming connection was made over an SSL/TLS transport layer,
12558 returns the full distinguished name of the issuer of the certificate
12559 presented by the frontend when no <entry> is specified, or the value of the
12560 first given entry found from the beginning of the DN. If a positive/negative
Emeric Brun87855892012-10-17 17:39:35 +020012561 occurrence number is specified as the optional second argument, it returns
Willy Tarreau74ca5042013-06-11 23:12:07 +020012562 the value of the nth given entry value from the beginning/end of the DN.
12563 For instance, "ssl_f_i_dn(OU,2)" the second organization unit, and
12564 "ssl_f_i_dn(CN)" retrieves the common name.
Emeric Brun87855892012-10-17 17:39:35 +020012565
Willy Tarreau74ca5042013-06-11 23:12:07 +020012566ssl_f_key_alg : string
12567 Returns the name of the algorithm used to generate the key of the certificate
12568 presented by the frontend when the incoming connection was made over an
12569 SSL/TLS transport layer.
Emeric Brun7f56e742012-10-19 18:15:40 +020012570
Willy Tarreau74ca5042013-06-11 23:12:07 +020012571ssl_f_notafter : string
12572 Returns the end date presented by the frontend as a formatted string
12573 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
12574 transport layer.
Emeric Brun2525b6b2012-10-18 15:59:43 +020012575
Willy Tarreau74ca5042013-06-11 23:12:07 +020012576ssl_f_notbefore : string
12577 Returns the start date presented by the frontend as a formatted string
12578 YYMMDDhhmmss[Z] when the incoming connection was made over an SSL/TLS
12579 transport layer.
Emeric Brun87855892012-10-17 17:39:35 +020012580
Willy Tarreau74ca5042013-06-11 23:12:07 +020012581ssl_f_s_dn([<entry>[,<occ>]]) : string
12582 When the incoming connection was made over an SSL/TLS transport layer,
12583 returns the full distinguished name of the subject of the certificate
12584 presented by the frontend when no <entry> is specified, or the value of the
12585 first given entry found from the beginning of the DN. If a positive/negative
12586 occurrence number is specified as the optional second argument, it returns
12587 the value of the nth given entry value from the beginning/end of the DN.
12588 For instance, "ssl_f_s_dn(OU,2)" the second organization unit, and
12589 "ssl_f_s_dn(CN)" retrieves the common name.
Emeric Brunce5ad802012-10-22 14:11:22 +020012590
Willy Tarreau74ca5042013-06-11 23:12:07 +020012591ssl_f_serial : binary
12592 Returns the serial of the certificate presented by the frontend when the
12593 incoming connection was made over an SSL/TLS transport layer. When used for
12594 an ACL, the value(s) to match against can be passed in hexadecimal form.
Emeric Brun87855892012-10-17 17:39:35 +020012595
Emeric Brun55f4fa82014-04-30 17:11:25 +020012596ssl_f_sha1 : binary
12597 Returns the SHA-1 fingerprint of the certificate presented by the frontend
12598 when the incoming connection was made over an SSL/TLS transport layer. This
12599 can be used to know which certificate was chosen using SNI.
12600
Willy Tarreau74ca5042013-06-11 23:12:07 +020012601ssl_f_sig_alg : string
12602 Returns the name of the algorithm used to sign the certificate presented by
12603 the frontend when the incoming connection was made over an SSL/TLS transport
12604 layer.
Emeric Brun7f56e742012-10-19 18:15:40 +020012605
Willy Tarreau74ca5042013-06-11 23:12:07 +020012606ssl_f_version : integer
12607 Returns the version of the certificate presented by the frontend when the
12608 incoming connection was made over an SSL/TLS transport layer.
12609
12610ssl_fc : boolean
Emeric Brun2525b6b2012-10-18 15:59:43 +020012611 Returns true when the front connection was made via an SSL/TLS transport
12612 layer and is locally deciphered. This means it has matched a socket declared
12613 with a "bind" line having the "ssl" option.
12614
Willy Tarreau74ca5042013-06-11 23:12:07 +020012615 Example :
12616 # This passes "X-Proto: https" to servers when client connects over SSL
12617 listen http-https
12618 bind :80
12619 bind :443 ssl crt /etc/haproxy.pem
12620 http-request add-header X-Proto https if { ssl_fc }
12621
12622ssl_fc_alg_keysize : integer
12623 Returns the symmetric cipher key size supported in bits when the incoming
12624 connection was made over an SSL/TLS transport layer.
12625
12626ssl_fc_alpn : string
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030012627 This extracts the Application Layer Protocol Negotiation field from an
Willy Tarreau74ca5042013-06-11 23:12:07 +020012628 incoming connection made via a TLS transport layer and locally deciphered by
12629 haproxy. The result is a string containing the protocol name advertised by
12630 the client. The SSL library must have been built with support for TLS
12631 extensions enabled (check haproxy -vv). Note that the TLS ALPN extension is
12632 not advertised unless the "alpn" keyword on the "bind" line specifies a
12633 protocol list. Also, nothing forces the client to pick a protocol from this
12634 list, any other one may be requested. The TLS ALPN extension is meant to
12635 replace the TLS NPN extension. See also "ssl_fc_npn".
12636
Willy Tarreau74ca5042013-06-11 23:12:07 +020012637ssl_fc_cipher : string
12638 Returns the name of the used cipher when the incoming connection was made
12639 over an SSL/TLS transport layer.
Willy Tarreauab861d32013-04-02 02:30:41 +020012640
Willy Tarreau74ca5042013-06-11 23:12:07 +020012641ssl_fc_has_crt : boolean
Emeric Brun2525b6b2012-10-18 15:59:43 +020012642 Returns true if a client certificate is present in an incoming connection over
12643 SSL/TLS transport layer. Useful if 'verify' statement is set to 'optional'.
Emeric Brun9143d372012-12-20 15:44:16 +010012644 Note: on SSL session resumption with Session ID or TLS ticket, client
12645 certificate is not present in the current connection but may be retrieved
12646 from the cache or the ticket. So prefer "ssl_c_used" if you want to check if
12647 current SSL session uses a client certificate.
Emeric Brun2525b6b2012-10-18 15:59:43 +020012648
Willy Tarreau74ca5042013-06-11 23:12:07 +020012649ssl_fc_has_sni : boolean
12650 This checks for the presence of a Server Name Indication TLS extension (SNI)
Willy Tarreauf7bc57c2012-10-03 00:19:48 +020012651 in an incoming connection was made over an SSL/TLS transport layer. Returns
12652 true when the incoming connection presents a TLS SNI field. This requires
12653 that the SSL library is build with support for TLS extensions enabled (check
12654 haproxy -vv).
Willy Tarreau7875d092012-09-10 08:20:03 +020012655
Nenad Merdanovic26ea8222015-05-18 02:28:57 +020012656ssl_fc_is_resumed: boolean
12657 Returns true if the SSL/TLS session has been resumed through the use of
12658 SSL session cache or TLS tickets.
12659
Willy Tarreau74ca5042013-06-11 23:12:07 +020012660ssl_fc_npn : string
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030012661 This extracts the Next Protocol Negotiation field from an incoming connection
Willy Tarreau74ca5042013-06-11 23:12:07 +020012662 made via a TLS transport layer and locally deciphered by haproxy. The result
12663 is a string containing the protocol name advertised by the client. The SSL
12664 library must have been built with support for TLS extensions enabled (check
12665 haproxy -vv). Note that the TLS NPN extension is not advertised unless the
12666 "npn" keyword on the "bind" line specifies a protocol list. Also, nothing
12667 forces the client to pick a protocol from this list, any other one may be
12668 requested. Please note that the TLS NPN extension was replaced with ALPN.
Willy Tarreaua33c6542012-10-15 13:19:06 +020012669
Willy Tarreau74ca5042013-06-11 23:12:07 +020012670ssl_fc_protocol : string
12671 Returns the name of the used protocol when the incoming connection was made
12672 over an SSL/TLS transport layer.
Willy Tarreau7875d092012-09-10 08:20:03 +020012673
Emeric Brunb73a9b02014-04-30 18:49:19 +020012674ssl_fc_unique_id : binary
David Sc1ad52e2014-04-08 18:48:47 -040012675 When the incoming connection was made over an SSL/TLS transport layer,
Emeric Brunb73a9b02014-04-30 18:49:19 +020012676 returns the TLS unique ID as defined in RFC5929 section 3. The unique id
12677 can be encoded to base64 using the converter: "ssl_bc_unique_id,base64".
David Sc1ad52e2014-04-08 18:48:47 -040012678
Willy Tarreau74ca5042013-06-11 23:12:07 +020012679ssl_fc_session_id : binary
12680 Returns the SSL ID of the front connection when the incoming connection was
12681 made over an SSL/TLS transport layer. It is useful to stick a given client to
12682 a server. It is important to note that some browsers refresh their session ID
12683 every few minutes.
Willy Tarreau7875d092012-09-10 08:20:03 +020012684
Willy Tarreau74ca5042013-06-11 23:12:07 +020012685ssl_fc_sni : string
12686 This extracts the Server Name Indication TLS extension (SNI) field from an
12687 incoming connection made via an SSL/TLS transport layer and locally
12688 deciphered by haproxy. The result (when present) typically is a string
12689 matching the HTTPS host name (253 chars or less). The SSL library must have
12690 been built with support for TLS extensions enabled (check haproxy -vv).
12691
12692 This fetch is different from "req_ssl_sni" above in that it applies to the
12693 connection being deciphered by haproxy and not to SSL contents being blindly
12694 forwarded. See also "ssl_fc_sni_end" and "ssl_fc_sni_reg" below. This
Cyril Bonté9c1eb1e2012-10-09 22:45:34 +020012695 requires that the SSL library is build with support for TLS extensions
12696 enabled (check haproxy -vv).
Willy Tarreau62644772008-07-16 18:36:06 +020012697
Willy Tarreau74ca5042013-06-11 23:12:07 +020012698 ACL derivatives :
Willy Tarreau74ca5042013-06-11 23:12:07 +020012699 ssl_fc_sni_end : suffix match
12700 ssl_fc_sni_reg : regex match
Emeric Brun589fcad2012-10-16 14:13:26 +020012701
Willy Tarreau74ca5042013-06-11 23:12:07 +020012702ssl_fc_use_keysize : integer
12703 Returns the symmetric cipher key size used in bits when the incoming
12704 connection was made over an SSL/TLS transport layer.
Willy Tarreaub6fb4202008-07-20 11:18:28 +020012705
Willy Tarreaub6fb4202008-07-20 11:18:28 +020012706
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200127077.3.5. Fetching samples from buffer contents (Layer 6)
Willy Tarreau74ca5042013-06-11 23:12:07 +020012708------------------------------------------------------
Willy Tarreaub6fb4202008-07-20 11:18:28 +020012709
Willy Tarreau74ca5042013-06-11 23:12:07 +020012710Fetching samples from buffer contents is a bit different from the previous
12711sample fetches above because the sampled data are ephemeral. These data can
12712only be used when they're available and will be lost when they're forwarded.
12713For this reason, samples fetched from buffer contents during a request cannot
12714be used in a response for example. Even while the data are being fetched, they
12715can change. Sometimes it is necessary to set some delays or combine multiple
12716sample fetch methods to ensure that the expected data are complete and usable,
12717for example through TCP request content inspection. Please see the "tcp-request
12718content" keyword for more detailed information on the subject.
Willy Tarreau62644772008-07-16 18:36:06 +020012719
Willy Tarreau74ca5042013-06-11 23:12:07 +020012720payload(<offset>,<length>) : binary (deprecated)
12721 This is an alias for "req.payload" when used in the context of a request (eg:
12722 "stick on", "stick match"), and for "res.payload" when used in the context of
12723 a response such as in "stick store response".
Willy Tarreau0ba27502007-12-24 16:55:16 +010012724
Willy Tarreau74ca5042013-06-11 23:12:07 +020012725payload_lv(<offset1>,<length>[,<offset2>]) : binary (deprecated)
12726 This is an alias for "req.payload_lv" when used in the context of a request
12727 (eg: "stick on", "stick match"), and for "res.payload_lv" when used in the
12728 context of a response such as in "stick store response".
Willy Tarreau0ba27502007-12-24 16:55:16 +010012729
Willy Tarreau74ca5042013-06-11 23:12:07 +020012730req.len : integer
12731req_len : integer (deprecated)
12732 Returns an integer value corresponding to the number of bytes present in the
12733 request buffer. This is mostly used in ACL. It is important to understand
12734 that this test does not return false as long as the buffer is changing. This
12735 means that a check with equality to zero will almost always immediately match
12736 at the beginning of the session, while a test for more data will wait for
12737 that data to come in and return false only when haproxy is certain that no
12738 more data will come in. This test was designed to be used with TCP request
12739 content inspection.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012740
Willy Tarreau74ca5042013-06-11 23:12:07 +020012741req.payload(<offset>,<length>) : binary
12742 This extracts a binary block of <length> bytes and starting at byte <offset>
Willy Tarreau00f00842013-08-02 11:07:32 +020012743 in the request buffer. As a special case, if the <length> argument is zero,
12744 the the whole buffer from <offset> to the end is extracted. This can be used
12745 with ACLs in order to check for the presence of some content in a buffer at
12746 any location.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012747
Willy Tarreau74ca5042013-06-11 23:12:07 +020012748 ACL alternatives :
12749 payload(<offset>,<length>) : hex binary match
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012750
Willy Tarreau74ca5042013-06-11 23:12:07 +020012751req.payload_lv(<offset1>,<length>[,<offset2>]) : binary
12752 This extracts a binary block whose size is specified at <offset1> for <length>
12753 bytes, and which starts at <offset2> if specified or just after the length in
12754 the request buffer. The <offset2> parameter also supports relative offsets if
12755 prepended with a '+' or '-' sign.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012756
Willy Tarreau74ca5042013-06-11 23:12:07 +020012757 ACL alternatives :
12758 payload_lv(<offset1>,<length>[,<offset2>]) : hex binary match
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012759
Willy Tarreau74ca5042013-06-11 23:12:07 +020012760 Example : please consult the example from the "stick store-response" keyword.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012761
Willy Tarreau74ca5042013-06-11 23:12:07 +020012762req.proto_http : boolean
12763req_proto_http : boolean (deprecated)
12764 Returns true when data in the request buffer look like HTTP and correctly
12765 parses as such. It is the same parser as the common HTTP request parser which
12766 is used so there should be no surprises. The test does not match until the
12767 request is complete, failed or timed out. This test may be used to report the
12768 protocol in TCP logs, but the biggest use is to block TCP request analysis
12769 until a complete HTTP request is present in the buffer, for example to track
12770 a header.
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012771
Willy Tarreau74ca5042013-06-11 23:12:07 +020012772 Example:
12773 # track request counts per "base" (concatenation of Host+URL)
12774 tcp-request inspect-delay 10s
12775 tcp-request content reject if !HTTP
Willy Tarreaube4a3ef2013-06-17 15:04:07 +020012776 tcp-request content track-sc0 base table req-rate
Willy Tarreaua7ad50c2012-04-29 15:39:40 +020012777
Willy Tarreau74ca5042013-06-11 23:12:07 +020012778req.rdp_cookie([<name>]) : string
12779rdp_cookie([<name>]) : string (deprecated)
12780 When the request buffer looks like the RDP protocol, extracts the RDP cookie
12781 <name>, or any cookie if unspecified. The parser only checks for the first
12782 cookie, as illustrated in the RDP protocol specification. The cookie name is
12783 case insensitive. Generally the "MSTS" cookie name will be used, as it can
12784 contain the user name of the client connecting to the server if properly
12785 configured on the client. The "MSTSHASH" cookie is often used as well for
12786 session stickiness to servers.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012787
Willy Tarreau74ca5042013-06-11 23:12:07 +020012788 This differs from "balance rdp-cookie" in that any balancing algorithm may be
12789 used and thus the distribution of clients to backend servers is not linked to
12790 a hash of the RDP cookie. It is envisaged that using a balancing algorithm
12791 such as "balance roundrobin" or "balance leastconn" will lead to a more even
12792 distribution of clients to backend servers than the hash used by "balance
12793 rdp-cookie".
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012794
Willy Tarreau74ca5042013-06-11 23:12:07 +020012795 ACL derivatives :
12796 req_rdp_cookie([<name>]) : exact string match
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012797
Willy Tarreau74ca5042013-06-11 23:12:07 +020012798 Example :
12799 listen tse-farm
12800 bind 0.0.0.0:3389
12801 # wait up to 5s for an RDP cookie in the request
12802 tcp-request inspect-delay 5s
12803 tcp-request content accept if RDP_COOKIE
12804 # apply RDP cookie persistence
12805 persist rdp-cookie
12806 # Persist based on the mstshash cookie
12807 # This is only useful makes sense if
12808 # balance rdp-cookie is not used
12809 stick-table type string size 204800
12810 stick on req.rdp_cookie(mstshash)
12811 server srv1 1.1.1.1:3389
12812 server srv1 1.1.1.2:3389
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012813
Willy Tarreau74ca5042013-06-11 23:12:07 +020012814 See also : "balance rdp-cookie", "persist rdp-cookie", "tcp-request" and the
12815 "req_rdp_cookie" ACL.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012816
Willy Tarreau74ca5042013-06-11 23:12:07 +020012817req.rdp_cookie_cnt([name]) : integer
12818rdp_cookie_cnt([name]) : integer (deprecated)
12819 Tries to parse the request buffer as RDP protocol, then returns an integer
12820 corresponding to the number of RDP cookies found. If an optional cookie name
12821 is passed, only cookies matching this name are considered. This is mostly
12822 used in ACL.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012823
Willy Tarreau74ca5042013-06-11 23:12:07 +020012824 ACL derivatives :
12825 req_rdp_cookie_cnt([<name>]) : integer match
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012826
Nenad Merdanovic5fc7d7e2015-07-07 22:00:17 +020012827req.ssl_ec_ext : boolean
12828 Returns a boolean identifying if client sent the Supported Elliptic Curves
12829 Extension as defined in RFC4492, section 5.1. within the SSL ClientHello
12830 message. This can be used to present ECC compatible clients with EC certificate
12831 and to use RSA for all others, on the same IP address. Note that this only
12832 applies to raw contents found in the request buffer and not to contents
12833 deciphered via an SSL data layer, so this will not work with "bind" lines
12834 having the "ssl" option.
12835
Willy Tarreau74ca5042013-06-11 23:12:07 +020012836req.ssl_hello_type : integer
12837req_ssl_hello_type : integer (deprecated)
12838 Returns an integer value containing the type of the SSL hello message found
12839 in the request buffer if the buffer contains data that parse as a complete
12840 SSL (v3 or superior) client hello message. Note that this only applies to raw
12841 contents found in the request buffer and not to contents deciphered via an
12842 SSL data layer, so this will not work with "bind" lines having the "ssl"
12843 option. This is mostly used in ACL to detect presence of an SSL hello message
12844 that is supposed to contain an SSL session ID usable for stickiness.
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012845
Willy Tarreau74ca5042013-06-11 23:12:07 +020012846req.ssl_sni : string
12847req_ssl_sni : string (deprecated)
12848 Returns a string containing the value of the Server Name TLS extension sent
12849 by a client in a TLS stream passing through the request buffer if the buffer
12850 contains data that parse as a complete SSL (v3 or superior) client hello
12851 message. Note that this only applies to raw contents found in the request
12852 buffer and not to contents deciphered via an SSL data layer, so this will not
12853 work with "bind" lines having the "ssl" option. SNI normally contains the
12854 name of the host the client tries to connect to (for recent browsers). SNI is
12855 useful for allowing or denying access to certain hosts when SSL/TLS is used
12856 by the client. This test was designed to be used with TCP request content
12857 inspection. If content switching is needed, it is recommended to first wait
12858 for a complete client hello (type 1), like in the example below. See also
12859 "ssl_fc_sni".
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012860
Willy Tarreau74ca5042013-06-11 23:12:07 +020012861 ACL derivatives :
12862 req_ssl_sni : exact string match
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012863
Willy Tarreau74ca5042013-06-11 23:12:07 +020012864 Examples :
12865 # Wait for a client hello for at most 5 seconds
12866 tcp-request inspect-delay 5s
12867 tcp-request content accept if { req_ssl_hello_type 1 }
12868 use_backend bk_allow if { req_ssl_sni -f allowed_sites }
12869 default_backend bk_sorry_page
Willy Tarreau04aa6a92012-04-06 18:57:55 +020012870
Willy Tarreau74ca5042013-06-11 23:12:07 +020012871res.ssl_hello_type : integer
12872rep_ssl_hello_type : integer (deprecated)
12873 Returns an integer value containing the type of the SSL hello message found
12874 in the response buffer if the buffer contains data that parses as a complete
12875 SSL (v3 or superior) hello message. Note that this only applies to raw
12876 contents found in the response buffer and not to contents deciphered via an
12877 SSL data layer, so this will not work with "server" lines having the "ssl"
12878 option. This is mostly used in ACL to detect presence of an SSL hello message
12879 that is supposed to contain an SSL session ID usable for stickiness.
Willy Tarreau51539362012-05-08 12:46:28 +020012880
Willy Tarreau74ca5042013-06-11 23:12:07 +020012881req.ssl_ver : integer
12882req_ssl_ver : integer (deprecated)
12883 Returns an integer value containing the version of the SSL/TLS protocol of a
12884 stream present in the request buffer. Both SSLv2 hello messages and SSLv3
12885 messages are supported. TLSv1 is announced as SSL version 3.1. The value is
12886 composed of the major version multiplied by 65536, added to the minor
12887 version. Note that this only applies to raw contents found in the request
12888 buffer and not to contents deciphered via an SSL data layer, so this will not
12889 work with "bind" lines having the "ssl" option. The ACL version of the test
12890 matches against a decimal notation in the form MAJOR.MINOR (eg: 3.1). This
12891 fetch is mostly used in ACL.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012892
Willy Tarreau74ca5042013-06-11 23:12:07 +020012893 ACL derivatives :
12894 req_ssl_ver : decimal match
Willy Tarreaud63335a2010-02-26 12:56:52 +010012895
Willy Tarreau47e8eba2013-09-11 23:28:46 +020012896res.len : integer
12897 Returns an integer value corresponding to the number of bytes present in the
12898 response buffer. This is mostly used in ACL. It is important to understand
12899 that this test does not return false as long as the buffer is changing. This
12900 means that a check with equality to zero will almost always immediately match
12901 at the beginning of the session, while a test for more data will wait for
12902 that data to come in and return false only when haproxy is certain that no
12903 more data will come in. This test was designed to be used with TCP response
12904 content inspection.
12905
Willy Tarreau74ca5042013-06-11 23:12:07 +020012906res.payload(<offset>,<length>) : binary
12907 This extracts a binary block of <length> bytes and starting at byte <offset>
Willy Tarreau00f00842013-08-02 11:07:32 +020012908 in the response buffer. As a special case, if the <length> argument is zero,
12909 the the whole buffer from <offset> to the end is extracted. This can be used
12910 with ACLs in order to check for the presence of some content in a buffer at
12911 any location.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012912
Willy Tarreau74ca5042013-06-11 23:12:07 +020012913res.payload_lv(<offset1>,<length>[,<offset2>]) : binary
12914 This extracts a binary block whose size is specified at <offset1> for <length>
12915 bytes, and which starts at <offset2> if specified or just after the length in
12916 the response buffer. The <offset2> parameter also supports relative offsets
12917 if prepended with a '+' or '-' sign.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012918
Willy Tarreau74ca5042013-06-11 23:12:07 +020012919 Example : please consult the example from the "stick store-response" keyword.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012920
Willy Tarreau74ca5042013-06-11 23:12:07 +020012921wait_end : boolean
12922 This fetch either returns true when the inspection period is over, or does
12923 not fetch. It is only used in ACLs, in conjunction with content analysis to
12924 avoid returning a wrong verdict early. It may also be used to delay some
12925 actions, such as a delayed reject for some special addresses. Since it either
12926 stops the rules evaluation or immediately returns true, it is recommended to
12927 use this acl as the last one in a rule. Please note that the default ACL
12928 "WAIT_END" is always usable without prior declaration. This test was designed
12929 to be used with TCP request content inspection.
Willy Tarreaud63335a2010-02-26 12:56:52 +010012930
Willy Tarreau74ca5042013-06-11 23:12:07 +020012931 Examples :
12932 # delay every incoming request by 2 seconds
12933 tcp-request inspect-delay 2s
12934 tcp-request content accept if WAIT_END
Willy Tarreaud63335a2010-02-26 12:56:52 +010012935
Willy Tarreau74ca5042013-06-11 23:12:07 +020012936 # don't immediately tell bad guys they are rejected
12937 tcp-request inspect-delay 10s
12938 acl goodguys src 10.0.0.0/24
12939 acl badguys src 10.0.1.0/24
12940 tcp-request content accept if goodguys
12941 tcp-request content reject if badguys WAIT_END
12942 tcp-request content reject
12943
12944
Thierry FOURNIER060762e2014-04-23 13:29:15 +0200129457.3.6. Fetching HTTP samples (Layer 7)
Willy Tarreau74ca5042013-06-11 23:12:07 +020012946--------------------------------------
12947
12948It is possible to fetch samples from HTTP contents, requests and responses.
12949This application layer is also called layer 7. It is only possible to fetch the
12950data in this section when a full HTTP request or response has been parsed from
12951its respective request or response buffer. This is always the case with all
12952HTTP specific rules and for sections running with "mode http". When using TCP
12953content inspection, it may be necessary to support an inspection delay in order
12954to let the request or response come in first. These fetches may require a bit
12955more CPU resources than the layer 4 ones, but not much since the request and
12956response are indexed.
12957
12958base : string
12959 This returns the concatenation of the first Host header and the path part of
12960 the request, which starts at the first slash and ends before the question
12961 mark. It can be useful in virtual hosted environments to detect URL abuses as
12962 well as to improve shared caches efficiency. Using this with a limited size
12963 stick table also allows one to collect statistics about most commonly
12964 requested objects by host/path. With ACLs it can allow simple content
12965 switching rules involving the host and the path at the same time, such as
12966 "www.example.com/favicon.ico". See also "path" and "uri".
12967
12968 ACL derivatives :
12969 base : exact string match
12970 base_beg : prefix match
12971 base_dir : subdir match
12972 base_dom : domain match
12973 base_end : suffix match
12974 base_len : length match
12975 base_reg : regex match
12976 base_sub : substring match
12977
12978base32 : integer
12979 This returns a 32-bit hash of the value returned by the "base" fetch method
12980 above. This is useful to track per-URL activity on high traffic sites without
12981 having to store all URLs. Instead a shorter hash is stored, saving a lot of
Willy Tarreau23ec4ca2014-07-15 20:15:37 +020012982 memory. The output type is an unsigned integer. The hash function used is
12983 SDBM with full avalanche on the output. Technically, base32 is exactly equal
12984 to "base,sdbm(1)".
Willy Tarreau74ca5042013-06-11 23:12:07 +020012985
12986base32+src : binary
12987 This returns the concatenation of the base32 fetch above and the src fetch
12988 below. The resulting type is of type binary, with a size of 8 or 20 bytes
12989 depending on the source address family. This can be used to track per-IP,
12990 per-URL counters.
12991
William Lallemand65ad6e12014-01-31 15:08:02 +010012992capture.req.hdr(<idx>) : string
12993 This extracts the content of the header captured by the "capture request
12994 header", idx is the position of the capture keyword in the configuration.
12995 The first entry is an index of 0. See also: "capture request header".
12996
12997capture.req.method : string
12998 This extracts the METHOD of an HTTP request. It can be used in both request
12999 and response. Unlike "method", it can be used in both request and response
13000 because it's allocated.
13001
13002capture.req.uri : string
13003 This extracts the request's URI, which starts at the first slash and ends
13004 before the first space in the request (without the host part). Unlike "path"
13005 and "url", it can be used in both request and response because it's
13006 allocated.
13007
Willy Tarreau3c1b5ec2014-04-24 23:41:57 +020013008capture.req.ver : string
13009 This extracts the request's HTTP version and returns either "HTTP/1.0" or
13010 "HTTP/1.1". Unlike "req.ver", it can be used in both request, response, and
13011 logs because it relies on a persistent flag.
13012
William Lallemand65ad6e12014-01-31 15:08:02 +010013013capture.res.hdr(<idx>) : string
13014 This extracts the content of the header captured by the "capture response
13015 header", idx is the position of the capture keyword in the configuration.
13016 The first entry is an index of 0.
13017 See also: "capture response header"
13018
Willy Tarreau3c1b5ec2014-04-24 23:41:57 +020013019capture.res.ver : string
13020 This extracts the response's HTTP version and returns either "HTTP/1.0" or
13021 "HTTP/1.1". Unlike "res.ver", it can be used in logs because it relies on a
13022 persistent flag.
13023
Willy Tarreaua5910cc2015-05-02 00:46:08 +020013024req.body : binary
13025 This returns the HTTP request's available body as a block of data. It
13026 requires that the request body has been buffered made available using
13027 "option http-buffer-request". In case of chunked-encoded body, currently only
13028 the first chunk is analyzed.
13029
Thierry FOURNIER9826c772015-05-20 15:50:54 +020013030req.body_param([<name>) : string
13031 This fetch assumes that the body of the POST request is url-encoded. The user
13032 can check if the "content-type" contains the value
13033 "application/x-www-form-urlencoded". This extracts the first occurrence of the
13034 parameter <name> in the body, which ends before '&'. The parameter name is
13035 case-sensitive. If no name is given, any parameter will match, and the first
13036 one will be returned. The result is a string corresponding to the value of the
13037 parameter <name> as presented in the request body (no URL decoding is
13038 performed). Note that the ACL version of this fetch iterates over multiple
13039 parameters and will iteratively report all parameters values if no name is
13040 given.
13041
Willy Tarreaua5910cc2015-05-02 00:46:08 +020013042req.body_len : integer
13043 This returns the length of the HTTP request's available body in bytes. It may
13044 be lower than the advertised length if the body is larger than the buffer. It
13045 requires that the request body has been buffered made available using
13046 "option http-buffer-request".
13047
13048req.body_size : integer
13049 This returns the advertised length of the HTTP request's body in bytes. It
13050 will represent the advertised Content-Length header, or the size of the first
13051 chunk in case of chunked encoding. In order to parse the chunks, it requires
13052 that the request body has been buffered made available using
13053 "option http-buffer-request".
13054
Willy Tarreau74ca5042013-06-11 23:12:07 +020013055req.cook([<name>]) : string
13056cook([<name>]) : string (deprecated)
13057 This extracts the last occurrence of the cookie name <name> on a "Cookie"
13058 header line from the request, and returns its value as string. If no name is
13059 specified, the first cookie value is returned. When used with ACLs, all
13060 matching cookies are evaluated. Spaces around the name and the value are
13061 ignored as requested by the Cookie header specification (RFC6265). The cookie
13062 name is case-sensitive. Empty cookies are valid, so an empty cookie may very
13063 well return an empty value if it is present. Use the "found" match to detect
13064 presence. Use the res.cook() variant for response cookies sent by the server.
13065
13066 ACL derivatives :
13067 cook([<name>]) : exact string match
13068 cook_beg([<name>]) : prefix match
13069 cook_dir([<name>]) : subdir match
13070 cook_dom([<name>]) : domain match
13071 cook_end([<name>]) : suffix match
13072 cook_len([<name>]) : length match
13073 cook_reg([<name>]) : regex match
13074 cook_sub([<name>]) : substring match
Willy Tarreaud63335a2010-02-26 12:56:52 +010013075
Willy Tarreau74ca5042013-06-11 23:12:07 +020013076req.cook_cnt([<name>]) : integer
13077cook_cnt([<name>]) : integer (deprecated)
13078 Returns an integer value representing the number of occurrences of the cookie
13079 <name> in the request, or all cookies if <name> is not specified.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013080
Willy Tarreau74ca5042013-06-11 23:12:07 +020013081req.cook_val([<name>]) : integer
13082cook_val([<name>]) : integer (deprecated)
13083 This extracts the last occurrence of the cookie name <name> on a "Cookie"
13084 header line from the request, and converts its value to an integer which is
13085 returned. If no name is specified, the first cookie value is returned. When
13086 used in ACLs, all matching names are iterated over until a value matches.
Willy Tarreau0e698542011-09-16 08:32:32 +020013087
Willy Tarreau74ca5042013-06-11 23:12:07 +020013088cookie([<name>]) : string (deprecated)
13089 This extracts the last occurrence of the cookie name <name> on a "Cookie"
13090 header line from the request, or a "Set-Cookie" header from the response, and
13091 returns its value as a string. A typical use is to get multiple clients
13092 sharing a same profile use the same server. This can be similar to what
Willy Tarreau294d0f02015-08-10 19:40:12 +020013093 "appsession" did with the "request-learn" statement, but with support for
Willy Tarreau74ca5042013-06-11 23:12:07 +020013094 multi-peer synchronization and state keeping across restarts. If no name is
13095 specified, the first cookie value is returned. This fetch should not be used
13096 anymore and should be replaced by req.cook() or res.cook() instead as it
13097 ambiguously uses the direction based on the context where it is used.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013098
Willy Tarreau74ca5042013-06-11 23:12:07 +020013099hdr([<name>[,<occ>]]) : string
13100 This is equivalent to req.hdr() when used on requests, and to res.hdr() when
13101 used on responses. Please refer to these respective fetches for more details.
13102 In case of doubt about the fetch direction, please use the explicit ones.
13103 Note that contrary to the hdr() sample fetch method, the hdr_* ACL keywords
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013104 unambiguously apply to the request headers.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013105
Willy Tarreau74ca5042013-06-11 23:12:07 +020013106req.fhdr(<name>[,<occ>]) : string
13107 This extracts the last occurrence of header <name> in an HTTP request. When
13108 used from an ACL, all occurrences are iterated over until a match is found.
13109 Optionally, a specific occurrence might be specified as a position number.
13110 Positive values indicate a position from the first occurrence, with 1 being
13111 the first one. Negative values indicate positions relative to the last one,
13112 with -1 being the last one. It differs from req.hdr() in that any commas
13113 present in the value are returned and are not used as delimiters. This is
13114 sometimes useful with headers such as User-Agent.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013115
Willy Tarreau74ca5042013-06-11 23:12:07 +020013116req.fhdr_cnt([<name>]) : integer
13117 Returns an integer value representing the number of occurrences of request
13118 header field name <name>, or the total number of header fields if <name> is
13119 not specified. Contrary to its req.hdr_cnt() cousin, this function returns
13120 the number of full line headers and does not stop on commas.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013121
Willy Tarreau74ca5042013-06-11 23:12:07 +020013122req.hdr([<name>[,<occ>]]) : string
13123 This extracts the last occurrence of header <name> in an HTTP request. When
13124 used from an ACL, all occurrences are iterated over until a match is found.
13125 Optionally, a specific occurrence might be specified as a position number.
13126 Positive values indicate a position from the first occurrence, with 1 being
13127 the first one. Negative values indicate positions relative to the last one,
13128 with -1 being the last one. A typical use is with the X-Forwarded-For header
13129 once converted to IP, associated with an IP stick-table. The function
13130 considers any comma as a delimiter for distinct values. If full-line headers
13131 are desired instead, use req.fhdr(). Please carefully check RFC2616 to know
13132 how certain headers are supposed to be parsed. Also, some of them are case
13133 insensitive (eg: Connection).
Willy Tarreaud63335a2010-02-26 12:56:52 +010013134
Willy Tarreau74ca5042013-06-11 23:12:07 +020013135 ACL derivatives :
13136 hdr([<name>[,<occ>]]) : exact string match
13137 hdr_beg([<name>[,<occ>]]) : prefix match
13138 hdr_dir([<name>[,<occ>]]) : subdir match
13139 hdr_dom([<name>[,<occ>]]) : domain match
13140 hdr_end([<name>[,<occ>]]) : suffix match
13141 hdr_len([<name>[,<occ>]]) : length match
13142 hdr_reg([<name>[,<occ>]]) : regex match
13143 hdr_sub([<name>[,<occ>]]) : substring match
13144
13145req.hdr_cnt([<name>]) : integer
13146hdr_cnt([<header>]) : integer (deprecated)
13147 Returns an integer value representing the number of occurrences of request
13148 header field name <name>, or the total number of header field values if
13149 <name> is not specified. It is important to remember that one header line may
13150 count as several headers if it has several values. The function considers any
13151 comma as a delimiter for distinct values. If full-line headers are desired
13152 instead, req.fhdr_cnt() should be used instead. With ACLs, it can be used to
13153 detect presence, absence or abuse of a specific header, as well as to block
13154 request smuggling attacks by rejecting requests which contain more than one
13155 of certain headers. See "req.hdr" for more information on header matching.
13156
13157req.hdr_ip([<name>[,<occ>]]) : ip
13158hdr_ip([<name>[,<occ>]]) : ip (deprecated)
13159 This extracts the last occurrence of header <name> in an HTTP request,
13160 converts it to an IPv4 or IPv6 address and returns this address. When used
13161 with ACLs, all occurrences are checked, and if <name> is omitted, every value
13162 of every header is checked. Optionally, a specific occurrence might be
13163 specified as a position number. Positive values indicate a position from the
13164 first occurrence, with 1 being the first one. Negative values indicate
13165 positions relative to the last one, with -1 being the last one. A typical use
13166 is with the X-Forwarded-For and X-Client-IP headers.
13167
13168req.hdr_val([<name>[,<occ>]]) : integer
13169hdr_val([<name>[,<occ>]]) : integer (deprecated)
13170 This extracts the last occurrence of header <name> in an HTTP request, and
13171 converts it to an integer value. When used with ACLs, all occurrences are
13172 checked, and if <name> is omitted, every value of every header is checked.
13173 Optionally, a specific occurrence might be specified as a position number.
13174 Positive values indicate a position from the first occurrence, with 1 being
13175 the first one. Negative values indicate positions relative to the last one,
13176 with -1 being the last one. A typical use is with the X-Forwarded-For header.
13177
13178http_auth(<userlist>) : boolean
13179 Returns a boolean indicating whether the authentication data received from
13180 the client match a username & password stored in the specified userlist. This
13181 fetch function is not really useful outside of ACLs. Currently only http
13182 basic auth is supported.
13183
Thierry FOURNIER9eec0a62014-01-22 18:38:02 +010013184http_auth_group(<userlist>) : string
13185 Returns a string corresponding to the user name found in the authentication
13186 data received from the client if both the user name and password are valid
13187 according to the specified userlist. The main purpose is to use it in ACLs
13188 where it is then checked whether the user belongs to any group within a list.
Willy Tarreau74ca5042013-06-11 23:12:07 +020013189 This fetch function is not really useful outside of ACLs. Currently only http
13190 basic auth is supported.
13191
13192 ACL derivatives :
Thierry FOURNIER9eec0a62014-01-22 18:38:02 +010013193 http_auth_group(<userlist>) : group ...
13194 Returns true when the user extracted from the request and whose password is
13195 valid according to the specified userlist belongs to at least one of the
13196 groups.
Willy Tarreau74ca5042013-06-11 23:12:07 +020013197
13198http_first_req : boolean
Willy Tarreau7f18e522010-10-22 20:04:13 +020013199 Returns true when the request being processed is the first one of the
13200 connection. This can be used to add or remove headers that may be missing
Willy Tarreau74ca5042013-06-11 23:12:07 +020013201 from some requests when a request is not the first one, or to help grouping
13202 requests in the logs.
Willy Tarreau7f18e522010-10-22 20:04:13 +020013203
Willy Tarreau74ca5042013-06-11 23:12:07 +020013204method : integer + string
13205 Returns an integer value corresponding to the method in the HTTP request. For
13206 example, "GET" equals 1 (check sources to establish the matching). Value 9
13207 means "other method" and may be converted to a string extracted from the
13208 stream. This should not be used directly as a sample, this is only meant to
13209 be used from ACLs, which transparently convert methods from patterns to these
13210 integer + string values. Some predefined ACL already check for most common
13211 methods.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013212
Willy Tarreau74ca5042013-06-11 23:12:07 +020013213 ACL derivatives :
13214 method : case insensitive method match
Willy Tarreau6a06a402007-07-15 20:15:28 +020013215
Willy Tarreau74ca5042013-06-11 23:12:07 +020013216 Example :
13217 # only accept GET and HEAD requests
13218 acl valid_method method GET HEAD
13219 http-request deny if ! valid_method
Willy Tarreau6a06a402007-07-15 20:15:28 +020013220
Willy Tarreau74ca5042013-06-11 23:12:07 +020013221path : string
13222 This extracts the request's URL path, which starts at the first slash and
13223 ends before the question mark (without the host part). A typical use is with
13224 prefetch-capable caches, and with portals which need to aggregate multiple
13225 information from databases and keep them in caches. Note that with outgoing
13226 caches, it would be wiser to use "url" instead. With ACLs, it's typically
13227 used to match exact file names (eg: "/login.php"), or directory parts using
13228 the derivative forms. See also the "url" and "base" fetch methods.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013229
Willy Tarreau74ca5042013-06-11 23:12:07 +020013230 ACL derivatives :
13231 path : exact string match
13232 path_beg : prefix match
13233 path_dir : subdir match
13234 path_dom : domain match
13235 path_end : suffix match
13236 path_len : length match
13237 path_reg : regex match
13238 path_sub : substring match
Willy Tarreau6a06a402007-07-15 20:15:28 +020013239
Willy Tarreau49ad95c2015-01-19 15:06:26 +010013240query : string
13241 This extracts the request's query string, which starts after the first
13242 question mark. If no question mark is present, this fetch returns nothing. If
13243 a question mark is present but nothing follows, it returns an empty string.
13244 This means it's possible to easily know whether a query string is present
13245 using the "found" matching method. This fetch is the completemnt of "path"
13246 which stops before the question mark.
13247
Willy Tarreaueb27ec72015-02-20 13:55:29 +010013248req.hdr_names([<delim>]) : string
13249 This builds a string made from the concatenation of all header names as they
13250 appear in the request when the rule is evaluated. The default delimiter is
13251 the comma (',') but it may be overridden as an optional argument <delim>. In
13252 this case, only the first character of <delim> is considered.
13253
Willy Tarreau74ca5042013-06-11 23:12:07 +020013254req.ver : string
13255req_ver : string (deprecated)
13256 Returns the version string from the HTTP request, for example "1.1". This can
13257 be useful for logs, but is mostly there for ACL. Some predefined ACL already
13258 check for versions 1.0 and 1.1.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013259
Willy Tarreau74ca5042013-06-11 23:12:07 +020013260 ACL derivatives :
13261 req_ver : exact string match
Willy Tarreau0e698542011-09-16 08:32:32 +020013262
Willy Tarreau74ca5042013-06-11 23:12:07 +020013263res.comp : boolean
13264 Returns the boolean "true" value if the response has been compressed by
13265 HAProxy, otherwise returns boolean "false". This may be used to add
13266 information in the logs.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013267
Willy Tarreau74ca5042013-06-11 23:12:07 +020013268res.comp_algo : string
13269 Returns a string containing the name of the algorithm used if the response
13270 was compressed by HAProxy, for example : "deflate". This may be used to add
13271 some information in the logs.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013272
Willy Tarreau74ca5042013-06-11 23:12:07 +020013273res.cook([<name>]) : string
13274scook([<name>]) : string (deprecated)
13275 This extracts the last occurrence of the cookie name <name> on a "Set-Cookie"
13276 header line from the response, and returns its value as string. If no name is
13277 specified, the first cookie value is returned.
Willy Tarreau0ce3aa02012-04-25 18:46:33 +020013278
Willy Tarreau74ca5042013-06-11 23:12:07 +020013279 ACL derivatives :
13280 scook([<name>] : exact string match
Willy Tarreau0ce3aa02012-04-25 18:46:33 +020013281
Willy Tarreau74ca5042013-06-11 23:12:07 +020013282res.cook_cnt([<name>]) : integer
13283scook_cnt([<name>]) : integer (deprecated)
13284 Returns an integer value representing the number of occurrences of the cookie
13285 <name> in the response, or all cookies if <name> is not specified. This is
13286 mostly useful when combined with ACLs to detect suspicious responses.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013287
Willy Tarreau74ca5042013-06-11 23:12:07 +020013288res.cook_val([<name>]) : integer
13289scook_val([<name>]) : integer (deprecated)
13290 This extracts the last occurrence of the cookie name <name> on a "Set-Cookie"
13291 header line from the response, and converts its value to an integer which is
13292 returned. If no name is specified, the first cookie value is returned.
Willy Tarreaud63335a2010-02-26 12:56:52 +010013293
Willy Tarreau74ca5042013-06-11 23:12:07 +020013294res.fhdr([<name>[,<occ>]]) : string
13295 This extracts the last occurrence of header <name> in an HTTP response, or of
13296 the last header if no <name> is specified. Optionally, a specific occurrence
13297 might be specified as a position number. Positive values indicate a position
13298 from the first occurrence, with 1 being the first one. Negative values
13299 indicate positions relative to the last one, with -1 being the last one. It
13300 differs from res.hdr() in that any commas present in the value are returned
13301 and are not used as delimiters. If this is not desired, the res.hdr() fetch
13302 should be used instead. This is sometimes useful with headers such as Date or
13303 Expires.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013304
Willy Tarreau74ca5042013-06-11 23:12:07 +020013305res.fhdr_cnt([<name>]) : integer
13306 Returns an integer value representing the number of occurrences of response
13307 header field name <name>, or the total number of header fields if <name> is
13308 not specified. Contrary to its res.hdr_cnt() cousin, this function returns
13309 the number of full line headers and does not stop on commas. If this is not
13310 desired, the res.hdr_cnt() fetch should be used instead.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013311
Willy Tarreau74ca5042013-06-11 23:12:07 +020013312res.hdr([<name>[,<occ>]]) : string
13313shdr([<name>[,<occ>]]) : string (deprecated)
13314 This extracts the last occurrence of header <name> in an HTTP response, or of
13315 the last header if no <name> is specified. Optionally, a specific occurrence
13316 might be specified as a position number. Positive values indicate a position
13317 from the first occurrence, with 1 being the first one. Negative values
13318 indicate positions relative to the last one, with -1 being the last one. This
13319 can be useful to learn some data into a stick-table. The function considers
13320 any comma as a delimiter for distinct values. If this is not desired, the
13321 res.fhdr() fetch should be used instead.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013322
Willy Tarreau74ca5042013-06-11 23:12:07 +020013323 ACL derivatives :
13324 shdr([<name>[,<occ>]]) : exact string match
13325 shdr_beg([<name>[,<occ>]]) : prefix match
13326 shdr_dir([<name>[,<occ>]]) : subdir match
13327 shdr_dom([<name>[,<occ>]]) : domain match
13328 shdr_end([<name>[,<occ>]]) : suffix match
13329 shdr_len([<name>[,<occ>]]) : length match
13330 shdr_reg([<name>[,<occ>]]) : regex match
13331 shdr_sub([<name>[,<occ>]]) : substring match
13332
13333res.hdr_cnt([<name>]) : integer
13334shdr_cnt([<name>]) : integer (deprecated)
13335 Returns an integer value representing the number of occurrences of response
13336 header field name <name>, or the total number of header fields if <name> is
13337 not specified. The function considers any comma as a delimiter for distinct
13338 values. If this is not desired, the res.fhdr_cnt() fetch should be used
13339 instead.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013340
Willy Tarreau74ca5042013-06-11 23:12:07 +020013341res.hdr_ip([<name>[,<occ>]]) : ip
13342shdr_ip([<name>[,<occ>]]) : ip (deprecated)
13343 This extracts the last occurrence of header <name> in an HTTP response,
13344 convert it to an IPv4 or IPv6 address and returns this address. Optionally, a
13345 specific occurrence might be specified as a position number. Positive values
13346 indicate a position from the first occurrence, with 1 being the first one.
13347 Negative values indicate positions relative to the last one, with -1 being
13348 the last one. This can be useful to learn some data into a stick table.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013349
Willy Tarreaueb27ec72015-02-20 13:55:29 +010013350res.hdr_names([<delim>]) : string
13351 This builds a string made from the concatenation of all header names as they
13352 appear in the response when the rule is evaluated. The default delimiter is
13353 the comma (',') but it may be overridden as an optional argument <delim>. In
13354 this case, only the first character of <delim> is considered.
13355
Willy Tarreau74ca5042013-06-11 23:12:07 +020013356res.hdr_val([<name>[,<occ>]]) : integer
13357shdr_val([<name>[,<occ>]]) : integer (deprecated)
13358 This extracts the last occurrence of header <name> in an HTTP response, and
13359 converts it to an integer value. Optionally, a specific occurrence might be
13360 specified as a position number. Positive values indicate a position from the
13361 first occurrence, with 1 being the first one. Negative values indicate
13362 positions relative to the last one, with -1 being the last one. This can be
13363 useful to learn some data into a stick table.
Alexandre Cassen5eb1a902007-11-29 15:43:32 +010013364
Willy Tarreau74ca5042013-06-11 23:12:07 +020013365res.ver : string
13366resp_ver : string (deprecated)
13367 Returns the version string from the HTTP response, for example "1.1". This
13368 can be useful for logs, but is mostly there for ACL.
Willy Tarreau0e698542011-09-16 08:32:32 +020013369
Willy Tarreau74ca5042013-06-11 23:12:07 +020013370 ACL derivatives :
13371 resp_ver : exact string match
Alexandre Cassen5eb1a902007-11-29 15:43:32 +010013372
Willy Tarreau74ca5042013-06-11 23:12:07 +020013373set-cookie([<name>]) : string (deprecated)
13374 This extracts the last occurrence of the cookie name <name> on a "Set-Cookie"
13375 header line from the response and uses the corresponding value to match. This
Willy Tarreau294d0f02015-08-10 19:40:12 +020013376 can be comparable to what "appsession" did with default options, but with
Willy Tarreau74ca5042013-06-11 23:12:07 +020013377 support for multi-peer synchronization and state keeping across restarts.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +010013378
Willy Tarreau74ca5042013-06-11 23:12:07 +020013379 This fetch function is deprecated and has been superseded by the "res.cook"
13380 fetch. This keyword will disappear soon.
Krzysztof Piotr Oledzki6b35ce12010-02-01 23:35:44 +010013381
Willy Tarreau74ca5042013-06-11 23:12:07 +020013382status : integer
13383 Returns an integer containing the HTTP status code in the HTTP response, for
13384 example, 302. It is mostly used within ACLs and integer ranges, for example,
13385 to remove any Location header if the response is not a 3xx.
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013386
Willy Tarreau74ca5042013-06-11 23:12:07 +020013387url : string
13388 This extracts the request's URL as presented in the request. A typical use is
13389 with prefetch-capable caches, and with portals which need to aggregate
13390 multiple information from databases and keep them in caches. With ACLs, using
13391 "path" is preferred over using "url", because clients may send a full URL as
13392 is normally done with proxies. The only real use is to match "*" which does
13393 not match in "path", and for which there is already a predefined ACL. See
13394 also "path" and "base".
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013395
Willy Tarreau74ca5042013-06-11 23:12:07 +020013396 ACL derivatives :
13397 url : exact string match
13398 url_beg : prefix match
13399 url_dir : subdir match
13400 url_dom : domain match
13401 url_end : suffix match
13402 url_len : length match
13403 url_reg : regex match
13404 url_sub : substring match
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013405
Willy Tarreau74ca5042013-06-11 23:12:07 +020013406url_ip : ip
13407 This extracts the IP address from the request's URL when the host part is
13408 presented as an IP address. Its use is very limited. For instance, a
13409 monitoring system might use this field as an alternative for the source IP in
13410 order to test what path a given source address would follow, or to force an
13411 entry in a table for a given source address. With ACLs it can be used to
13412 restrict access to certain systems through a proxy, for example when combined
13413 with option "http_proxy".
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013414
Willy Tarreau74ca5042013-06-11 23:12:07 +020013415url_port : integer
13416 This extracts the port part from the request's URL. Note that if the port is
13417 not specified in the request, port 80 is assumed. With ACLs it can be used to
13418 restrict access to certain systems through a proxy, for example when combined
13419 with option "http_proxy".
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013420
Willy Tarreau1ede1da2015-05-07 16:06:18 +020013421urlp([<name>[,<delim>]]) : string
13422url_param([<name>[,<delim>]]) : string
Willy Tarreau74ca5042013-06-11 23:12:07 +020013423 This extracts the first occurrence of the parameter <name> in the query
13424 string, which begins after either '?' or <delim>, and which ends before '&',
Willy Tarreau1ede1da2015-05-07 16:06:18 +020013425 ';' or <delim>. The parameter name is case-sensitive. If no name is given,
13426 any parameter will match, and the first one will be returned. The result is
13427 a string corresponding to the value of the parameter <name> as presented in
13428 the request (no URL decoding is performed). This can be used for session
Willy Tarreau74ca5042013-06-11 23:12:07 +020013429 stickiness based on a client ID, to extract an application cookie passed as a
13430 URL parameter, or in ACLs to apply some checks. Note that the ACL version of
Willy Tarreau1ede1da2015-05-07 16:06:18 +020013431 this fetch iterates over multiple parameters and will iteratively report all
13432 parameters values if no name is given
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013433
Willy Tarreau74ca5042013-06-11 23:12:07 +020013434 ACL derivatives :
13435 urlp(<name>[,<delim>]) : exact string match
13436 urlp_beg(<name>[,<delim>]) : prefix match
13437 urlp_dir(<name>[,<delim>]) : subdir match
13438 urlp_dom(<name>[,<delim>]) : domain match
13439 urlp_end(<name>[,<delim>]) : suffix match
13440 urlp_len(<name>[,<delim>]) : length match
13441 urlp_reg(<name>[,<delim>]) : regex match
13442 urlp_sub(<name>[,<delim>]) : substring match
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013443
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013444
Willy Tarreau74ca5042013-06-11 23:12:07 +020013445 Example :
13446 # match http://example.com/foo?PHPSESSIONID=some_id
13447 stick on urlp(PHPSESSIONID)
13448 # match http://example.com/foo;JSESSIONID=some_id
13449 stick on urlp(JSESSIONID,;)
Willy Tarreau25c1ebc2012-04-25 16:21:44 +020013450
Willy Tarreau1ede1da2015-05-07 16:06:18 +020013451urlp_val([<name>[,<delim>])] : integer
Willy Tarreau74ca5042013-06-11 23:12:07 +020013452 See "urlp" above. This one extracts the URL parameter <name> in the request
13453 and converts it to an integer value. This can be used for session stickiness
13454 based on a user ID for example, or with ACLs to match a page number or price.
Willy Tarreaua9fddca2012-07-31 07:51:48 +020013455
Willy Tarreau198a7442008-01-17 12:05:32 +010013456
Willy Tarreau74ca5042013-06-11 23:12:07 +0200134577.4. Pre-defined ACLs
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013458---------------------
Willy Tarreauced27012008-01-17 20:35:34 +010013459
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013460Some predefined ACLs are hard-coded so that they do not have to be declared in
13461every frontend which needs them. They all have their names in upper case in
Patrick Mézard2382ad62010-05-09 10:43:32 +020013462order to avoid confusion. Their equivalence is provided below.
Willy Tarreauced27012008-01-17 20:35:34 +010013463
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013464ACL name Equivalent to Usage
13465---------------+-----------------------------+---------------------------------
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013466FALSE always_false never match
Willy Tarreau2492d5b2009-07-11 00:06:00 +020013467HTTP req_proto_http match if protocol is valid HTTP
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013468HTTP_1.0 req_ver 1.0 match HTTP version 1.0
13469HTTP_1.1 req_ver 1.1 match HTTP version 1.1
Willy Tarreaud63335a2010-02-26 12:56:52 +010013470HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
13471HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
13472HTTP_URL_SLASH url_beg / match URL beginning with "/"
13473HTTP_URL_STAR url * match URL equal to "*"
13474LOCALHOST src 127.0.0.1/8 match connection from local host
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013475METH_CONNECT method CONNECT match HTTP CONNECT method
13476METH_GET method GET HEAD match HTTP GET or HEAD method
13477METH_HEAD method HEAD match HTTP HEAD method
13478METH_OPTIONS method OPTIONS match HTTP OPTIONS method
13479METH_POST method POST match HTTP POST method
13480METH_TRACE method TRACE match HTTP TRACE method
Emeric Brunbede3d02009-06-30 17:54:00 +020013481RDP_COOKIE req_rdp_cookie_cnt gt 0 match presence of an RDP cookie
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013482REQ_CONTENT req_len gt 0 match data in the request buffer
Willy Tarreaud63335a2010-02-26 12:56:52 +010013483TRUE always_true always match
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013484WAIT_END wait_end wait for end of content analysis
13485---------------+-----------------------------+---------------------------------
Willy Tarreauced27012008-01-17 20:35:34 +010013486
Willy Tarreaub937b7e2010-01-12 15:27:54 +010013487
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200134888. Logging
13489----------
Willy Tarreau844e3c52008-01-11 16:28:18 +010013490
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013491One of HAProxy's strong points certainly lies is its precise logs. It probably
13492provides the finest level of information available for such a product, which is
13493very important for troubleshooting complex environments. Standard information
13494provided in logs include client ports, TCP/HTTP state timers, precise session
13495state at termination and precise termination cause, information about decisions
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010013496to direct traffic to a server, and of course the ability to capture arbitrary
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013497headers.
13498
13499In order to improve administrators reactivity, it offers a great transparency
13500about encountered problems, both internal and external, and it is possible to
13501send logs to different sources at the same time with different level filters :
13502
13503 - global process-level logs (system errors, start/stop, etc..)
13504 - per-instance system and internal errors (lack of resource, bugs, ...)
13505 - per-instance external troubles (servers up/down, max connections)
13506 - per-instance activity (client connections), either at the establishment or
13507 at the termination.
Jim Freeman9e8714b2015-05-26 09:16:34 -060013508 - per-request control of log-level, eg:
13509 http-request set-log-level silent if sensitive_request
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013510
13511The ability to distribute different levels of logs to different log servers
13512allow several production teams to interact and to fix their problems as soon
13513as possible. For example, the system team might monitor system-wide errors,
13514while the application team might be monitoring the up/down for their servers in
13515real time, and the security team might analyze the activity logs with one hour
13516delay.
13517
13518
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200135198.1. Log levels
13520---------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013521
Simon Hormandf791f52011-05-29 15:01:10 +090013522TCP and HTTP connections can be logged with information such as the date, time,
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013523source IP address, destination address, connection duration, response times,
Simon Hormandf791f52011-05-29 15:01:10 +090013524HTTP request, HTTP return code, number of bytes transmitted, conditions
13525in which the session ended, and even exchanged cookies values. For example
13526track a particular user's problems. All messages may be sent to up to two
13527syslog servers. Check the "log" keyword in section 4.2 for more information
13528about log facilities.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013529
13530
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200135318.2. Log formats
13532----------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013533
William Lallemand48940402012-01-30 16:47:22 +010013534HAProxy supports 5 log formats. Several fields are common between these formats
Simon Hormandf791f52011-05-29 15:01:10 +090013535and will be detailed in the following sections. A few of them may vary
13536slightly with the configuration, due to indicators specific to certain
13537options. The supported formats are as follows :
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013538
13539 - the default format, which is very basic and very rarely used. It only
13540 provides very basic information about the incoming connection at the moment
13541 it is accepted : source IP:port, destination IP:port, and frontend-name.
13542 This mode will eventually disappear so it will not be described to great
13543 extents.
13544
13545 - the TCP format, which is more advanced. This format is enabled when "option
13546 tcplog" is set on the frontend. HAProxy will then usually wait for the
13547 connection to terminate before logging. This format provides much richer
13548 information, such as timers, connection counts, queue size, etc... This
13549 format is recommended for pure TCP proxies.
13550
13551 - the HTTP format, which is the most advanced for HTTP proxying. This format
13552 is enabled when "option httplog" is set on the frontend. It provides the
13553 same information as the TCP format with some HTTP-specific fields such as
13554 the request, the status code, and captures of headers and cookies. This
13555 format is recommended for HTTP proxies.
13556
Emeric Brun3a058f32009-06-30 18:26:00 +020013557 - the CLF HTTP format, which is equivalent to the HTTP format, but with the
13558 fields arranged in the same order as the CLF format. In this mode, all
13559 timers, captures, flags, etc... appear one per field after the end of the
13560 common fields, in the same order they appear in the standard HTTP format.
13561
William Lallemand48940402012-01-30 16:47:22 +010013562 - the custom log format, allows you to make your own log line.
13563
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013564Next sections will go deeper into details for each of these formats. Format
13565specification will be performed on a "field" basis. Unless stated otherwise, a
13566field is a portion of text delimited by any number of spaces. Since syslog
13567servers are susceptible of inserting fields at the beginning of a line, it is
13568always assumed that the first field is the one containing the process name and
13569identifier.
13570
13571Note : Since log lines may be quite long, the log examples in sections below
13572 might be broken into multiple lines. The example log lines will be
13573 prefixed with 3 closing angle brackets ('>>>') and each time a log is
13574 broken into multiple lines, each non-final line will end with a
13575 backslash ('\') and the next line will start indented by two characters.
13576
13577
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200135788.2.1. Default log format
13579-------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013580
13581This format is used when no specific option is set. The log is emitted as soon
13582as the connection is accepted. One should note that this currently is the only
13583format which logs the request's destination IP and ports.
13584
13585 Example :
13586 listen www
13587 mode http
13588 log global
13589 server srv1 127.0.0.1:8000
13590
13591 >>> Feb 6 12:12:09 localhost \
13592 haproxy[14385]: Connect from 10.0.1.2:33312 to 10.0.3.31:8012 \
13593 (www/HTTP)
13594
13595 Field Format Extract from the example above
13596 1 process_name '[' pid ']:' haproxy[14385]:
13597 2 'Connect from' Connect from
13598 3 source_ip ':' source_port 10.0.1.2:33312
13599 4 'to' to
13600 5 destination_ip ':' destination_port 10.0.3.31:8012
13601 6 '(' frontend_name '/' mode ')' (www/HTTP)
13602
13603Detailed fields description :
13604 - "source_ip" is the IP address of the client which initiated the connection.
13605 - "source_port" is the TCP port of the client which initiated the connection.
13606 - "destination_ip" is the IP address the client connected to.
13607 - "destination_port" is the TCP port the client connected to.
13608 - "frontend_name" is the name of the frontend (or listener) which received
13609 and processed the connection.
13610 - "mode is the mode the frontend is operating (TCP or HTTP).
13611
Willy Tarreauceb24bc2010-11-09 12:46:41 +010013612In case of a UNIX socket, the source and destination addresses are marked as
13613"unix:" and the ports reflect the internal ID of the socket which accepted the
13614connection (the same ID as reported in the stats).
13615
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013616It is advised not to use this deprecated format for newer installations as it
13617will eventually disappear.
13618
13619
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200136208.2.2. TCP log format
13621---------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013622
13623The TCP format is used when "option tcplog" is specified in the frontend, and
13624is the recommended format for pure TCP proxies. It provides a lot of precious
13625information for troubleshooting. Since this format includes timers and byte
13626counts, the log is normally emitted at the end of the session. It can be
13627emitted earlier if "option logasap" is specified, which makes sense in most
13628environments with long sessions such as remote terminals. Sessions which match
13629the "monitor" rules are never logged. It is also possible not to emit logs for
13630sessions for which no data were exchanged between the client and the server, by
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020013631specifying "option dontlognull" in the frontend. Successful connections will
13632not be logged if "option dontlog-normal" is specified in the frontend. A few
13633fields may slightly vary depending on some configuration options, those are
13634marked with a star ('*') after the field name below.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013635
13636 Example :
13637 frontend fnt
13638 mode tcp
13639 option tcplog
13640 log global
13641 default_backend bck
13642
13643 backend bck
13644 server srv1 127.0.0.1:8000
13645
13646 >>> Feb 6 12:12:56 localhost \
13647 haproxy[14387]: 10.0.1.2:33313 [06/Feb/2009:12:12:51.443] fnt \
13648 bck/srv1 0/0/5007 212 -- 0/0/0/0/3 0/0
13649
13650 Field Format Extract from the example above
13651 1 process_name '[' pid ']:' haproxy[14387]:
13652 2 client_ip ':' client_port 10.0.1.2:33313
13653 3 '[' accept_date ']' [06/Feb/2009:12:12:51.443]
13654 4 frontend_name fnt
13655 5 backend_name '/' server_name bck/srv1
13656 6 Tw '/' Tc '/' Tt* 0/0/5007
13657 7 bytes_read* 212
13658 8 termination_state --
13659 9 actconn '/' feconn '/' beconn '/' srv_conn '/' retries* 0/0/0/0/3
13660 10 srv_queue '/' backend_queue 0/0
13661
13662Detailed fields description :
13663 - "client_ip" is the IP address of the client which initiated the TCP
Willy Tarreauceb24bc2010-11-09 12:46:41 +010013664 connection to haproxy. If the connection was accepted on a UNIX socket
13665 instead, the IP address would be replaced with the word "unix". Note that
13666 when the connection is accepted on a socket configured with "accept-proxy"
13667 and the PROXY protocol is correctly used, then the logs will reflect the
13668 forwarded connection's information.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013669
13670 - "client_port" is the TCP port of the client which initiated the connection.
Willy Tarreauceb24bc2010-11-09 12:46:41 +010013671 If the connection was accepted on a UNIX socket instead, the port would be
13672 replaced with the ID of the accepting socket, which is also reported in the
13673 stats interface.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013674
13675 - "accept_date" is the exact date when the connection was received by haproxy
13676 (which might be very slightly different from the date observed on the
13677 network if there was some queuing in the system's backlog). This is usually
13678 the same date which may appear in any upstream firewall's log.
13679
13680 - "frontend_name" is the name of the frontend (or listener) which received
13681 and processed the connection.
13682
13683 - "backend_name" is the name of the backend (or listener) which was selected
13684 to manage the connection to the server. This will be the same as the
13685 frontend if no switching rule has been applied, which is common for TCP
13686 applications.
13687
13688 - "server_name" is the name of the last server to which the connection was
13689 sent, which might differ from the first one if there were connection errors
13690 and a redispatch occurred. Note that this server belongs to the backend
13691 which processed the request. If the connection was aborted before reaching
13692 a server, "<NOSRV>" is indicated instead of a server name.
13693
13694 - "Tw" is the total time in milliseconds spent waiting in the various queues.
13695 It can be "-1" if the connection was aborted before reaching the queue.
13696 See "Timers" below for more details.
13697
13698 - "Tc" is the total time in milliseconds spent waiting for the connection to
13699 establish to the final server, including retries. It can be "-1" if the
13700 connection was aborted before a connection could be established. See
13701 "Timers" below for more details.
13702
13703 - "Tt" is the total time in milliseconds elapsed between the accept and the
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013704 last close. It covers all possible processing. There is one exception, if
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013705 "option logasap" was specified, then the time counting stops at the moment
13706 the log is emitted. In this case, a '+' sign is prepended before the value,
13707 indicating that the final one will be larger. See "Timers" below for more
13708 details.
13709
13710 - "bytes_read" is the total number of bytes transmitted from the server to
13711 the client when the log is emitted. If "option logasap" is specified, the
13712 this value will be prefixed with a '+' sign indicating that the final one
13713 may be larger. Please note that this value is a 64-bit counter, so log
13714 analysis tools must be able to handle it without overflowing.
13715
13716 - "termination_state" is the condition the session was in when the session
13717 ended. This indicates the session state, which side caused the end of
13718 session to happen, and for what reason (timeout, error, ...). The normal
13719 flags should be "--", indicating the session was closed by either end with
13720 no data remaining in buffers. See below "Session state at disconnection"
13721 for more details.
13722
13723 - "actconn" is the total number of concurrent connections on the process when
Jamie Gloudonaaa21002012-08-25 00:18:33 -040013724 the session was logged. It is useful to detect when some per-process system
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013725 limits have been reached. For instance, if actconn is close to 512 when
13726 multiple connection errors occur, chances are high that the system limits
13727 the process to use a maximum of 1024 file descriptors and that all of them
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013728 are used. See section 3 "Global parameters" to find how to tune the system.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013729
13730 - "feconn" is the total number of concurrent connections on the frontend when
13731 the session was logged. It is useful to estimate the amount of resource
13732 required to sustain high loads, and to detect when the frontend's "maxconn"
13733 has been reached. Most often when this value increases by huge jumps, it is
13734 because there is congestion on the backend servers, but sometimes it can be
13735 caused by a denial of service attack.
13736
13737 - "beconn" is the total number of concurrent connections handled by the
13738 backend when the session was logged. It includes the total number of
13739 concurrent connections active on servers as well as the number of
13740 connections pending in queues. It is useful to estimate the amount of
13741 additional servers needed to support high loads for a given application.
13742 Most often when this value increases by huge jumps, it is because there is
13743 congestion on the backend servers, but sometimes it can be caused by a
13744 denial of service attack.
13745
13746 - "srv_conn" is the total number of concurrent connections still active on
13747 the server when the session was logged. It can never exceed the server's
13748 configured "maxconn" parameter. If this value is very often close or equal
13749 to the server's "maxconn", it means that traffic regulation is involved a
13750 lot, meaning that either the server's maxconn value is too low, or that
13751 there aren't enough servers to process the load with an optimal response
13752 time. When only one of the server's "srv_conn" is high, it usually means
13753 that this server has some trouble causing the connections to take longer to
13754 be processed than on other servers.
13755
13756 - "retries" is the number of connection retries experienced by this session
13757 when trying to connect to the server. It must normally be zero, unless a
13758 server is being stopped at the same moment the connection was attempted.
13759 Frequent retries generally indicate either a network problem between
13760 haproxy and the server, or a misconfigured system backlog on the server
13761 preventing new connections from being queued. This field may optionally be
13762 prefixed with a '+' sign, indicating that the session has experienced a
13763 redispatch after the maximal retry count has been reached on the initial
13764 server. In this case, the server name appearing in the log is the one the
13765 connection was redispatched to, and not the first one, though both may
13766 sometimes be the same in case of hashing for instance. So as a general rule
13767 of thumb, when a '+' is present in front of the retry count, this count
13768 should not be attributed to the logged server.
13769
13770 - "srv_queue" is the total number of requests which were processed before
13771 this one in the server queue. It is zero when the request has not gone
13772 through the server queue. It makes it possible to estimate the approximate
13773 server's response time by dividing the time spent in queue by the number of
13774 requests in the queue. It is worth noting that if a session experiences a
13775 redispatch and passes through two server queues, their positions will be
13776 cumulated. A request should not pass through both the server queue and the
13777 backend queue unless a redispatch occurs.
13778
13779 - "backend_queue" is the total number of requests which were processed before
13780 this one in the backend's global queue. It is zero when the request has not
13781 gone through the global queue. It makes it possible to estimate the average
13782 queue length, which easily translates into a number of missing servers when
13783 divided by a server's "maxconn" parameter. It is worth noting that if a
13784 session experiences a redispatch, it may pass twice in the backend's queue,
13785 and then both positions will be cumulated. A request should not pass
13786 through both the server queue and the backend queue unless a redispatch
13787 occurs.
13788
13789
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200137908.2.3. HTTP log format
13791----------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013792
13793The HTTP format is the most complete and the best suited for HTTP proxies. It
13794is enabled by when "option httplog" is specified in the frontend. It provides
13795the same level of information as the TCP format with additional features which
13796are specific to the HTTP protocol. Just like the TCP format, the log is usually
13797emitted at the end of the session, unless "option logasap" is specified, which
13798generally only makes sense for download sites. A session which matches the
13799"monitor" rules will never logged. It is also possible not to log sessions for
13800which no data were sent by the client by specifying "option dontlognull" in the
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020013801frontend. Successful connections will not be logged if "option dontlog-normal"
13802is specified in the frontend.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013803
13804Most fields are shared with the TCP log, some being different. A few fields may
13805slightly vary depending on some configuration options. Those ones are marked
13806with a star ('*') after the field name below.
13807
13808 Example :
13809 frontend http-in
13810 mode http
13811 option httplog
13812 log global
13813 default_backend bck
13814
13815 backend static
13816 server srv1 127.0.0.1:8000
13817
13818 >>> Feb 6 12:14:14 localhost \
13819 haproxy[14389]: 10.0.1.2:33317 [06/Feb/2009:12:14:14.655] http-in \
13820 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 +010013821 {} "GET /index.html HTTP/1.1"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013822
13823 Field Format Extract from the example above
13824 1 process_name '[' pid ']:' haproxy[14389]:
13825 2 client_ip ':' client_port 10.0.1.2:33317
13826 3 '[' accept_date ']' [06/Feb/2009:12:14:14.655]
13827 4 frontend_name http-in
13828 5 backend_name '/' server_name static/srv1
13829 6 Tq '/' Tw '/' Tc '/' Tr '/' Tt* 10/0/30/69/109
13830 7 status_code 200
13831 8 bytes_read* 2750
13832 9 captured_request_cookie -
13833 10 captured_response_cookie -
13834 11 termination_state ----
13835 12 actconn '/' feconn '/' beconn '/' srv_conn '/' retries* 1/1/1/1/0
13836 13 srv_queue '/' backend_queue 0/0
13837 14 '{' captured_request_headers* '}' {haproxy.1wt.eu}
13838 15 '{' captured_response_headers* '}' {}
13839 16 '"' http_request '"' "GET /index.html HTTP/1.1"
Willy Tarreaud72758d2010-01-12 10:42:19 +010013840
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013841
13842Detailed fields description :
13843 - "client_ip" is the IP address of the client which initiated the TCP
Willy Tarreauceb24bc2010-11-09 12:46:41 +010013844 connection to haproxy. If the connection was accepted on a UNIX socket
13845 instead, the IP address would be replaced with the word "unix". Note that
13846 when the connection is accepted on a socket configured with "accept-proxy"
13847 and the PROXY protocol is correctly used, then the logs will reflect the
13848 forwarded connection's information.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013849
13850 - "client_port" is the TCP port of the client which initiated the connection.
Willy Tarreauceb24bc2010-11-09 12:46:41 +010013851 If the connection was accepted on a UNIX socket instead, the port would be
13852 replaced with the ID of the accepting socket, which is also reported in the
13853 stats interface.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013854
13855 - "accept_date" is the exact date when the TCP connection was received by
13856 haproxy (which might be very slightly different from the date observed on
13857 the network if there was some queuing in the system's backlog). This is
13858 usually the same date which may appear in any upstream firewall's log. This
13859 does not depend on the fact that the client has sent the request or not.
13860
13861 - "frontend_name" is the name of the frontend (or listener) which received
13862 and processed the connection.
13863
13864 - "backend_name" is the name of the backend (or listener) which was selected
13865 to manage the connection to the server. This will be the same as the
13866 frontend if no switching rule has been applied.
13867
13868 - "server_name" is the name of the last server to which the connection was
13869 sent, which might differ from the first one if there were connection errors
13870 and a redispatch occurred. Note that this server belongs to the backend
13871 which processed the request. If the request was aborted before reaching a
13872 server, "<NOSRV>" is indicated instead of a server name. If the request was
13873 intercepted by the stats subsystem, "<STATS>" is indicated instead.
13874
13875 - "Tq" is the total time in milliseconds spent waiting for the client to send
13876 a full HTTP request, not counting data. It can be "-1" if the connection
13877 was aborted before a complete request could be received. It should always
13878 be very small because a request generally fits in one single packet. Large
13879 times here generally indicate network trouble between the client and
13880 haproxy. See "Timers" below for more details.
13881
13882 - "Tw" is the total time in milliseconds spent waiting in the various queues.
13883 It can be "-1" if the connection was aborted before reaching the queue.
13884 See "Timers" below for more details.
13885
13886 - "Tc" is the total time in milliseconds spent waiting for the connection to
13887 establish to the final server, including retries. It can be "-1" if the
13888 request was aborted before a connection could be established. See "Timers"
13889 below for more details.
13890
13891 - "Tr" is the total time in milliseconds spent waiting for the server to send
13892 a full HTTP response, not counting data. It can be "-1" if the request was
13893 aborted before a complete response could be received. It generally matches
13894 the server's processing time for the request, though it may be altered by
13895 the amount of data sent by the client to the server. Large times here on
13896 "GET" requests generally indicate an overloaded server. See "Timers" below
13897 for more details.
13898
13899 - "Tt" is the total time in milliseconds elapsed between the accept and the
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030013900 last close. It covers all possible processing. There is one exception, if
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013901 "option logasap" was specified, then the time counting stops at the moment
13902 the log is emitted. In this case, a '+' sign is prepended before the value,
13903 indicating that the final one will be larger. See "Timers" below for more
13904 details.
13905
13906 - "status_code" is the HTTP status code returned to the client. This status
13907 is generally set by the server, but it might also be set by haproxy when
13908 the server cannot be reached or when its response is blocked by haproxy.
13909
13910 - "bytes_read" is the total number of bytes transmitted to the client when
13911 the log is emitted. This does include HTTP headers. If "option logasap" is
13912 specified, the this value will be prefixed with a '+' sign indicating that
13913 the final one may be larger. Please note that this value is a 64-bit
13914 counter, so log analysis tools must be able to handle it without
13915 overflowing.
13916
13917 - "captured_request_cookie" is an optional "name=value" entry indicating that
13918 the client had this cookie in the request. The cookie name and its maximum
13919 length are defined by the "capture cookie" statement in the frontend
13920 configuration. The field is a single dash ('-') when the option is not
13921 set. Only one cookie may be captured, it is generally used to track session
13922 ID exchanges between a client and a server to detect session crossing
13923 between clients due to application bugs. For more details, please consult
13924 the section "Capturing HTTP headers and cookies" below.
13925
13926 - "captured_response_cookie" is an optional "name=value" entry indicating
13927 that the server has returned a cookie with its response. The cookie name
13928 and its maximum length are defined by the "capture cookie" statement in the
13929 frontend configuration. The field is a single dash ('-') when the option is
13930 not set. Only one cookie may be captured, it is generally used to track
13931 session ID exchanges between a client and a server to detect session
13932 crossing between clients due to application bugs. For more details, please
13933 consult the section "Capturing HTTP headers and cookies" below.
13934
13935 - "termination_state" is the condition the session was in when the session
13936 ended. This indicates the session state, which side caused the end of
13937 session to happen, for what reason (timeout, error, ...), just like in TCP
13938 logs, and information about persistence operations on cookies in the last
13939 two characters. The normal flags should begin with "--", indicating the
13940 session was closed by either end with no data remaining in buffers. See
13941 below "Session state at disconnection" for more details.
13942
13943 - "actconn" is the total number of concurrent connections on the process when
Jamie Gloudonaaa21002012-08-25 00:18:33 -040013944 the session was logged. It is useful to detect when some per-process system
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013945 limits have been reached. For instance, if actconn is close to 512 or 1024
13946 when multiple connection errors occur, chances are high that the system
13947 limits the process to use a maximum of 1024 file descriptors and that all
Willy Tarreauc57f0e22009-05-10 13:12:33 +020013948 of them are used. See section 3 "Global parameters" to find how to tune the
Willy Tarreaucc6c8912009-02-22 10:53:55 +010013949 system.
13950
13951 - "feconn" is the total number of concurrent connections on the frontend when
13952 the session was logged. It is useful to estimate the amount of resource
13953 required to sustain high loads, and to detect when the frontend's "maxconn"
13954 has been reached. Most often when this value increases by huge jumps, it is
13955 because there is congestion on the backend servers, but sometimes it can be
13956 caused by a denial of service attack.
13957
13958 - "beconn" is the total number of concurrent connections handled by the
13959 backend when the session was logged. It includes the total number of
13960 concurrent connections active on servers as well as the number of
13961 connections pending in queues. It is useful to estimate the amount of
13962 additional servers needed to support high loads for a given application.
13963 Most often when this value increases by huge jumps, it is because there is
13964 congestion on the backend servers, but sometimes it can be caused by a
13965 denial of service attack.
13966
13967 - "srv_conn" is the total number of concurrent connections still active on
13968 the server when the session was logged. It can never exceed the server's
13969 configured "maxconn" parameter. If this value is very often close or equal
13970 to the server's "maxconn", it means that traffic regulation is involved a
13971 lot, meaning that either the server's maxconn value is too low, or that
13972 there aren't enough servers to process the load with an optimal response
13973 time. When only one of the server's "srv_conn" is high, it usually means
13974 that this server has some trouble causing the requests to take longer to be
13975 processed than on other servers.
13976
13977 - "retries" is the number of connection retries experienced by this session
13978 when trying to connect to the server. It must normally be zero, unless a
13979 server is being stopped at the same moment the connection was attempted.
13980 Frequent retries generally indicate either a network problem between
13981 haproxy and the server, or a misconfigured system backlog on the server
13982 preventing new connections from being queued. This field may optionally be
13983 prefixed with a '+' sign, indicating that the session has experienced a
13984 redispatch after the maximal retry count has been reached on the initial
13985 server. In this case, the server name appearing in the log is the one the
13986 connection was redispatched to, and not the first one, though both may
13987 sometimes be the same in case of hashing for instance. So as a general rule
13988 of thumb, when a '+' is present in front of the retry count, this count
13989 should not be attributed to the logged server.
13990
13991 - "srv_queue" is the total number of requests which were processed before
13992 this one in the server queue. It is zero when the request has not gone
13993 through the server queue. It makes it possible to estimate the approximate
13994 server's response time by dividing the time spent in queue by the number of
13995 requests in the queue. It is worth noting that if a session experiences a
13996 redispatch and passes through two server queues, their positions will be
13997 cumulated. A request should not pass through both the server queue and the
13998 backend queue unless a redispatch occurs.
13999
14000 - "backend_queue" is the total number of requests which were processed before
14001 this one in the backend's global queue. It is zero when the request has not
14002 gone through the global queue. It makes it possible to estimate the average
14003 queue length, which easily translates into a number of missing servers when
14004 divided by a server's "maxconn" parameter. It is worth noting that if a
14005 session experiences a redispatch, it may pass twice in the backend's queue,
14006 and then both positions will be cumulated. A request should not pass
14007 through both the server queue and the backend queue unless a redispatch
14008 occurs.
14009
14010 - "captured_request_headers" is a list of headers captured in the request due
14011 to the presence of the "capture request header" statement in the frontend.
14012 Multiple headers can be captured, they will be delimited by a vertical bar
14013 ('|'). When no capture is enabled, the braces do not appear, causing a
14014 shift of remaining fields. It is important to note that this field may
14015 contain spaces, and that using it requires a smarter log parser than when
14016 it's not used. Please consult the section "Capturing HTTP headers and
14017 cookies" below for more details.
14018
14019 - "captured_response_headers" is a list of headers captured in the response
14020 due to the presence of the "capture response header" statement in the
14021 frontend. Multiple headers can be captured, they will be delimited by a
14022 vertical bar ('|'). When no capture is enabled, the braces do not appear,
14023 causing a shift of remaining fields. It is important to note that this
14024 field may contain spaces, and that using it requires a smarter log parser
14025 than when it's not used. Please consult the section "Capturing HTTP headers
14026 and cookies" below for more details.
14027
14028 - "http_request" is the complete HTTP request line, including the method,
14029 request and HTTP version string. Non-printable characters are encoded (see
14030 below the section "Non-printable characters"). This is always the last
14031 field, and it is always delimited by quotes and is the only one which can
14032 contain quotes. If new fields are added to the log format, they will be
14033 added before this field. This field might be truncated if the request is
14034 huge and does not fit in the standard syslog buffer (1024 characters). This
14035 is the reason why this field must always remain the last one.
14036
14037
Cyril Bontédc4d9032012-04-08 21:57:39 +0200140388.2.4. Custom log format
14039------------------------
William Lallemand48940402012-01-30 16:47:22 +010014040
Willy Tarreau2beef582012-12-20 17:22:52 +010014041The directive log-format allows you to customize the logs in http mode and tcp
William Lallemandbddd4fd2012-02-27 11:23:10 +010014042mode. It takes a string as argument.
William Lallemand48940402012-01-30 16:47:22 +010014043
14044HAproxy understands some log format variables. % precedes log format variables.
14045Variables can take arguments using braces ('{}'), and multiple arguments are
14046separated by commas within the braces. Flags may be added or removed by
14047prefixing them with a '+' or '-' sign.
14048
14049Special variable "%o" may be used to propagate its flags to all other
14050variables on the same format string. This is particularly handy with quoted
14051string formats ("Q").
14052
Willy Tarreauc8368452012-12-21 00:09:23 +010014053If a variable is named between square brackets ('[' .. ']') then it is used
Willy Tarreaube722a22014-06-13 16:31:59 +020014054as a sample expression rule (see section 7.3). This it useful to add some
Willy Tarreauc8368452012-12-21 00:09:23 +010014055less common information such as the client's SSL certificate's DN, or to log
14056the key that would be used to store an entry into a stick table.
14057
William Lallemand48940402012-01-30 16:47:22 +010014058Note: spaces must be escaped. A space character is considered as a separator.
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030014059In order to emit a verbatim '%', it must be preceded by another '%' resulting
Willy Tarreau06d97f92013-12-02 17:45:48 +010014060in '%%'. HAProxy will automatically merge consecutive separators.
William Lallemand48940402012-01-30 16:47:22 +010014061
14062Flags are :
14063 * Q: quote a string
Jamie Gloudonaaa21002012-08-25 00:18:33 -040014064 * X: hexadecimal representation (IPs, Ports, %Ts, %rt, %pid)
William Lallemand48940402012-01-30 16:47:22 +010014065
14066 Example:
14067
14068 log-format %T\ %t\ Some\ Text
14069 log-format %{+Q}o\ %t\ %s\ %{-Q}r
14070
14071At the moment, the default HTTP format is defined this way :
14072
Willy Tarreau2beef582012-12-20 17:22:52 +010014073 log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ \
14074 %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r
William Lallemand48940402012-01-30 16:47:22 +010014075
William Lallemandbddd4fd2012-02-27 11:23:10 +010014076the default CLF format is defined this way :
William Lallemand48940402012-01-30 16:47:22 +010014077
Willy Tarreau2beef582012-12-20 17:22:52 +010014078 log-format %{+Q}o\ %{-Q}ci\ -\ -\ [%T]\ %r\ %ST\ %B\ \"\"\ \"\"\ %cp\ \
Willy Tarreau773d65f2012-10-12 14:56:11 +020014079 %ms\ %ft\ %b\ %s\ \%Tq\ %Tw\ %Tc\ %Tr\ %Tt\ %tsc\ %ac\ %fc\ \
Willy Tarreau2beef582012-12-20 17:22:52 +010014080 %bc\ %sc\ %rc\ %sq\ %bq\ %CC\ %CS\ \%hrl\ %hsl
William Lallemand48940402012-01-30 16:47:22 +010014081
William Lallemandbddd4fd2012-02-27 11:23:10 +010014082and the default TCP format is defined this way :
14083
Willy Tarreau2beef582012-12-20 17:22:52 +010014084 log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tw/%Tc/%Tt\ %B\ %ts\ \
William Lallemandbddd4fd2012-02-27 11:23:10 +010014085 %ac/%fc/%bc/%sc/%rc\ %sq/%bq
14086
William Lallemand48940402012-01-30 16:47:22 +010014087Please refer to the table below for currently defined variables :
14088
William Lallemandbddd4fd2012-02-27 11:23:10 +010014089 +---+------+-----------------------------------------------+-------------+
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020014090 | R | var | field name (8.2.2 and 8.2.3 for description) | type |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014091 +---+------+-----------------------------------------------+-------------+
14092 | | %o | special variable, apply flags on all next var | |
14093 +---+------+-----------------------------------------------+-------------+
Willy Tarreau2beef582012-12-20 17:22:52 +010014094 | | %B | bytes_read (from server to client) | numeric |
14095 | H | %CC | captured_request_cookie | string |
14096 | H | %CS | captured_response_cookie | string |
William Lallemand5f232402012-04-05 18:02:55 +020014097 | | %H | hostname | string |
Andrew Hayworth0ebc55f2015-04-27 21:37:03 +000014098 | H | %HM | HTTP method (ex: POST) | string |
14099 | H | %HP | HTTP request URI without query string (path) | string |
Andrew Hayworthe63ac872015-07-31 16:14:16 +000014100 | H | %HQ | HTTP request URI query string (ex: ?bar=baz) | string |
Andrew Hayworth0ebc55f2015-04-27 21:37:03 +000014101 | H | %HU | HTTP request URI (ex: /foo?bar=baz) | string |
14102 | H | %HV | HTTP version (ex: HTTP/1.0) | string |
William Lallemanda73203e2012-03-12 12:48:57 +010014103 | | %ID | unique-id | string |
Willy Tarreau4bf99632014-06-13 12:21:40 +020014104 | | %ST | status_code | numeric |
William Lallemand5f232402012-04-05 18:02:55 +020014105 | | %T | gmt_date_time | date |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014106 | | %Tc | Tc | numeric |
Yuxans Yao4e25b012012-10-19 10:36:09 +080014107 | | %Tl | local_date_time | date |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020014108 | H | %Tq | Tq | numeric |
14109 | H | %Tr | Tr | numeric |
William Lallemand5f232402012-04-05 18:02:55 +020014110 | | %Ts | timestamp | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014111 | | %Tt | Tt | numeric |
14112 | | %Tw | Tw | numeric |
Willy Tarreau2beef582012-12-20 17:22:52 +010014113 | | %U | bytes_uploaded (from client to server) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014114 | | %ac | actconn | numeric |
14115 | | %b | backend_name | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010014116 | | %bc | beconn (backend concurrent connections) | numeric |
14117 | | %bi | backend_source_ip (connecting address) | IP |
14118 | | %bp | backend_source_port (connecting address) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014119 | | %bq | backend_queue | numeric |
Willy Tarreau2beef582012-12-20 17:22:52 +010014120 | | %ci | client_ip (accepted address) | IP |
14121 | | %cp | client_port (accepted address) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014122 | | %f | frontend_name | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010014123 | | %fc | feconn (frontend concurrent connections) | numeric |
14124 | | %fi | frontend_ip (accepting address) | IP |
14125 | | %fp | frontend_port (accepting address) | numeric |
Willy Tarreau773d65f2012-10-12 14:56:11 +020014126 | | %ft | frontend_name_transport ('~' suffix for SSL) | string |
Willy Tarreau7346acb2014-08-28 15:03:15 +020014127 | | %lc | frontend_log_counter | numeric |
Willy Tarreaud9ed3d22014-06-13 12:23:06 +020014128 | | %hr | captured_request_headers default style | string |
14129 | | %hrl | captured_request_headers CLF style | string list |
14130 | | %hs | captured_response_headers default style | string |
14131 | | %hsl | captured_response_headers CLF style | string list |
Willy Tarreau812c88e2015-08-09 10:56:35 +020014132 | | %ms | accept date milliseconds (left-padded with 0) | numeric |
William Lallemand5f232402012-04-05 18:02:55 +020014133 | | %pid | PID | numeric |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020014134 | H | %r | http_request | string |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014135 | | %rc | retries | numeric |
Willy Tarreau1f0da242014-01-25 11:01:50 +010014136 | | %rt | request_counter (HTTP req or TCP session) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014137 | | %s | server_name | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010014138 | | %sc | srv_conn (server concurrent connections) | numeric |
14139 | | %si | server_IP (target address) | IP |
14140 | | %sp | server_port (target address) | numeric |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014141 | | %sq | srv_queue | numeric |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020014142 | S | %sslc| ssl_ciphers (ex: AES-SHA) | string |
14143 | S | %sslv| ssl_version (ex: TLSv1) | string |
Willy Tarreau2beef582012-12-20 17:22:52 +010014144 | | %t | date_time (with millisecond resolution) | date |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014145 | | %ts | termination_state | string |
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020014146 | H | %tsc | termination_state with cookie status | string |
William Lallemandbddd4fd2012-02-27 11:23:10 +010014147 +---+------+-----------------------------------------------+-------------+
William Lallemand48940402012-01-30 16:47:22 +010014148
Willy Tarreauffc3fcd2012-10-12 20:17:54 +020014149 R = Restrictions : H = mode http only ; S = SSL only
William Lallemand48940402012-01-30 16:47:22 +010014150
Willy Tarreau5f51e1a2012-12-03 18:40:10 +010014151
141528.2.5. Error log format
14153-----------------------
14154
14155When an incoming connection fails due to an SSL handshake or an invalid PROXY
14156protocol header, haproxy will log the event using a shorter, fixed line format.
14157By default, logs are emitted at the LOG_INFO level, unless the option
14158"log-separate-errors" is set in the backend, in which case the LOG_ERR level
14159will be used. Connections on which no data are exchanged (eg: probes) are not
14160logged if the "dontlognull" option is set.
14161
14162The format looks like this :
14163
14164 >>> Dec 3 18:27:14 localhost \
14165 haproxy[6103]: 127.0.0.1:56059 [03/Dec/2012:17:35:10.380] frt/f1: \
14166 Connection error during SSL handshake
14167
14168 Field Format Extract from the example above
14169 1 process_name '[' pid ']:' haproxy[6103]:
14170 2 client_ip ':' client_port 127.0.0.1:56059
14171 3 '[' accept_date ']' [03/Dec/2012:17:35:10.380]
14172 4 frontend_name "/" bind_name ":" frt/f1:
14173 5 message Connection error during SSL handshake
14174
14175These fields just provide minimal information to help debugging connection
14176failures.
14177
14178
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200141798.3. Advanced logging options
14180-----------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014181
14182Some advanced logging options are often looked for but are not easy to find out
14183just by looking at the various options. Here is an entry point for the few
14184options which can enable better logging. Please refer to the keywords reference
14185for more information about their usage.
14186
14187
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200141888.3.1. Disabling logging of external tests
14189------------------------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014190
14191It is quite common to have some monitoring tools perform health checks on
14192haproxy. Sometimes it will be a layer 3 load-balancer such as LVS or any
14193commercial load-balancer, and sometimes it will simply be a more complete
14194monitoring system such as Nagios. When the tests are very frequent, users often
14195ask how to disable logging for those checks. There are three possibilities :
14196
14197 - if connections come from everywhere and are just TCP probes, it is often
14198 desired to simply disable logging of connections without data exchange, by
14199 setting "option dontlognull" in the frontend. It also disables logging of
14200 port scans, which may or may not be desired.
14201
14202 - if the connection come from a known source network, use "monitor-net" to
14203 declare this network as monitoring only. Any host in this network will then
14204 only be able to perform health checks, and their requests will not be
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030014205 logged. This is generally appropriate to designate a list of equipment
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014206 such as other load-balancers.
14207
14208 - if the tests are performed on a known URI, use "monitor-uri" to declare
14209 this URI as dedicated to monitoring. Any host sending this request will
14210 only get the result of a health-check, and the request will not be logged.
14211
14212
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200142138.3.2. Logging before waiting for the session to terminate
14214----------------------------------------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014215
14216The problem with logging at end of connection is that you have no clue about
14217what is happening during very long sessions, such as remote terminal sessions
14218or large file downloads. This problem can be worked around by specifying
14219"option logasap" in the frontend. Haproxy will then log as soon as possible,
14220just before data transfer begins. This means that in case of TCP, it will still
14221log the connection status to the server, and in case of HTTP, it will log just
14222after processing the server headers. In this case, the number of bytes reported
14223is the number of header bytes sent to the client. In order to avoid confusion
14224with normal logs, the total time field and the number of bytes are prefixed
14225with a '+' sign which means that real numbers are certainly larger.
14226
14227
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200142288.3.3. Raising log level upon errors
14229------------------------------------
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020014230
14231Sometimes it is more convenient to separate normal traffic from errors logs,
14232for instance in order to ease error monitoring from log files. When the option
14233"log-separate-errors" is used, connections which experience errors, timeouts,
14234retries, redispatches or HTTP status codes 5xx will see their syslog level
14235raised from "info" to "err". This will help a syslog daemon store the log in
14236a separate file. It is very important to keep the errors in the normal traffic
14237file too, so that log ordering is not altered. You should also be careful if
14238you already have configured your syslog daemon to store all logs higher than
14239"notice" in an "admin" file, because the "err" level is higher than "notice".
14240
14241
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200142428.3.4. Disabling logging of successful connections
14243--------------------------------------------------
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +020014244
14245Although this may sound strange at first, some large sites have to deal with
14246multiple thousands of logs per second and are experiencing difficulties keeping
14247them intact for a long time or detecting errors within them. If the option
14248"dontlog-normal" is set on the frontend, all normal connections will not be
14249logged. In this regard, a normal connection is defined as one without any
14250error, timeout, retry nor redispatch. In HTTP, the status code is checked too,
14251and a response with a status 5xx is not considered normal and will be logged
14252too. Of course, doing is is really discouraged as it will remove most of the
14253useful information from the logs. Do this only if you have no other
14254alternative.
14255
14256
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200142578.4. Timing events
14258------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014259
14260Timers provide a great help in troubleshooting network problems. All values are
14261reported in milliseconds (ms). These timers should be used in conjunction with
14262the session termination flags. In TCP mode with "option tcplog" set on the
14263frontend, 3 control points are reported under the form "Tw/Tc/Tt", and in HTTP
14264mode, 5 control points are reported under the form "Tq/Tw/Tc/Tr/Tt" :
14265
14266 - Tq: total time to get the client request (HTTP mode only). It's the time
14267 elapsed between the moment the client connection was accepted and the
14268 moment the proxy received the last HTTP header. The value "-1" indicates
14269 that the end of headers (empty line) has never been seen. This happens when
14270 the client closes prematurely or times out.
14271
14272 - Tw: total time spent in the queues waiting for a connection slot. It
14273 accounts for backend queue as well as the server queues, and depends on the
14274 queue size, and the time needed for the server to complete previous
14275 requests. The value "-1" means that the request was killed before reaching
14276 the queue, which is generally what happens with invalid or denied requests.
14277
14278 - Tc: total time to establish the TCP connection to the server. It's the time
14279 elapsed between the moment the proxy sent the connection request, and the
14280 moment it was acknowledged by the server, or between the TCP SYN packet and
14281 the matching SYN/ACK packet in return. The value "-1" means that the
14282 connection never established.
14283
14284 - Tr: server response time (HTTP mode only). It's the time elapsed between
14285 the moment the TCP connection was established to the server and the moment
14286 the server sent its complete response headers. It purely shows its request
14287 processing time, without the network overhead due to the data transmission.
14288 It is worth noting that when the client has data to send to the server, for
14289 instance during a POST request, the time already runs, and this can distort
14290 apparent response time. For this reason, it's generally wise not to trust
14291 too much this field for POST requests initiated from clients behind an
14292 untrusted network. A value of "-1" here means that the last the response
14293 header (empty line) was never seen, most likely because the server timeout
14294 stroke before the server managed to process the request.
14295
14296 - Tt: total session duration time, between the moment the proxy accepted it
14297 and the moment both ends were closed. The exception is when the "logasap"
14298 option is specified. In this case, it only equals (Tq+Tw+Tc+Tr), and is
14299 prefixed with a '+' sign. From this field, we can deduce "Td", the data
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030014300 transmission time, by subtracting other timers when valid :
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014301
14302 Td = Tt - (Tq + Tw + Tc + Tr)
14303
14304 Timers with "-1" values have to be excluded from this equation. In TCP
14305 mode, "Tq" and "Tr" have to be excluded too. Note that "Tt" can never be
14306 negative.
14307
14308These timers provide precious indications on trouble causes. Since the TCP
14309protocol defines retransmit delays of 3, 6, 12... seconds, we know for sure
14310that timers close to multiples of 3s are nearly always related to lost packets
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014311due to network problems (wires, negotiation, congestion). Moreover, if "Tt" is
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014312close to a timeout value specified in the configuration, it often means that a
14313session has been aborted on timeout.
14314
14315Most common cases :
14316
14317 - If "Tq" is close to 3000, a packet has probably been lost between the
14318 client and the proxy. This is very rare on local networks but might happen
14319 when clients are on far remote networks and send large requests. It may
14320 happen that values larger than usual appear here without any network cause.
14321 Sometimes, during an attack or just after a resource starvation has ended,
14322 haproxy may accept thousands of connections in a few milliseconds. The time
14323 spent accepting these connections will inevitably slightly delay processing
14324 of other connections, and it can happen that request times in the order of
14325 a few tens of milliseconds are measured after a few thousands of new
Patrick Mezard105faca2010-06-12 17:02:46 +020014326 connections have been accepted at once. Setting "option http-server-close"
14327 may display larger request times since "Tq" also measures the time spent
14328 waiting for additional requests.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014329
14330 - If "Tc" is close to 3000, a packet has probably been lost between the
14331 server and the proxy during the server connection phase. This value should
14332 always be very low, such as 1 ms on local networks and less than a few tens
14333 of ms on remote networks.
14334
Willy Tarreau55165fe2009-05-10 12:02:55 +020014335 - If "Tr" is nearly always lower than 3000 except some rare values which seem
14336 to be the average majored by 3000, there are probably some packets lost
14337 between the proxy and the server.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014338
14339 - If "Tt" is large even for small byte counts, it generally is because
14340 neither the client nor the server decides to close the connection, for
14341 instance because both have agreed on a keep-alive connection mode. In order
14342 to solve this issue, it will be needed to specify "option httpclose" on
14343 either the frontend or the backend. If the problem persists, it means that
14344 the server ignores the "close" connection mode and expects the client to
14345 close. Then it will be required to use "option forceclose". Having the
14346 smallest possible 'Tt' is important when connection regulation is used with
14347 the "maxconn" option on the servers, since no new connection will be sent
14348 to the server until another one is released.
14349
14350Other noticeable HTTP log cases ('xx' means any value to be ignored) :
14351
14352 Tq/Tw/Tc/Tr/+Tt The "option logasap" is present on the frontend and the log
14353 was emitted before the data phase. All the timers are valid
14354 except "Tt" which is shorter than reality.
14355
14356 -1/xx/xx/xx/Tt The client was not able to send a complete request in time
14357 or it aborted too early. Check the session termination flags
14358 then "timeout http-request" and "timeout client" settings.
14359
14360 Tq/-1/xx/xx/Tt It was not possible to process the request, maybe because
14361 servers were out of order, because the request was invalid
14362 or forbidden by ACL rules. Check the session termination
14363 flags.
14364
14365 Tq/Tw/-1/xx/Tt The connection could not establish on the server. Either it
14366 actively refused it or it timed out after Tt-(Tq+Tw) ms.
14367 Check the session termination flags, then check the
14368 "timeout connect" setting. Note that the tarpit action might
14369 return similar-looking patterns, with "Tw" equal to the time
14370 the client connection was maintained open.
14371
14372 Tq/Tw/Tc/-1/Tt The server has accepted the connection but did not return
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030014373 a complete response in time, or it closed its connection
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014374 unexpectedly after Tt-(Tq+Tw+Tc) ms. Check the session
14375 termination flags, then check the "timeout server" setting.
14376
14377
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200143788.5. Session state at disconnection
14379-----------------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014380
14381TCP and HTTP logs provide a session termination indicator in the
14382"termination_state" field, just before the number of active connections. It is
143832-characters long in TCP mode, and is extended to 4 characters in HTTP mode,
14384each of which has a special meaning :
14385
14386 - On the first character, a code reporting the first event which caused the
14387 session to terminate :
14388
14389 C : the TCP session was unexpectedly aborted by the client.
14390
14391 S : the TCP session was unexpectedly aborted by the server, or the
14392 server explicitly refused it.
14393
14394 P : the session was prematurely aborted by the proxy, because of a
14395 connection limit enforcement, because a DENY filter was matched,
14396 because of a security check which detected and blocked a dangerous
14397 error in server response which might have caused information leak
Willy Tarreau570f2212013-06-10 16:42:09 +020014398 (eg: cacheable cookie).
14399
14400 L : the session was locally processed by haproxy and was not passed to
14401 a server. This is what happens for stats and redirects.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014402
14403 R : a resource on the proxy has been exhausted (memory, sockets, source
14404 ports, ...). Usually, this appears during the connection phase, and
14405 system logs should contain a copy of the precise error. If this
14406 happens, it must be considered as a very serious anomaly which
14407 should be fixed as soon as possible by any means.
14408
14409 I : an internal error was identified by the proxy during a self-check.
14410 This should NEVER happen, and you are encouraged to report any log
14411 containing this, because this would almost certainly be a bug. It
14412 would be wise to preventively restart the process after such an
14413 event too, in case it would be caused by memory corruption.
14414
Simon Horman752dc4a2011-06-21 14:34:59 +090014415 D : the session was killed by haproxy because the server was detected
14416 as down and was configured to kill all connections when going down.
14417
Justin Karnegeseb2c24a2012-05-24 15:28:52 -070014418 U : the session was killed by haproxy on this backup server because an
14419 active server was detected as up and was configured to kill all
14420 backup connections when going up.
14421
Willy Tarreaua2a64e92011-09-07 23:01:56 +020014422 K : the session was actively killed by an admin operating on haproxy.
14423
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014424 c : the client-side timeout expired while waiting for the client to
14425 send or receive data.
14426
14427 s : the server-side timeout expired while waiting for the server to
14428 send or receive data.
14429
14430 - : normal session completion, both the client and the server closed
14431 with nothing left in the buffers.
14432
14433 - on the second character, the TCP or HTTP session state when it was closed :
14434
Willy Tarreauf7b30a92010-12-06 22:59:17 +010014435 R : the proxy was waiting for a complete, valid REQUEST from the client
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014436 (HTTP mode only). Nothing was sent to any server.
14437
14438 Q : the proxy was waiting in the QUEUE for a connection slot. This can
14439 only happen when servers have a 'maxconn' parameter set. It can
14440 also happen in the global queue after a redispatch consecutive to
14441 a failed attempt to connect to a dying server. If no redispatch is
14442 reported, then no connection attempt was made to any server.
14443
14444 C : the proxy was waiting for the CONNECTION to establish on the
14445 server. The server might at most have noticed a connection attempt.
14446
14447 H : the proxy was waiting for complete, valid response HEADERS from the
14448 server (HTTP only).
14449
14450 D : the session was in the DATA phase.
14451
14452 L : the proxy was still transmitting LAST data to the client while the
14453 server had already finished. This one is very rare as it can only
14454 happen when the client dies while receiving the last packets.
14455
14456 T : the request was tarpitted. It has been held open with the client
14457 during the whole "timeout tarpit" duration or until the client
14458 closed, both of which will be reported in the "Tw" timer.
14459
14460 - : normal session completion after end of data transfer.
14461
14462 - the third character tells whether the persistence cookie was provided by
14463 the client (only in HTTP mode) :
14464
14465 N : the client provided NO cookie. This is usually the case for new
14466 visitors, so counting the number of occurrences of this flag in the
14467 logs generally indicate a valid trend for the site frequentation.
14468
14469 I : the client provided an INVALID cookie matching no known server.
14470 This might be caused by a recent configuration change, mixed
Cyril Bontéa8e7bbc2010-04-25 22:29:29 +020014471 cookies between HTTP/HTTPS sites, persistence conditionally
14472 ignored, or an attack.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014473
14474 D : the client provided a cookie designating a server which was DOWN,
14475 so either "option persist" was used and the client was sent to
14476 this server, or it was not set and the client was redispatched to
14477 another server.
14478
Willy Tarreau996a92c2010-10-13 19:30:47 +020014479 V : the client provided a VALID cookie, and was sent to the associated
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014480 server.
14481
Willy Tarreau996a92c2010-10-13 19:30:47 +020014482 E : the client provided a valid cookie, but with a last date which was
14483 older than what is allowed by the "maxidle" cookie parameter, so
14484 the cookie is consider EXPIRED and is ignored. The request will be
14485 redispatched just as if there was no cookie.
14486
14487 O : the client provided a valid cookie, but with a first date which was
14488 older than what is allowed by the "maxlife" cookie parameter, so
14489 the cookie is consider too OLD and is ignored. The request will be
14490 redispatched just as if there was no cookie.
14491
Willy Tarreauc89ccb62012-04-05 21:18:22 +020014492 U : a cookie was present but was not used to select the server because
14493 some other server selection mechanism was used instead (typically a
14494 "use-server" rule).
14495
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014496 - : does not apply (no cookie set in configuration).
14497
14498 - the last character reports what operations were performed on the persistence
14499 cookie returned by the server (only in HTTP mode) :
14500
14501 N : NO cookie was provided by the server, and none was inserted either.
14502
14503 I : no cookie was provided by the server, and the proxy INSERTED one.
14504 Note that in "cookie insert" mode, if the server provides a cookie,
14505 it will still be overwritten and reported as "I" here.
14506
Willy Tarreau996a92c2010-10-13 19:30:47 +020014507 U : the proxy UPDATED the last date in the cookie that was presented by
14508 the client. This can only happen in insert mode with "maxidle". It
Jarno Huuskonen0e82b922014-04-12 18:22:19 +030014509 happens every time there is activity at a different date than the
Willy Tarreau996a92c2010-10-13 19:30:47 +020014510 date indicated in the cookie. If any other change happens, such as
14511 a redispatch, then the cookie will be marked as inserted instead.
14512
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014513 P : a cookie was PROVIDED by the server and transmitted as-is.
14514
14515 R : the cookie provided by the server was REWRITTEN by the proxy, which
14516 happens in "cookie rewrite" or "cookie prefix" modes.
14517
14518 D : the cookie provided by the server was DELETED by the proxy.
14519
14520 - : does not apply (no cookie set in configuration).
14521
Willy Tarreau996a92c2010-10-13 19:30:47 +020014522The combination of the two first flags gives a lot of information about what
14523was happening when the session terminated, and why it did terminate. It can be
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014524helpful to detect server saturation, network troubles, local system resource
14525starvation, attacks, etc...
14526
14527The most common termination flags combinations are indicated below. They are
14528alphabetically sorted, with the lowercase set just after the upper case for
14529easier finding and understanding.
14530
14531 Flags Reason
14532
14533 -- Normal termination.
14534
14535 CC The client aborted before the connection could be established to the
14536 server. This can happen when haproxy tries to connect to a recently
14537 dead (or unchecked) server, and the client aborts while haproxy is
14538 waiting for the server to respond or for "timeout connect" to expire.
14539
14540 CD The client unexpectedly aborted during data transfer. This can be
14541 caused by a browser crash, by an intermediate equipment between the
14542 client and haproxy which decided to actively break the connection,
14543 by network routing issues between the client and haproxy, or by a
14544 keep-alive session between the server and the client terminated first
14545 by the client.
Willy Tarreaud72758d2010-01-12 10:42:19 +010014546
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014547 cD The client did not send nor acknowledge any data for as long as the
14548 "timeout client" delay. This is often caused by network failures on
Cyril Bontédc4d9032012-04-08 21:57:39 +020014549 the client side, or the client simply leaving the net uncleanly.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014550
14551 CH The client aborted while waiting for the server to start responding.
14552 It might be the server taking too long to respond or the client
14553 clicking the 'Stop' button too fast.
14554
14555 cH The "timeout client" stroke while waiting for client data during a
14556 POST request. This is sometimes caused by too large TCP MSS values
14557 for PPPoE networks which cannot transport full-sized packets. It can
14558 also happen when client timeout is smaller than server timeout and
14559 the server takes too long to respond.
14560
14561 CQ The client aborted while its session was queued, waiting for a server
14562 with enough empty slots to accept it. It might be that either all the
14563 servers were saturated or that the assigned server was taking too
14564 long a time to respond.
14565
14566 CR The client aborted before sending a full HTTP request. Most likely
14567 the request was typed by hand using a telnet client, and aborted
14568 too early. The HTTP status code is likely a 400 here. Sometimes this
14569 might also be caused by an IDS killing the connection between haproxy
Willy Tarreau0f228a02015-05-01 15:37:53 +020014570 and the client. "option http-ignore-probes" can be used to ignore
14571 connections without any data transfer.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014572
14573 cR The "timeout http-request" stroke before the client sent a full HTTP
14574 request. This is sometimes caused by too large TCP MSS values on the
14575 client side for PPPoE networks which cannot transport full-sized
14576 packets, or by clients sending requests by hand and not typing fast
14577 enough, or forgetting to enter the empty line at the end of the
Willy Tarreau2705a612014-05-23 17:38:34 +020014578 request. The HTTP status code is likely a 408 here. Note: recently,
Willy Tarreau0f228a02015-05-01 15:37:53 +020014579 some browsers started to implement a "pre-connect" feature consisting
14580 in speculatively connecting to some recently visited web sites just
14581 in case the user would like to visit them. This results in many
14582 connections being established to web sites, which end up in 408
14583 Request Timeout if the timeout strikes first, or 400 Bad Request when
14584 the browser decides to close them first. These ones pollute the log
14585 and feed the error counters. Some versions of some browsers have even
14586 been reported to display the error code. It is possible to work
14587 around the undesirable effects of this behaviour by adding "option
14588 http-ignore-probes" in the frontend, resulting in connections with
14589 zero data transfer to be totally ignored. This will definitely hide
14590 the errors of people experiencing connectivity issues though.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014591
14592 CT The client aborted while its session was tarpitted. It is important to
14593 check if this happens on valid requests, in order to be sure that no
Willy Tarreau55165fe2009-05-10 12:02:55 +020014594 wrong tarpit rules have been written. If a lot of them happen, it
14595 might make sense to lower the "timeout tarpit" value to something
14596 closer to the average reported "Tw" timer, in order not to consume
14597 resources for just a few attackers.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014598
Willy Tarreau570f2212013-06-10 16:42:09 +020014599 LR The request was intercepted and locally handled by haproxy. Generally
14600 it means that this was a redirect or a stats request.
14601
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014602 SC The server or an equipment between it and haproxy explicitly refused
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014603 the TCP connection (the proxy received a TCP RST or an ICMP message
14604 in return). Under some circumstances, it can also be the network
14605 stack telling the proxy that the server is unreachable (eg: no route,
14606 or no ARP response on local network). When this happens in HTTP mode,
14607 the status code is likely a 502 or 503 here.
14608
14609 sC The "timeout connect" stroke before a connection to the server could
14610 complete. When this happens in HTTP mode, the status code is likely a
14611 503 or 504 here.
14612
14613 SD The connection to the server died with an error during the data
14614 transfer. This usually means that haproxy has received an RST from
14615 the server or an ICMP message from an intermediate equipment while
14616 exchanging data with the server. This can be caused by a server crash
14617 or by a network issue on an intermediate equipment.
14618
14619 sD The server did not send nor acknowledge any data for as long as the
14620 "timeout server" setting during the data phase. This is often caused
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014621 by too short timeouts on L4 equipments before the server (firewalls,
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014622 load-balancers, ...), as well as keep-alive sessions maintained
14623 between the client and the server expiring first on haproxy.
14624
14625 SH The server aborted before sending its full HTTP response headers, or
14626 it crashed while processing the request. Since a server aborting at
14627 this moment is very rare, it would be wise to inspect its logs to
14628 control whether it crashed and why. The logged request may indicate a
14629 small set of faulty requests, demonstrating bugs in the application.
14630 Sometimes this might also be caused by an IDS killing the connection
14631 between haproxy and the server.
14632
14633 sH The "timeout server" stroke before the server could return its
14634 response headers. This is the most common anomaly, indicating too
14635 long transactions, probably caused by server or database saturation.
14636 The immediate workaround consists in increasing the "timeout server"
14637 setting, but it is important to keep in mind that the user experience
14638 will suffer from these long response times. The only long term
14639 solution is to fix the application.
14640
14641 sQ The session spent too much time in queue and has been expired. See
14642 the "timeout queue" and "timeout connect" settings to find out how to
14643 fix this if it happens too often. If it often happens massively in
14644 short periods, it may indicate general problems on the affected
14645 servers due to I/O or database congestion, or saturation caused by
14646 external attacks.
14647
14648 PC The proxy refused to establish a connection to the server because the
14649 process' socket limit has been reached while attempting to connect.
Cyril Bontédc4d9032012-04-08 21:57:39 +020014650 The global "maxconn" parameter may be increased in the configuration
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014651 so that it does not happen anymore. This status is very rare and
14652 might happen when the global "ulimit-n" parameter is forced by hand.
14653
Willy Tarreaued2fd2d2010-12-29 11:23:27 +010014654 PD The proxy blocked an incorrectly formatted chunked encoded message in
14655 a request or a response, after the server has emitted its headers. In
14656 most cases, this will indicate an invalid message from the server to
Willy Tarreauf3a3e132013-08-31 08:16:26 +020014657 the client. Haproxy supports chunk sizes of up to 2GB - 1 (2147483647
14658 bytes). Any larger size will be considered as an error.
Willy Tarreaued2fd2d2010-12-29 11:23:27 +010014659
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014660 PH The proxy blocked the server's response, because it was invalid,
14661 incomplete, dangerous (cache control), or matched a security filter.
14662 In any case, an HTTP 502 error is sent to the client. One possible
14663 cause for this error is an invalid syntax in an HTTP header name
Willy Tarreaued2fd2d2010-12-29 11:23:27 +010014664 containing unauthorized characters. It is also possible but quite
14665 rare, that the proxy blocked a chunked-encoding request from the
14666 client due to an invalid syntax, before the server responded. In this
14667 case, an HTTP 400 error is sent to the client and reported in the
14668 logs.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014669
14670 PR The proxy blocked the client's HTTP request, either because of an
14671 invalid HTTP syntax, in which case it returned an HTTP 400 error to
14672 the client, or because a deny filter matched, in which case it
14673 returned an HTTP 403 error.
14674
14675 PT The proxy blocked the client's request and has tarpitted its
14676 connection before returning it a 500 server error. Nothing was sent
14677 to the server. The connection was maintained open for as long as
14678 reported by the "Tw" timer field.
14679
14680 RC A local resource has been exhausted (memory, sockets, source ports)
14681 preventing the connection to the server from establishing. The error
14682 logs will tell precisely what was missing. This is very rare and can
14683 only be solved by proper system tuning.
14684
Willy Tarreau996a92c2010-10-13 19:30:47 +020014685The combination of the two last flags gives a lot of information about how
14686persistence was handled by the client, the server and by haproxy. This is very
14687important to troubleshoot disconnections, when users complain they have to
14688re-authenticate. The commonly encountered flags are :
14689
14690 -- Persistence cookie is not enabled.
14691
14692 NN No cookie was provided by the client, none was inserted in the
14693 response. For instance, this can be in insert mode with "postonly"
14694 set on a GET request.
14695
14696 II A cookie designating an invalid server was provided by the client,
14697 a valid one was inserted in the response. This typically happens when
Jamie Gloudonaaa21002012-08-25 00:18:33 -040014698 a "server" entry is removed from the configuration, since its cookie
Willy Tarreau996a92c2010-10-13 19:30:47 +020014699 value can be presented by a client when no other server knows it.
14700
14701 NI No cookie was provided by the client, one was inserted in the
14702 response. This typically happens for first requests from every user
14703 in "insert" mode, which makes it an easy way to count real users.
14704
14705 VN A cookie was provided by the client, none was inserted in the
14706 response. This happens for most responses for which the client has
14707 already got a cookie.
14708
14709 VU A cookie was provided by the client, with a last visit date which is
14710 not completely up-to-date, so an updated cookie was provided in
14711 response. This can also happen if there was no date at all, or if
14712 there was a date but the "maxidle" parameter was not set, so that the
14713 cookie can be switched to unlimited time.
14714
14715 EI A cookie was provided by the client, with a last visit date which is
14716 too old for the "maxidle" parameter, so the cookie was ignored and a
14717 new cookie was inserted in the response.
14718
14719 OI A cookie was provided by the client, with a first visit date which is
14720 too old for the "maxlife" parameter, so the cookie was ignored and a
14721 new cookie was inserted in the response.
14722
14723 DI The server designated by the cookie was down, a new server was
14724 selected and a new cookie was emitted in the response.
14725
14726 VI The server designated by the cookie was not marked dead but could not
14727 be reached. A redispatch happened and selected another one, which was
14728 then advertised in the response.
14729
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014730
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200147318.6. Non-printable characters
14732-----------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014733
14734In order not to cause trouble to log analysis tools or terminals during log
14735consulting, non-printable characters are not sent as-is into log files, but are
14736converted to the two-digits hexadecimal representation of their ASCII code,
14737prefixed by the character '#'. The only characters that can be logged without
14738being escaped are comprised between 32 and 126 (inclusive). Obviously, the
14739escape character '#' itself is also encoded to avoid any ambiguity ("#23"). It
14740is the same for the character '"' which becomes "#22", as well as '{', '|' and
14741'}' when logging headers.
14742
14743Note that the space character (' ') is not encoded in headers, which can cause
14744issues for tools relying on space count to locate fields. A typical header
14745containing spaces is "User-Agent".
14746
14747Last, it has been observed that some syslog daemons such as syslog-ng escape
14748the quote ('"') with a backslash ('\'). The reverse operation can safely be
14749performed since no quote may appear anywhere else in the logs.
14750
14751
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200147528.7. Capturing HTTP cookies
14753---------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014754
14755Cookie capture simplifies the tracking a complete user session. This can be
14756achieved using the "capture cookie" statement in the frontend. Please refer to
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014757section 4.2 for more details. Only one cookie can be captured, and the same
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014758cookie will simultaneously be checked in the request ("Cookie:" header) and in
14759the response ("Set-Cookie:" header). The respective values will be reported in
14760the HTTP logs at the "captured_request_cookie" and "captured_response_cookie"
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014761locations (see section 8.2.3 about HTTP log format). When either cookie is
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014762not seen, a dash ('-') replaces the value. This way, it's easy to detect when a
14763user switches to a new session for example, because the server will reassign it
14764a new cookie. It is also possible to detect if a server unexpectedly sets a
14765wrong cookie to a client, leading to session crossing.
14766
14767 Examples :
14768 # capture the first cookie whose name starts with "ASPSESSION"
14769 capture cookie ASPSESSION len 32
14770
14771 # capture the first cookie whose name is exactly "vgnvisitor"
14772 capture cookie vgnvisitor= len 32
14773
14774
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200147758.8. Capturing HTTP headers
14776---------------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014777
14778Header captures are useful to track unique request identifiers set by an upper
14779proxy, virtual host names, user-agents, POST content-length, referrers, etc. In
14780the response, one can search for information about the response length, how the
14781server asked the cache to behave, or an object location during a redirection.
14782
14783Header captures are performed using the "capture request header" and "capture
14784response header" statements in the frontend. Please consult their definition in
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014785section 4.2 for more details.
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014786
14787It is possible to include both request headers and response headers at the same
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014788time. Non-existent headers are logged as empty strings, and if one header
14789appears more than once, only its last occurrence will be logged. Request headers
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014790are grouped within braces '{' and '}' in the same order as they were declared,
14791and delimited with a vertical bar '|' without any space. Response headers
14792follow the same representation, but are displayed after a space following the
14793request headers block. These blocks are displayed just before the HTTP request
14794in the logs.
14795
Willy Tarreaud9ed3d22014-06-13 12:23:06 +020014796As a special case, it is possible to specify an HTTP header capture in a TCP
14797frontend. The purpose is to enable logging of headers which will be parsed in
14798an HTTP backend if the request is then switched to this HTTP backend.
14799
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014800 Example :
14801 # This instance chains to the outgoing proxy
14802 listen proxy-out
14803 mode http
14804 option httplog
14805 option logasap
14806 log global
14807 server cache1 192.168.1.1:3128
14808
14809 # log the name of the virtual server
14810 capture request header Host len 20
14811
14812 # log the amount of data uploaded during a POST
14813 capture request header Content-Length len 10
14814
14815 # log the beginning of the referrer
14816 capture request header Referer len 20
14817
14818 # server name (useful for outgoing proxies only)
14819 capture response header Server len 20
14820
14821 # logging the content-length is useful with "option logasap"
14822 capture response header Content-Length len 10
14823
14824 # log the expected cache behaviour on the response
14825 capture response header Cache-Control len 8
14826
14827 # the Via header will report the next proxy's name
14828 capture response header Via len 20
14829
14830 # log the URL location during a redirection
14831 capture response header Location len 20
14832
14833 >>> Aug 9 20:26:09 localhost \
14834 haproxy[2022]: 127.0.0.1:34014 [09/Aug/2004:20:26:09] proxy-out \
14835 proxy-out/cache1 0/0/0/162/+162 200 +350 - - ---- 0/0/0/0/0 0/0 \
14836 {fr.adserver.yahoo.co||http://fr.f416.mail.} {|864|private||} \
14837 "GET http://fr.adserver.yahoo.com/"
14838
14839 >>> Aug 9 20:30:46 localhost \
14840 haproxy[2022]: 127.0.0.1:34020 [09/Aug/2004:20:30:46] proxy-out \
14841 proxy-out/cache1 0/0/0/182/+182 200 +279 - - ---- 0/0/0/0/0 0/0 \
14842 {w.ods.org||} {Formilux/0.1.8|3495|||} \
Willy Tarreaud72758d2010-01-12 10:42:19 +010014843 "GET http://trafic.1wt.eu/ HTTP/1.1"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014844
14845 >>> Aug 9 20:30:46 localhost \
14846 haproxy[2022]: 127.0.0.1:34028 [09/Aug/2004:20:30:46] proxy-out \
14847 proxy-out/cache1 0/0/2/126/+128 301 +223 - - ---- 0/0/0/0/0 0/0 \
14848 {www.sytadin.equipement.gouv.fr||http://trafic.1wt.eu/} \
14849 {Apache|230|||http://www.sytadin.} \
Willy Tarreaud72758d2010-01-12 10:42:19 +010014850 "GET http://www.sytadin.equipement.gouv.fr/ HTTP/1.1"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014851
14852
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200148538.9. Examples of logs
14854---------------------
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014855
14856These are real-world examples of logs accompanied with an explanation. Some of
14857them have been made up by hand. The syslog part has been removed for better
14858reading. Their sole purpose is to explain how to decipher them.
14859
14860 >>> haproxy[674]: 127.0.0.1:33318 [15/Oct/2003:08:31:57.130] px-http \
14861 px-http/srv1 6559/0/7/147/6723 200 243 - - ---- 5/3/3/1/0 0/0 \
14862 "HEAD / HTTP/1.0"
14863
14864 => long request (6.5s) entered by hand through 'telnet'. The server replied
14865 in 147 ms, and the session ended normally ('----')
14866
14867 >>> haproxy[674]: 127.0.0.1:33319 [15/Oct/2003:08:31:57.149] px-http \
14868 px-http/srv1 6559/1230/7/147/6870 200 243 - - ---- 324/239/239/99/0 \
14869 0/9 "HEAD / HTTP/1.0"
14870
14871 => Idem, but the request was queued in the global queue behind 9 other
14872 requests, and waited there for 1230 ms.
14873
14874 >>> haproxy[674]: 127.0.0.1:33320 [15/Oct/2003:08:32:17.654] px-http \
14875 px-http/srv1 9/0/7/14/+30 200 +243 - - ---- 3/3/3/1/0 0/0 \
14876 "GET /image.iso HTTP/1.0"
14877
14878 => request for a long data transfer. The "logasap" option was specified, so
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010014879 the log was produced just before transferring data. The server replied in
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014880 14 ms, 243 bytes of headers were sent to the client, and total time from
14881 accept to first data byte is 30 ms.
14882
14883 >>> haproxy[674]: 127.0.0.1:33320 [15/Oct/2003:08:32:17.925] px-http \
14884 px-http/srv1 9/0/7/14/30 502 243 - - PH-- 3/2/2/0/0 0/0 \
14885 "GET /cgi-bin/bug.cgi? HTTP/1.0"
14886
14887 => the proxy blocked a server response either because of an "rspdeny" or
14888 "rspideny" filter, or because the response was improperly formatted and
Willy Tarreau3c92c5f2011-08-28 09:45:47 +020014889 not HTTP-compliant, or because it blocked sensitive information which
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014890 risked being cached. In this case, the response is replaced with a "502
14891 bad gateway". The flags ("PH--") tell us that it was haproxy who decided
14892 to return the 502 and not the server.
14893
14894 >>> haproxy[18113]: 127.0.0.1:34548 [15/Oct/2003:15:18:55.798] px-http \
Willy Tarreaud72758d2010-01-12 10:42:19 +010014895 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 +010014896
14897 => the client never completed its request and aborted itself ("C---") after
14898 8.5s, while the proxy was waiting for the request headers ("-R--").
14899 Nothing was sent to any server.
14900
14901 >>> haproxy[18113]: 127.0.0.1:34549 [15/Oct/2003:15:19:06.103] px-http \
14902 px-http/<NOSRV> -1/-1/-1/-1/50001 408 0 - - cR-- 2/2/2/0/0 0/0 ""
14903
14904 => The client never completed its request, which was aborted by the
14905 time-out ("c---") after 50s, while the proxy was waiting for the request
14906 headers ("-R--"). Nothing was sent to any server, but the proxy could
14907 send a 408 return code to the client.
14908
14909 >>> haproxy[18989]: 127.0.0.1:34550 [15/Oct/2003:15:24:28.312] px-tcp \
14910 px-tcp/srv1 0/0/5007 0 cD 0/0/0/0/0 0/0
14911
14912 => This log was produced with "option tcplog". The client timed out after
14913 5 seconds ("c----").
14914
14915 >>> haproxy[18989]: 10.0.0.1:34552 [15/Oct/2003:15:26:31.462] px-http \
14916 px-http/srv1 3183/-1/-1/-1/11215 503 0 - - SC-- 205/202/202/115/3 \
Willy Tarreaud72758d2010-01-12 10:42:19 +010014917 0/0 "HEAD / HTTP/1.0"
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014918
14919 => The request took 3s to complete (probably a network problem), and the
Willy Tarreauc57f0e22009-05-10 13:12:33 +020014920 connection to the server failed ('SC--') after 4 attempts of 2 seconds
Willy Tarreaucc6c8912009-02-22 10:53:55 +010014921 (config says 'retries 3'), and no redispatch (otherwise we would have
14922 seen "/+3"). Status code 503 was returned to the client. There were 115
14923 connections on this server, 202 connections on this proxy, and 205 on
14924 the global process. It is possible that the server refused the
14925 connection because of too many already established.
Willy Tarreau844e3c52008-01-11 16:28:18 +010014926
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014927
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200149289. Statistics and monitoring
14929----------------------------
14930
14931It is possible to query HAProxy about its status. The most commonly used
14932mechanism is the HTTP statistics page. This page also exposes an alternative
14933CSV output format for monitoring tools. The same format is provided on the
14934Unix socket.
14935
14936
149379.1. CSV format
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010014938---------------
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +010014939
Willy Tarreau7f062c42009-03-05 18:43:00 +010014940The statistics may be consulted either from the unix socket or from the HTTP
Willy Tarreaua3310dc2014-06-16 15:43:21 +020014941page. Both means provide a CSV format whose fields follow. The first line
14942begins with a sharp ('#') and has one word per comma-delimited field which
14943represents the title of the column. All other lines starting at the second one
14944use a classical CSV format using a comma as the delimiter, and the double quote
14945('"') as an optional text delimiter, but only if the enclosed text is ambiguous
14946(if it contains a quote or a comma). The double-quote character ('"') in the
14947text is doubled ('""'), which is the format that most tools recognize. Please
14948do not insert any column before these ones in order not to break tools which
14949use hard-coded column positions.
Willy Tarreau7f062c42009-03-05 18:43:00 +010014950
James Westbyebe62d62014-07-08 10:14:57 -040014951In brackets after each field name are the types which may have a value for
14952that field. The types are L (Listeners), F (Frontends), B (Backends), and
14953S (Servers).
14954
14955 0. pxname [LFBS]: proxy name
14956 1. svname [LFBS]: service name (FRONTEND for frontend, BACKEND for backend,
14957 any name for server/listener)
14958 2. qcur [..BS]: current queued requests. For the backend this reports the
14959 number queued without a server assigned.
14960 3. qmax [..BS]: max value of qcur
14961 4. scur [LFBS]: current sessions
14962 5. smax [LFBS]: max sessions
14963 6. slim [LFBS]: configured session limit
14964 7. stot [LFBS]: cumulative number of connections
14965 8. bin [LFBS]: bytes in
14966 9. bout [LFBS]: bytes out
14967 10. dreq [LFB.]: requests denied because of security concerns.
14968 - For tcp this is because of a matched tcp-request content rule.
14969 - For http this is because of a matched http-request or tarpit rule.
14970 11. dresp [LFBS]: responses denied because of security concerns.
14971 - For http this is because of a matched http-request rule, or
14972 "option checkcache".
14973 12. ereq [LF..]: request errors. Some of the possible causes are:
14974 - early termination from the client, before the request has been sent.
14975 - read error from the client
14976 - client timeout
14977 - client closed connection
14978 - various bad requests from the client.
14979 - request was tarpitted.
14980 13. econ [..BS]: number of requests that encountered an error trying to
14981 connect to a backend server. The backend stat is the sum of the stat
14982 for all servers of that backend, plus any connection errors not
14983 associated with a particular server (such as the backend having no
14984 active servers).
14985 14. eresp [..BS]: response errors. srv_abrt will be counted here also.
14986 Some other errors are:
14987 - write error on the client socket (won't be counted for the server stat)
14988 - failure applying filters to the response.
14989 15. wretr [..BS]: number of times a connection to a server was retried.
14990 16. wredis [..BS]: number of times a request was redispatched to another
14991 server. The server value counts the number of times that server was
14992 switched away from.
14993 17. status [LFBS]: status (UP/DOWN/NOLB/MAINT/MAINT(via)...)
Pavlos Parissis1f673c72015-05-02 20:30:44 +020014994 18. weight [..BS]: total weight (backend), server weight (server)
14995 19. act [..BS]: number of active servers (backend), server is active (server)
14996 20. bck [..BS]: number of backup servers (backend), server is backup (server)
James Westbyebe62d62014-07-08 10:14:57 -040014997 21. chkfail [...S]: number of failed checks. (Only counts checks failed when
14998 the server is up.)
14999 22. chkdown [..BS]: number of UP->DOWN transitions. The backend counter counts
15000 transitions to the whole backend being down, rather than the sum of the
15001 counters for each server.
15002 23. lastchg [..BS]: number of seconds since the last UP<->DOWN transition
15003 24. downtime [..BS]: total downtime (in seconds). The value for the backend
15004 is the downtime for the whole backend, not the sum of the server downtime.
15005 25. qlimit [...S]: configured maxqueue for the server, or nothing in the
15006 value is 0 (default, meaning no limit)
15007 26. pid [LFBS]: process id (0 for first instance, 1 for second, ...)
15008 27. iid [LFBS]: unique proxy id
15009 28. sid [L..S]: server id (unique inside a proxy)
15010 29. throttle [...S]: current throttle percentage for the server, when
15011 slowstart is active, or no value if not in slowstart.
15012 30. lbtot [..BS]: total number of times a server was selected, either for new
15013 sessions, or when re-dispatching. The server counter is the number
15014 of times that server was selected.
15015 31. tracked [...S]: id of proxy/server if tracking is enabled.
15016 32. type [LFBS]: (0=frontend, 1=backend, 2=server, 3=socket/listener)
15017 33. rate [.FBS]: number of sessions per second over last elapsed second
15018 34. rate_lim [.F..]: configured limit on new sessions per second
15019 35. rate_max [.FBS]: max number of new sessions per second
15020 36. check_status [...S]: status of last health check, one of:
Cyril Bontéf0c60612010-02-06 14:44:47 +010015021 UNK -> unknown
15022 INI -> initializing
15023 SOCKERR -> socket error
15024 L4OK -> check passed on layer 4, no upper layers testing enabled
Jason Harvey83104802015-04-16 11:13:21 -080015025 L4TOUT -> layer 1-4 timeout
Cyril Bontéf0c60612010-02-06 14:44:47 +010015026 L4CON -> layer 1-4 connection problem, for example
15027 "Connection refused" (tcp rst) or "No route to host" (icmp)
15028 L6OK -> check passed on layer 6
15029 L6TOUT -> layer 6 (SSL) timeout
15030 L6RSP -> layer 6 invalid response - protocol error
15031 L7OK -> check passed on layer 7
15032 L7OKC -> check conditionally passed on layer 7, for example 404 with
15033 disable-on-404
15034 L7TOUT -> layer 7 (HTTP/SMTP) timeout
15035 L7RSP -> layer 7 invalid response - protocol error
15036 L7STS -> layer 7 response error, for example HTTP 5xx
James Westbyebe62d62014-07-08 10:14:57 -040015037 37. check_code [...S]: layer5-7 code, if available
15038 38. check_duration [...S]: time in ms took to finish last health check
15039 39. hrsp_1xx [.FBS]: http responses with 1xx code
15040 40. hrsp_2xx [.FBS]: http responses with 2xx code
15041 41. hrsp_3xx [.FBS]: http responses with 3xx code
15042 42. hrsp_4xx [.FBS]: http responses with 4xx code
15043 43. hrsp_5xx [.FBS]: http responses with 5xx code
15044 44. hrsp_other [.FBS]: http responses with other codes (protocol error)
15045 45. hanafail [...S]: failed health checks details
15046 46. req_rate [.F..]: HTTP requests per second over last elapsed second
15047 47. req_rate_max [.F..]: max number of HTTP requests per second observed
15048 48. req_tot [.F..]: total number of HTTP requests received
15049 49. cli_abrt [..BS]: number of data transfers aborted by the client
15050 50. srv_abrt [..BS]: number of data transfers aborted by the server
15051 (inc. in eresp)
15052 51. comp_in [.FB.]: number of HTTP response bytes fed to the compressor
15053 52. comp_out [.FB.]: number of HTTP response bytes emitted by the compressor
15054 53. comp_byp [.FB.]: number of bytes that bypassed the HTTP compressor
15055 (CPU/BW limit)
15056 54. comp_rsp [.FB.]: number of HTTP responses that were compressed
15057 55. lastsess [..BS]: number of seconds since last session assigned to
15058 server/backend
15059 56. last_chk [...S]: last health check contents or textual error
15060 57. last_agt [...S]: last agent check contents or textual error
15061 58. qtime [..BS]: the average queue time in ms over the 1024 last requests
15062 59. ctime [..BS]: the average connect time in ms over the 1024 last requests
15063 60. rtime [..BS]: the average response time in ms over the 1024 last requests
15064 (0 for TCP)
15065 61. ttime [..BS]: the average total session time in ms over the 1024 last
15066 requests
Willy Tarreau844e3c52008-01-11 16:28:18 +010015067
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010015068
Willy Tarreauc57f0e22009-05-10 13:12:33 +0200150699.2. Unix Socket commands
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010015070-------------------------
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010015071
Willy Tarreau468f4932013-08-01 16:50:16 +020015072The stats socket is not enabled by default. In order to enable it, it is
15073necessary to add one line in the global section of the haproxy configuration.
15074A second line is recommended to set a larger timeout, always appreciated when
15075issuing commands by hand :
15076
15077 global
15078 stats socket /var/run/haproxy.sock mode 600 level admin
15079 stats timeout 2m
15080
15081It is also possible to add multiple instances of the stats socket by repeating
15082the line, and make them listen to a TCP port instead of a UNIX socket. This is
15083never done by default because this is dangerous, but can be handy in some
15084situations :
15085
15086 global
15087 stats socket /var/run/haproxy.sock mode 600 level admin
15088 stats socket ipv4@192.168.0.1:9999 level admin
15089 stats timeout 2m
15090
15091To access the socket, an external utility such as "socat" is required. Socat is a
15092swiss-army knife to connect anything to anything. We use it to connect terminals
15093to the socket, or a couple of stdin/stdout pipes to it for scripts. The two main
15094syntaxes we'll use are the following :
15095
15096 # socat /var/run/haproxy.sock stdio
15097 # socat /var/run/haproxy.sock readline
15098
15099The first one is used with scripts. It is possible to send the output of a
15100script to haproxy, and pass haproxy's output to another script. That's useful
15101for retrieving counters or attack traces for example.
15102
15103The second one is only useful for issuing commands by hand. It has the benefit
15104that the terminal is handled by the readline library which supports line
15105editing and history, which is very convenient when issuing repeated commands
15106(eg: watch a counter).
15107
15108The socket supports two operation modes :
15109 - interactive
15110 - non-interactive
15111
15112The non-interactive mode is the default when socat connects to the socket. In
15113this mode, a single line may be sent. It is processed as a whole, responses are
15114sent back, and the connection closes after the end of the response. This is the
15115mode that scripts and monitoring tools use. It is possible to send multiple
15116commands in this mode, they need to be delimited by a semi-colon (';'). For
15117example :
15118
15119 # echo "show info;show stat;show table" | socat /var/run/haproxy stdio
15120
15121The interactive mode displays a prompt ('>') and waits for commands to be
15122entered on the line, then processes them, and displays the prompt again to wait
15123for a new command. This mode is entered via the "prompt" command which must be
15124sent on the first line in non-interactive mode. The mode is a flip switch, if
15125"prompt" is sent in interactive mode, it is disabled and the connection closes
15126after processing the last command of the same line.
15127
15128For this reason, when debugging by hand, it's quite common to start with the
15129"prompt" command :
15130
15131 # socat /var/run/haproxy readline
15132 prompt
15133 > show info
15134 ...
15135 >
15136
15137Since multiple commands may be issued at once, haproxy uses the empty line as a
15138delimiter to mark an end of output for each command, and takes care of ensuring
15139that no command can emit an empty line on output. A script can thus easily
15140parse the output even when multiple commands were pipelined on a single line.
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010015141
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015142It is important to understand that when multiple haproxy processes are started
15143on the same sockets, any process may pick up the request and will output its
15144own stats.
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010015145
Willy Tarreau468f4932013-08-01 16:50:16 +020015146The list of commands currently supported on the stats socket is provided below.
15147If an unknown command is sent, haproxy displays the usage message which reminds
15148all supported commands. Some commands support a more complex syntax, generally
15149it will explain what part of the command is invalid when this happens.
15150
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015151add acl <acl> <pattern>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015152 Add an entry into the acl <acl>. <acl> is the #<id> or the <file> returned by
15153 "show acl". This command does not verify if the entry already exists. This
15154 command cannot be used if the reference <acl> is a file also used with a map.
15155 In this case, you must use the command "add map" in place of "add acl".
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015156
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015157add map <map> <key> <value>
15158 Add an entry into the map <map> to associate the value <value> to the key
15159 <key>. This command does not verify if the entry already exists. It is
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015160 mainly used to fill a map after a clear operation. Note that if the reference
15161 <map> is a file and is shared with a map, this map will contain also a new
15162 pattern entry.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015163
Willy Tarreaud63335a2010-02-26 12:56:52 +010015164clear counters
15165 Clear the max values of the statistics counters in each proxy (frontend &
15166 backend) and in each server. The cumulated counters are not affected. This
15167 can be used to get clean counters after an incident, without having to
15168 restart nor to clear traffic counters. This command is restricted and can
15169 only be issued on sockets configured for levels "operator" or "admin".
15170
15171clear counters all
15172 Clear all statistics counters in each proxy (frontend & backend) and in each
15173 server. This has the same effect as restarting. This command is restricted
15174 and can only be issued on sockets configured for level "admin".
15175
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015176clear acl <acl>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015177 Remove all entries from the acl <acl>. <acl> is the #<id> or the <file>
15178 returned by "show acl". Note that if the reference <acl> is a file and is
15179 shared with a map, this map will be also cleared.
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015180
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015181clear map <map>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015182 Remove all entries from the map <map>. <map> is the #<id> or the <file>
15183 returned by "show map". Note that if the reference <map> is a file and is
15184 shared with a acl, this acl will be also cleared.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015185
Simon Hormanc88b8872011-06-15 15:18:49 +090015186clear table <table> [ data.<type> <operator> <value> ] | [ key <key> ]
15187 Remove entries from the stick-table <table>.
15188
15189 This is typically used to unblock some users complaining they have been
15190 abusively denied access to a service, but this can also be used to clear some
15191 stickiness entries matching a server that is going to be replaced (see "show
15192 table" below for details). Note that sometimes, removal of an entry will be
15193 refused because it is currently tracked by a session. Retrying a few seconds
15194 later after the session ends is usual enough.
15195
15196 In the case where no options arguments are given all entries will be removed.
15197
15198 When the "data." form is used entries matching a filter applied using the
15199 stored data (see "stick-table" in section 4.2) are removed. A stored data
15200 type must be specified in <type>, and this data type must be stored in the
15201 table otherwise an error is reported. The data is compared according to
15202 <operator> with the 64-bit integer <value>. Operators are the same as with
15203 the ACLs :
15204
15205 - eq : match entries whose data is equal to this value
15206 - ne : match entries whose data is not equal to this value
15207 - le : match entries whose data is less than or equal to this value
15208 - ge : match entries whose data is greater than or equal to this value
15209 - lt : match entries whose data is less than this value
15210 - gt : match entries whose data is greater than this value
15211
15212 When the key form is used the entry <key> is removed. The key must be of the
Simon Horman619e3cc2011-06-15 15:18:52 +090015213 same type as the table, which currently is limited to IPv4, IPv6, integer and
15214 string.
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015215
15216 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020015217 $ echo "show table http_proxy" | socat stdio /tmp/sock1
Emeric Brun7c6b82e2010-09-24 16:34:28 +020015218 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020015219 >>> 0x80e6a4c: key=127.0.0.1 use=0 exp=3594729 gpc0=0 conn_rate(30000)=1 \
15220 bytes_out_rate(60000)=187
15221 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
15222 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015223
15224 $ echo "clear table http_proxy key 127.0.0.1" | socat stdio /tmp/sock1
15225
15226 $ echo "show table http_proxy" | socat stdio /tmp/sock1
Emeric Brun7c6b82e2010-09-24 16:34:28 +020015227 >>> # table: http_proxy, type: ip, size:204800, used:1
Willy Tarreau62a36c42010-08-17 15:53:10 +020015228 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
15229 bytes_out_rate(60000)=191
Simon Hormanc88b8872011-06-15 15:18:49 +090015230 $ echo "clear table http_proxy data.gpc0 eq 1" | socat stdio /tmp/sock1
15231 $ echo "show table http_proxy" | socat stdio /tmp/sock1
15232 >>> # table: http_proxy, type: ip, size:204800, used:1
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015233
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015234del acl <acl> [<key>|#<ref>]
15235 Delete all the acl entries from the acl <acl> corresponding to the key <key>.
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015236 <acl> is the #<id> or the <file> returned by "show acl". If the <ref> is used,
15237 this command delete only the listed reference. The reference can be found with
15238 listing the content of the acl. Note that if the reference <acl> is a file and
15239 is shared with a map, the entry will be also deleted in the map.
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015240
15241del map <map> [<key>|#<ref>]
Thierry FOURNIER0b90f312014-01-29 20:40:18 +010015242 Delete all the map entries from the map <map> corresponding to the key <key>.
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015243 <map> is the #<id> or the <file> returned by "show map". If the <ref> is used,
15244 this command delete only the listed reference. The reference can be found with
15245 listing the content of the map. Note that if the reference <map> is a file and
15246 is shared with a acl, the entry will be also deleted in the map.
Thierry FOURNIER0b90f312014-01-29 20:40:18 +010015247
15248disable agent <backend>/<server>
Simon Horman671b6f02013-11-25 10:46:39 +090015249 Mark the auxiliary agent check as temporarily stopped.
15250
15251 In the case where an agent check is being run as a auxiliary check, due
15252 to the agent-check parameter of a server directive, new checks are only
15253 initialised when the agent is in the enabled. Thus, disable agent will
15254 prevent any new agent checks from begin initiated until the agent
15255 re-enabled using enable agent.
15256
15257 When an agent is disabled the processing of an auxiliary agent check that
15258 was initiated while the agent was set as enabled is as follows: All
15259 results that would alter the weight, specifically "drain" or a weight
15260 returned by the agent, are ignored. The processing of agent check is
15261 otherwise unchanged.
15262
15263 The motivation for this feature is to allow the weight changing effects
15264 of the agent checks to be paused to allow the weight of a server to be
15265 configured using set weight without being overridden by the agent.
15266
15267 This command is restricted and can only be issued on sockets configured for
15268 level "admin".
15269
Willy Tarreau532a4502011-09-07 22:37:44 +020015270disable frontend <frontend>
15271 Mark the frontend as temporarily stopped. This corresponds to the mode which
15272 is used during a soft restart : the frontend releases the port but can be
15273 enabled again if needed. This should be used with care as some non-Linux OSes
15274 are unable to enable it back. This is intended to be used in environments
15275 where stopping a proxy is not even imaginable but a misconfigured proxy must
15276 be fixed. That way it's possible to release the port and bind it into another
15277 process to restore operations. The frontend will appear with status "STOP"
15278 on the stats page.
15279
15280 The frontend may be specified either by its name or by its numeric ID,
15281 prefixed with a sharp ('#').
15282
15283 This command is restricted and can only be issued on sockets configured for
15284 level "admin".
15285
Willy Tarreau9b5aecd2014-05-23 11:53:10 +020015286disable health <backend>/<server>
15287 Mark the primary health check as temporarily stopped. This will disable
15288 sending of health checks, and the last health check result will be ignored.
15289 The server will be in unchecked state and considered UP unless an auxiliary
15290 agent check forces it down.
15291
15292 This command is restricted and can only be issued on sockets configured for
15293 level "admin".
15294
Willy Tarreaud63335a2010-02-26 12:56:52 +010015295disable server <backend>/<server>
15296 Mark the server DOWN for maintenance. In this mode, no more checks will be
15297 performed on the server until it leaves maintenance.
15298 If the server is tracked by other servers, those servers will be set to DOWN
15299 during the maintenance.
15300
15301 In the statistics page, a server DOWN for maintenance will appear with a
15302 "MAINT" status, its tracking servers with the "MAINT(via)" one.
15303
15304 Both the backend and the server may be specified either by their name or by
Willy Tarreauf5f31922011-08-02 11:32:07 +020015305 their numeric ID, prefixed with a sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010015306
15307 This command is restricted and can only be issued on sockets configured for
15308 level "admin".
15309
Simon Horman671b6f02013-11-25 10:46:39 +090015310enable agent <backend>/<server>
15311 Resume auxiliary agent check that was temporarily stopped.
15312
15313 See "disable agent" for details of the effect of temporarily starting
15314 and stopping an auxiliary agent.
15315
15316 This command is restricted and can only be issued on sockets configured for
15317 level "admin".
15318
Willy Tarreau532a4502011-09-07 22:37:44 +020015319enable frontend <frontend>
15320 Resume a frontend which was temporarily stopped. It is possible that some of
15321 the listening ports won't be able to bind anymore (eg: if another process
15322 took them since the 'disable frontend' operation). If this happens, an error
15323 is displayed. Some operating systems might not be able to resume a frontend
15324 which was disabled.
15325
15326 The frontend may be specified either by its name or by its numeric ID,
15327 prefixed with a sharp ('#').
15328
15329 This command is restricted and can only be issued on sockets configured for
15330 level "admin".
15331
Willy Tarreau9b5aecd2014-05-23 11:53:10 +020015332enable health <backend>/<server>
15333 Resume a primary health check that was temporarily stopped. This will enable
15334 sending of health checks again. Please see "disable health" for details.
15335
15336 This command is restricted and can only be issued on sockets configured for
15337 level "admin".
15338
Willy Tarreaud63335a2010-02-26 12:56:52 +010015339enable server <backend>/<server>
15340 If the server was previously marked as DOWN for maintenance, this marks the
15341 server UP and checks are re-enabled.
15342
15343 Both the backend and the server may be specified either by their name or by
Willy Tarreauf5f31922011-08-02 11:32:07 +020015344 their numeric ID, prefixed with a sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010015345
15346 This command is restricted and can only be issued on sockets configured for
15347 level "admin".
15348
Thierry FOURNIER5b16df72014-02-26 18:07:38 +010015349get map <map> <value>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015350get acl <acl> <value>
15351 Lookup the value <value> in the map <map> or in the ACL <acl>. <map> or <acl>
15352 are the #<id> or the <file> returned by "show map" or "show acl". This command
15353 returns all the matching patterns associated with this map. This is useful for
15354 debugging maps and ACLs. The output format is composed by one line par
15355 matching type. Each line is composed by space-delimited series of words.
Thierry FOURNIER5b16df72014-02-26 18:07:38 +010015356
15357 The first two words are:
15358
15359 <match method>: The match method applied. It can be "found", "bool",
15360 "int", "ip", "bin", "len", "str", "beg", "sub", "dir",
15361 "dom", "end" or "reg".
15362
15363 <match result>: The result. Can be "match" or "no-match".
15364
15365 The following words are returned only if the pattern matches an entry.
15366
15367 <index type>: "tree" or "list". The internal lookup algorithm.
15368
15369 <case>: "case-insensitive" or "case-sensitive". The
15370 interpretation of the case.
15371
15372 <entry matched>: match="<entry>". Return the matched pattern. It is
15373 useful with regular expressions.
15374
15375 The two last word are used to show the returned value and its type. With the
15376 "acl" case, the pattern doesn't exist.
15377
15378 return=nothing: No return because there are no "map".
15379 return="<value>": The value returned in the string format.
15380 return=cannot-display: The value cannot be converted as string.
15381
15382 type="<type>": The type of the returned sample.
15383
Willy Tarreaud63335a2010-02-26 12:56:52 +010015384get weight <backend>/<server>
15385 Report the current weight and the initial weight of server <server> in
15386 backend <backend> or an error if either doesn't exist. The initial weight is
15387 the one that appears in the configuration file. Both are normally equal
15388 unless the current weight has been changed. Both the backend and the server
15389 may be specified either by their name or by their numeric ID, prefixed with a
Willy Tarreauf5f31922011-08-02 11:32:07 +020015390 sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010015391
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015392help
15393 Print the list of known keywords and their basic usage. The same help screen
15394 is also displayed for unknown commands.
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +010015395
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015396prompt
15397 Toggle the prompt at the beginning of the line and enter or leave interactive
15398 mode. In interactive mode, the connection is not closed after a command
15399 completes. Instead, the prompt will appear again, indicating the user that
15400 the interpreter is waiting for a new command. The prompt consists in a right
15401 angle bracket followed by a space "> ". This mode is particularly convenient
15402 when one wants to periodically check information such as stats or errors.
15403 It is also a good idea to enter interactive mode before issuing a "help"
15404 command.
15405
15406quit
15407 Close the connection when in interactive mode.
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010015408
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015409set map <map> [<key>|#<ref>] <value>
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015410 Modify the value corresponding to each key <key> in a map <map>. <map> is the
15411 #<id> or <file> returned by "show map". If the <ref> is used in place of
15412 <key>, only the entry pointed by <ref> is changed. The new value is <value>.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015413
Willy Tarreau2a0f4d22011-08-02 11:49:05 +020015414set maxconn frontend <frontend> <value>
Willy Tarreau3c7a79d2012-09-26 21:07:15 +020015415 Dynamically change the specified frontend's maxconn setting. Any positive
15416 value is allowed including zero, but setting values larger than the global
15417 maxconn does not make much sense. If the limit is increased and connections
15418 were pending, they will immediately be accepted. If it is lowered to a value
15419 below the current number of connections, new connections acceptation will be
Willy Tarreau2a0f4d22011-08-02 11:49:05 +020015420 delayed until the threshold is reached. The frontend might be specified by
15421 either its name or its numeric ID prefixed with a sharp ('#').
15422
Willy Tarreau91886b62011-09-07 14:38:31 +020015423set maxconn global <maxconn>
15424 Dynamically change the global maxconn setting within the range defined by the
15425 initial global maxconn setting. If it is increased and connections were
15426 pending, they will immediately be accepted. If it is lowered to a value below
15427 the current number of connections, new connections acceptation will be
15428 delayed until the threshold is reached. A value of zero restores the initial
15429 setting.
15430
Willy Tarreauf5b22872011-09-07 16:13:44 +020015431set rate-limit connections global <value>
15432 Change the process-wide connection rate limit, which is set by the global
15433 'maxconnrate' setting. A value of zero disables the limitation. This limit
15434 applies to all frontends and the change has an immediate effect. The value
15435 is passed in number of connections per second.
15436
William Lallemandd85f9172012-11-09 17:05:39 +010015437set rate-limit http-compression global <value>
15438 Change the maximum input compression rate, which is set by the global
15439 'maxcomprate' setting. A value of zero disables the limitation. The value is
William Lallemand096f5542012-11-19 17:26:05 +010015440 passed in number of kilobytes per second. The value is available in the "show
15441 info" on the line "CompressBpsRateLim" in bytes.
William Lallemandd85f9172012-11-09 17:05:39 +010015442
Willy Tarreau93e7c002013-10-07 18:51:07 +020015443set rate-limit sessions global <value>
15444 Change the process-wide session rate limit, which is set by the global
15445 'maxsessrate' setting. A value of zero disables the limitation. This limit
15446 applies to all frontends and the change has an immediate effect. The value
15447 is passed in number of sessions per second.
15448
Willy Tarreaue43d5322013-10-07 20:01:52 +020015449set rate-limit ssl-sessions global <value>
15450 Change the process-wide SSL session rate limit, which is set by the global
15451 'maxsslrate' setting. A value of zero disables the limitation. This limit
15452 applies to all frontends and the change has an immediate effect. The value
15453 is passed in number of sessions per second sent to the SSL stack. It applies
15454 before the handshake in order to protect the stack against handshake abuses.
15455
Baptiste Assmann3d8f8312015-04-13 22:54:33 +020015456set server <backend>/<server> addr <ip4 or ip6 address>
15457 Replace the current IP address of a server by the one provided.
15458
Willy Tarreau2a4b70f2014-05-22 18:42:35 +020015459set server <backend>/<server> agent [ up | down ]
15460 Force a server's agent to a new state. This can be useful to immediately
15461 switch a server's state regardless of some slow agent checks for example.
15462 Note that the change is propagated to tracking servers if any.
15463
15464set server <backend>/<server> health [ up | stopping | down ]
15465 Force a server's health to a new state. This can be useful to immediately
15466 switch a server's state regardless of some slow health checks for example.
15467 Note that the change is propagated to tracking servers if any.
15468
15469set server <backend>/<server> state [ ready | drain | maint ]
15470 Force a server's administrative state to a new state. This can be useful to
15471 disable load balancing and/or any traffic to a server. Setting the state to
15472 "ready" puts the server in normal mode, and the command is the equivalent of
15473 the "enable server" command. Setting the state to "maint" disables any traffic
15474 to the server as well as any health checks. This is the equivalent of the
15475 "disable server" command. Setting the mode to "drain" only removes the server
15476 from load balancing but still allows it to be checked and to accept new
15477 persistent connections. Changes are propagated to tracking servers if any.
15478
15479set server <backend>/<server> weight <weight>[%]
15480 Change a server's weight to the value passed in argument. This is the exact
15481 equivalent of the "set weight" command below.
15482
Emeric Brun4147b2e2014-06-16 18:36:30 +020015483set ssl ocsp-response <response>
15484 This command is used to update an OCSP Response for a certificate (see "crt"
15485 on "bind" lines). Same controls are performed as during the initial loading of
15486 the response. The <response> must be passed as a base64 encoded string of the
15487 DER encoded response from the OCSP server.
15488
15489 Example:
15490 openssl ocsp -issuer issuer.pem -cert server.pem \
15491 -host ocsp.issuer.com:80 -respout resp.der
15492 echo "set ssl ocsp-response $(base64 -w 10000 resp.der)" | \
15493 socat stdio /var/run/haproxy.stat
15494
Nenad Merdanovicc6985f02015-05-09 08:46:02 +020015495set ssl tls-key <id> <tlskey>
15496 Set the next TLS key for the <id> listener to <tlskey>. This key becomes the
15497 ultimate key, while the penultimate one is used for encryption (others just
15498 decrypt). The oldest TLS key present is overwritten. <id> is either a numeric
15499 #<id> or <file> returned by "show tls-keys". <tlskey> is a base64 encoded 48
15500 bit TLS ticket key (ex. openssl rand -base64 48).
15501
Willy Tarreau47060b62013-08-01 21:11:42 +020015502set table <table> key <key> [data.<data_type> <value>]*
Willy Tarreau654694e2012-06-07 01:03:16 +020015503 Create or update a stick-table entry in the table. If the key is not present,
15504 an entry is inserted. See stick-table in section 4.2 to find all possible
15505 values for <data_type>. The most likely use consists in dynamically entering
15506 entries for source IP addresses, with a flag in gpc0 to dynamically block an
Willy Tarreau47060b62013-08-01 21:11:42 +020015507 IP address or affect its quality of service. It is possible to pass multiple
15508 data_types in a single call.
Willy Tarreau654694e2012-06-07 01:03:16 +020015509
Willy Tarreaud63335a2010-02-26 12:56:52 +010015510set timeout cli <delay>
15511 Change the CLI interface timeout for current connection. This can be useful
15512 during long debugging sessions where the user needs to constantly inspect
15513 some indicators without being disconnected. The delay is passed in seconds.
15514
15515set weight <backend>/<server> <weight>[%]
15516 Change a server's weight to the value passed in argument. If the value ends
15517 with the '%' sign, then the new weight will be relative to the initially
Simon Horman58b5d292013-02-12 10:45:52 +090015518 configured weight. Absolute weights are permitted between 0 and 256.
15519 Relative weights must be positive with the resulting absolute weight is
15520 capped at 256. Servers which are part of a farm running a static
15521 load-balancing algorithm have stricter limitations because the weight
15522 cannot change once set. Thus for these servers, the only accepted values
15523 are 0 and 100% (or 0 and the initial weight). Changes take effect
15524 immediately, though certain LB algorithms require a certain amount of
15525 requests to consider changes. A typical usage of this command is to
15526 disable a server during an update by setting its weight to zero, then to
15527 enable it again after the update by setting it back to 100%. This command
15528 is restricted and can only be issued on sockets configured for level
15529 "admin". Both the backend and the server may be specified either by their
15530 name or by their numeric ID, prefixed with a sharp ('#').
Willy Tarreaud63335a2010-02-26 12:56:52 +010015531
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010015532show errors [<iid>]
15533 Dump last known request and response errors collected by frontends and
15534 backends. If <iid> is specified, the limit the dump to errors concerning
Willy Tarreau6162db22009-10-10 17:13:00 +020015535 either frontend or backend whose ID is <iid>. This command is restricted
15536 and can only be issued on sockets configured for levels "operator" or
15537 "admin".
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010015538
15539 The errors which may be collected are the last request and response errors
15540 caused by protocol violations, often due to invalid characters in header
15541 names. The report precisely indicates what exact character violated the
15542 protocol. Other important information such as the exact date the error was
15543 detected, frontend and backend names, the server name (when known), the
15544 internal session ID and the source address which has initiated the session
15545 are reported too.
15546
15547 All characters are returned, and non-printable characters are encoded. The
15548 most common ones (\t = 9, \n = 10, \r = 13 and \e = 27) are encoded as one
15549 letter following a backslash. The backslash itself is encoded as '\\' to
15550 avoid confusion. Other non-printable characters are encoded '\xNN' where
15551 NN is the two-digits hexadecimal representation of the character's ASCII
15552 code.
15553
15554 Lines are prefixed with the position of their first character, starting at 0
15555 for the beginning of the buffer. At most one input line is printed per line,
15556 and large lines will be broken into multiple consecutive output lines so that
15557 the output never goes beyond 79 characters wide. It is easy to detect if a
15558 line was broken, because it will not end with '\n' and the next line's offset
15559 will be followed by a '+' sign, indicating it is a continuation of previous
15560 line.
15561
15562 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020015563 $ echo "show errors" | socat stdio /tmp/sock1
15564 >>> [04/Mar/2009:15:46:56.081] backend http-in (#2) : invalid response
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010015565 src 127.0.0.1, session #54, frontend fe-eth0 (#1), server s2 (#1)
15566 response length 213 bytes, error at position 23:
15567
15568 00000 HTTP/1.0 200 OK\r\n
15569 00017 header/bizarre:blah\r\n
15570 00038 Location: blah\r\n
15571 00054 Long-line: this is a very long line which should b
15572 00104+ e broken into multiple lines on the output buffer,
15573 00154+ otherwise it would be too large to print in a ter
15574 00204+ minal\r\n
15575 00211 \r\n
15576
Willy Tarreauc57f0e22009-05-10 13:12:33 +020015577 In the example above, we see that the backend "http-in" which has internal
Willy Tarreaue0c8a1a2009-03-04 16:33:10 +010015578 ID 2 has blocked an invalid response from its server s2 which has internal
15579 ID 1. The request was on session 54 initiated by source 127.0.0.1 and
15580 received by frontend fe-eth0 whose ID is 1. The total response length was
15581 213 bytes when the error was detected, and the error was at byte 23. This
15582 is the slash ('/') in header name "header/bizarre", which is not a valid
15583 HTTP character for a header name.
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010015584
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015585show info
15586 Dump info about haproxy status on current process.
15587
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015588show map [<map>]
15589 Dump info about map converters. Without argument, the list of all available
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015590 maps is returned. If a <map> is specified, its contents are dumped. <map> is
15591 the #<id> or <file>. The first column is a unique identifier. It can be used
15592 as reference for the operation "del map" and "set map". The second column is
15593 the pattern and the third column is the sample if available. The data returned
15594 are not directly a list of available maps, but are the list of all patterns
15595 composing any map. Many of these patterns can be shared with ACL.
Thierry FOURNIERd32079e2014-01-29 20:02:04 +010015596
15597show acl [<acl>]
15598 Dump info about acl converters. Without argument, the list of all available
Thierry FOURNIER65ce6132014-03-20 11:42:45 +010015599 acls is returned. If a <acl> is specified, its contents are dumped. <acl> if
15600 the #<id> or <file>. The dump format is the same than the map even for the
15601 sample value. The data returned are not a list of available ACL, but are the
15602 list of all patterns composing any ACL. Many of these patterns can be shared
15603 with maps.
Thierry FOURNIERc0e0d7b2013-12-11 16:55:52 +010015604
Willy Tarreau12833bb2014-01-28 16:49:56 +010015605show pools
15606 Dump the status of internal memory pools. This is useful to track memory
15607 usage when suspecting a memory leak for example. It does exactly the same
15608 as the SIGQUIT when running in foreground except that it does not flush
15609 the pools.
15610
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015611show sess
15612 Dump all known sessions. Avoid doing this on slow connections as this can
Willy Tarreau6162db22009-10-10 17:13:00 +020015613 be huge. This command is restricted and can only be issued on sockets
15614 configured for levels "operator" or "admin".
15615
Willy Tarreau66dc20a2010-03-05 17:53:32 +010015616show sess <id>
15617 Display a lot of internal information about the specified session identifier.
15618 This identifier is the first field at the beginning of the lines in the dumps
15619 of "show sess" (it corresponds to the session pointer). Those information are
15620 useless to most users but may be used by haproxy developers to troubleshoot a
15621 complex bug. The output format is intentionally not documented so that it can
Olivierce31e6e2014-09-05 18:49:10 +020015622 freely evolve depending on demands. You may find a description of all fields
15623 returned in src/dumpstats.c
15624
15625 The special id "all" dumps the states of all sessions, which must be avoided
15626 as much as possible as it is highly CPU intensive and can take a lot of time.
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015627
15628show stat [<iid> <type> <sid>]
15629 Dump statistics in the CSV format. By passing <id>, <type> and <sid>, it is
15630 possible to dump only selected items :
15631 - <iid> is a proxy ID, -1 to dump everything
15632 - <type> selects the type of dumpable objects : 1 for frontends, 2 for
15633 backends, 4 for servers, -1 for everything. These values can be ORed,
15634 for example:
15635 1 + 2 = 3 -> frontend + backend.
15636 1 + 2 + 4 = 7 -> frontend + backend + server.
15637 - <sid> is a server ID, -1 to dump everything from the selected proxy.
15638
15639 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020015640 $ echo "show info;show stat" | socat stdio unix-connect:/tmp/sock1
15641 >>> Name: HAProxy
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015642 Version: 1.4-dev2-49
15643 Release_date: 2009/09/23
15644 Nbproc: 1
15645 Process_num: 1
15646 (...)
15647
15648 # pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq, (...)
15649 stats,FRONTEND,,,0,0,1000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,1,0, (...)
15650 stats,BACKEND,0,0,0,0,1000,0,0,0,0,0,,0,0,0,0,UP,0,0,0,,0,250,(...)
15651 (...)
15652 www1,BACKEND,0,0,0,0,1000,0,0,0,0,0,,0,0,0,0,UP,1,1,0,,0,250, (...)
15653
15654 $
15655
15656 Here, two commands have been issued at once. That way it's easy to find
15657 which process the stats apply to in multi-process mode. Notice the empty
15658 line after the information output which marks the end of the first block.
15659 A similar empty line appears at the end of the second block (stats) so that
Krzysztof Piotr Oledzkif8645332009-12-13 21:55:50 +010015660 the reader knows the output has not been truncated.
Willy Tarreau9a42c0d2009-09-22 19:31:03 +020015661
Baptiste Assmann3863f972015-05-17 00:33:24 +020015662show stat resolvers <resolvers section id>
15663 Dump statistics for the given resolvers section.
15664 For each name server, the following counters are reported:
15665 sent: number of DNS requests sent to this server
15666 valid: number of DNS valid responses received from this server
15667 update: number of DNS responses used to update the server's IP address
15668 cname: number of CNAME responses
15669 cname_error: CNAME errors encountered with this server
15670 any_err: number of empty response (IE: server does not support ANY type)
15671 nx: non existent domain response received from this server
15672 timeout: how many time this server did not answer in time
15673 refused: number of requests refused by this server
15674 other: any other DNS errors
15675 invalid: invalid DNS response (from a protocol point of view)
15676 too_big: too big response
15677 outdated: number of response arrived too late (after an other name server)
15678
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015679show table
15680 Dump general information on all known stick-tables. Their name is returned
15681 (the name of the proxy which holds them), their type (currently zero, always
15682 IP), their size in maximum possible number of entries, and the number of
15683 entries currently in use.
15684
15685 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020015686 $ echo "show table" | socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090015687 >>> # table: front_pub, type: ip, size:204800, used:171454
15688 >>> # table: back_rdp, type: ip, size:204800, used:0
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015689
Simon Horman17bce342011-06-15 15:18:47 +090015690show table <name> [ data.<type> <operator> <value> ] | [ key <key> ]
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015691 Dump contents of stick-table <name>. In this mode, a first line of generic
15692 information about the table is reported as with "show table", then all
15693 entries are dumped. Since this can be quite heavy, it is possible to specify
Simon Horman17bce342011-06-15 15:18:47 +090015694 a filter in order to specify what entries to display.
15695
15696 When the "data." form is used the filter applies to the stored data (see
15697 "stick-table" in section 4.2). A stored data type must be specified
15698 in <type>, and this data type must be stored in the table otherwise an
15699 error is reported. The data is compared according to <operator> with the
15700 64-bit integer <value>. Operators are the same as with the ACLs :
15701
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015702 - eq : match entries whose data is equal to this value
15703 - ne : match entries whose data is not equal to this value
15704 - le : match entries whose data is less than or equal to this value
15705 - ge : match entries whose data is greater than or equal to this value
15706 - lt : match entries whose data is less than this value
15707 - gt : match entries whose data is greater than this value
15708
Simon Hormanc88b8872011-06-15 15:18:49 +090015709
15710 When the key form is used the entry <key> is shown. The key must be of the
Simon Horman619e3cc2011-06-15 15:18:52 +090015711 same type as the table, which currently is limited to IPv4, IPv6, integer,
15712 and string.
Simon Horman17bce342011-06-15 15:18:47 +090015713
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015714 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020015715 $ echo "show table http_proxy" | socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090015716 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020015717 >>> 0x80e6a4c: key=127.0.0.1 use=0 exp=3594729 gpc0=0 conn_rate(30000)=1 \
15718 bytes_out_rate(60000)=187
15719 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
15720 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015721
Willy Tarreau62a36c42010-08-17 15:53:10 +020015722 $ echo "show table http_proxy data.gpc0 gt 0" | socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090015723 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020015724 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
15725 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015726
Willy Tarreau62a36c42010-08-17 15:53:10 +020015727 $ echo "show table http_proxy data.conn_rate gt 5" | \
15728 socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090015729 >>> # table: http_proxy, type: ip, size:204800, used:2
Willy Tarreau62a36c42010-08-17 15:53:10 +020015730 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
15731 bytes_out_rate(60000)=191
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015732
Simon Horman17bce342011-06-15 15:18:47 +090015733 $ echo "show table http_proxy key 127.0.0.2" | \
15734 socat stdio /tmp/sock1
Simon Horman64b28d02011-08-13 08:03:50 +090015735 >>> # table: http_proxy, type: ip, size:204800, used:2
Simon Horman17bce342011-06-15 15:18:47 +090015736 >>> 0x80e6a80: key=127.0.0.2 use=0 exp=3594740 gpc0=1 conn_rate(30000)=10 \
15737 bytes_out_rate(60000)=191
15738
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015739 When the data criterion applies to a dynamic value dependent on time such as
15740 a bytes rate, the value is dynamically computed during the evaluation of the
15741 entry in order to decide whether it has to be dumped or not. This means that
15742 such a filter could match for some time then not match anymore because as
15743 time goes, the average event rate drops.
15744
15745 It is possible to use this to extract lists of IP addresses abusing the
15746 service, in order to monitor them or even blacklist them in a firewall.
15747 Example :
Willy Tarreau62a36c42010-08-17 15:53:10 +020015748 $ echo "show table http_proxy data.gpc0 gt 0" \
15749 | socat stdio /tmp/sock1 \
Willy Tarreau88bc4ec2010-08-01 07:58:48 +020015750 | fgrep 'key=' | cut -d' ' -f2 | cut -d= -f2 > abusers-ip.txt
15751 ( or | awk '/key/{ print a[split($2,a,"=")]; }' )
Krzysztof Piotr Oledzki719e7262009-10-04 15:02:46 +020015752
Nenad Merdanovicc6985f02015-05-09 08:46:02 +020015753show tls-keys
15754 Dump all loaded TLS ticket keys. The TLS ticket key reference ID and the
15755 file from which the keys have been loaded is shown. Both of those can be
15756 used to update the TLS keys using "set ssl tls-key".
15757
Willy Tarreau532a4502011-09-07 22:37:44 +020015758shutdown frontend <frontend>
15759 Completely delete the specified frontend. All the ports it was bound to will
15760 be released. It will not be possible to enable the frontend anymore after
15761 this operation. This is intended to be used in environments where stopping a
15762 proxy is not even imaginable but a misconfigured proxy must be fixed. That
15763 way it's possible to release the port and bind it into another process to
15764 restore operations. The frontend will not appear at all on the stats page
15765 once it is terminated.
15766
15767 The frontend may be specified either by its name or by its numeric ID,
15768 prefixed with a sharp ('#').
15769
15770 This command is restricted and can only be issued on sockets configured for
15771 level "admin".
15772
Willy Tarreaua295edc2011-09-07 23:21:03 +020015773shutdown session <id>
15774 Immediately terminate the session matching the specified session identifier.
15775 This identifier is the first field at the beginning of the lines in the dumps
15776 of "show sess" (it corresponds to the session pointer). This can be used to
15777 terminate a long-running session without waiting for a timeout or when an
15778 endless transfer is ongoing. Such terminated sessions are reported with a 'K'
15779 flag in the logs.
15780
Cyril Bontée63a1eb2014-07-12 18:22:42 +020015781shutdown sessions server <backend>/<server>
Willy Tarreau52b2d222011-09-07 23:48:48 +020015782 Immediately terminate all the sessions attached to the specified server. This
15783 can be used to terminate long-running sessions after a server is put into
15784 maintenance mode, for instance. Such terminated sessions are reported with a
15785 'K' flag in the logs.
15786
Willy Tarreau0ba27502007-12-24 16:55:16 +010015787/*
15788 * Local variables:
15789 * fill-column: 79
15790 * End:
15791 */