blob: 943158a930d86cc5c45a0746529807e2c43cfaaa [file] [log] [blame]
Willy Tarreau6a06a402007-07-15 20:15:28 +02001 ----------------------
2 HAProxy
3 Configuration Manual
4 ----------------------
Willy Tarreaub1e52e82008-01-13 14:49:51 +01005 version 1.3.15
Willy Tarreau6a06a402007-07-15 20:15:28 +02006 willy tarreau
Willy Tarreau7b4c5ae2008-04-19 21:06:14 +02007 2008/04/19
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 Tarreau6a06a402007-07-15 20:15:28 +020013
Willy Tarreau41a340d2008-01-22 12:25:31 +010014Note to documentation contributors : this document is formated with 80 columns
15per line, with even number of spaces for indentation and without tabs. Please
16follow these rules strictly so that it remains easily printable everywhere. If
17a line needs to be printed verbatim and does not fit, please end each line with
18a backslash ('\') and continue on next line.
Willy Tarreau6a06a402007-07-15 20:15:28 +020019
20HAProxy's configuration process involves 3 major sources of parameters :
21
22 - the arguments from the command-line, which always take precedence
23 - the "global" section, which sets process-wide parameters
24 - the proxies sections which can take form of "defaults", "listen",
25 "frontend" and "backend".
26
Willy Tarreau0ba27502007-12-24 16:55:16 +010027The configuration file syntax consists in lines beginning with a keyword
28referenced in this manual, optionally followed by one or several parameters
29delimited by spaces. If spaces have to be entered in strings, then they must be
30preceeded by a backslash ('\') to be escaped. Backslashes also have to be
31escaped by doubling them.
32
33Some parameters involve values representating time, such as timeouts. These
34values are generally expressed in milliseconds (unless explicitly stated
35otherwise) but may be expressed in any other unit by suffixing the unit to the
36numeric value. It is important to consider this because it will not be repeated
37for every keyword. Supported units are :
38
39 - us : microseconds. 1 microsecond = 1/1000000 second
40 - ms : milliseconds. 1 millisecond = 1/1000 second. This is the default.
41 - s : seconds. 1s = 1000ms
42 - m : minutes. 1m = 60s = 60000ms
43 - h : hours. 1h = 60m = 3600s = 3600000ms
44 - d : days. 1d = 24h = 1440m = 86400s = 86400000ms
45
46
Willy Tarreau6a06a402007-07-15 20:15:28 +0200471. Global parameters
48--------------------
49
50Parameters in the "global" section are process-wide and often OS-specific. They
51are generally set once for all and do not need being changed once correct. Some
52of them have command-line equivalents.
53
54The following keywords are supported in the "global" section :
55
56 * Process management and security
57 - chroot
58 - daemon
59 - gid
60 - group
61 - log
62 - nbproc
63 - pidfile
64 - uid
65 - ulimit-n
66 - user
Willy Tarreaufbee7132007-10-18 13:53:22 +020067 - stats
Willy Tarreau6a06a402007-07-15 20:15:28 +020068
69 * Performance tuning
70 - maxconn
71 - noepoll
72 - nokqueue
73 - nopoll
74 - nosepoll
Willy Tarreaufe255b72007-10-14 23:09:26 +020075 - spread-checks
Willy Tarreaua0250ba2008-01-06 11:22:57 +010076 - tune.maxaccept
77 - tune.maxpollevents
Willy Tarreau6a06a402007-07-15 20:15:28 +020078
79 * Debugging
80 - debug
81 - quiet
Willy Tarreau6a06a402007-07-15 20:15:28 +020082
83
841.1) Process management and security
85------------------------------------
86
87chroot <jail dir>
88 Changes current directory to <jail dir> and performs a chroot() there before
89 dropping privileges. This increases the security level in case an unknown
90 vulnerability would be exploited, since it would make it very hard for the
91 attacker to exploit the system. This only works when the process is started
92 with superuser privileges. It is important to ensure that <jail_dir> is both
93 empty and unwritable to anyone.
94
95daemon
96 Makes the process fork into background. This is the recommended mode of
97 operation. It is equivalent to the command line "-D" argument. It can be
98 disabled by the command line "-db" argument.
99
100gid <number>
101 Changes the process' group ID to <number>. It is recommended that the group
102 ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
103 be started with a user belonging to this group, or with superuser privileges.
104 See also "group" and "uid".
105
106group <group name>
107 Similar to "gid" but uses the GID of group name <group name> from /etc/group.
108 See also "gid" and "user".
109
110log <address> <facility> [max level]
111 Adds a global syslog server. Up to two global servers can be defined. They
112 will receive logs for startups and exits, as well as all logs from proxies
Robert Tsai81ae1952007-12-05 10:47:29 +0100113 configured with "log global".
114
115 <address> can be one of:
116
Willy Tarreau2769aa02007-12-27 18:26:09 +0100117 - An IPv4 address optionally followed by a colon and a UDP port. If
Robert Tsai81ae1952007-12-05 10:47:29 +0100118 no port is specified, 514 is used by default (the standard syslog
119 port).
120
121 - A filesystem path to a UNIX domain socket, keeping in mind
122 considerations for chroot (be sure the path is accessible inside
123 the chroot) and uid/gid (be sure the path is appropriately
124 writeable).
125
126 <facility> must be one of the 24 standard syslog facilities :
Willy Tarreau6a06a402007-07-15 20:15:28 +0200127
128 kern user mail daemon auth syslog lpr news
129 uucp cron auth2 ftp ntp audit alert cron2
130 local0 local1 local2 local3 local4 local5 local6 local7
131
132 An optional level can be specified to filter outgoing messages. By default,
133 all messages are sent. If a level is specified, only messages with a severity
134 at least as important as this level will be sent. 8 levels are known :
135
136 emerg alert crit err warning notice info debug
137
138nbproc <number>
139 Creates <number> processes when going daemon. This requires the "daemon"
140 mode. By default, only one process is created, which is the recommended mode
141 of operation. For systems limited to small sets of file descriptors per
142 process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
143 IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
144
145pidfile <pidfile>
146 Writes pids of all daemons into file <pidfile>. This option is equivalent to
147 the "-p" command line argument. The file must be accessible to the user
148 starting the process. See also "daemon".
149
Willy Tarreaufbee7132007-10-18 13:53:22 +0200150stats socket <path> [{uid | user} <uid>] [{gid | group} <gid>] [mode <mode>]
151 Creates a UNIX socket in stream mode at location <path>. Any previously
152 existing socket will be backed up then replaced. Connections to this socket
153 will get a CSV-formated output of the process statistics in response to the
Willy Tarreaua8efd362008-01-03 10:19:15 +0100154 "show stat" command followed by a line feed, and more general process
155 information in response to the "show info" command followed by a line feed.
156
157 On platforms which support it, it is possible to restrict access to this
158 socket by specifying numerical IDs after "uid" and "gid", or valid user and
159 group names after the "user" and "group" keywords. It is also possible to
160 restrict permissions on the socket by passing an octal value after the "mode"
161 keyword (same syntax as chmod). Depending on the platform, the permissions on
162 the socket will be inherited from the directory which hosts it, or from the
163 user the process is started with.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200164
165stats timeout <timeout, in milliseconds>
166 The default timeout on the stats socket is set to 10 seconds. It is possible
167 to change this value with "stats timeout". The value must be passed in
Willy Tarreaubefdff12007-12-02 22:27:38 +0100168 milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200169
170stats maxconn <connections>
171 By default, the stats socket is limited to 10 concurrent connections. It is
172 possible to change this value with "stats maxconn".
173
Willy Tarreau6a06a402007-07-15 20:15:28 +0200174uid <number>
175 Changes the process' user ID to <number>. It is recommended that the user ID
176 is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
177 be started with superuser privileges in order to be able to switch to another
178 one. See also "gid" and "user".
179
180ulimit-n <number>
181 Sets the maximum number of per-process file-descriptors to <number>. By
182 default, it is automatically computed, so it is recommended not to use this
183 option.
184
185user <user name>
186 Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
187 See also "uid" and "group".
188
189
1901.2) Performance tuning
191-----------------------
192
193maxconn <number>
194 Sets the maximum per-process number of concurrent connections to <number>. It
195 is equivalent to the command-line argument "-n". Proxies will stop accepting
196 connections when this limit is reached. The "ulimit-n" parameter is
197 automatically adjusted according to this value. See also "ulimit-n".
198
199noepoll
200 Disables the use of the "epoll" event polling system on Linux. It is
201 equivalent to the command-line argument "-de". The next polling system
202 used will generally be "poll". See also "nosepoll", and "nopoll".
203
204nokqueue
205 Disables the use of the "kqueue" event polling system on BSD. It is
206 equivalent to the command-line argument "-dk". The next polling system
207 used will generally be "poll". See also "nopoll".
208
209nopoll
210 Disables the use of the "poll" event polling system. It is equivalent to the
211 command-line argument "-dp". The next polling system used will be "select".
Willy Tarreau0ba27502007-12-24 16:55:16 +0100212 It should never be needed to disable "poll" since it's available on all
Willy Tarreau6a06a402007-07-15 20:15:28 +0200213 platforms supported by HAProxy. See also "nosepoll", and "nopoll" and
214 "nokqueue".
215
216nosepoll
217 Disables the use of the "speculative epoll" event polling system on Linux. It
218 is equivalent to the command-line argument "-ds". The next polling system
219 used will generally be "epoll". See also "nosepoll", and "nopoll".
220
Willy Tarreaufe255b72007-10-14 23:09:26 +0200221spread-checks <0..50, in percent>
222 Sometimes it is desirable to avoid sending health checks to servers at exact
223 intervals, for instance when many logical servers are located on the same
224 physical server. With the help of this parameter, it becomes possible to add
225 some randomness in the check interval between 0 and +/- 50%. A value between
226 2 and 5 seems to show good results. The default value remains at 0.
227
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100228tune.maxaccept <number>
229 Sets the maximum number of consecutive accepts that a process may perform on
230 a single wake up. High values give higher priority to high connection rates,
231 while lower values give higher priority to already established connections.
232 This value is unlimited by default in single process mode. However, in
233 multi-process mode (nbproc > 1), it defaults to 8 so that when one process
234 wakes up, it does not take all incoming connections for itself and leaves a
235 part of them to other processes. Setting this value to zero or less disables
236 the limitation. It should normally not be needed to tweak this value.
237
238tune.maxpollevents <number>
239 Sets the maximum amount of events that can be processed at once in a call to
240 the polling system. The default value is adapted to the operating system. It
241 has been noticed that reducing it below 200 tends to slightly decrease
242 latency at the expense of network bandwidth, and increasing it above 200
243 tends to trade latency for slightly increased bandwidth.
244
Willy Tarreau6a06a402007-07-15 20:15:28 +0200245
2461.3) Debugging
247---------------
248
249debug
250 Enables debug mode which dumps to stdout all exchanges, and disables forking
251 into background. It is the equivalent of the command-line argument "-d". It
252 should never be used in a production configuration since it may prevent full
253 system startup.
254
255quiet
256 Do not display any message during startup. It is equivalent to the command-
257 line argument "-q".
258
Willy Tarreau6a06a402007-07-15 20:15:28 +0200259
2602) Proxies
261----------
Willy Tarreau0ba27502007-12-24 16:55:16 +0100262
Willy Tarreau6a06a402007-07-15 20:15:28 +0200263Proxy configuration can be located in a set of sections :
264 - defaults <name>
265 - frontend <name>
266 - backend <name>
267 - listen <name>
268
269A "defaults" section sets default parameters for all other sections following
270its declaration. Those default parameters are reset by the next "defaults"
271section. See below for the list of parameters which can be set in a "defaults"
Willy Tarreau0ba27502007-12-24 16:55:16 +0100272section. The name is optional but its use is encouraged for better readability.
Willy Tarreau6a06a402007-07-15 20:15:28 +0200273
274A "frontend" section describes a set of listening sockets accepting client
275connections.
276
277A "backend" section describes a set of servers to which the proxy will connect
278to forward incoming connections.
279
280A "listen" section defines a complete proxy with its frontend and backend
281parts combined in one section. It is generally useful for TCP-only traffic.
282
Willy Tarreau0ba27502007-12-24 16:55:16 +0100283All proxy names must be formed from upper and lower case letters, digits,
284'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
285case-sensitive, which means that "www" and "WWW" are two different proxies.
286
287Historically, all proxy names could overlap, it just caused troubles in the
288logs. Since the introduction of content switching, it is mandatory that two
289proxies with overlapping capabilities (frontend/backend) have different names.
290However, it is still permitted that a frontend and a backend share the same
291name, as this configuration seems to be commonly encountered.
292
293Right now, two major proxy modes are supported : "tcp", also known as layer 4,
294and "http", also known as layer 7. In layer 4 mode, HAProxy simply forwards
295bidirectionnal traffic between two sides. In layer 7 mode, HAProxy analyzes the
296protocol, and can interact with it by allowing, blocking, switching, adding,
297modifying, or removing arbitrary contents in requests or responses, based on
298arbitrary criteria.
299
300
3012.1) Quick reminder about HTTP
302------------------------------
303
304When a proxy is running in HTTP mode, both the request and the response are
305fully analyzed and indexed, thus it becomes possible to build matching criteria
306on almost anything found in the contents.
307
308However, it is important to understand how HTTP requests and responses are
309formed, and how HAProxy decomposes them. It will then become easier to write
310correct rules and to debug existing configurations.
311
312
3132.1.1) The HTTP transaction model
314---------------------------------
315
316The HTTP protocol is transaction-driven. This means that each request will lead
317to one and only one response. Traditionnally, a TCP connection is established
318from the client to the server, a request is sent by the client on the
319connection, the server responds and the connection is closed. A new request
320will involve a new connection :
321
322 [CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ...
323
324In this mode, called the "HTTP close" mode, there are as many connection
325establishments as there are HTTP transactions. Since the connection is closed
326by the server after the response, the client does not need to know the content
327length.
328
329Due to the transactional nature of the protocol, it was possible to improve it
330to avoid closing a connection between two subsequent transactions. In this mode
331however, it is mandatory that the server indicates the content length for each
332response so that the client does not wait indefinitely. For this, a special
333header is used: "Content-length". This mode is called the "keep-alive" mode :
334
335 [CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ...
336
337Its advantages are a reduced latency between transactions, and less processing
338power required on the server side. It is generally better than the close mode,
339but not always because the clients often limit their concurrent connections to
340a smaller value. HAProxy currently does not support the HTTP keep-alive mode,
341but knows how to transform it to the close mode.
342
343A last improvement in the communications is the pipelining mode. It still uses
344keep-alive, but the client does not wait for the first response to send the
345second request. This is useful for fetching large number of images composing a
346page :
347
348 [CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ...
349
350This can obviously have a tremendous benefit on performance because the network
351latency is eliminated between subsequent requests. Many HTTP agents do not
352correctly support pipelining since there is no way to associate a response with
353the corresponding request in HTTP. For this reason, it is mandatory for the
354server to reply in the exact same order as the requests were received.
355
356Right now, HAProxy only supports the first mode (HTTP close) if it needs to
357process the request. This means that for each request, there will be one TCP
358connection. If keep-alive or pipelining are required, HAProxy will still
359support them, but will only see the first request and the first response of
360each transaction. While this is generally problematic with regards to logs,
361content switching or filtering, it most often causes no problem for persistence
362with cookie insertion.
363
364
3652.1.2) HTTP request
366-------------------
367
368First, let's consider this HTTP request :
369
370 Line Contents
371 number
372 1 GET /serv/login.php?lang=en&profile=2 HTTP/1.1
373 2 Host: www.mydomain.com
374 3 User-agent: my small browser
375 4 Accept: image/jpeg, image/gif
376 5 Accept: image/png
377
378
3792.1.2.1) The Request line
380-------------------------
381
382Line 1 is the "request line". It is always composed of 3 fields :
383
384 - a METHOD : GET
385 - a URI : /serv/login.php?lang=en&profile=2
386 - a version tag : HTTP/1.1
387
388All of them are delimited by what the standard calls LWS (linear white spaces),
389which are commonly spaces, but can also be tabs or line feeds/carriage returns
390followed by spaces/tabs. The method itself cannot contain any colon (':') and
391is limited to alphabetic letters. All those various combinations make it
392desirable that HAProxy performs the splitting itself rather than leaving it to
393the user to write a complex or inaccurate regular expression.
394
395The URI itself can have several forms :
396
397 - A "relative URI" :
398
399 /serv/login.php?lang=en&profile=2
400
401 It is a complete URL without the host part. This is generally what is
402 received by servers, reverse proxies and transparent proxies.
403
404 - An "absolute URI", also called a "URL" :
405
406 http://192.168.0.12:8080/serv/login.php?lang=en&profile=2
407
408 It is composed of a "scheme" (the protocol name followed by '://'), a host
409 name or address, optionally a colon (':') followed by a port number, then
410 a relative URI beginning at the first slash ('/') after the address part.
411 This is generally what proxies receive, but a server supporting HTTP/1.1
412 must accept this form too.
413
414 - a star ('*') : this form is only accepted in association with the OPTIONS
415 method and is not relayable. It is used to inquiry a next hop's
416 capabilities.
417
418 - an address:port combination : 192.168.0.12:80
419 This is used with the CONNECT method, which is used to establish TCP
420 tunnels through HTTP proxies, generally for HTTPS, but sometimes for
421 other protocols too.
422
423In a relative URI, two sub-parts are identified. The part before the question
424mark is called the "path". It is typically the relative path to static objects
425on the server. The part after the question mark is called the "query string".
426It is mostly used with GET requests sent to dynamic scripts and is very
427specific to the language, framework or application in use.
428
429
4302.1.2.2) The request headers
431----------------------------
432
433The headers start at the second line. They are composed of a name at the
434beginning of the line, immediately followed by a colon (':'). Traditionally,
435an LWS is added after the colon but that's not required. Then come the values.
436Multiple identical headers may be folded into one single line, delimiting the
437values with commas, provided that their order is respected. This is commonly
Willy Tarreau198a7442008-01-17 12:05:32 +0100438encountered in the "Cookie:" field. A header may span over multiple lines if
Willy Tarreau0ba27502007-12-24 16:55:16 +0100439the subsequent lines begin with an LWS. In the example in 2.1.2, lines 4 and 5
Willy Tarreau198a7442008-01-17 12:05:32 +0100440define a total of 3 values for the "Accept:" header.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100441
442Contrary to a common mis-conception, header names are not case-sensitive, and
443their values are not either if they refer to other header names (such as the
Willy Tarreau198a7442008-01-17 12:05:32 +0100444"Connection:" header).
Willy Tarreau0ba27502007-12-24 16:55:16 +0100445
446The end of the headers is indicated by the first empty line. People often say
447that it's a double line feed, which is not exact, even if a double line feed
448is one valid form of empty line.
449
450Fortunately, HAProxy takes care of all these complex combinations when indexing
451headers, checking values and counting them, so there is no reason to worry
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100452about the way they could be written, but it is important not to accuse an
Willy Tarreau0ba27502007-12-24 16:55:16 +0100453application of being buggy if it does unusual, valid things.
454
455Important note:
456 As suggested by RFC2616, HAProxy normalizes headers by replacing line breaks
457 in the middle of headers by LWS in order to join multi-line headers. This
458 is necessary for proper analysis and helps less capable HTTP parsers to work
459 correctly and not to be fooled by such complex constructs.
460
461
4622.1.3) HTTP response
463--------------------
464
465An HTTP response looks very much like an HTTP request. Both are called HTTP
466messages. Let's consider this HTTP response :
467
468 Line Contents
469 number
470 1 HTTP/1.1 200 OK
471 2 Content-length: 350
472 3 Content-Type: text/html
473
474
4752.1.3.1) The Response line
476--------------------------
477
478Line 1 is the "response line". It is always composed of 3 fields :
479
480 - a version tag : HTTP/1.1
481 - a status code : 200
482 - a reason : OK
483
484The status code is always 3-digit. The first digit indicates a general status :
485 - 2xx = OK, content is following (eg: 200, 206)
486 - 3xx = OK, no content following (eg: 302, 304)
487 - 4xx = error caused by the client (eg: 401, 403, 404)
488 - 5xx = error caused by the server (eg: 500, 502, 503)
489
490Please refer to RFC2616 for the detailed meaning of all such codes. The
491"reason" field is just a hint, but is not parsed by clients. Anything can be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100492found there, but it's a common practice to respect the well-established
Willy Tarreau0ba27502007-12-24 16:55:16 +0100493messages. It can be composed of one or multiple words, such as "OK", "Found",
494or "Authentication Required".
495
496
4972.1.3.2) The response headers
498-----------------------------
499
500Response headers work exactly like request headers, and as such, HAProxy uses
501the same parsing function for both. Please refer to paragraph 2.1.2.2 for more
502details.
503
504
5052.2) Proxy keywords matrix
506----------------------------
507
Willy Tarreau6a06a402007-07-15 20:15:28 +0200508The following list of keywords is supported. Most of them may only be used in a
Willy Tarreau0ba27502007-12-24 16:55:16 +0100509limited set of section types. Some of them are marked as "deprecated" because
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100510they are inherited from an old syntax which may be confusing or functionally
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100511limited, and there are new recommended keywords to replace them. Keywords
512listed with [no] can be optionally inverted using the "no" prefix, ex. "no
513option contstats". This makes sense when the option has been enabled by default
514and must be disabled for a specific instance.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100515
Willy Tarreau6a06a402007-07-15 20:15:28 +0200516
517keyword defaults frontend listen backend
518----------------------+----------+----------+---------+---------
519acl - X X X
520appsession - - X X
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100521backlog X X X -
Willy Tarreau0ba27502007-12-24 16:55:16 +0100522balance X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200523bind - X X -
524block - X X X
Willy Tarreau0ba27502007-12-24 16:55:16 +0100525capture cookie - X X -
526capture request header - X X -
527capture response header - X X -
Willy Tarreaue219db72007-12-03 01:30:13 +0100528clitimeout X X X - (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +0100529contimeout X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200530cookie X - X X
531default_backend - X X -
Willy Tarreau0ba27502007-12-24 16:55:16 +0100532disabled X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200533dispatch - - X X
Willy Tarreau0ba27502007-12-24 16:55:16 +0100534enabled X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200535errorfile X X X X
536errorloc X X X X
537errorloc302 X X X X
538errorloc303 X X X X
539fullconn X - X X
540grace - X X X
Willy Tarreaudbc36f62007-11-30 12:29:11 +0100541http-check disable-on-404 X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200542log X X X X
543maxconn X X X -
544mode X X X X
Willy Tarreauc7246fc2007-12-02 17:31:20 +0100545monitor fail - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200546monitor-net X X X -
547monitor-uri X X X -
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100548[no] option abortonclose X - X X
549[no] option allbackups X - X X
550[no] option checkcache X - X X
551[no] option clitcpka X X X -
552[no] option contstats X X X -
553[no] option dontlognull X X X -
554[no] option forceclose X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200555option forwardfor X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100556[no] option http_proxy X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200557option httpchk X - X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100558[no] option httpclose X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200559option httplog X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100560[no] option logasap X X X -
561[no] option nolinger X X X X
562[no] option persist X - X X
563[no] option redispatch X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200564option smtpchk X - X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100565[no] option srvtcpka X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200566option ssl-hello-chk X - X X
567option tcpka X X X X
568option tcplog X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100569[no] option tcpsplice X X X X
570[no] option transparent X X X -
Willy Tarreaub463dfb2008-06-07 23:08:56 +0200571redirect - X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100572redisp X - X X (deprecated)
573redispatch X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200574reqadd - X X X
575reqallow - X X X
576reqdel - X X X
577reqdeny - X X X
578reqiallow - X X X
579reqidel - X X X
580reqideny - X X X
581reqipass - X X X
582reqirep - X X X
583reqisetbe - X X X
584reqitarpit - X X X
585reqpass - X X X
586reqrep - X X X
587reqsetbe - X X X
588reqtarpit - X X X
589retries X - X X
590rspadd - X X X
591rspdel - X X X
592rspdeny - X X X
593rspidel - X X X
594rspideny - X X X
595rspirep - X X X
596rsprep - X X X
597server - - X X
598source X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100599srvtimeout X - X X (deprecated)
Willy Tarreau24e779b2007-07-24 23:43:37 +0200600stats auth X - X X
601stats enable X - X X
602stats realm X - X X
Willy Tarreaubbd42122007-07-25 07:26:38 +0200603stats refresh X - X X
Willy Tarreau24e779b2007-07-24 23:43:37 +0200604stats scope X - X X
605stats uri X - X X
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +0200606stats hide-version X - X X
Willy Tarreau62644772008-07-16 18:36:06 +0200607tcp-request content accept - X X -
608tcp-request content reject - X X -
609tcp-request inspect-delay - X X -
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +0100610timeout check X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100611timeout client X X X -
612timeout clitimeout X X X - (deprecated)
613timeout connect X - X X
614timeout contimeout X - X X (deprecated)
Willy Tarreau844e3c52008-01-11 16:28:18 +0100615timeout http-request X X X -
Willy Tarreaue219db72007-12-03 01:30:13 +0100616timeout queue X - X X
617timeout server X - X X
618timeout srvtimeout X - X X (deprecated)
Willy Tarreau51c9bde2008-01-06 13:40:03 +0100619timeout tarpit X X X X
Willy Tarreau844e3c52008-01-11 16:28:18 +0100620transparent X X X - (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200621use_backend - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200622----------------------+----------+----------+---------+---------
623keyword defaults frontend listen backend
624
Willy Tarreau0ba27502007-12-24 16:55:16 +0100625
6262.2.1) Alphabetically sorted keywords reference
627-----------------------------------------------
628
629This section provides a description of each keyword and its usage.
630
631
632acl <aclname> <criterion> [flags] [operator] <value> ...
633 Declare or complete an access list.
634 May be used in sections : defaults | frontend | listen | backend
635 no | yes | yes | yes
636 Example:
637 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
638 acl invalid_src src_port 0:1023
639 acl local_dst hdr(host) -i localhost
640
641 See section 2.3 about ACL usage.
642
643
644appsession <cookie> len <length> timeout <holdtime>
645 Define session stickiness on an existing application cookie.
646 May be used in sections : defaults | frontend | listen | backend
647 no | no | yes | yes
648 Arguments :
649 <cookie> this is the name of the cookie used by the application and which
650 HAProxy will have to learn for each new session.
651
652 <length> this is the number of characters that will be memorized and
653 checked in each cookie value.
654
655 <holdtime> this is the time after which the cookie will be removed from
656 memory if unused. If no unit is specified, this time is in
657 milliseconds.
658
659 When an application cookie is defined in a backend, HAProxy will check when
660 the server sets such a cookie, and will store its value in a table, and
661 associate it with the server's identifier. Up to <length> characters from
662 the value will be retained. On each connection, haproxy will look for this
663 cookie both in the "Cookie:" headers, and as a URL parameter in the query
664 string. If a known value is found, the client will be directed to the server
665 associated with this value. Otherwise, the load balancing algorithm is
666 applied. Cookies are automatically removed from memory when they have been
667 unused for a duration longer than <holdtime>.
668
669 The definition of an application cookie is limited to one per backend.
670
671 Example :
672 appsession JSESSIONID len 52 timeout 3h
673
674 See also : "cookie", "capture cookie" and "balance".
675
676
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100677backlog <conns>
678 Give hints to the system about the approximate listen backlog desired size
679 May be used in sections : defaults | frontend | listen | backend
680 yes | yes | yes | no
681 Arguments :
682 <conns> is the number of pending connections. Depending on the operating
683 system, it may represent the number of already acknowledged
684 connections, of non-acknowledged ones, or both.
685
686 In order to protect against SYN flood attacks, one solution is to increase
687 the system's SYN backlog size. Depending on the system, sometimes it is just
688 tunable via a system parameter, sometimes it is not adjustable at all, and
689 sometimes the system relies on hints given by the application at the time of
690 the listen() syscall. By default, HAProxy passes the frontend's maxconn value
691 to the listen() syscall. On systems which can make use of this value, it can
692 sometimes be useful to be able to specify a different value, hence this
693 backlog parameter.
694
695 On Linux 2.4, the parameter is ignored by the system. On Linux 2.6, it is
696 used as a hint and the system accepts up to the smallest greater power of
697 two, and never more than some limits (usually 32768).
698
699 See also : "maxconn" and the target operating system's tuning guide.
700
701
Willy Tarreau0ba27502007-12-24 16:55:16 +0100702balance <algorithm> [ <arguments> ]
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200703balance url_param <param> [check_post [<max_wait>]]
Willy Tarreau0ba27502007-12-24 16:55:16 +0100704 Define the load balancing algorithm to be used in a backend.
705 May be used in sections : defaults | frontend | listen | backend
706 yes | no | yes | yes
707 Arguments :
708 <algorithm> is the algorithm used to select a server when doing load
709 balancing. This only applies when no persistence information
710 is available, or when a connection is redispatched to another
711 server. <algorithm> may be one of the following :
712
713 roundrobin Each server is used in turns, according to their weights.
714 This is the smoothest and fairest algorithm when the server's
715 processing time remains equally distributed. This algorithm
716 is dynamic, which means that server weights may be adjusted
717 on the fly for slow starts for instance.
718
Willy Tarreau2d2a7f82008-03-17 12:07:56 +0100719 leastconn The server with the lowest number of connections receives the
720 connection. Round-robin is performed within groups of servers
721 of the same load to ensure that all servers will be used. Use
722 of this algorithm is recommended where very long sessions are
723 expected, such as LDAP, SQL, TSE, etc... but is not very well
724 suited for protocols using short sessions such as HTTP. This
725 algorithm is dynamic, which means that server weights may be
726 adjusted on the fly for slow starts for instance.
727
Willy Tarreau0ba27502007-12-24 16:55:16 +0100728 source The source IP address is hashed and divided by the total
729 weight of the running servers to designate which server will
730 receive the request. This ensures that the same client IP
731 address will always reach the same server as long as no
732 server goes down or up. If the hash result changes due to the
733 number of running servers changing, many clients will be
734 directed to a different server. This algorithm is generally
735 used in TCP mode where no cookie may be inserted. It may also
736 be used on the Internet to provide a best-effort stickyness
737 to clients which refuse session cookies. This algorithm is
738 static, which means that changing a server's weight on the
739 fly will have no effect.
740
741 uri The left part of the URI (before the question mark) is hashed
742 and divided by the total weight of the running servers. The
743 result designates which server will receive the request. This
744 ensures that a same URI will always be directed to the same
745 server as long as no server goes up or down. This is used
746 with proxy caches and anti-virus proxies in order to maximize
747 the cache hit rate. Note that this algorithm may only be used
748 in an HTTP backend. This algorithm is static, which means
749 that changing a server's weight on the fly will have no
750 effect.
751
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200752 This algorithm support two optional parameters "len" and
753 "depth", both followed by a positive integer number. These
754 options may be helpful when it is needed to balance servers
755 based on the beginning of the URI only. The "len" parameter
756 indicates that the algorithm should only consider that many
757 characters at the beginning of the URI to compute the hash.
758 Note that having "len" set to 1 rarely makes sense since most
759 URIs start with a leading "/".
760
761 The "depth" parameter indicates the maximum directory depth
762 to be used to compute the hash. One level is counted for each
763 slash in the request. If both parameters are specified, the
764 evaluation stops when either is reached.
765
Willy Tarreau0ba27502007-12-24 16:55:16 +0100766 url_param The URL parameter specified in argument will be looked up in
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200767 the query string of each HTTP GET request.
768
769 If the modifier "check_post" is used, then an HTTP POST
770 request entity will be searched for the parameter argument,
771 when the question mark indicating a query string ('?') is not
772 present in the URL. Optionally, specify a number of octets to
773 wait for before attempting to search the message body. If the
774 entity can not be searched, then round robin is used for each
775 request. For instance, if your clients always send the LB
776 parameter in the first 128 bytes, then specify that. The
777 default is 48. The entity data will not be scanned until the
778 required number of octets have arrived at the gateway, this
779 is the minimum of: (default/max_wait, Content-Length or first
780 chunk length). If Content-Length is missing or zero, it does
781 not need to wait for more data than the client promised to
782 send. When Content-Length is present and larger than
783 <max_wait>, then waiting is limited to <max_wait> and it is
784 assumed that this will be enough data to search for the
785 presence of the parameter. In the unlikely event that
786 Transfer-Encoding: chunked is used, only the first chunk is
787 scanned. Parameter values separated by a chunk boundary, may
788 be randomly balanced if at all.
789
790 If the parameter is found followed by an equal sign ('=') and
791 a value, then the value is hashed and divided by the total
792 weight of the running servers. The result designates which
793 server will receive the request.
794
795 This is used to track user identifiers in requests and ensure
796 that a same user ID will always be sent to the same server as
797 long as no server goes up or down. If no value is found or if
798 the parameter is not found, then a round robin algorithm is
799 applied. Note that this algorithm may only be used in an HTTP
800 backend. This algorithm is static, which means that changing a
801 server's weight on the fly will have no effect.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100802
803 <arguments> is an optional list of arguments which may be needed by some
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200804 algorithms. Right now, only "url_param" and "uri" support an
805 optional argument.
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200806
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200807 balance uri [len <len>] [depth <depth>]
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200808 balance url_param <param> [check_post [<max_wait>]]
Willy Tarreau0ba27502007-12-24 16:55:16 +0100809
810 The definition of the load balancing algorithm is mandatory for a backend
811 and limited to one per backend.
812
813 Examples :
814 balance roundrobin
815 balance url_param userid
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200816 balance url_param session_id check_post 64
817
818 Note: the following caveats and limitations on using the "check_post"
819 extension with "url_param" must be considered :
820
821 - all POST requests are eligable for consideration, because there is no way
822 to determine if the parameters will be found in the body or entity which
823 may contain binary data. Therefore another method may be required to
824 restrict consideration of POST requests that have no URL parameters in
825 the body. (see acl reqideny http_end)
826
827 - using a <max_wait> value larger than the request buffer size does not
828 make sense and is useless. The buffer size is set at build time, and
829 defaults to 16 kB.
830
831 - Content-Encoding is not supported, the parameter search will probably
832 fail; and load balancing will fall back to Round Robin.
833
834 - Expect: 100-continue is not supported, load balancing will fall back to
835 Round Robin.
836
837 - Transfer-Encoding (RFC2616 3.6.1) is only supported in the first chunk.
838 If the entire parameter value is not present in the first chunk, the
839 selection of server is undefined (actually, defined by how little
840 actually appeared in the first chunk).
841
842 - This feature does not support generation of a 100, 411 or 501 response.
843
844 - In some cases, requesting "check_post" MAY attempt to scan the entire
845 contents of a message body. Scaning normally terminates when linear
846 white space or control characters are found, indicating the end of what
847 might be a URL parameter list. This is probably not a concern with SGML
848 type message bodies.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100849
850 See also : "dispatch", "cookie", "appsession", "transparent" and "http_proxy".
851
852
853bind [<address>]:<port> [, ...]
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100854bind [<address>]:<port> [, ...] transparent
Willy Tarreau0ba27502007-12-24 16:55:16 +0100855 Define one or several listening addresses and/or ports in a frontend.
856 May be used in sections : defaults | frontend | listen | backend
857 no | yes | yes | no
858 Arguments :
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100859 <address> is optional and can be a host name, an IPv4 address, an IPv6
860 address, or '*'. It designates the address the frontend will
861 listen on. If unset, all IPv4 addresses of the system will be
862 listened on. The same will apply for '*' or the system's
863 special address "0.0.0.0".
864
865 <port> is the TCP port number the proxy will listen on. The port is
866 mandatory. Note that in the case of an IPv6 address, the port
867 is always the number after the last colon (':').
Willy Tarreau0ba27502007-12-24 16:55:16 +0100868
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100869 transparent is an optional keyword which is supported only on certain
870 Linux kernels. It indicates that the addresses will be bound
871 even if they do not belong to the local machine. Any packet
872 targetting any of these addresses will be caught just as if
873 the address was locally configured. This normally requires
874 that IP forwarding is enabled. Caution! do not use this with
875 the default address '*', as it would redirect any traffic for
876 the specified port. This keyword is available only when
877 HAProxy is built with USE_LINUX_TPROXY=1.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100878
879 It is possible to specify a list of address:port combinations delimited by
880 commas. The frontend will then listen on all of these addresses. There is no
881 fixed limit to the number of addresses and ports which can be listened on in
882 a frontend, as well as there is no limit to the number of "bind" statements
883 in a frontend.
884
885 Example :
886 listen http_proxy
887 bind :80,:443
888 bind 10.0.0.1:10080,10.0.0.1:10443
889
890 See also : "source".
891
892
893block { if | unless } <condition>
894 Block a layer 7 request if/unless a condition is matched
895 May be used in sections : defaults | frontend | listen | backend
896 no | yes | yes | yes
897
898 The HTTP request will be blocked very early in the layer 7 processing
899 if/unless <condition> is matched. A 403 error will be returned if the request
900 is blocked. The condition has to reference ACLs (see section 2.3). This is
901 typically used to deny access to certain sensible resources if some
902 conditions are met or not met. There is no fixed limit to the number of
903 "block" statements per instance.
904
905 Example:
906 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
907 acl invalid_src src_port 0:1023
908 acl local_dst hdr(host) -i localhost
909 block if invalid_src || local_dst
910
911 See section 2.3 about ACL usage.
912
913
914capture cookie <name> len <length>
915 Capture and log a cookie in the request and in the response.
916 May be used in sections : defaults | frontend | listen | backend
917 no | yes | yes | no
918 Arguments :
919 <name> is the beginning of the name of the cookie to capture. In order
920 to match the exact name, simply suffix the name with an equal
921 sign ('='). The full name will appear in the logs, which is
922 useful with application servers which adjust both the cookie name
923 and value (eg: ASPSESSIONXXXXX).
924
925 <length> is the maximum number of characters to report in the logs, which
926 include the cookie name, the equal sign and the value, all in the
927 standard "name=value" form. The string will be truncated on the
928 right if it exceeds <length>.
929
930 Only the first cookie is captured. Both the "cookie" request headers and the
931 "set-cookie" response headers are monitored. This is particularly useful to
932 check for application bugs causing session crossing or stealing between
933 users, because generally the user's cookies can only change on a login page.
934
935 When the cookie was not presented by the client, the associated log column
936 will report "-". When a request does not cause a cookie to be assigned by the
937 server, a "-" is reported in the response column.
938
939 The capture is performed in the frontend only because it is necessary that
940 the log format does not change for a given frontend depending on the
941 backends. This may change in the future. Note that there can be only one
942 "capture cookie" statement in a frontend. The maximum capture length is
943 configured in the souces by default to 64 characters. It is not possible to
944 specify a capture in a "defaults" section.
945
946 Example:
947 capture cookie ASPSESSION len 32
948
949 See also : "capture request header", "capture response header" as well as
Willy Tarreauced27012008-01-17 20:35:34 +0100950 section 2.6 about logging.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100951
952
953capture request header <name> len <length>
954 Capture and log the first occurrence of the specified request header.
955 May be used in sections : defaults | frontend | listen | backend
956 no | yes | yes | no
957 Arguments :
958 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100959 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +0100960 appear in the requests, with the first letter of each word in
961 upper case. The header name will not appear in the logs, only the
962 value is reported, but the position in the logs is respected.
963
964 <length> is the maximum number of characters to extract from the value and
965 report in the logs. The string will be truncated on the right if
966 it exceeds <length>.
967
968 Only the first value of the first occurrence of the header is captured. The
969 value will be added to the logs between braces ('{}'). If multiple headers
970 are captured, they will be delimited by a vertical bar ('|') and will appear
971 in the same order they were declared in the configuration. Common uses for
972 request header captures include the "Host" field in virtual hosting
973 environments, the "Content-length" when uploads are supported, "User-agent"
974 to quickly differenciate between real users and robots, and "X-Forwarded-For"
975 in proxied environments to find where the request came from.
976
977 There is no limit to the number of captured request headers, but each capture
978 is limited to 64 characters. In order to keep log format consistent for a
979 same frontend, header captures can only be declared in a frontend. It is not
980 possible to specify a capture in a "defaults" section.
981
982 Example:
983 capture request header Host len 15
984 capture request header X-Forwarded-For len 15
985 capture request header Referrer len 15
986
Willy Tarreauced27012008-01-17 20:35:34 +0100987 See also : "capture cookie", "capture response header" as well as section 2.6
Willy Tarreau0ba27502007-12-24 16:55:16 +0100988 about logging.
989
990
991capture response header <name> len <length>
992 Capture and log the first occurrence of the specified response header.
993 May be used in sections : defaults | frontend | listen | backend
994 no | yes | yes | no
995 Arguments :
996 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100997 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +0100998 appear in the response, with the first letter of each word in
999 upper case. The header name will not appear in the logs, only the
1000 value is reported, but the position in the logs is respected.
1001
1002 <length> is the maximum number of characters to extract from the value and
1003 report in the logs. The string will be truncated on the right if
1004 it exceeds <length>.
1005
1006 Only the first value of the first occurrence of the header is captured. The
1007 result will be added to the logs between braces ('{}') after the captured
1008 request headers. If multiple headers are captured, they will be delimited by
1009 a vertical bar ('|') and will appear in the same order they were declared in
1010 the configuration. Common uses for response header captures include the
1011 "Content-length" header which indicates how many bytes are expected to be
1012 returned, the "Location" header to track redirections.
1013
1014 There is no limit to the number of captured response headers, but each
1015 capture is limited to 64 characters. In order to keep log format consistent
1016 for a same frontend, header captures can only be declared in a frontend. It
1017 is not possible to specify a capture in a "defaults" section.
1018
1019 Example:
1020 capture response header Content-length len 9
1021 capture response header Location len 15
1022
Willy Tarreauced27012008-01-17 20:35:34 +01001023 See also : "capture cookie", "capture request header" as well as section 2.6
Willy Tarreau0ba27502007-12-24 16:55:16 +01001024 about logging.
1025
1026
1027clitimeout <timeout>
1028 Set the maximum inactivity time on the client side.
1029 May be used in sections : defaults | frontend | listen | backend
1030 yes | yes | yes | no
1031 Arguments :
1032 <timeout> is the timeout value is specified in milliseconds by default, but
1033 can be in any other unit if the number is suffixed by the unit,
1034 as explained at the top of this document.
1035
1036 The inactivity timeout applies when the client is expected to acknowledge or
1037 send data. In HTTP mode, this timeout is particularly important to consider
1038 during the first phase, when the client sends the request, and during the
1039 response while it is reading data sent by the server. The value is specified
1040 in milliseconds by default, but can be in any other unit if the number is
1041 suffixed by the unit, as specified at the top of this document. In TCP mode
1042 (and to a lesser extent, in HTTP mode), it is highly recommended that the
1043 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001044 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01001045 losses by specifying timeouts that are slightly above multiples of 3 seconds
1046 (eg: 4 or 5 seconds).
1047
1048 This parameter is specific to frontends, but can be specified once for all in
1049 "defaults" sections. This is in fact one of the easiest solutions not to
1050 forget about it. An unspecified timeout results in an infinite timeout, which
1051 is not recommended. Such a usage is accepted and works but reports a warning
1052 during startup because it may results in accumulation of expired sessions in
1053 the system if the system's timeouts are not configured either.
1054
1055 This parameter is provided for compatibility but is currently deprecated.
1056 Please use "timeout client" instead.
1057
Willy Tarreau036fae02008-01-06 13:24:40 +01001058 See also : "timeout client", "timeout http-request", "timeout server", and
1059 "srvtimeout".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001060
1061
1062contimeout <timeout>
1063 Set the maximum time to wait for a connection attempt to a server to succeed.
1064 May be used in sections : defaults | frontend | listen | backend
1065 yes | no | yes | yes
1066 Arguments :
1067 <timeout> is the timeout value is specified in milliseconds by default, but
1068 can be in any other unit if the number is suffixed by the unit,
1069 as explained at the top of this document.
1070
1071 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001072 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +01001073 cover one or several TCP packet losses by specifying timeouts that are
1074 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
1075 connect timeout also presets the queue timeout to the same value if this one
1076 has not been specified. Historically, the contimeout was also used to set the
1077 tarpit timeout in a listen section, which is not possible in a pure frontend.
1078
1079 This parameter is specific to backends, but can be specified once for all in
1080 "defaults" sections. This is in fact one of the easiest solutions not to
1081 forget about it. An unspecified timeout results in an infinite timeout, which
1082 is not recommended. Such a usage is accepted and works but reports a warning
1083 during startup because it may results in accumulation of failed sessions in
1084 the system if the system's timeouts are not configured either.
1085
1086 This parameter is provided for backwards compatibility but is currently
1087 deprecated. Please use "timeout connect", "timeout queue" or "timeout tarpit"
1088 instead.
1089
1090 See also : "timeout connect", "timeout queue", "timeout tarpit",
1091 "timeout server", "contimeout".
1092
1093
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02001094cookie <name> [ rewrite|insert|prefix ] [ indirect ] [ nocache ] [ postonly ] [domain <domain>]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001095 Enable cookie-based persistence in a backend.
1096 May be used in sections : defaults | frontend | listen | backend
1097 yes | no | yes | yes
1098 Arguments :
1099 <name> is the name of the cookie which will be monitored, modified or
1100 inserted in order to bring persistence. This cookie is sent to
1101 the client via a "Set-Cookie" header in the response, and is
1102 brought back by the client in a "Cookie" header in all requests.
1103 Special care should be taken to choose a name which does not
1104 conflict with any likely application cookie. Also, if the same
1105 backends are subject to be used by the same clients (eg:
1106 HTTP/HTTPS), care should be taken to use different cookie names
1107 between all backends if persistence between them is not desired.
1108
1109 rewrite This keyword indicates that the cookie will be provided by the
1110 server and that haproxy will have to modify its value to set the
1111 server's identifier in it. This mode is handy when the management
1112 of complex combinations of "Set-cookie" and "Cache-control"
1113 headers is left to the application. The application can then
1114 decide whether or not it is appropriate to emit a persistence
1115 cookie. Since all responses should be monitored, this mode only
1116 works in HTTP close mode. Unless the application behaviour is
1117 very complex and/or broken, it is advised not to start with this
1118 mode for new deployments. This keyword is incompatible with
1119 "insert" and "prefix".
1120
1121 insert This keyword indicates that the persistence cookie will have to
1122 be inserted by haproxy in the responses. If the server emits a
1123 cookie with the same name, it will be replaced anyway. For this
1124 reason, this mode can be used to upgrade existing configurations
1125 running in the "rewrite" mode. The cookie will only be a session
1126 cookie and will not be stored on the client's disk. Due to
1127 caching effects, it is generally wise to add the "indirect" and
1128 "nocache" or "postonly" keywords (see below). The "insert"
1129 keyword is not compatible with "rewrite" and "prefix".
1130
1131 prefix This keyword indicates that instead of relying on a dedicated
1132 cookie for the persistence, an existing one will be completed.
1133 This may be needed in some specific environments where the client
1134 does not support more than one single cookie and the application
1135 already needs it. In this case, whenever the server sets a cookie
1136 named <name>, it will be prefixed with the server's identifier
1137 and a delimiter. The prefix will be removed from all client
1138 requests so that the server still finds the cookie it emitted.
1139 Since all requests and responses are subject to being modified,
1140 this mode requires the HTTP close mode. The "prefix" keyword is
1141 not compatible with "rewrite" and "insert".
1142
1143 indirect When this option is specified in insert mode, cookies will only
1144 be added when the server was not reached after a direct access,
1145 which means that only when a server is elected after applying a
1146 load-balancing algorithm, or after a redispatch, then the cookie
1147 will be inserted. If the client has all the required information
1148 to connect to the same server next time, no further cookie will
1149 be inserted. In all cases, when the "indirect" option is used in
1150 insert mode, the cookie is always removed from the requests
1151 transmitted to the server. The persistence mechanism then becomes
1152 totally transparent from the application point of view.
1153
1154 nocache This option is recommended in conjunction with the insert mode
1155 when there is a cache between the client and HAProxy, as it
1156 ensures that a cacheable response will be tagged non-cacheable if
1157 a cookie needs to be inserted. This is important because if all
1158 persistence cookies are added on a cacheable home page for
1159 instance, then all customers will then fetch the page from an
1160 outer cache and will all share the same persistence cookie,
1161 leading to one server receiving much more traffic than others.
1162 See also the "insert" and "postonly" options.
1163
1164 postonly This option ensures that cookie insertion will only be performed
1165 on responses to POST requests. It is an alternative to the
1166 "nocache" option, because POST responses are not cacheable, so
1167 this ensures that the persistence cookie will never get cached.
1168 Since most sites do not need any sort of persistence before the
1169 first POST which generally is a login request, this is a very
1170 efficient method to optimize caching without risking to find a
1171 persistence cookie in the cache.
1172 See also the "insert" and "nocache" options.
1173
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02001174 domain This option allows to specify the domain at which a cookie is
1175 inserted. It requires exactly one paramater: a valid domain
1176 name.
1177
Willy Tarreau0ba27502007-12-24 16:55:16 +01001178 There can be only one persistence cookie per HTTP backend, and it can be
1179 declared in a defaults section. The value of the cookie will be the value
1180 indicated after the "cookie" keyword in a "server" statement. If no cookie
1181 is declared for a given server, the cookie is not set.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001182
Willy Tarreau0ba27502007-12-24 16:55:16 +01001183 Examples :
1184 cookie JSESSIONID prefix
1185 cookie SRV insert indirect nocache
1186 cookie SRV insert postonly indirect
1187
1188 See also : "appsession", "balance source", "capture cookie", "server".
1189
1190
1191default_backend <backend>
1192 Specify the backend to use when no "use_backend" rule has been matched.
1193 May be used in sections : defaults | frontend | listen | backend
1194 yes | yes | yes | no
1195 Arguments :
1196 <backend> is the name of the backend to use.
1197
1198 When doing content-switching between frontend and backends using the
1199 "use_backend" keyword, it is often useful to indicate which backend will be
1200 used when no rule has matched. It generally is the dynamic backend which
1201 will catch all undetermined requests.
1202
1203 The "default_backend" keyword is also supported in TCP mode frontends to
1204 facilitate the ordering of configurations in frontends and backends,
1205 eventhough it does not make much more sense in case of TCP due to the fact
1206 that use_backend currently does not work in TCP mode.
1207
1208 Example :
1209
1210 use_backend dynamic if url_dyn
1211 use_backend static if url_css url_img extension_img
1212 default_backend dynamic
1213
Willy Tarreau2769aa02007-12-27 18:26:09 +01001214 See also : "use_backend", "reqsetbe", "reqisetbe"
1215
Willy Tarreau0ba27502007-12-24 16:55:16 +01001216
1217disabled
1218 Disable a proxy, frontend or backend.
1219 May be used in sections : defaults | frontend | listen | backend
1220 yes | yes | yes | yes
1221 Arguments : none
1222
1223 The "disabled" keyword is used to disable an instance, mainly in order to
1224 liberate a listening port or to temporarily disable a service. The instance
1225 will still be created and its configuration will be checked, but it will be
1226 created in the "stopped" state and will appear as such in the statistics. It
1227 will not receive any traffic nor will it send any health-checks or logs. It
1228 is possible to disable many instances at once by adding the "disabled"
1229 keyword in a "defaults" section.
1230
1231 See also : "enabled"
1232
1233
1234enabled
1235 Enable a proxy, frontend or backend.
1236 May be used in sections : defaults | frontend | listen | backend
1237 yes | yes | yes | yes
1238 Arguments : none
1239
1240 The "enabled" keyword is used to explicitly enable an instance, when the
1241 defaults has been set to "disabled". This is very rarely used.
1242
1243 See also : "disabled"
1244
1245
1246errorfile <code> <file>
1247 Return a file contents instead of errors generated by HAProxy
1248 May be used in sections : defaults | frontend | listen | backend
1249 yes | yes | yes | yes
1250 Arguments :
1251 <code> is the HTTP status code. Currently, HAProxy is capable of
1252 generating codes 400, 403, 408, 500, 502, 503, and 504.
1253
1254 <file> designates a file containing the full HTTP response. It is
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001255 recommended to follow the common practice of appending ".http" to
Willy Tarreau0ba27502007-12-24 16:55:16 +01001256 the filename so that people do not confuse the response with HTML
1257 error pages.
1258
1259 It is important to understand that this keyword is not meant to rewrite
1260 errors returned by the server, but errors detected and returned by HAProxy.
1261 This is why the list of supported errors is limited to a small set.
1262
1263 The files are returned verbatim on the TCP socket. This allows any trick such
1264 as redirections to another URL or site, as well as tricks to clean cookies,
1265 force enable or disable caching, etc... The package provides default error
1266 files returning the same contents as default errors.
1267
1268 The files are read at the same time as the configuration and kept in memory.
1269 For this reason, the errors continue to be returned even when the process is
1270 chrooted, and no file change is considered while the process is running. A
Willy Tarreauc27debf2008-01-06 08:57:02 +01001271 simple method for developing those files consists in associating them to the
Willy Tarreau0ba27502007-12-24 16:55:16 +01001272 403 status code and interrogating a blocked URL.
1273
1274 See also : "errorloc", "errorloc302", "errorloc303"
1275
Willy Tarreau2769aa02007-12-27 18:26:09 +01001276
1277errorloc <code> <url>
1278errorloc302 <code> <url>
1279 Return an HTTP redirection to a URL instead of errors generated by HAProxy
1280 May be used in sections : defaults | frontend | listen | backend
1281 yes | yes | yes | yes
1282 Arguments :
1283 <code> is the HTTP status code. Currently, HAProxy is capable of
1284 generating codes 400, 403, 408, 500, 502, 503, and 504.
1285
1286 <url> it is the exact contents of the "Location" header. It may contain
1287 either a relative URI to an error page hosted on the same site,
1288 or an absolute URI designating an error page on another site.
1289 Special care should be given to relative URIs to avoid redirect
1290 loops if the URI itself may generate the same error (eg: 500).
1291
1292 It is important to understand that this keyword is not meant to rewrite
1293 errors returned by the server, but errors detected and returned by HAProxy.
1294 This is why the list of supported errors is limited to a small set.
1295
1296 Note that both keyword return the HTTP 302 status code, which tells the
1297 client to fetch the designated URL using the same HTTP method. This can be
1298 quite problematic in case of non-GET methods such as POST, because the URL
1299 sent to the client might not be allowed for something other than GET. To
1300 workaround this problem, please use "errorloc303" which send the HTTP 303
1301 status code, indicating to the client that the URL must be fetched with a GET
1302 request.
1303
1304 See also : "errorfile", "errorloc303"
1305
1306
1307errorloc303 <code> <url>
1308 Return an HTTP redirection to a URL instead of errors generated by HAProxy
1309 May be used in sections : defaults | frontend | listen | backend
1310 yes | yes | yes | yes
1311 Arguments :
1312 <code> is the HTTP status code. Currently, HAProxy is capable of
1313 generating codes 400, 403, 408, 500, 502, 503, and 504.
1314
1315 <url> it is the exact contents of the "Location" header. It may contain
1316 either a relative URI to an error page hosted on the same site,
1317 or an absolute URI designating an error page on another site.
1318 Special care should be given to relative URIs to avoid redirect
1319 loops if the URI itself may generate the same error (eg: 500).
1320
1321 It is important to understand that this keyword is not meant to rewrite
1322 errors returned by the server, but errors detected and returned by HAProxy.
1323 This is why the list of supported errors is limited to a small set.
1324
1325 Note that both keyword return the HTTP 303 status code, which tells the
1326 client to fetch the designated URL using the same HTTP GET method. This
1327 solves the usual problems associated with "errorloc" and the 302 code. It is
1328 possible that some very old browsers designed before HTTP/1.1 do not support
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001329 it, but no such problem has been reported till now.
Willy Tarreau2769aa02007-12-27 18:26:09 +01001330
1331 See also : "errorfile", "errorloc", "errorloc302"
1332
1333
1334fullconn <conns>
1335 Specify at what backend load the servers will reach their maxconn
1336 May be used in sections : defaults | frontend | listen | backend
1337 yes | no | yes | yes
1338 Arguments :
1339 <conns> is the number of connections on the backend which will make the
1340 servers use the maximal number of connections.
1341
Willy Tarreau198a7442008-01-17 12:05:32 +01001342 When a server has a "maxconn" parameter specified, it means that its number
Willy Tarreau2769aa02007-12-27 18:26:09 +01001343 of concurrent connections will never go higher. Additionally, if it has a
Willy Tarreau198a7442008-01-17 12:05:32 +01001344 "minconn" parameter, it indicates a dynamic limit following the backend's
Willy Tarreau2769aa02007-12-27 18:26:09 +01001345 load. The server will then always accept at least <minconn> connections,
1346 never more than <maxconn>, and the limit will be on the ramp between both
1347 values when the backend has less than <conns> concurrent connections. This
1348 makes it possible to limit the load on the servers during normal loads, but
1349 push it further for important loads without overloading the servers during
1350 exceptionnal loads.
1351
1352 Example :
1353 # The servers will accept between 100 and 1000 concurrent connections each
1354 # and the maximum of 1000 will be reached when the backend reaches 10000
1355 # connections.
1356 backend dynamic
1357 fullconn 10000
1358 server srv1 dyn1:80 minconn 100 maxconn 1000
1359 server srv2 dyn2:80 minconn 100 maxconn 1000
1360
1361 See also : "maxconn", "server"
1362
1363
1364grace <time>
1365 Maintain a proxy operational for some time after a soft stop
1366 May be used in sections : defaults | frontend | listen | backend
1367 no | yes | yes | yes
1368 Arguments :
1369 <time> is the time (by default in milliseconds) for which the instance
1370 will remain operational with the frontend sockets still listening
1371 when a soft-stop is received via the SIGUSR1 signal.
1372
1373 This may be used to ensure that the services disappear in a certain order.
1374 This was designed so that frontends which are dedicated to monitoring by an
1375 external equipement fail immediately while other ones remain up for the time
1376 needed by the equipment to detect the failure.
1377
1378 Note that currently, there is very little benefit in using this parameter,
1379 and it may in fact complicate the soft-reconfiguration process more than
1380 simplify it.
1381
Willy Tarreau0ba27502007-12-24 16:55:16 +01001382
1383http-check disable-on-404
1384 Enable a maintenance mode upon HTTP/404 response to health-checks
1385 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau2769aa02007-12-27 18:26:09 +01001386 yes | no | yes | yes
Willy Tarreau0ba27502007-12-24 16:55:16 +01001387 Arguments : none
1388
1389 When this option is set, a server which returns an HTTP code 404 will be
1390 excluded from further load-balancing, but will still receive persistent
1391 connections. This provides a very convenient method for Web administrators
1392 to perform a graceful shutdown of their servers. It is also important to note
1393 that a server which is detected as failed while it was in this mode will not
1394 generate an alert, just a notice. If the server responds 2xx or 3xx again, it
1395 will immediately be reinserted into the farm. The status on the stats page
1396 reports "NOLB" for a server in this mode. It is important to note that this
1397 option only works in conjunction with the "httpchk" option.
1398
Willy Tarreau2769aa02007-12-27 18:26:09 +01001399 See also : "option httpchk"
1400
1401
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01001402id <value>
1403 Set a persistent value for proxy ID. Must be unique and larger than 1000, as
1404 smaller values are reserved for auto-assigned ids.
1405
1406
Willy Tarreau2769aa02007-12-27 18:26:09 +01001407log global
1408log <address> <facility> [<level>]
1409 Enable per-instance logging of events and traffic.
1410 May be used in sections : defaults | frontend | listen | backend
1411 yes | yes | yes | yes
1412 Arguments :
1413 global should be used when the instance's logging parameters are the
1414 same as the global ones. This is the most common usage. "global"
1415 replaces <address>, <facility> and <level> with those of the log
1416 entries found in the "global" section. Only one "log global"
1417 statement may be used per instance, and this form takes no other
1418 parameter.
1419
1420 <address> indicates where to send the logs. It takes the same format as
1421 for the "global" section's logs, and can be one of :
1422
1423 - An IPv4 address optionally followed by a colon (':') and a UDP
1424 port. If no port is specified, 514 is used by default (the
1425 standard syslog port).
1426
1427 - A filesystem path to a UNIX domain socket, keeping in mind
1428 considerations for chroot (be sure the path is accessible
1429 inside the chroot) and uid/gid (be sure the path is
1430 appropriately writeable).
1431
1432 <facility> must be one of the 24 standard syslog facilities :
1433
1434 kern user mail daemon auth syslog lpr news
1435 uucp cron auth2 ftp ntp audit alert cron2
1436 local0 local1 local2 local3 local4 local5 local6 local7
1437
1438 <level> is optional and can be specified to filter outgoing messages. By
1439 default, all messages are sent. If a level is specified, only
1440 messages with a severity at least as important as this level
1441 will be sent. 8 levels are known :
1442
1443 emerg alert crit err warning notice info debug
1444
1445 Note that up to two "log" entries may be specified per instance. However, if
1446 "log global" is used and if the "global" section already contains 2 log
1447 entries, then additional log entries will be ignored.
1448
1449 Also, it is important to keep in mind that it is the frontend which decides
1450 what to log, and that in case of content switching, the log entries from the
1451 backend will be ignored.
1452
1453 Example :
1454 log global
1455 log 127.0.0.1:514 local0 notice
1456
1457
1458maxconn <conns>
1459 Fix the maximum number of concurrent connections on a frontend
1460 May be used in sections : defaults | frontend | listen | backend
1461 yes | yes | yes | no
1462 Arguments :
1463 <conns> is the maximum number of concurrent connections the frontend will
1464 accept to serve. Excess connections will be queued by the system
1465 in the socket's listen queue and will be served once a connection
1466 closes.
1467
1468 If the system supports it, it can be useful on big sites to raise this limit
1469 very high so that haproxy manages connection queues, instead of leaving the
1470 clients with unanswered connection attempts. This value should not exceed the
1471 global maxconn. Also, keep in mind that a connection contains two buffers
1472 of 8kB each, as well as some other data resulting in about 17 kB of RAM being
1473 consumed per established connection. That means that a medium system equipped
1474 with 1GB of RAM can withstand around 40000-50000 concurrent connections if
1475 properly tuned.
1476
1477 Also, when <conns> is set to large values, it is possible that the servers
1478 are not sized to accept such loads, and for this reason it is generally wise
1479 to assign them some reasonable connection limits.
1480
1481 See also : "server", global section's "maxconn", "fullconn"
1482
1483
1484mode { tcp|http|health }
1485 Set the running mode or protocol of the instance
1486 May be used in sections : defaults | frontend | listen | backend
1487 yes | yes | yes | yes
1488 Arguments :
1489 tcp The instance will work in pure TCP mode. A full-duplex connection
1490 will be established between clients and servers, and no layer 7
1491 examination will be performed. This is the default mode. It
1492 should be used for SSL, SSH, SMTP, ...
1493
1494 http The instance will work in HTTP mode. The client request will be
1495 analyzed in depth before connecting to any server. Any request
1496 which is not RFC-compliant will be rejected. Layer 7 filtering,
1497 processing and switching will be possible. This is the mode which
1498 brings HAProxy most of its value.
1499
1500 health The instance will work in "health" mode. It will just reply "OK"
1501 to incoming connections and close the connection. Nothing will be
1502 logged. This mode is used to reply to external components health
1503 checks. This mode is deprecated and should not be used anymore as
1504 it is possible to do the same and even better by combining TCP or
1505 HTTP modes with the "monitor" keyword.
1506
1507 When doing content switching, it is mandatory that the frontend and the
1508 backend are in the same mode (generally HTTP), otherwise the configuration
1509 will be refused.
1510
1511 Example :
1512 defaults http_instances
1513 mode http
1514
1515 See also : "monitor", "monitor-net"
1516
Willy Tarreau0ba27502007-12-24 16:55:16 +01001517
1518monitor fail [if | unless] <condition>
Willy Tarreau2769aa02007-12-27 18:26:09 +01001519 Add a condition to report a failure to a monitor HTTP request.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001520 May be used in sections : defaults | frontend | listen | backend
1521 no | yes | yes | no
Willy Tarreau0ba27502007-12-24 16:55:16 +01001522 Arguments :
1523 if <cond> the monitor request will fail if the condition is satisfied,
1524 and will succeed otherwise. The condition should describe a
1525 combinated test which must induce a failure if all conditions
1526 are met, for instance a low number of servers both in a
1527 backend and its backup.
1528
1529 unless <cond> the monitor request will succeed only if the condition is
1530 satisfied, and will fail otherwise. Such a condition may be
1531 based on a test on the presence of a minimum number of active
1532 servers in a list of backends.
1533
1534 This statement adds a condition which can force the response to a monitor
1535 request to report a failure. By default, when an external component queries
1536 the URI dedicated to monitoring, a 200 response is returned. When one of the
1537 conditions above is met, haproxy will return 503 instead of 200. This is
1538 very useful to report a site failure to an external component which may base
1539 routing advertisements between multiple sites on the availability reported by
1540 haproxy. In this case, one would rely on an ACL involving the "nbsrv"
Willy Tarreau2769aa02007-12-27 18:26:09 +01001541 criterion. Note that "monitor fail" only works in HTTP mode.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001542
1543 Example:
1544 frontend www
Willy Tarreau2769aa02007-12-27 18:26:09 +01001545 mode http
Willy Tarreau0ba27502007-12-24 16:55:16 +01001546 acl site_dead nbsrv(dynamic) lt 2
1547 acl site_dead nbsrv(static) lt 2
1548 monitor-uri /site_alive
1549 monitor fail if site_dead
1550
Willy Tarreau2769aa02007-12-27 18:26:09 +01001551 See also : "monitor-net", "monitor-uri"
1552
1553
1554monitor-net <source>
1555 Declare a source network which is limited to monitor requests
1556 May be used in sections : defaults | frontend | listen | backend
1557 yes | yes | yes | no
1558 Arguments :
1559 <source> is the source IPv4 address or network which will only be able to
1560 get monitor responses to any request. It can be either an IPv4
1561 address, a host name, or an address followed by a slash ('/')
1562 followed by a mask.
1563
1564 In TCP mode, any connection coming from a source matching <source> will cause
1565 the connection to be immediately closed without any log. This allows another
1566 equipement to probe the port and verify that it is still listening, without
1567 forwarding the connection to a remote server.
1568
1569 In HTTP mode, a connection coming from a source matching <source> will be
1570 accepted, the following response will be sent without waiting for a request,
1571 then the connection will be closed : "HTTP/1.0 200 OK". This is normally
1572 enough for any front-end HTTP probe to detect that the service is UP and
1573 running without forwarding the request to a backend server.
1574
1575 Monitor requests are processed very early. It is not possible to block nor
1576 divert them using ACLs. They cannot be logged either, and it is the intended
1577 purpose. They are only used to report HAProxy's health to an upper component,
1578 nothing more. Right now, it is not possible to set failure conditions on
1579 requests caught by "monitor-net".
1580
1581 Example :
1582 # addresses .252 and .253 are just probing us.
1583 frontend www
1584 monitor-net 192.168.0.252/31
1585
1586 See also : "monitor fail", "monitor-uri"
1587
1588
1589monitor-uri <uri>
1590 Intercept a URI used by external components' monitor requests
1591 May be used in sections : defaults | frontend | listen | backend
1592 yes | yes | yes | no
1593 Arguments :
1594 <uri> is the exact URI which we want to intercept to return HAProxy's
1595 health status instead of forwarding the request.
1596
1597 When an HTTP request referencing <uri> will be received on a frontend,
1598 HAProxy will not forward it nor log it, but instead will return either
1599 "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure
1600 conditions defined with "monitor fail". This is normally enough for any
1601 front-end HTTP probe to detect that the service is UP and running without
1602 forwarding the request to a backend server. Note that the HTTP method, the
1603 version and all headers are ignored, but the request must at least be valid
1604 at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
1605
1606 Monitor requests are processed very early. It is not possible to block nor
1607 divert them using ACLs. They cannot be logged either, and it is the intended
1608 purpose. They are only used to report HAProxy's health to an upper component,
1609 nothing more. However, it is possible to add any number of conditions using
1610 "monitor fail" and ACLs so that the result can be adjusted to whatever check
1611 can be imagined (most often the number of available servers in a backend).
1612
1613 Example :
1614 # Use /haproxy_test to report haproxy's status
1615 frontend www
1616 mode http
1617 monitor-uri /haproxy_test
1618
1619 See also : "monitor fail", "monitor-net"
1620
Willy Tarreau0ba27502007-12-24 16:55:16 +01001621
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001622option abortonclose
1623no option abortonclose
1624 Enable or disable early dropping of aborted requests pending in queues.
1625 May be used in sections : defaults | frontend | listen | backend
1626 yes | no | yes | yes
1627 Arguments : none
1628
1629 In presence of very high loads, the servers will take some time to respond.
1630 The per-instance connection queue will inflate, and the response time will
1631 increase respective to the size of the queue times the average per-session
1632 response time. When clients will wait for more than a few seconds, they will
Willy Tarreau198a7442008-01-17 12:05:32 +01001633 often hit the "STOP" button on their browser, leaving a useless request in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001634 the queue, and slowing down other users, and the servers as well, because the
1635 request will eventually be served, then aborted at the first error
1636 encountered while delivering the response.
1637
1638 As there is no way to distinguish between a full STOP and a simple output
1639 close on the client side, HTTP agents should be conservative and consider
1640 that the client might only have closed its output channel while waiting for
1641 the response. However, this introduces risks of congestion when lots of users
1642 do the same, and is completely useless nowadays because probably no client at
1643 all will close the session while waiting for the response. Some HTTP agents
1644 support this behaviour (Squid, Apache, HAProxy), and others do not (TUX, most
1645 hardware-based load balancers). So the probability for a closed input channel
Willy Tarreau198a7442008-01-17 12:05:32 +01001646 to represent a user hitting the "STOP" button is close to 100%, and the risk
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001647 of being the single component to break rare but valid traffic is extremely
1648 low, which adds to the temptation to be able to abort a session early while
1649 still not served and not pollute the servers.
1650
1651 In HAProxy, the user can choose the desired behaviour using the option
1652 "abortonclose". By default (without the option) the behaviour is HTTP
1653 compliant and aborted requests will be served. But when the option is
1654 specified, a session with an incoming channel closed will be aborted while
1655 it is still possible, either pending in the queue for a connection slot, or
1656 during the connection establishment if the server has not yet acknowledged
1657 the connection request. This considerably reduces the queue size and the load
1658 on saturated servers when users are tempted to click on STOP, which in turn
1659 reduces the response time for other users.
1660
1661 If this option has been enabled in a "defaults" section, it can be disabled
1662 in a specific instance by prepending the "no" keyword before it.
1663
1664 See also : "timeout queue" and server's "maxconn" and "maxqueue" parameters
1665
1666
1667option allbackups
1668no option allbackups
1669 Use either all backup servers at a time or only the first one
1670 May be used in sections : defaults | frontend | listen | backend
1671 yes | no | yes | yes
1672 Arguments : none
1673
1674 By default, the first operational backup server gets all traffic when normal
1675 servers are all down. Sometimes, it may be preferred to use multiple backups
1676 at once, because one will not be enough. When "option allbackups" is enabled,
1677 the load balancing will be performed among all backup servers when all normal
1678 ones are unavailable. The same load balancing algorithm will be used and the
1679 servers' weights will be respected. Thus, there will not be any priority
1680 order between the backup servers anymore.
1681
1682 This option is mostly used with static server farms dedicated to return a
1683 "sorry" page when an application is completely offline.
1684
1685 If this option has been enabled in a "defaults" section, it can be disabled
1686 in a specific instance by prepending the "no" keyword before it.
1687
1688
1689option checkcache
1690no option checkcache
1691 Analyze all server responses and block requests with cachable cookies
1692 May be used in sections : defaults | frontend | listen | backend
1693 yes | no | yes | yes
1694 Arguments : none
1695
1696 Some high-level frameworks set application cookies everywhere and do not
1697 always let enough control to the developer to manage how the responses should
1698 be cached. When a session cookie is returned on a cachable object, there is a
1699 high risk of session crossing or stealing between users traversing the same
1700 caches. In some situations, it is better to block the response than to let
1701 some sensible session information go in the wild.
1702
1703 The option "checkcache" enables deep inspection of all server responses for
1704 strict compliance with HTTP specification in terms of cachability. It
Willy Tarreau198a7442008-01-17 12:05:32 +01001705 carefully checks "Cache-control", "Pragma" and "Set-cookie" headers in server
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001706 response to check if there's a risk of caching a cookie on a client-side
1707 proxy. When this option is enabled, the only responses which can be delivered
Willy Tarreau198a7442008-01-17 12:05:32 +01001708 to the client are :
1709 - all those without "Set-Cookie" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001710 - all those with a return code other than 200, 203, 206, 300, 301, 410,
Willy Tarreau198a7442008-01-17 12:05:32 +01001711 provided that the server has not set a "Cache-control: public" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001712 - all those that come from a POST request, provided that the server has not
1713 set a 'Cache-Control: public' header ;
1714 - those with a 'Pragma: no-cache' header
1715 - those with a 'Cache-control: private' header
1716 - those with a 'Cache-control: no-store' header
1717 - those with a 'Cache-control: max-age=0' header
1718 - those with a 'Cache-control: s-maxage=0' header
1719 - those with a 'Cache-control: no-cache' header
1720 - those with a 'Cache-control: no-cache="set-cookie"' header
1721 - those with a 'Cache-control: no-cache="set-cookie,' header
1722 (allowing other fields after set-cookie)
1723
1724 If a response doesn't respect these requirements, then it will be blocked
Willy Tarreau198a7442008-01-17 12:05:32 +01001725 just as if it was from an "rspdeny" filter, with an "HTTP 502 bad gateway".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001726 The session state shows "PH--" meaning that the proxy blocked the response
1727 during headers processing. Additionnaly, an alert will be sent in the logs so
1728 that admins are informed that there's something to be fixed.
1729
1730 Due to the high impact on the application, the application should be tested
1731 in depth with the option enabled before going to production. It is also a
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001732 good practice to always activate it during tests, even if it is not used in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001733 production, as it will report potentially dangerous application behaviours.
1734
1735 If this option has been enabled in a "defaults" section, it can be disabled
1736 in a specific instance by prepending the "no" keyword before it.
1737
1738
1739option clitcpka
1740no option clitcpka
1741 Enable or disable the sending of TCP keepalive packets on the client side
1742 May be used in sections : defaults | frontend | listen | backend
1743 yes | yes | yes | no
1744 Arguments : none
1745
1746 When there is a firewall or any session-aware component between a client and
1747 a server, and when the protocol involves very long sessions with long idle
1748 periods (eg: remote desktops), there is a risk that one of the intermediate
1749 components decides to expire a session which has remained idle for too long.
1750
1751 Enabling socket-level TCP keep-alives makes the system regularly send packets
1752 to the other end of the connection, leaving it active. The delay between
1753 keep-alive probes is controlled by the system only and depends both on the
1754 operating system and its tuning parameters.
1755
1756 It is important to understand that keep-alive packets are neither emitted nor
1757 received at the application level. It is only the network stacks which sees
1758 them. For this reason, even if one side of the proxy already uses keep-alives
1759 to maintain its connection alive, those keep-alive packets will not be
1760 forwarded to the other side of the proxy.
1761
1762 Please note that this has nothing to do with HTTP keep-alive.
1763
1764 Using option "clitcpka" enables the emission of TCP keep-alive probes on the
1765 client side of a connection, which should help when session expirations are
1766 noticed between HAProxy and a client.
1767
1768 If this option has been enabled in a "defaults" section, it can be disabled
1769 in a specific instance by prepending the "no" keyword before it.
1770
1771 See also : "option srvtcpka", "option tcpka"
1772
1773
Willy Tarreau0ba27502007-12-24 16:55:16 +01001774option contstats
1775 Enable continuous traffic statistics updates
1776 May be used in sections : defaults | frontend | listen | backend
1777 yes | yes | yes | no
1778 Arguments : none
1779
1780 By default, counters used for statistics calculation are incremented
1781 only when a session finishes. It works quite well when serving small
1782 objects, but with big ones (for example large images or archives) or
1783 with A/V streaming, a graph generated from haproxy counters looks like
1784 a hedgehog. With this option enabled counters get incremented continuously,
1785 during a whole session. Recounting touches a hotpath directly so
1786 it is not enabled by default, as it has small performance impact (~0.5%).
1787
1788
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001789option dontlognull
1790no option dontlognull
1791 Enable or disable logging of null connections
1792 May be used in sections : defaults | frontend | listen | backend
1793 yes | yes | yes | no
1794 Arguments : none
1795
1796 In certain environments, there are components which will regularly connect to
1797 various systems to ensure that they are still alive. It can be the case from
1798 another load balancer as well as from monitoring systems. By default, even a
1799 simple port probe or scan will produce a log. If those connections pollute
1800 the logs too much, it is possible to enable option "dontlognull" to indicate
1801 that a connection on which no data has been transferred will not be logged,
1802 which typically corresponds to those probes.
1803
1804 It is generally recommended not to use this option in uncontrolled
1805 environments (eg: internet), otherwise scans and other malicious activities
1806 would not be logged.
1807
1808 If this option has been enabled in a "defaults" section, it can be disabled
1809 in a specific instance by prepending the "no" keyword before it.
1810
Willy Tarreauced27012008-01-17 20:35:34 +01001811 See also : "log", "monitor-net", "monitor-uri" and section 2.6 about logging.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001812
1813
1814option forceclose
1815no option forceclose
1816 Enable or disable active connection closing after response is transferred.
1817 May be used in sections : defaults | frontend | listen | backend
1818 yes | no | yes | yes
1819 Arguments : none
1820
1821 Some HTTP servers do not necessarily close the connections when they receive
1822 the "Connection: close" set by "option httpclose", and if the client does not
1823 close either, then the connection remains open till the timeout expires. This
1824 causes high number of simultaneous connections on the servers and shows high
1825 global session times in the logs.
1826
1827 When this happens, it is possible to use "option forceclose". It will
1828 actively close the outgoing server channel as soon as the server begins to
1829 reply and only if the request buffer is empty. Note that this should NOT be
1830 used if CONNECT requests are expected between the client and the server. This
1831 option implicitly enables the "httpclose" option.
1832
1833 If this option has been enabled in a "defaults" section, it can be disabled
1834 in a specific instance by prepending the "no" keyword before it.
1835
1836 See also : "option httpclose"
1837
1838
Ross Westaf72a1d2008-08-03 10:51:45 +02001839option forwardfor [ except <network> ] [ header <name> ]
Willy Tarreauc27debf2008-01-06 08:57:02 +01001840 Enable insertion of the X-Forwarded-For header to requests sent to servers
1841 May be used in sections : defaults | frontend | listen | backend
1842 yes | yes | yes | yes
1843 Arguments :
1844 <network> is an optional argument used to disable this option for sources
1845 matching <network>
Ross Westaf72a1d2008-08-03 10:51:45 +02001846 <name> an optional argument to specify a different "X-Forwarded-For"
1847 header name.
Willy Tarreauc27debf2008-01-06 08:57:02 +01001848
1849 Since HAProxy works in reverse-proxy mode, the servers see its IP address as
1850 their client address. This is sometimes annoying when the client's IP address
1851 is expected in server logs. To solve this problem, the well-known HTTP header
1852 "X-Forwarded-For" may be added by HAProxy to all requests sent to the server.
1853 This header contains a value representing the client's IP address. Since this
1854 header is always appended at the end of the existing header list, the server
1855 must be configured to always use the last occurrence of this header only. See
Ross Westaf72a1d2008-08-03 10:51:45 +02001856 the server's manual to find how to enable use of this standard header. Note
1857 that only the last occurrence of the header must be used, since it is really
1858 possible that the client has already brought one.
1859
1860 The keyword "header" may be used to supply a different header name to replace
1861 the default "X-Forwarded-For". This can be useful where you might already
1862 have a "X-Forwarded-For" header from a different application (eg: stunnel),
1863 and you need preserve it. Also if your backend server doesn't use the
1864 "X-Forwarded-For" header and requires different one (eg: Zeus Web Servers
1865 require "X-Cluster-Client-IP").
Willy Tarreauc27debf2008-01-06 08:57:02 +01001866
1867 Sometimes, a same HAProxy instance may be shared between a direct client
1868 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
1869 used to decrypt HTTPS traffic). It is possible to disable the addition of the
1870 header for a known source address or network by adding the "except" keyword
1871 followed by the network address. In this case, any source IP matching the
1872 network will not cause an addition of this header. Most common uses are with
1873 private networks or 127.0.0.1.
1874
1875 This option may be specified either in the frontend or in the backend. If at
Ross Westaf72a1d2008-08-03 10:51:45 +02001876 least one of them uses it, the header will be added. Note that the backend's
1877 setting of the header subargument takes precedence over the frontend's if
1878 both are defined.
Willy Tarreauc27debf2008-01-06 08:57:02 +01001879
1880 It is important to note that as long as HAProxy does not support keep-alive
1881 connections, only the first request of a connection will receive the header.
1882 For this reason, it is important to ensure that "option httpclose" is set
1883 when using this option.
1884
Ross Westaf72a1d2008-08-03 10:51:45 +02001885 Examples :
Willy Tarreauc27debf2008-01-06 08:57:02 +01001886 # Public HTTP address also used by stunnel on the same machine
1887 frontend www
1888 mode http
1889 option forwardfor except 127.0.0.1 # stunnel already adds the header
1890
Ross Westaf72a1d2008-08-03 10:51:45 +02001891 # Those servers want the IP Address in X-Client
1892 backend www
1893 mode http
1894 option forwardfor header X-Client
1895
Willy Tarreauc27debf2008-01-06 08:57:02 +01001896 See also : "option httpclose"
1897
1898
1899option http_proxy
1900no option http_proxy
1901 Enable or disable plain HTTP proxy mode
1902 May be used in sections : defaults | frontend | listen | backend
1903 yes | yes | yes | yes
1904 Arguments : none
1905
1906 It sometimes happens that people need a pure HTTP proxy which understands
1907 basic proxy requests without caching nor any fancy feature. In this case,
1908 it may be worth setting up an HAProxy instance with the "option http_proxy"
1909 set. In this mode, no server is declared, and the connection is forwarded to
1910 the IP address and port found in the URL after the "http://" scheme.
1911
1912 No host address resolution is performed, so this only works when pure IP
1913 addresses are passed. Since this option's usage perimeter is rather limited,
1914 it will probably be used only by experts who know they need exactly it. Last,
1915 if the clients are susceptible of sending keep-alive requests, it will be
1916 needed to add "option http_close" to ensure that all requests will correctly
1917 be analyzed.
1918
1919 If this option has been enabled in a "defaults" section, it can be disabled
1920 in a specific instance by prepending the "no" keyword before it.
1921
1922 Example :
1923 # this backend understands HTTP proxy requests and forwards them directly.
1924 backend direct_forward
1925 option httpclose
1926 option http_proxy
1927
1928 See also : "option httpclose"
1929
1930
1931option httpchk
1932option httpchk <uri>
1933option httpchk <method> <uri>
1934option httpchk <method> <uri> <version>
1935 Enable HTTP protocol to check on the servers health
1936 May be used in sections : defaults | frontend | listen | backend
1937 yes | no | yes | yes
1938 Arguments :
1939 <method> is the optional HTTP method used with the requests. When not set,
1940 the "OPTIONS" method is used, as it generally requires low server
1941 processing and is easy to filter out from the logs. Any method
1942 may be used, though it is not recommended to invent non-standard
1943 ones.
1944
1945 <uri> is the URI referenced in the HTTP requests. It defaults to " / "
1946 which is accessible by default on almost any server, but may be
1947 changed to any other URI. Query strings are permitted.
1948
1949 <version> is the optional HTTP version string. It defaults to "HTTP/1.0"
1950 but some servers might behave incorrectly in HTTP 1.0, so turning
1951 it to HTTP/1.1 may sometimes help. Note that the Host field is
1952 mandatory in HTTP/1.1, and as a trick, it is possible to pass it
1953 after "\r\n" following the version string.
1954
1955 By default, server health checks only consist in trying to establish a TCP
1956 connection. When "option httpchk" is specified, a complete HTTP request is
1957 sent once the TCP connection is established, and responses 2xx and 3xx are
1958 considered valid, while all other ones indicate a server failure, including
1959 the lack of any response.
1960
1961 The port and interval are specified in the server configuration.
1962
1963 This option does not necessarily require an HTTP backend, it also works with
1964 plain TCP backends. This is particularly useful to check simple scripts bound
1965 to some dedicated ports using the inetd daemon.
1966
1967 Examples :
1968 # Relay HTTPS traffic to Apache instance and check service availability
1969 # using HTTP request "OPTIONS * HTTP/1.1" on port 80.
1970 backend https_relay
1971 mode tcp
Willy Tarreauebaf21a2008-03-21 20:17:14 +01001972 option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
Willy Tarreauc27debf2008-01-06 08:57:02 +01001973 server apache1 192.168.1.1:443 check port 80
1974
1975 See also : "option ssl-hello-chk", "option smtpchk", "http-check" and the
1976 "check", "port" and "interval" server options.
1977
1978
1979option httpclose
1980no option httpclose
1981 Enable or disable passive HTTP connection closing
1982 May be used in sections : defaults | frontend | listen | backend
1983 yes | yes | yes | yes
1984 Arguments : none
1985
1986 As stated in section 2.1, HAProxy does not yes support the HTTP keep-alive
1987 mode. So by default, if a client communicates with a server in this mode, it
1988 will only analyze, log, and process the first request of each connection. To
1989 workaround this limitation, it is possible to specify "option httpclose". It
1990 will check if a "Connection: close" header is already set in each direction,
1991 and will add one if missing. Each end should react to this by actively
1992 closing the TCP connection after each transfer, thus resulting in a switch to
1993 the HTTP close mode. Any "Connection" header different from "close" will also
1994 be removed.
1995
1996 It seldom happens that some servers incorrectly ignore this header and do not
1997 close the connection eventough they reply "Connection: close". For this
1998 reason, they are not compatible with older HTTP 1.0 browsers. If this
1999 happens it is possible to use the "option forceclose" which actively closes
2000 the request connection once the server responds.
2001
2002 This option may be set both in a frontend and in a backend. It is enabled if
2003 at least one of the frontend or backend holding a connection has it enabled.
2004 If "option forceclose" is specified too, it has precedence over "httpclose".
2005
2006 If this option has been enabled in a "defaults" section, it can be disabled
2007 in a specific instance by prepending the "no" keyword before it.
2008
2009 See also : "option forceclose"
2010
2011
2012option httplog
2013 Enable logging of HTTP request, session state and timers
2014 May be used in sections : defaults | frontend | listen | backend
2015 yes | yes | yes | yes
2016 Arguments : none
2017
2018 By default, the log output format is very poor, as it only contains the
2019 source and destination addresses, and the instance name. By specifying
2020 "option httplog", each log line turns into a much richer format including,
2021 but not limited to, the HTTP request, the connection timers, the session
2022 status, the connections numbers, the captured headers and cookies, the
2023 frontend, backend and server name, and of course the source address and
2024 ports.
2025
2026 This option may be set either in the frontend or the backend.
2027
Willy Tarreauced27012008-01-17 20:35:34 +01002028 See also : section 2.6 about logging.
Willy Tarreauc27debf2008-01-06 08:57:02 +01002029
Willy Tarreauc27debf2008-01-06 08:57:02 +01002030
2031option logasap
2032no option logasap
2033 Enable or disable early logging of HTTP requests
2034 May be used in sections : defaults | frontend | listen | backend
2035 yes | yes | yes | no
2036 Arguments : none
2037
2038 By default, HTTP requests are logged upon termination so that the total
2039 transfer time and the number of bytes appear in the logs. When large objects
2040 are being transferred, it may take a while before the request appears in the
2041 logs. Using "option logasap", the request gets logged as soon as the server
2042 sends the complete headers. The only missing information in the logs will be
2043 the total number of bytes which will indicate everything except the amount
2044 of data transferred, and the total time which will not take the transfer
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002045 time into account. In such a situation, it's a good practice to capture the
Willy Tarreauc27debf2008-01-06 08:57:02 +01002046 "Content-Length" response header so that the logs at least indicate how many
2047 bytes are expected to be transferred.
2048
Willy Tarreauced27012008-01-17 20:35:34 +01002049 See also : "option httplog", "capture response header", and section 2.6 about
Willy Tarreauc27debf2008-01-06 08:57:02 +01002050 logging.
2051
2052
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002053option nolinger
2054no option nolinger
2055 Enable or disable immediate session ressource cleaning after close
2056 May be used in sections: defaults | frontend | listen | backend
2057 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002058 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002059
2060 When clients or servers abort connections in a dirty way (eg: they are
2061 physically disconnected), the session timeouts triggers and the session is
2062 closed. But it will remain in FIN_WAIT1 state for some time in the system,
2063 using some resources and possibly limiting the ability to establish newer
2064 connections.
2065
2066 When this happens, it is possible to activate "option nolinger" which forces
2067 the system to immediately remove any socket's pending data on close. Thus,
2068 the session is instantly purged from the system's tables. This usually has
2069 side effects such as increased number of TCP resets due to old retransmits
2070 getting immediately rejected. Some firewalls may sometimes complain about
2071 this too.
2072
2073 For this reason, it is not recommended to use this option when not absolutely
2074 needed. You know that you need it when you have thousands of FIN_WAIT1
2075 sessions on your system (TIME_WAIT ones do not count).
2076
2077 This option may be used both on frontends and backends, depending on the side
2078 where it is required. Use it on the frontend for clients, and on the backend
2079 for servers.
2080
2081 If this option has been enabled in a "defaults" section, it can be disabled
2082 in a specific instance by prepending the "no" keyword before it.
2083
2084
2085option persist
2086no option persist
2087 Enable or disable forced persistence on down servers
2088 May be used in sections: defaults | frontend | listen | backend
2089 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002090 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002091
2092 When an HTTP request reaches a backend with a cookie which references a dead
2093 server, by default it is redispatched to another server. It is possible to
2094 force the request to be sent to the dead server first using "option persist"
2095 if absolutely needed. A common use case is when servers are under extreme
2096 load and spend their time flapping. In this case, the users would still be
2097 directed to the server they opened the session on, in the hope they would be
2098 correctly served. It is recommended to use "option redispatch" in conjunction
2099 with this option so that in the event it would not be possible to connect to
2100 the server at all (server definitely dead), the client would finally be
2101 redirected to another valid server.
2102
2103 If this option has been enabled in a "defaults" section, it can be disabled
2104 in a specific instance by prepending the "no" keyword before it.
2105
2106 See also : "option redispatch", "retries"
2107
2108
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002109option redispatch
2110no option redispatch
2111 Enable or disable session redistribution in case of connection failure
2112 May be used in sections: defaults | frontend | listen | backend
2113 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002114 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002115
2116 In HTTP mode, if a server designated by a cookie is down, clients may
2117 definitely stick to it because they cannot flush the cookie, so they will not
2118 be able to access the service anymore.
2119
2120 Specifying "option redispatch" will allow the proxy to break their
2121 persistence and redistribute them to a working server.
2122
2123 It also allows to retry last connection to another server in case of multiple
2124 connection failures. Of course, it requires having "retries" set to a nonzero
2125 value.
2126
2127 This form is the preferred form, which replaces both the "redispatch" and
2128 "redisp" keywords.
2129
2130 If this option has been enabled in a "defaults" section, it can be disabled
2131 in a specific instance by prepending the "no" keyword before it.
2132
2133 See also : "redispatch", "retries"
2134
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002135
2136option smtpchk
2137option smtpchk <hello> <domain>
2138 Use SMTP health checks for server testing
2139 May be used in sections : defaults | frontend | listen | backend
2140 yes | no | yes | yes
2141 Arguments :
2142 <hello> is an optional argument. It is the "hello" command to use. It can
2143 be either "HELO" (for SMTP) or "EHLO" (for ESTMP). All other
2144 values will be turned into the default command ("HELO").
2145
2146 <domain> is the domain name to present to the server. It may only be
2147 specified (and is mandatory) if the hello command has been
2148 specified. By default, "localhost" is used.
2149
2150 When "option smtpchk" is set, the health checks will consist in TCP
2151 connections followed by an SMTP command. By default, this command is
2152 "HELO localhost". The server's return code is analyzed and only return codes
2153 starting with a "2" will be considered as valid. All other responses,
2154 including a lack of response will constitute an error and will indicate a
2155 dead server.
2156
2157 This test is meant to be used with SMTP servers or relays. Depending on the
2158 request, it is possible that some servers do not log each connection attempt,
2159 so you may want to experiment to improve the behaviour. Using telnet on port
2160 25 is often easier than adjusting the configuration.
2161
2162 Most often, an incoming SMTP server needs to see the client's IP address for
2163 various purposes, including spam filtering, anti-spoofing and logging. When
2164 possible, it is often wise to masquerade the client's IP address when
2165 connecting to the server using the "usesrc" argument of the "source" keyword,
2166 which requires the cttproxy feature to be compiled in.
2167
2168 Example :
2169 option smtpchk HELO mydomain.org
2170
2171 See also : "option httpchk", "source"
2172
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002173
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002174option srvtcpka
2175no option srvtcpka
2176 Enable or disable the sending of TCP keepalive packets on the server side
2177 May be used in sections : defaults | frontend | listen | backend
2178 yes | no | yes | yes
2179 Arguments : none
2180
2181 When there is a firewall or any session-aware component between a client and
2182 a server, and when the protocol involves very long sessions with long idle
2183 periods (eg: remote desktops), there is a risk that one of the intermediate
2184 components decides to expire a session which has remained idle for too long.
2185
2186 Enabling socket-level TCP keep-alives makes the system regularly send packets
2187 to the other end of the connection, leaving it active. The delay between
2188 keep-alive probes is controlled by the system only and depends both on the
2189 operating system and its tuning parameters.
2190
2191 It is important to understand that keep-alive packets are neither emitted nor
2192 received at the application level. It is only the network stacks which sees
2193 them. For this reason, even if one side of the proxy already uses keep-alives
2194 to maintain its connection alive, those keep-alive packets will not be
2195 forwarded to the other side of the proxy.
2196
2197 Please note that this has nothing to do with HTTP keep-alive.
2198
2199 Using option "srvtcpka" enables the emission of TCP keep-alive probes on the
2200 server side of a connection, which should help when session expirations are
2201 noticed between HAProxy and a server.
2202
2203 If this option has been enabled in a "defaults" section, it can be disabled
2204 in a specific instance by prepending the "no" keyword before it.
2205
2206 See also : "option clitcpka", "option tcpka"
2207
2208
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002209option ssl-hello-chk
2210 Use SSLv3 client hello health checks for server testing
2211 May be used in sections : defaults | frontend | listen | backend
2212 yes | no | yes | yes
2213 Arguments : none
2214
2215 When some SSL-based protocols are relayed in TCP mode through HAProxy, it is
2216 possible to test that the server correctly talks SSL instead of just testing
2217 that it accepts the TCP connection. When "option ssl-hello-chk" is set, pure
2218 SSLv3 client hello messages are sent once the connection is established to
2219 the server, and the response is analyzed to find an SSL server hello message.
2220 The server is considered valid only when the response contains this server
2221 hello message.
2222
2223 All servers tested till there correctly reply to SSLv3 client hello messages,
2224 and most servers tested do not even log the requests containing only hello
2225 messages, which is appreciable.
2226
2227 See also: "option httpchk"
2228
2229
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002230option tcpka
2231 Enable or disable the sending of TCP keepalive packets on both sides
2232 May be used in sections : defaults | frontend | listen | backend
2233 yes | yes | yes | yes
2234 Arguments : none
2235
2236 When there is a firewall or any session-aware component between a client and
2237 a server, and when the protocol involves very long sessions with long idle
2238 periods (eg: remote desktops), there is a risk that one of the intermediate
2239 components decides to expire a session which has remained idle for too long.
2240
2241 Enabling socket-level TCP keep-alives makes the system regularly send packets
2242 to the other end of the connection, leaving it active. The delay between
2243 keep-alive probes is controlled by the system only and depends both on the
2244 operating system and its tuning parameters.
2245
2246 It is important to understand that keep-alive packets are neither emitted nor
2247 received at the application level. It is only the network stacks which sees
2248 them. For this reason, even if one side of the proxy already uses keep-alives
2249 to maintain its connection alive, those keep-alive packets will not be
2250 forwarded to the other side of the proxy.
2251
2252 Please note that this has nothing to do with HTTP keep-alive.
2253
2254 Using option "tcpka" enables the emission of TCP keep-alive probes on both
2255 the client and server sides of a connection. Note that this is meaningful
2256 only in "defaults" or "listen" sections. If this option is used in a
2257 frontend, only the client side will get keep-alives, and if this option is
2258 used in a backend, only the server side will get keep-alives. For this
2259 reason, it is strongly recommended to explicitly use "option clitcpka" and
2260 "option srvtcpka" when the configuration is split between frontends and
2261 backends.
2262
2263 See also : "option clitcpka", "option srvtcpka"
2264
Willy Tarreau844e3c52008-01-11 16:28:18 +01002265
2266option tcplog
2267 Enable advanced logging of TCP connections with session state and timers
2268 May be used in sections : defaults | frontend | listen | backend
2269 yes | yes | yes | yes
2270 Arguments : none
2271
2272 By default, the log output format is very poor, as it only contains the
2273 source and destination addresses, and the instance name. By specifying
2274 "option tcplog", each log line turns into a much richer format including, but
2275 not limited to, the connection timers, the session status, the connections
2276 numbers, the frontend, backend and server name, and of course the source
2277 address and ports. This option is useful for pure TCP proxies in order to
2278 find which of the client or server disconnects or times out. For normal HTTP
2279 proxies, it's better to use "option httplog" which is even more complete.
2280
2281 This option may be set either in the frontend or the backend.
2282
Willy Tarreauced27012008-01-17 20:35:34 +01002283 See also : "option httplog", and section 2.6 about logging.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002284
2285
2286option tcpsplice [ experimental ]
2287 Enable linux kernel-based acceleration of data relaying
2288 May be used in sections : defaults | frontend | listen | backend
2289 yes | yes | yes | yes
2290 Arguments : none
2291
2292 This option is only available when HAProxy has been built for use on Linux
2293 with USE_TCPSPLICE=1. This option requires a kernel patch which is available
2294 on http://www.linux-l7sw.org/.
2295
2296 When "option tcpsplice" is set, as soon as the server's response headers have
2297 been transferred, the session handling is transferred to the kernel which
2298 will forward all subsequent data from the server to the client untill the
2299 session closes. This leads to much faster data transfers between client and
2300 server since the data is not copied twice between kernel and user space, but
2301 there are some limitations such as the lack of information about the number
2302 of bytes transferred and the total transfer time.
2303
2304 This is an experimental feature. It happens to reliably work but issues
2305 caused by corner cases are to be expected.
2306
2307 Note that this option requires that the process permanently runs with
2308 CAP_NETADMIN privileges, which most often translates into running as root.
2309
2310
2311option transparent
2312no option transparent
2313 Enable client-side transparent proxying
2314 May be used in sections : defaults | frontend | listen | backend
2315 yes | yes | yes | no
2316 Arguments : none
2317
2318 This option was introduced in order to provide layer 7 persistence to layer 3
2319 load balancers. The idea is to use the OS's ability to redirect an incoming
2320 connection for a remote address to a local process (here HAProxy), and let
2321 this process know what address was initially requested. When this option is
2322 used, sessions without cookies will be forwarded to the original destination
2323 IP address of the incoming request (which should match that of another
2324 equipment), while requests with cookies will still be forwarded to the
2325 appropriate server.
2326
2327 Note that contrary to a common belief, this option does NOT make HAProxy
2328 present the client's IP to the server when establishing the connection.
2329
2330 Use of this option is really discouraged, and since no really valid use of it
2331 has been reported for years, it will probably be removed in future versions.
2332
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002333 See also: the "usersrc" argument of the "source" keyword, and the
2334 "transparent" option of the "bind" keyword.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002335
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002336
Willy Tarreaub463dfb2008-06-07 23:08:56 +02002337redirect {location | prefix} <to> [code <code>] {if | unless} <condition>
2338 Return an HTTP redirection if/unless a condition is matched
2339 May be used in sections : defaults | frontend | listen | backend
2340 no | yes | yes | yes
2341
2342 If/unless the condition is matched, the HTTP request will lead to a redirect
2343 response. There are currently two types of redirections : "location" and
2344 "prefix". With "location", the exact value in <to> is placed into the HTTP
2345 "Location" header. With "prefix", the "Location" header is built from the
2346 concatenation of <to> and the URI. It is particularly suited for global site
2347 redirections.
2348
2349 The code is optional. It indicates in <code> which type of HTTP redirection
2350 is desired. Only codes 301, 302 and 303 are supported. 302 is used if no code
2351 is specified.
2352
2353 Example: move the login URL only to HTTPS.
2354 acl clear dst_port 80
2355 acl secure dst_port 8080
2356 acl login_page url_beg /login
2357 redirect prefix https://mysite.com if login_page !secure
2358 redirect location http://mysite.com/ if !login_page secure
2359
2360 See section 2.3 about ACL usage.
2361
2362
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002363redisp (deprecated)
2364redispatch (deprecated)
2365 Enable or disable session redistribution in case of connection failure
2366 May be used in sections: defaults | frontend | listen | backend
2367 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002368 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002369
2370 In HTTP mode, if a server designated by a cookie is down, clients may
2371 definitely stick to it because they cannot flush the cookie, so they will not
2372 be able to access the service anymore.
2373
2374 Specifying "redispatch" will allow the proxy to break their persistence and
2375 redistribute them to a working server.
2376
2377 It also allows to retry last connection to another server in case of multiple
2378 connection failures. Of course, it requires having "retries" set to a nonzero
2379 value.
2380
2381 This form is deprecated, do not use it in any new configuration, use the new
2382 "option redispatch" instead.
2383
2384 See also : "option redispatch"
2385
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002386
Willy Tarreau303c0352008-01-17 19:01:39 +01002387reqadd <string>
2388 Add a header at the end of the HTTP request
2389 May be used in sections : defaults | frontend | listen | backend
2390 no | yes | yes | yes
2391 Arguments :
2392 <string> is the complete line to be added. Any space or known delimiter
2393 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002394 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002395
2396 A new line consisting in <string> followed by a line feed will be added after
2397 the last header of an HTTP request.
2398
2399 Header transformations only apply to traffic which passes through HAProxy,
2400 and not to traffic generated by HAProxy, such as health-checks or error
2401 responses.
2402
Willy Tarreauced27012008-01-17 20:35:34 +01002403 See also: "rspadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002404
2405
2406reqallow <search>
2407reqiallow <search> (ignore case)
2408 Definitely allow an HTTP request if a line matches a regular expression
2409 May be used in sections : defaults | frontend | listen | backend
2410 no | yes | yes | yes
2411 Arguments :
2412 <search> is the regular expression applied to HTTP headers and to the
2413 request line. This is an extended regular expression. Parenthesis
2414 grouping is supported and no preliminary backslash is required.
2415 Any space or known delimiter must be escaped using a backslash
2416 ('\'). The pattern applies to a full line at a time. The
2417 "reqallow" keyword strictly matches case while "reqiallow"
2418 ignores case.
2419
2420 A request containing any line which matches extended regular expression
2421 <search> will mark the request as allowed, even if any later test would
2422 result in a deny. The test applies both to the request line and to request
2423 headers. Keep in mind that URLs in request line are case-sensitive while
2424 header names are not.
2425
2426 It is easier, faster and more powerful to use ACLs to write access policies.
2427 Reqdeny, reqallow and reqpass should be avoided in new designs.
2428
2429 Example :
2430 # allow www.* but refuse *.local
2431 reqiallow ^Host:\ www\.
2432 reqideny ^Host:\ .*\.local
2433
Willy Tarreauced27012008-01-17 20:35:34 +01002434 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002435 manipulation
2436
2437
2438reqdel <search>
2439reqidel <search> (ignore case)
2440 Delete all headers matching a regular expression in an HTTP request
2441 May be used in sections : defaults | frontend | listen | backend
2442 no | yes | yes | yes
2443 Arguments :
2444 <search> is the regular expression applied to HTTP headers and to the
2445 request line. This is an extended regular expression. Parenthesis
2446 grouping is supported and no preliminary backslash is required.
2447 Any space or known delimiter must be escaped using a backslash
2448 ('\'). The pattern applies to a full line at a time. The "reqdel"
2449 keyword strictly matches case while "reqidel" ignores case.
2450
2451 Any header line matching extended regular expression <search> in the request
2452 will be completely deleted. Most common use of this is to remove unwanted
2453 and/or dangerous headers or cookies from a request before passing it to the
2454 next servers.
2455
2456 Header transformations only apply to traffic which passes through HAProxy,
2457 and not to traffic generated by HAProxy, such as health-checks or error
2458 responses. Keep in mind that header names are not case-sensitive.
2459
2460 Example :
2461 # remove X-Forwarded-For header and SERVER cookie
2462 reqidel ^X-Forwarded-For:.*
2463 reqidel ^Cookie:.*SERVER=
2464
Willy Tarreauced27012008-01-17 20:35:34 +01002465 See also: "reqadd", "reqrep", "rspdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002466 manipulation
2467
2468
2469reqdeny <search>
2470reqideny <search> (ignore case)
2471 Deny an HTTP request if a line matches a regular expression
2472 May be used in sections : defaults | frontend | listen | backend
2473 no | yes | yes | yes
2474 Arguments :
2475 <search> is the regular expression applied to HTTP headers and to the
2476 request line. This is an extended regular expression. Parenthesis
2477 grouping is supported and no preliminary backslash is required.
2478 Any space or known delimiter must be escaped using a backslash
2479 ('\'). The pattern applies to a full line at a time. The
2480 "reqdeny" keyword strictly matches case while "reqideny" ignores
2481 case.
2482
2483 A request containing any line which matches extended regular expression
2484 <search> will mark the request as denied, even if any later test would
2485 result in an allow. The test applies both to the request line and to request
2486 headers. Keep in mind that URLs in request line are case-sensitive while
2487 header names are not.
2488
Willy Tarreauced27012008-01-17 20:35:34 +01002489 A denied request will generate an "HTTP 403 forbidden" response once the
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002490 complete request has been parsed. This is consistent with what is practiced
Willy Tarreauced27012008-01-17 20:35:34 +01002491 using ACLs.
2492
Willy Tarreau303c0352008-01-17 19:01:39 +01002493 It is easier, faster and more powerful to use ACLs to write access policies.
2494 Reqdeny, reqallow and reqpass should be avoided in new designs.
2495
2496 Example :
2497 # refuse *.local, then allow www.*
2498 reqideny ^Host:\ .*\.local
2499 reqiallow ^Host:\ www\.
2500
Willy Tarreauced27012008-01-17 20:35:34 +01002501 See also: "reqallow", "rspdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002502 header manipulation
2503
2504
2505reqpass <search>
2506reqipass <search> (ignore case)
2507 Ignore any HTTP request line matching a regular expression in next rules
2508 May be used in sections : defaults | frontend | listen | backend
2509 no | yes | yes | yes
2510 Arguments :
2511 <search> is the regular expression applied to HTTP headers and to the
2512 request line. This is an extended regular expression. Parenthesis
2513 grouping is supported and no preliminary backslash is required.
2514 Any space or known delimiter must be escaped using a backslash
2515 ('\'). The pattern applies to a full line at a time. The
2516 "reqpass" keyword strictly matches case while "reqipass" ignores
2517 case.
2518
2519 A request containing any line which matches extended regular expression
2520 <search> will skip next rules, without assigning any deny or allow verdict.
2521 The test applies both to the request line and to request headers. Keep in
2522 mind that URLs in request line are case-sensitive while header names are not.
2523
2524 It is easier, faster and more powerful to use ACLs to write access policies.
2525 Reqdeny, reqallow and reqpass should be avoided in new designs.
2526
2527 Example :
2528 # refuse *.local, then allow www.*, but ignore "www.private.local"
2529 reqipass ^Host:\ www.private\.local
2530 reqideny ^Host:\ .*\.local
2531 reqiallow ^Host:\ www\.
2532
Willy Tarreauced27012008-01-17 20:35:34 +01002533 See also: "reqallow", "reqdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002534 header manipulation
2535
2536
2537reqrep <search> <string>
2538reqirep <search> <string> (ignore case)
2539 Replace a regular expression with a string in an HTTP request line
2540 May be used in sections : defaults | frontend | listen | backend
2541 no | yes | yes | yes
2542 Arguments :
2543 <search> is the regular expression applied to HTTP headers and to the
2544 request line. This is an extended regular expression. Parenthesis
2545 grouping is supported and no preliminary backslash is required.
2546 Any space or known delimiter must be escaped using a backslash
2547 ('\'). The pattern applies to a full line at a time. The "reqrep"
2548 keyword strictly matches case while "reqirep" ignores case.
2549
2550 <string> is the complete line to be added. Any space or known delimiter
2551 must be escaped using a backslash ('\'). References to matched
2552 pattern groups are possible using the common \N form, with N
2553 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002554 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002555
2556 Any line matching extended regular expression <search> in the request (both
2557 the request line and header lines) will be completely replaced with <string>.
2558 Most common use of this is to rewrite URLs or domain names in "Host" headers.
2559
2560 Header transformations only apply to traffic which passes through HAProxy,
2561 and not to traffic generated by HAProxy, such as health-checks or error
2562 responses. Note that for increased readability, it is suggested to add enough
2563 spaces between the request and the response. Keep in mind that URLs in
2564 request line are case-sensitive while header names are not.
2565
2566 Example :
2567 # replace "/static/" with "/" at the beginning of any request path.
2568 reqrep ^([^\ ]*)\ /static/(.*) \1\ /\2
2569 # replace "www.mydomain.com" with "www" in the host name.
2570 reqirep ^Host:\ www.mydomain.com Host:\ www
2571
Willy Tarreauced27012008-01-17 20:35:34 +01002572 See also: "reqadd", "reqdel", "rsprep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002573 manipulation
2574
2575
2576reqtarpit <search>
2577reqitarpit <search> (ignore case)
2578 Tarpit an HTTP request containing a line matching a regular expression
2579 May be used in sections : defaults | frontend | listen | backend
2580 no | yes | yes | yes
2581 Arguments :
2582 <search> is the regular expression applied to HTTP headers and to the
2583 request line. This is an extended regular expression. Parenthesis
2584 grouping is supported and no preliminary backslash is required.
2585 Any space or known delimiter must be escaped using a backslash
2586 ('\'). The pattern applies to a full line at a time. The
2587 "reqtarpit" keyword strictly matches case while "reqitarpit"
2588 ignores case.
2589
2590 A request containing any line which matches extended regular expression
2591 <search> will be tarpitted, which means that it will connect to nowhere, will
Willy Tarreauced27012008-01-17 20:35:34 +01002592 be kept open for a pre-defined time, then will return an HTTP error 500 so
2593 that the attacker does not suspect it has been tarpitted. The status 500 will
2594 be reported in the logs, but the completion flags will indicate "PT". The
Willy Tarreau303c0352008-01-17 19:01:39 +01002595 delay is defined by "timeout tarpit", or "timeout connect" if the former is
2596 not set.
2597
2598 The goal of the tarpit is to slow down robots attacking servers with
2599 identifiable requests. Many robots limit their outgoing number of connections
2600 and stay connected waiting for a reply which can take several minutes to
2601 come. Depending on the environment and attack, it may be particularly
2602 efficient at reducing the load on the network and firewalls.
2603
2604 Example :
2605 # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but
2606 # block all others.
2607 reqipass ^User-Agent:\.*(Mozilla|MSIE)
2608 reqitarpit ^User-Agent:
2609
Willy Tarreauced27012008-01-17 20:35:34 +01002610 See also: "reqallow", "reqdeny", "reqpass", and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002611 manipulation
2612
2613
Willy Tarreaue5c5ce92008-06-20 17:27:19 +02002614retries <value>
2615 Set the number of retries to perform on a server after a connection failure
2616 May be used in sections: defaults | frontend | listen | backend
2617 yes | no | yes | yes
2618 Arguments :
2619 <value> is the number of times a connection attempt should be retried on
2620 a server when a connection either is refused or times out. The
2621 default value is 3.
2622
2623 It is important to understand that this value applies to the number of
2624 connection attempts, not full requests. When a connection has effectively
2625 been established to a server, there will be no more retry.
2626
2627 In order to avoid immediate reconnections to a server which is restarting,
2628 a turn-around timer of 1 second is applied before a retry occurs.
2629
2630 When "option redispatch" is set, the last retry may be performed on another
2631 server even if a cookie references a different server.
2632
2633 See also : "option redispatch"
2634
2635
Willy Tarreau303c0352008-01-17 19:01:39 +01002636rspadd <string>
2637 Add a header at the end of the HTTP response
2638 May be used in sections : defaults | frontend | listen | backend
2639 no | yes | yes | yes
2640 Arguments :
2641 <string> is the complete line to be added. Any space or known delimiter
2642 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002643 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002644
2645 A new line consisting in <string> followed by a line feed will be added after
2646 the last header of an HTTP response.
2647
2648 Header transformations only apply to traffic which passes through HAProxy,
2649 and not to traffic generated by HAProxy, such as health-checks or error
2650 responses.
2651
Willy Tarreauced27012008-01-17 20:35:34 +01002652 See also: "reqadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002653
2654
2655rspdel <search>
2656rspidel <search> (ignore case)
2657 Delete all headers matching a regular expression in an HTTP response
2658 May be used in sections : defaults | frontend | listen | backend
2659 no | yes | yes | yes
2660 Arguments :
2661 <search> is the regular expression applied to HTTP headers and to the
2662 response line. This is an extended regular expression, so
2663 parenthesis grouping is supported and no preliminary backslash
2664 is required. Any space or known delimiter must be escaped using
2665 a backslash ('\'). The pattern applies to a full line at a time.
2666 The "rspdel" keyword strictly matches case while "rspidel"
2667 ignores case.
2668
2669 Any header line matching extended regular expression <search> in the response
2670 will be completely deleted. Most common use of this is to remove unwanted
2671 and/or sensible headers or cookies from a response before passing it to the
2672 client.
2673
2674 Header transformations only apply to traffic which passes through HAProxy,
2675 and not to traffic generated by HAProxy, such as health-checks or error
2676 responses. Keep in mind that header names are not case-sensitive.
2677
2678 Example :
2679 # remove the Server header from responses
2680 reqidel ^Server:.*
2681
Willy Tarreauced27012008-01-17 20:35:34 +01002682 See also: "rspadd", "rsprep", "reqdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002683 manipulation
2684
2685
2686rspdeny <search>
2687rspideny <search> (ignore case)
2688 Block an HTTP response if a line matches a regular expression
2689 May be used in sections : defaults | frontend | listen | backend
2690 no | yes | yes | yes
2691 Arguments :
2692 <search> is the regular expression applied to HTTP headers and to the
2693 response line. This is an extended regular expression, so
2694 parenthesis grouping is supported and no preliminary backslash
2695 is required. Any space or known delimiter must be escaped using
2696 a backslash ('\'). The pattern applies to a full line at a time.
2697 The "rspdeny" keyword strictly matches case while "rspideny"
2698 ignores case.
2699
2700 A response containing any line which matches extended regular expression
2701 <search> will mark the request as denied. The test applies both to the
2702 response line and to response headers. Keep in mind that header names are not
2703 case-sensitive.
2704
2705 Main use of this keyword is to prevent sensitive information leak and to
Willy Tarreauced27012008-01-17 20:35:34 +01002706 block the response before it reaches the client. If a response is denied, it
2707 will be replaced with an HTTP 502 error so that the client never retrieves
2708 any sensitive data.
Willy Tarreau303c0352008-01-17 19:01:39 +01002709
2710 It is easier, faster and more powerful to use ACLs to write access policies.
2711 Rspdeny should be avoided in new designs.
2712
2713 Example :
2714 # Ensure that no content type matching ms-word will leak
2715 rspideny ^Content-type:\.*/ms-word
2716
Willy Tarreauced27012008-01-17 20:35:34 +01002717 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002718 manipulation
2719
2720
2721rsprep <search> <string>
2722rspirep <search> <string> (ignore case)
2723 Replace a regular expression with a string in an HTTP response line
2724 May be used in sections : defaults | frontend | listen | backend
2725 no | yes | yes | yes
2726 Arguments :
2727 <search> is the regular expression applied to HTTP headers and to the
2728 response line. This is an extended regular expression, so
2729 parenthesis grouping is supported and no preliminary backslash
2730 is required. Any space or known delimiter must be escaped using
2731 a backslash ('\'). The pattern applies to a full line at a time.
2732 The "rsprep" keyword strictly matches case while "rspirep"
2733 ignores case.
2734
2735 <string> is the complete line to be added. Any space or known delimiter
2736 must be escaped using a backslash ('\'). References to matched
2737 pattern groups are possible using the common \N form, with N
2738 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002739 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002740
2741 Any line matching extended regular expression <search> in the response (both
2742 the response line and header lines) will be completely replaced with
2743 <string>. Most common use of this is to rewrite Location headers.
2744
2745 Header transformations only apply to traffic which passes through HAProxy,
2746 and not to traffic generated by HAProxy, such as health-checks or error
2747 responses. Note that for increased readability, it is suggested to add enough
2748 spaces between the request and the response. Keep in mind that header names
2749 are not case-sensitive.
2750
2751 Example :
2752 # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com"
2753 rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com
2754
Willy Tarreauced27012008-01-17 20:35:34 +01002755 See also: "rspadd", "rspdel", "reqrep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002756 manipulation
2757
2758
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002759server <name> <address>[:port] [param*]
2760 Declare a server in a backend
2761 May be used in sections : defaults | frontend | listen | backend
2762 no | no | yes | yes
2763 Arguments :
2764 <name> is the internal name assigned to this server. This name will
2765 appear in logs and alerts.
2766
2767 <address> is the IPv4 address of the server. Alternatively, a resolvable
2768 hostname is supported, but this name will be resolved during
2769 start-up.
2770
2771 <ports> is an optional port specification. If set, all connections will
2772 be sent to this port. If unset, the same port the client
2773 connected to will be used. The port may also be prefixed by a "+"
2774 or a "-". In this case, the server's port will be determined by
2775 adding this value to the client's port.
2776
2777 <param*> is a list of parameters for this server. The "server" keywords
2778 accepts an important number of options and has a complete section
2779 dedicated to it. Please refer to section 2.4 for more details.
2780
2781 Examples :
2782 server first 10.1.1.1:1080 cookie first check inter 1000
2783 server second 10.1.1.2:1080 cookie second check inter 1000
2784
2785 See also : section 2.4 about server options
2786
2787
2788source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
2789 Set the source address for outgoing connections
2790 May be used in sections : defaults | frontend | listen | backend
2791 yes | no | yes | yes
2792 Arguments :
2793 <addr> is the IPv4 address HAProxy will bind to before connecting to a
2794 server. This address is also used as a source for health checks.
2795 The default value of 0.0.0.0 means that the system will select
2796 the most appropriate address to reach its destination.
2797
2798 <port> is an optional port. It is normally not needed but may be useful
2799 in some very specific contexts. The default value of zero means
2800 the system will select a free port.
2801
2802 <addr2> is the IP address to present to the server when connections are
2803 forwarded in full transparent proxy mode. This is currently only
2804 supported on some patched Linux kernels. When this address is
2805 specified, clients connecting to the server will be presented
2806 with this address, while health checks will still use the address
2807 <addr>.
2808
2809 <port2> is the optional port to present to the server when connections
2810 are forwarded in full transparent proxy mode (see <addr2> above).
2811 The default value of zero means the system will select a free
2812 port.
2813
2814 The "source" keyword is useful in complex environments where a specific
2815 address only is allowed to connect to the servers. It may be needed when a
2816 private address must be used through a public gateway for instance, and it is
2817 known that the system cannot determine the adequate source address by itself.
2818
2819 An extension which is available on certain patched Linux kernels may be used
2820 through the "usesrc" optional keyword. It makes it possible to connect to the
2821 servers with an IP address which does not belong to the system itself. This
2822 is called "full transparent proxy mode". For this to work, the destination
2823 servers have to route their traffic back to this address through the machine
2824 running HAProxy, and IP forwarding must generally be enabled on this machine.
2825
2826 In this "full transparent proxy" mode, it is possible to force a specific IP
2827 address to be presented to the servers. This is not much used in fact. A more
2828 common use is to tell HAProxy to present the client's IP address. For this,
2829 there are two methods :
2830
2831 - present the client's IP and port addresses. This is the most transparent
2832 mode, but it can cause problems when IP connection tracking is enabled on
2833 the machine, because a same connection may be seen twice with different
2834 states. However, this solution presents the huge advantage of not
2835 limiting the system to the 64k outgoing address+port couples, because all
2836 of the client ranges may be used.
2837
2838 - present only the client's IP address and select a spare port. This
2839 solution is still quite elegant but slightly less transparent (downstream
2840 firewalls logs will not match upstream's). It also presents the downside
2841 of limiting the number of concurrent connections to the usual 64k ports.
2842 However, since the upstream and downstream ports are different, local IP
2843 connection tracking on the machine will not be upset by the reuse of the
2844 same session.
2845
2846 Note that depending on the transparent proxy technology used, it may be
2847 required to force the source address. In fact, cttproxy version 2 requires an
2848 IP address in <addr> above, and does not support setting of "0.0.0.0" as the
2849 IP address because it creates NAT entries which much match the exact outgoing
2850 address. Tproxy version 4 and some other kernel patches which work in pure
2851 forwarding mode generally will not have this limitation.
2852
2853 This option sets the default source for all servers in the backend. It may
2854 also be specified in a "defaults" section. Finer source address specification
2855 is possible at the server level using the "source" server option. Refer to
2856 section 2.4 for more information.
2857
2858 Examples :
2859 backend private
2860 # Connect to the servers using our 192.168.1.200 source address
2861 source 192.168.1.200
2862
2863 backend transparent_ssl1
2864 # Connect to the SSL farm from the client's source address
2865 source 192.168.1.200 usesrc clientip
2866
2867 backend transparent_ssl2
2868 # Connect to the SSL farm from the client's source address and port
2869 # not recommended if IP conntrack is present on the local machine.
2870 source 192.168.1.200 usesrc client
2871
2872 backend transparent_ssl3
2873 # Connect to the SSL farm from the client's source address. It
2874 # is more conntrack-friendly.
2875 source 192.168.1.200 usesrc clientip
2876
2877 backend transparent_smtp
2878 # Connect to the SMTP farm from the client's source address/port
2879 # with Tproxy version 4.
2880 source 0.0.0.0 usesrc clientip
2881
2882 See also : the "source" server option in section 2.4, the Tproxy patches for
2883 the Linux kernel on www.balabit.com, the "bind" keyword.
2884
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002885
Willy Tarreau844e3c52008-01-11 16:28:18 +01002886srvtimeout <timeout> (deprecated)
2887 Set the maximum inactivity time on the server side.
2888 May be used in sections : defaults | frontend | listen | backend
2889 yes | no | yes | yes
2890 Arguments :
2891 <timeout> is the timeout value specified in milliseconds by default, but
2892 can be in any other unit if the number is suffixed by the unit,
2893 as explained at the top of this document.
2894
2895 The inactivity timeout applies when the server is expected to acknowledge or
2896 send data. In HTTP mode, this timeout is particularly important to consider
2897 during the first phase of the server's response, when it has to send the
2898 headers, as it directly represents the server's processing time for the
2899 request. To find out what value to put there, it's often good to start with
2900 what would be considered as unacceptable response times, then check the logs
2901 to observe the response time distribution, and adjust the value accordingly.
2902
2903 The value is specified in milliseconds by default, but can be in any other
2904 unit if the number is suffixed by the unit, as specified at the top of this
2905 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
2906 recommended that the client timeout remains equal to the server timeout in
2907 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002908 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01002909 packet losses by specifying timeouts that are slightly above multiples of 3
2910 seconds (eg: 4 or 5 seconds minimum).
2911
2912 This parameter is specific to backends, but can be specified once for all in
2913 "defaults" sections. This is in fact one of the easiest solutions not to
2914 forget about it. An unspecified timeout results in an infinite timeout, which
2915 is not recommended. Such a usage is accepted and works but reports a warning
2916 during startup because it may results in accumulation of expired sessions in
2917 the system if the system's timeouts are not configured either.
2918
2919 This parameter is provided for compatibility but is currently deprecated.
2920 Please use "timeout server" instead.
2921
2922 See also : "timeout server", "timeout client" and "clitimeout".
2923
2924
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002925stats auth <user>:<passwd>
2926 Enable statistics with authentication and grant access to an account
2927 May be used in sections : defaults | frontend | listen | backend
2928 yes | no | yes | yes
2929 Arguments :
2930 <user> is a user name to grant access to
2931
2932 <passwd> is the cleartext password associated to this user
2933
2934 This statement enables statistics with default settings, and restricts access
2935 to declared users only. It may be repeated as many times as necessary to
2936 allow as many users as desired. When a user tries to access the statistics
2937 without a valid account, a "401 Forbidden" response will be returned so that
2938 the browser asks the user to provide a valid user and password. The real
2939 which will be returned to the browser is configurable using "stats realm".
2940
2941 Since the authentication method is HTTP Basic Authentication, the passwords
2942 circulate in cleartext on the network. Thus, it was decided that the
2943 configuration file would also use cleartext passwords to remind the users
2944 that those ones should not be sensible and not shared with any other account.
2945
2946 It is also possible to reduce the scope of the proxies which appear in the
2947 report using "stats scope".
2948
2949 Though this statement alone is enough to enable statistics reporting, it is
2950 recommended to set all other settings in order to avoid relying on default
2951 unobvious parameters.
2952
2953 Example :
2954 # public access (limited to this backend only)
2955 backend public_www
2956 server srv1 192.168.0.1:80
2957 stats enable
2958 stats hide-version
2959 stats scope .
2960 stats uri /admin?stats
2961 stats realm Haproxy\ Statistics
2962 stats auth admin1:AdMiN123
2963 stats auth admin2:AdMiN321
2964
2965 # internal monitoring access (unlimited)
2966 backend private_monitoring
2967 stats enable
2968 stats uri /admin?stats
2969 stats refresh 5s
2970
2971 See also : "stats enable", "stats realm", "stats scope", "stats uri"
2972
2973
2974stats enable
2975 Enable statistics reporting with default settings
2976 May be used in sections : defaults | frontend | listen | backend
2977 yes | no | yes | yes
2978 Arguments : none
2979
2980 This statement enables statistics reporting with default settings defined
2981 at build time. Unless stated otherwise, these settings are used :
2982 - stats uri : /haproxy?stats
2983 - stats realm : "HAProxy Statistics"
2984 - stats auth : no authentication
2985 - stats scope : no restriction
2986
2987 Though this statement alone is enough to enable statistics reporting, it is
2988 recommended to set all other settings in order to avoid relying on default
2989 unobvious parameters.
2990
2991 Example :
2992 # public access (limited to this backend only)
2993 backend public_www
2994 server srv1 192.168.0.1:80
2995 stats enable
2996 stats hide-version
2997 stats scope .
2998 stats uri /admin?stats
2999 stats realm Haproxy\ Statistics
3000 stats auth admin1:AdMiN123
3001 stats auth admin2:AdMiN321
3002
3003 # internal monitoring access (unlimited)
3004 backend private_monitoring
3005 stats enable
3006 stats uri /admin?stats
3007 stats refresh 5s
3008
3009 See also : "stats auth", "stats realm", "stats uri"
3010
3011
3012stats realm <realm>
3013 Enable statistics and set authentication realm
3014 May be used in sections : defaults | frontend | listen | backend
3015 yes | no | yes | yes
3016 Arguments :
3017 <realm> is the name of the HTTP Basic Authentication realm reported to
3018 the browser. The browser uses it to display it in the pop-up
3019 inviting the user to enter a valid username and password.
3020
3021 The realm is read as a single word, so any spaces in it should be escaped
3022 using a backslash ('\').
3023
3024 This statement is useful only in conjunction with "stats auth" since it is
3025 only related to authentication.
3026
3027 Though this statement alone is enough to enable statistics reporting, it is
3028 recommended to set all other settings in order to avoid relying on default
3029 unobvious parameters.
3030
3031 Example :
3032 # public access (limited to this backend only)
3033 backend public_www
3034 server srv1 192.168.0.1:80
3035 stats enable
3036 stats hide-version
3037 stats scope .
3038 stats uri /admin?stats
3039 stats realm Haproxy\ Statistics
3040 stats auth admin1:AdMiN123
3041 stats auth admin2:AdMiN321
3042
3043 # internal monitoring access (unlimited)
3044 backend private_monitoring
3045 stats enable
3046 stats uri /admin?stats
3047 stats refresh 5s
3048
3049 See also : "stats auth", "stats enable", "stats uri"
3050
3051
3052stats refresh <delay>
3053 Enable statistics with automatic refresh
3054 May be used in sections : defaults | frontend | listen | backend
3055 yes | no | yes | yes
3056 Arguments :
3057 <delay> is the suggested refresh delay, specified in seconds, which will
3058 be returned to the browser consulting the report page. While the
3059 browser is free to apply any delay, it will generally respect it
3060 and refresh the page this every seconds. The refresh interval may
3061 be specified in any other non-default time unit, by suffixing the
3062 unit after the value, as explained at the top of this document.
3063
3064 This statement is useful on monitoring displays with a permanent page
3065 reporting the load balancer's activity. When set, the HTML report page will
3066 include a link "refresh"/"stop refresh" so that the user can select whether
3067 he wants automatic refresh of the page or not.
3068
3069 Though this statement alone is enough to enable statistics reporting, it is
3070 recommended to set all other settings in order to avoid relying on default
3071 unobvious parameters.
3072
3073 Example :
3074 # public access (limited to this backend only)
3075 backend public_www
3076 server srv1 192.168.0.1:80
3077 stats enable
3078 stats hide-version
3079 stats scope .
3080 stats uri /admin?stats
3081 stats realm Haproxy\ Statistics
3082 stats auth admin1:AdMiN123
3083 stats auth admin2:AdMiN321
3084
3085 # internal monitoring access (unlimited)
3086 backend private_monitoring
3087 stats enable
3088 stats uri /admin?stats
3089 stats refresh 5s
3090
3091 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3092
3093
3094stats scope { <name> | "." }
3095 Enable statistics and limit access scope
3096 May be used in sections : defaults | frontend | listen | backend
3097 yes | no | yes | yes
3098 Arguments :
3099 <name> is the name of a listen, frontend or backend section to be
3100 reported. The special name "." (a single dot) designates the
3101 section in which the statement appears.
3102
3103 When this statement is specified, only the sections enumerated with this
3104 statement will appear in the report. All other ones will be hidden. This
3105 statement may appear as many times as needed if multiple sections need to be
3106 reported. Please note that the name checking is performed as simple string
3107 comparisons, and that it is never checked that a give section name really
3108 exists.
3109
3110 Though this statement alone is enough to enable statistics reporting, it is
3111 recommended to set all other settings in order to avoid relying on default
3112 unobvious parameters.
3113
3114 Example :
3115 # public access (limited to this backend only)
3116 backend public_www
3117 server srv1 192.168.0.1:80
3118 stats enable
3119 stats hide-version
3120 stats scope .
3121 stats uri /admin?stats
3122 stats realm Haproxy\ Statistics
3123 stats auth admin1:AdMiN123
3124 stats auth admin2:AdMiN321
3125
3126 # internal monitoring access (unlimited)
3127 backend private_monitoring
3128 stats enable
3129 stats uri /admin?stats
3130 stats refresh 5s
3131
3132 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3133
3134
3135stats uri <prefix>
3136 Enable statistics and define the URI prefix to access them
3137 May be used in sections : defaults | frontend | listen | backend
3138 yes | no | yes | yes
3139 Arguments :
3140 <prefix> is the prefix of any URI which will be redirected to stats. This
3141 prefix may contain a question mark ('?') to indicate part of a
3142 query string.
3143
3144 The statistics URI is intercepted on the relayed traffic, so it appears as a
3145 page within the normal application. It is strongly advised to ensure that the
3146 selected URI will never appear in the application, otherwise it will never be
3147 possible to reach it in the application.
3148
3149 The default URI compiled in haproxy is "/haproxy?stats", but this may be
3150 changed at build time, so it's better to always explictly specify it here.
3151 It is generally a good idea to include a question mark in the URI so that
3152 intermediate proxies refrain from caching the results. Also, since any string
3153 beginning with the prefix will be accepted as a stats request, the question
3154 mark helps ensuring that no valid URI will begin with the same words.
3155
3156 It is sometimes very convenient to use "/" as the URI prefix, and put that
3157 statement in a "listen" instance of its own. That makes it easy to dedicate
3158 an address or a port to statistics only.
3159
3160 Though this statement alone is enough to enable statistics reporting, it is
3161 recommended to set all other settings in order to avoid relying on default
3162 unobvious parameters.
3163
3164 Example :
3165 # public access (limited to this backend only)
3166 backend public_www
3167 server srv1 192.168.0.1:80
3168 stats enable
3169 stats hide-version
3170 stats scope .
3171 stats uri /admin?stats
3172 stats realm Haproxy\ Statistics
3173 stats auth admin1:AdMiN123
3174 stats auth admin2:AdMiN321
3175
3176 # internal monitoring access (unlimited)
3177 backend private_monitoring
3178 stats enable
3179 stats uri /admin?stats
3180 stats refresh 5s
3181
3182 See also : "stats auth", "stats enable", "stats realm"
3183
3184
3185stats hide-version
3186 Enable statistics and hide HAProxy version reporting
3187 May be used in sections : defaults | frontend | listen | backend
3188 yes | no | yes | yes
3189 Arguments : none
3190
3191 By default, the stats page reports some useful status information along with
3192 the statistics. Among them is HAProxy's version. However, it is generally
3193 considered dangerous to report precise version to anyone, as it can help them
3194 target known weaknesses with specific attacks. The "stats hide-version"
3195 statement removes the version from the statistics report. This is recommended
3196 for public sites or any site with a weak login/password.
3197
3198 Though this statement alone is enough to enable statistics reporting, it is
3199 recommended to set all other settings in order to avoid relying on default
3200 unobvious parameters.
3201
3202 Example :
3203 # public access (limited to this backend only)
3204 backend public_www
3205 server srv1 192.168.0.1:80
3206 stats enable
3207 stats hide-version
3208 stats scope .
3209 stats uri /admin?stats
3210 stats realm Haproxy\ Statistics
3211 stats auth admin1:AdMiN123
3212 stats auth admin2:AdMiN321
3213
3214 # internal monitoring access (unlimited)
3215 backend private_monitoring
3216 stats enable
3217 stats uri /admin?stats
3218 stats refresh 5s
3219
3220 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3221
3222
Willy Tarreau62644772008-07-16 18:36:06 +02003223tcp-request content accept [{if | unless} <condition>]
3224 Accept a connection if/unless a content inspection condition is matched
3225 May be used in sections : defaults | frontend | listen | backend
3226 no | yes | yes | no
3227
3228 During TCP content inspection, the connection is immediately validated if the
3229 condition is true (when used with "if") or false (when used with "unless").
3230 Most of the time during content inspection, a condition will be in an
3231 uncertain state which is neither true nor false. The evaluation immediately
3232 stops when such a condition is encountered. It is important to understand
3233 that "accept" and "reject" rules are evaluated in their exact declaration
3234 order, so that it is possible to build complex rules from them. There is no
3235 specific limit to the number of rules which may be inserted.
3236
3237 Note that the "if/unless" condition is optionnal. If no condition is set on
3238 the action, it is simply performed unconditionally.
3239
3240 If no "tcp-request content" rules are matched, the default action already is
3241 "accept". Thus, this statement alone does not bring anything without another
3242 "reject" statement.
3243
3244 See section 2.3 about ACL usage.
3245
3246 See also : "tcp-request content-reject", "tcp-request inspect-delay"
3247
3248
3249tcp-request content reject [{if | unless} <condition>]
3250 Reject a connection if/unless a content inspection condition is matched
3251 May be used in sections : defaults | frontend | listen | backend
3252 no | yes | yes | no
3253
3254 During TCP content inspection, the connection is immediately rejected if the
3255 condition is true (when used with "if") or false (when used with "unless").
3256 Most of the time during content inspection, a condition will be in an
3257 uncertain state which is neither true nor false. The evaluation immediately
3258 stops when such a condition is encountered. It is important to understand
3259 that "accept" and "reject" rules are evaluated in their exact declaration
3260 order, so that it is possible to build complex rules from them. There is no
3261 specific limit to the number of rules which may be inserted.
3262
3263 Note that the "if/unless" condition is optionnal. If no condition is set on
3264 the action, it is simply performed unconditionally.
3265
3266 If no "tcp-request content" rules are matched, the default action is set to
3267 "accept".
3268
3269 Example:
3270 # reject SMTP connection if client speaks first
3271 tcp-request inspect-delay 30s
3272 acl content_present req_len gt 0
3273 tcp-request reject if content_present
3274
3275 # Forward HTTPS connection only if client speaks
3276 tcp-request inspect-delay 30s
3277 acl content_present req_len gt 0
3278 tcp-request accept if content_present
3279 tcp-request reject
3280
3281 See section 2.3 about ACL usage.
3282
3283 See also : "tcp-request content-accept", "tcp-request inspect-delay"
3284
3285
3286tcp-request inspect-delay <timeout>
3287 Set the maximum allowed time to wait for data during content inspection
3288 May be used in sections : defaults | frontend | listen | backend
3289 no | yes | yes | no
3290 Arguments :
3291 <timeout> is the timeout value specified in milliseconds by default, but
3292 can be in any other unit if the number is suffixed by the unit,
3293 as explained at the top of this document.
3294
3295 People using haproxy primarily as a TCP relay are often worried about the
3296 risk of passing any type of protocol to a server without any analysis. In
3297 order to be able to analyze the request contents, we must first withhold
3298 the data then analyze them. This statement simply enables withholding of
3299 data for at most the specified amount of time.
3300
3301 Note that when performing content inspection, haproxy will evaluate the whole
3302 rules for every new chunk which gets in, taking into account the fact that
3303 those data are partial. If no rule matches before the aforementionned delay,
3304 a last check is performed upon expiration, this time considering that the
3305 contents are definitive.
3306
3307 As soon as a rule matches, the request is released and continues as usual. If
3308 the timeout is reached and no rule matches, the default policy will be to let
3309 it pass through unaffected.
3310
3311 For most protocols, it is enough to set it to a few seconds, as most clients
3312 send the full request immediately upon connection. Add 3 or more seconds to
3313 cover TCP retransmits but that's all. For some protocols, it may make sense
3314 to use large values, for instance to ensure that the client never talks
3315 before the server (eg: SMTP), or to wait for a client to talk before passing
3316 data to the server (eg: SSL). Note that the client timeout must cover at
3317 least the inspection delay, otherwise it will expire first.
3318
3319 See also : "tcp-request content accept", "tcp-request content-reject",
3320 "timeout client".
3321
3322
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003323timeout check <timeout>
3324 Set additional check timeout, but only after a connection has been already
3325 established.
3326
3327 May be used in sections: defaults | frontend | listen | backend
3328 yes | no | yes | yes
3329 Arguments:
3330 <timeout> is the timeout value specified in milliseconds by default, but
3331 can be in any other unit if the number is suffixed by the unit,
3332 as explained at the top of this document.
3333
3334 If set, haproxy uses min("timeout connect", "inter") as a connect timeout
3335 for check and "timeout check" as an additional read timeout. The "min" is
3336 used so that people running with *very* long "timeout connect" (eg. those
3337 who needed this due to the queue or tarpit) do not slow down their checks.
3338 Of course it is better to use "check queue" and "check tarpit" instead of
3339 long "timeout connect".
3340
3341 If "timeout check" is not set haproxy uses "inter" for complete check
3342 timeout (connect + read) exactly like all <1.3.15 version.
3343
3344 In most cases check request is much simpler and faster to handle than normal
3345 requests and people may want to kick out laggy servers so this timeout should
Willy Tarreau41a340d2008-01-22 12:25:31 +01003346 be smaller than "timeout server".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003347
3348 This parameter is specific to backends, but can be specified once for all in
3349 "defaults" sections. This is in fact one of the easiest solutions not to
3350 forget about it.
3351
Willy Tarreau41a340d2008-01-22 12:25:31 +01003352 See also: "timeout connect", "timeout queue", "timeout server",
3353 "timeout tarpit".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003354
3355
Willy Tarreau0ba27502007-12-24 16:55:16 +01003356timeout client <timeout>
3357timeout clitimeout <timeout> (deprecated)
3358 Set the maximum inactivity time on the client side.
3359 May be used in sections : defaults | frontend | listen | backend
3360 yes | yes | yes | no
3361 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003362 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003363 can be in any other unit if the number is suffixed by the unit,
3364 as explained at the top of this document.
3365
3366 The inactivity timeout applies when the client is expected to acknowledge or
3367 send data. In HTTP mode, this timeout is particularly important to consider
3368 during the first phase, when the client sends the request, and during the
3369 response while it is reading data sent by the server. The value is specified
3370 in milliseconds by default, but can be in any other unit if the number is
3371 suffixed by the unit, as specified at the top of this document. In TCP mode
3372 (and to a lesser extent, in HTTP mode), it is highly recommended that the
3373 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003374 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01003375 losses by specifying timeouts that are slightly above multiples of 3 seconds
3376 (eg: 4 or 5 seconds).
3377
3378 This parameter is specific to frontends, but can be specified once for all in
3379 "defaults" sections. This is in fact one of the easiest solutions not to
3380 forget about it. An unspecified timeout results in an infinite timeout, which
3381 is not recommended. Such a usage is accepted and works but reports a warning
3382 during startup because it may results in accumulation of expired sessions in
3383 the system if the system's timeouts are not configured either.
3384
3385 This parameter replaces the old, deprecated "clitimeout". It is recommended
3386 to use it to write new configurations. The form "timeout clitimeout" is
3387 provided only by backwards compatibility but its use is strongly discouraged.
3388
3389 See also : "clitimeout", "timeout server".
3390
3391
3392timeout connect <timeout>
3393timeout contimeout <timeout> (deprecated)
3394 Set the maximum time to wait for a connection attempt to a server to succeed.
3395 May be used in sections : defaults | frontend | listen | backend
3396 yes | no | yes | yes
3397 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003398 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003399 can be in any other unit if the number is suffixed by the unit,
3400 as explained at the top of this document.
3401
3402 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003403 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +01003404 cover one or several TCP packet losses by specifying timeouts that are
3405 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003406 connect timeout also presets both queue and tarpit timeouts to the same value
3407 if these have not been specified.
Willy Tarreau0ba27502007-12-24 16:55:16 +01003408
3409 This parameter is specific to backends, but can be specified once for all in
3410 "defaults" sections. This is in fact one of the easiest solutions not to
3411 forget about it. An unspecified timeout results in an infinite timeout, which
3412 is not recommended. Such a usage is accepted and works but reports a warning
3413 during startup because it may results in accumulation of failed sessions in
3414 the system if the system's timeouts are not configured either.
3415
3416 This parameter replaces the old, deprecated "contimeout". It is recommended
3417 to use it to write new configurations. The form "timeout contimeout" is
3418 provided only by backwards compatibility but its use is strongly discouraged.
3419
Willy Tarreau41a340d2008-01-22 12:25:31 +01003420 See also: "timeout check", "timeout queue", "timeout server", "contimeout",
3421 "timeout tarpit".
Willy Tarreau0ba27502007-12-24 16:55:16 +01003422
3423
Willy Tarreau036fae02008-01-06 13:24:40 +01003424timeout http-request <timeout>
3425 Set the maximum allowed time to wait for a complete HTTP request
3426 May be used in sections : defaults | frontend | listen | backend
3427 yes | yes | yes | no
3428 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003429 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau036fae02008-01-06 13:24:40 +01003430 can be in any other unit if the number is suffixed by the unit,
3431 as explained at the top of this document.
3432
3433 In order to offer DoS protection, it may be required to lower the maximum
3434 accepted time to receive a complete HTTP request without affecting the client
3435 timeout. This helps protecting against established connections on which
3436 nothing is sent. The client timeout cannot offer a good protection against
3437 this abuse because it is an inactivity timeout, which means that if the
3438 attacker sends one character every now and then, the timeout will not
3439 trigger. With the HTTP request timeout, no matter what speed the client
3440 types, the request will be aborted if it does not complete in time.
3441
3442 Note that this timeout only applies to the header part of the request, and
3443 not to any data. As soon as the empty line is received, this timeout is not
3444 used anymore.
3445
3446 Generally it is enough to set it to a few seconds, as most clients send the
3447 full request immediately upon connection. Add 3 or more seconds to cover TCP
3448 retransmits but that's all. Setting it to very low values (eg: 50 ms) will
3449 generally work on local networks as long as there are no packet losses. This
3450 will prevent people from sending bare HTTP requests using telnet.
3451
3452 If this parameter is not set, the client timeout still applies between each
3453 chunk of the incoming request.
3454
3455 See also : "timeout client".
3456
Willy Tarreau844e3c52008-01-11 16:28:18 +01003457
3458timeout queue <timeout>
3459 Set the maximum time to wait in the queue for a connection slot to be free
3460 May be used in sections : defaults | frontend | listen | backend
3461 yes | no | yes | yes
3462 Arguments :
3463 <timeout> is the timeout value specified in milliseconds by default, but
3464 can be in any other unit if the number is suffixed by the unit,
3465 as explained at the top of this document.
3466
3467 When a server's maxconn is reached, connections are left pending in a queue
3468 which may be server-specific or global to the backend. In order not to wait
3469 indefinitely, a timeout is applied to requests pending in the queue. If the
3470 timeout is reached, it is considered that the request will almost never be
3471 served, so it is dropped and a 503 error is returned to the client.
3472
3473 The "timeout queue" statement allows to fix the maximum time for a request to
3474 be left pending in a queue. If unspecified, the same value as the backend's
3475 connection timeout ("timeout connect") is used, for backwards compatibility
3476 with older versions with no "timeout queue" parameter.
3477
3478 See also : "timeout connect", "contimeout".
3479
3480
3481timeout server <timeout>
3482timeout srvtimeout <timeout> (deprecated)
3483 Set the maximum inactivity time on the server side.
3484 May be used in sections : defaults | frontend | listen | backend
3485 yes | no | yes | yes
3486 Arguments :
3487 <timeout> is the timeout value specified in milliseconds by default, but
3488 can be in any other unit if the number is suffixed by the unit,
3489 as explained at the top of this document.
3490
3491 The inactivity timeout applies when the server is expected to acknowledge or
3492 send data. In HTTP mode, this timeout is particularly important to consider
3493 during the first phase of the server's response, when it has to send the
3494 headers, as it directly represents the server's processing time for the
3495 request. To find out what value to put there, it's often good to start with
3496 what would be considered as unacceptable response times, then check the logs
3497 to observe the response time distribution, and adjust the value accordingly.
3498
3499 The value is specified in milliseconds by default, but can be in any other
3500 unit if the number is suffixed by the unit, as specified at the top of this
3501 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
3502 recommended that the client timeout remains equal to the server timeout in
3503 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003504 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01003505 packet losses by specifying timeouts that are slightly above multiples of 3
3506 seconds (eg: 4 or 5 seconds minimum).
3507
3508 This parameter is specific to backends, but can be specified once for all in
3509 "defaults" sections. This is in fact one of the easiest solutions not to
3510 forget about it. An unspecified timeout results in an infinite timeout, which
3511 is not recommended. Such a usage is accepted and works but reports a warning
3512 during startup because it may results in accumulation of expired sessions in
3513 the system if the system's timeouts are not configured either.
3514
3515 This parameter replaces the old, deprecated "srvtimeout". It is recommended
3516 to use it to write new configurations. The form "timeout srvtimeout" is
3517 provided only by backwards compatibility but its use is strongly discouraged.
3518
3519 See also : "srvtimeout", "timeout client".
3520
3521
3522timeout tarpit <timeout>
3523 Set the duration for which tapitted connections will be maintained
3524 May be used in sections : defaults | frontend | listen | backend
3525 yes | yes | yes | yes
3526 Arguments :
3527 <timeout> is the tarpit duration specified in milliseconds by default, but
3528 can be in any other unit if the number is suffixed by the unit,
3529 as explained at the top of this document.
3530
3531 When a connection is tarpitted using "reqtarpit", it is maintained open with
3532 no activity for a certain amount of time, then closed. "timeout tarpit"
3533 defines how long it will be maintained open.
3534
3535 The value is specified in milliseconds by default, but can be in any other
3536 unit if the number is suffixed by the unit, as specified at the top of this
3537 document. If unspecified, the same value as the backend's connection timeout
3538 ("timeout connect") is used, for backwards compatibility with older versions
3539 with no "timeout tapit" parameter.
3540
3541 See also : "timeout connect", "contimeout".
3542
3543
3544transparent (deprecated)
3545 Enable client-side transparent proxying
3546 May be used in sections : defaults | frontend | listen | backend
3547 yes | yes | yes | no
3548 Arguments : none
3549
3550 This keyword was introduced in order to provide layer 7 persistence to layer
3551 3 load balancers. The idea is to use the OS's ability to redirect an incoming
3552 connection for a remote address to a local process (here HAProxy), and let
3553 this process know what address was initially requested. When this option is
3554 used, sessions without cookies will be forwarded to the original destination
3555 IP address of the incoming request (which should match that of another
3556 equipment), while requests with cookies will still be forwarded to the
3557 appropriate server.
3558
3559 The "transparent" keyword is deprecated, use "option transparent" instead.
3560
3561 Note that contrary to a common belief, this option does NOT make HAProxy
3562 present the client's IP to the server when establishing the connection.
3563
3564 Use of this option is really discouraged, and since no really valid use of it
3565 has been reported for years, it will probably be removed in future versions.
3566
3567 See also: "option transparent"
3568
3569
3570use_backend <backend> if <condition>
3571use_backend <backend> unless <condition>
3572 Switch to a specific backend if/unless a Layer 7 condition is matched.
3573 May be used in sections : defaults | frontend | listen | backend
3574 no | yes | yes | no
3575 Arguments :
3576 <backend> is the name of a valid backend or "listen" section.
3577
3578 <condition> is a condition composed of ACLs, as described in section 2.3.
3579
3580 When doing content-switching, connections arrive on a frontend and are then
3581 dispatched to various backends depending on a number of conditions. The
3582 relation between the conditions and the backends is described with the
3583 "use_backend" keyword. This is supported only in HTTP mode.
3584
3585 There may be as many "use_backend" rules as desired. All of these rules are
3586 evaluated in their declaration order, and the first one which matches will
3587 assign the backend.
3588
3589 In the first form, the backend will be used if the condition is met. In the
3590 second form, the backend will be used if the condition is not met. If no
3591 condition is valid, the backend defined with "default_backend" will be used.
3592 If no default backend is defined, either the servers in the same section are
3593 used (in case of a "listen" section) or, in case of a frontend, no server is
3594 used and a 503 service unavailable response is returned.
3595
3596 See also: "default_backend" and section 2.3 about ACLs.
3597
Willy Tarreau036fae02008-01-06 13:24:40 +01003598
Willy Tarreau0ba27502007-12-24 16:55:16 +010035992.3) Using ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003600---------------
3601
3602The use of Access Control Lists (ACL) provides a flexible solution to perform
Willy Tarreau0ba27502007-12-24 16:55:16 +01003603content switching and generally to take decisions based on content extracted
3604from the request, the response or any environmental status. The principle is
3605simple :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003606
3607 - define test criteria with sets of values
3608 - perform actions only if a set of tests is valid
3609
3610The actions generally consist in blocking the request, or selecting a backend.
3611
3612In order to define a test, the "acl" keyword is used. The syntax is :
3613
3614 acl <aclname> <criterion> [flags] [operator] <value> ...
3615
Willy Tarreau0ba27502007-12-24 16:55:16 +01003616This creates a new ACL <aclname> or completes an existing one with new tests.
3617Those tests apply to the portion of request/response specified in <criterion>
Willy Tarreau6a06a402007-07-15 20:15:28 +02003618and may be adjusted with optional flags [flags]. Some criteria also support
3619an operator which may be specified before the set of values. The values are
3620of the type supported by the criterion, and are separated by spaces.
3621
Willy Tarreau0ba27502007-12-24 16:55:16 +01003622ACL names must be formed from upper and lower case letters, digits, '-' (dash),
3623'_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive,
3624which means that "my_acl" and "My_Acl" are two different ACLs.
3625
3626There is no enforced limit to the number of ACLs. The unused ones do not affect
Willy Tarreau6a06a402007-07-15 20:15:28 +02003627performance, they just consume a small amount of memory.
3628
Willy Tarreau0ba27502007-12-24 16:55:16 +01003629The following ACL flags are currently supported :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003630
3631 -i : ignore case during matching.
3632 -- : force end of flags. Useful when a string looks like one of the flags.
3633
3634Supported types of values are :
Willy Tarreau0ba27502007-12-24 16:55:16 +01003635
Willy Tarreau6a06a402007-07-15 20:15:28 +02003636 - integers or integer ranges
3637 - strings
3638 - regular expressions
3639 - IP addresses and networks
3640
3641
Willy Tarreau0ba27502007-12-24 16:55:16 +010036422.3.1) Matching integers
Willy Tarreau6a06a402007-07-15 20:15:28 +02003643------------------------
3644
3645Matching integers is special in that ranges and operators are permitted. Note
3646that integer matching only applies to positive values. A range is a value
3647expressed with a lower and an upper bound separated with a colon, both of which
3648may be omitted.
3649
3650For instance, "1024:65535" is a valid range to represent a range of
3651unprivileged ports, and "1024:" would also work. "0:1023" is a valid
3652representation of privileged ports, and ":1023" would also work.
3653
Willy Tarreau62644772008-07-16 18:36:06 +02003654As a special case, some ACL functions support decimal numbers which are in fact
3655two integers separated by a dot. This is used with some version checks for
3656instance. All integer properties apply to those decimal numbers, including
3657ranges and operators.
3658
Willy Tarreau6a06a402007-07-15 20:15:28 +02003659For an easier usage, comparison operators are also supported. Note that using
Willy Tarreau0ba27502007-12-24 16:55:16 +01003660operators with ranges does not make much sense and is strongly discouraged.
3661Similarly, it does not make much sense to perform order comparisons with a set
3662of values.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003663
Willy Tarreau0ba27502007-12-24 16:55:16 +01003664Available operators for integer matching are :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003665
3666 eq : true if the tested value equals at least one value
3667 ge : true if the tested value is greater than or equal to at least one value
3668 gt : true if the tested value is greater than at least one value
3669 le : true if the tested value is less than or equal to at least one value
3670 lt : true if the tested value is less than at least one value
3671
Willy Tarreau0ba27502007-12-24 16:55:16 +01003672For instance, the following ACL matches any negative Content-Length header :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003673
3674 acl negative-length hdr_val(content-length) lt 0
3675
Willy Tarreau62644772008-07-16 18:36:06 +02003676This one matches SSL versions between 3.0 and 3.1 (inclusive) :
3677
3678 acl sslv3 req_ssl_ver 3:3.1
3679
Willy Tarreau6a06a402007-07-15 20:15:28 +02003680
Willy Tarreau0ba27502007-12-24 16:55:16 +010036812.3.2) Matching strings
Willy Tarreau6a06a402007-07-15 20:15:28 +02003682-----------------------
3683
3684String matching applies to verbatim strings as they are passed, with the
3685exception of the backslash ("\") which makes it possible to escape some
3686characters such as the space. If the "-i" flag is passed before the first
3687string, then the matching will be performed ignoring the case. In order
3688to match the string "-i", either set it second, or pass the "--" flag
Willy Tarreau0ba27502007-12-24 16:55:16 +01003689before the first string. Same applies of course to match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003690
3691
Willy Tarreau0ba27502007-12-24 16:55:16 +010036922.3.3) Matching regular expressions (regexes)
Willy Tarreau6a06a402007-07-15 20:15:28 +02003693---------------------------------------------
3694
3695Just like with string matching, regex matching applies to verbatim strings as
3696they are passed, with the exception of the backslash ("\") which makes it
3697possible to escape some characters such as the space. If the "-i" flag is
3698passed before the first regex, then the matching will be performed ignoring
3699the case. In order to match the string "-i", either set it second, or pass
Willy Tarreau0ba27502007-12-24 16:55:16 +01003700the "--" flag before the first string. Same principle applies of course to
3701match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003702
3703
Willy Tarreau0ba27502007-12-24 16:55:16 +010037042.3.4) Matching IPv4 addresses
3705------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02003706
3707IPv4 addresses values can be specified either as plain addresses or with a
3708netmask appended, in which case the IPv4 address matches whenever it is
3709within the network. Plain addresses may also be replaced with a resolvable
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003710host name, but this practice is generally discouraged as it makes it more
Willy Tarreau0ba27502007-12-24 16:55:16 +01003711difficult to read and debug configurations. If hostnames are used, you should
3712at least ensure that they are present in /etc/hosts so that the configuration
3713does not depend on any random DNS match at the moment the configuration is
3714parsed.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003715
3716
Willy Tarreau0ba27502007-12-24 16:55:16 +010037172.3.5) Available matching criteria
Willy Tarreau6a06a402007-07-15 20:15:28 +02003718----------------------------------
3719
Willy Tarreau0ba27502007-12-24 16:55:16 +010037202.3.5.1) Matching at Layer 4 and below
3721--------------------------------------
3722
3723A first set of criteria applies to information which does not require any
3724analysis of the request or response contents. Those generally include TCP/IP
3725addresses and ports, as well as internal values independant on the stream.
3726
Willy Tarreau6a06a402007-07-15 20:15:28 +02003727always_false
3728 This one never matches. All values and flags are ignored. It may be used as
3729 a temporary replacement for another one when adjusting configurations.
3730
3731always_true
3732 This one always matches. All values and flags are ignored. It may be used as
3733 a temporary replacement for another one when adjusting configurations.
3734
3735src <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003736 Applies to the client's IPv4 address. It is usually used to limit access to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003737 certain resources such as statistics. Note that it is the TCP-level source
3738 address which is used, and not the address of a client behind a proxy.
3739
3740src_port <integer>
3741 Applies to the client's TCP source port. This has a very limited usage.
3742
3743dst <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003744 Applies to the local IPv4 address the client connected to. It can be used to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003745 switch to a different backend for some alternative addresses.
3746
3747dst_port <integer>
3748 Applies to the local port the client connected to. It can be used to switch
3749 to a different backend for some alternative ports.
3750
3751dst_conn <integer>
3752 Applies to the number of currently established connections on the frontend,
3753 including the one being evaluated. It can be used to either return a sorry
Willy Tarreau0ba27502007-12-24 16:55:16 +01003754 page before hard-blocking, or to use a specific backend to drain new requests
Willy Tarreau6a06a402007-07-15 20:15:28 +02003755 when the farm is considered saturated.
3756
Willy Tarreau0ba27502007-12-24 16:55:16 +01003757nbsrv <integer>
3758nbsrv(backend) <integer>
3759 Returns true when the number of usable servers of either the current backend
3760 or the named backend matches the values or ranges specified. This is used to
3761 switch to an alternate backend when the number of servers is too low to
3762 to handle some load. It is useful to report a failure when combined with
3763 "monitor fail".
3764
3765
Willy Tarreau62644772008-07-16 18:36:06 +020037662.3.5.2) Matching contents at Layer 4
3767-------------------------------------
3768
3769A second set of criteria depends on data found in buffers, but which can change
3770during analysis. This requires that some data has been buffered, for instance
3771through TCP request content inspection. Please see the "tcp-request" keyword
3772for more detailed information on the subject.
3773
3774req_len <integer>
3775 Returns true when the lenght of the data in the request buffer matches the
3776 specified range. It is important to understand that this test does not
3777 return false as long as the buffer is changing. This means that a check with
3778 equality to zero will almost always immediately match at the beginning of the
3779 session, while a test for more data will wait for that data to come in and
3780 return false only when haproxy is certain that no more data will come in.
3781 This test was designed to be used with TCP request content inspection.
3782
3783req_ssl_ver <decimal>
3784 Returns true when data in the request buffer look like SSL, with a protocol
3785 version matching the specified range. Both SSLv2 hello messages and SSLv3
3786 messages are supported. The test tries to be strict enough to avoid being
3787 easily fooled. In particular, it waits for as many bytes as announced in the
3788 message header if this header looks valid (bound to the buffer size). Note
3789 that TLSv1 is announced as SSL version 3.1. This test was designed to be used
3790 with TCP request content inspection.
3791
Willy Tarreaub6fb4202008-07-20 11:18:28 +02003792wait_end
3793 Waits for the end of the analysis period to return true. This may be used in
3794 conjunction with content analysis to avoid returning a wrong verdict early.
3795 It may also be used to delay some actions, such as a delayed reject for some
3796 special addresses. Since it either stops the rules evaluation or immediately
3797 returns true, it is recommended to use this acl as the last one in a rule.
3798 Please note that the default ACL "WAIT_END" is always usable without prior
3799 declaration. This test was designed to be used with TCP request content
3800 inspection.
3801
3802 Examples :
3803 # delay every incoming request by 2 seconds
3804 tcp-request inspect-delay 2s
3805 tcp-request content accept if WAIT_END
3806
3807 # don't immediately tell bad guys they are rejected
3808 tcp-request inspect-delay 10s
3809 acl goodguys src 10.0.0.0/24
3810 acl badguys src 10.0.1.0/24
3811 tcp-request content accept if goodguys
3812 tcp-request content reject if badguys WAIT_END
3813 tcp-request content reject
3814
Willy Tarreau62644772008-07-16 18:36:06 +02003815
38162.3.5.3) Matching at Layer 7
Willy Tarreau0ba27502007-12-24 16:55:16 +01003817----------------------------
3818
Willy Tarreau62644772008-07-16 18:36:06 +02003819A third set of criteria applies to information which can be found at the
Willy Tarreau0ba27502007-12-24 16:55:16 +01003820application layer (layer 7). Those require that a full HTTP request has been
3821read, and are only evaluated then. They may require slightly more CPU resources
3822than the layer 4 ones, but not much since the request and response are indexed.
3823
Willy Tarreau6a06a402007-07-15 20:15:28 +02003824method <string>
3825 Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
3826 already check for most common methods.
3827
3828req_ver <string>
3829 Applies to the version string in the HTTP request, eg: "1.0". Some predefined
3830 ACL already check for versions 1.0 and 1.1.
3831
3832path <string>
3833 Returns true when the path part of the request, which starts at the first
3834 slash and ends before the question mark, equals one of the strings. It may be
3835 used to match known files, such as /favicon.ico.
3836
3837path_beg <string>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003838 Returns true when the path begins with one of the strings. This can be used
3839 to send certain directory names to alternative backends.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003840
3841path_end <string>
3842 Returns true when the path ends with one of the strings. This may be used to
3843 control file name extension.
3844
3845path_sub <string>
3846 Returns true when the path contains one of the strings. It can be used to
3847 detect particular patterns in paths, such as "../" for example. See also
3848 "path_dir".
3849
3850path_dir <string>
3851 Returns true when one of the strings is found isolated or delimited with
3852 slashes in the path. This is used to perform filename or directory name
3853 matching without the risk of wrong match due to colliding prefixes. See also
3854 "url_dir" and "path_sub".
3855
3856path_dom <string>
3857 Returns true when one of the strings is found isolated or delimited with dots
3858 in the path. This may be used to perform domain name matching in proxy
3859 requests. See also "path_sub" and "url_dom".
3860
3861path_reg <regex>
3862 Returns true when the path matches one of the regular expressions. It can be
3863 used any time, but it is important to remember that regex matching is slower
3864 than other methods. See also "url_reg" and all "path_" criteria.
3865
3866url <string>
3867 Applies to the whole URL passed in the request. The only real use is to match
3868 "*", for which there already is a predefined ACL.
3869
3870url_beg <string>
3871 Returns true when the URL begins with one of the strings. This can be used to
3872 check whether a URL begins with a slash or with a protocol scheme.
3873
3874url_end <string>
3875 Returns true when the URL ends with one of the strings. It has very limited
3876 use. "path_end" should be used instead for filename matching.
3877
3878url_sub <string>
3879 Returns true when the URL contains one of the strings. It can be used to
3880 detect particular patterns in query strings for example. See also "path_sub".
3881
3882url_dir <string>
3883 Returns true when one of the strings is found isolated or delimited with
3884 slashes in the URL. This is used to perform filename or directory name
3885 matching without the risk of wrong match due to colliding prefixes. See also
3886 "path_dir" and "url_sub".
3887
3888url_dom <string>
3889 Returns true when one of the strings is found isolated or delimited with dots
3890 in the URL. This is used to perform domain name matching without the risk of
3891 wrong match due to colliding prefixes. See also "url_sub".
3892
3893url_reg <regex>
3894 Returns true when the URL matches one of the regular expressions. It can be
3895 used any time, but it is important to remember that regex matching is slower
3896 than other methods. See also "path_reg" and all "url_" criteria.
3897
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003898url_ip <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003899 Applies to the IP address specified in the absolute URI in an HTTP request.
3900 It can be used to prevent access to certain resources such as local network.
Willy Tarreau198a7442008-01-17 12:05:32 +01003901 It is useful with option "http_proxy".
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003902
3903url_port <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003904 Applies to the port specified in the absolute URI in an HTTP request. It can
3905 be used to prevent access to certain resources. It is useful with option
Willy Tarreau198a7442008-01-17 12:05:32 +01003906 "http_proxy". Note that if the port is not specified in the request, port 80
Willy Tarreau0ba27502007-12-24 16:55:16 +01003907 is assumed.
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003908
Willy Tarreau6a06a402007-07-15 20:15:28 +02003909hdr <string>
3910hdr(header) <string>
3911 Note: all the "hdr*" matching criteria either apply to all headers, or to a
3912 particular header whose name is passed between parenthesis and without any
Willy Tarreau0ba27502007-12-24 16:55:16 +01003913 space. The header name is not case-sensitive. The header matching complies
3914 with RFC2616, and treats as separate headers all values delimited by commas.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003915
3916 The "hdr" criteria returns true if any of the headers matching the criteria
Willy Tarreau0ba27502007-12-24 16:55:16 +01003917 match any of the strings. This can be used to check exact for values. For
Willy Tarreau6a06a402007-07-15 20:15:28 +02003918 instance, checking that "connection: close" is set :
3919
3920 hdr(Connection) -i close
3921
3922hdr_beg <string>
3923hdr_beg(header) <string>
3924 Returns true when one of the headers begins with one of the strings. See
3925 "hdr" for more information on header matching.
3926
3927hdr_end <string>
3928hdr_end(header) <string>
3929 Returns true when one of the headers ends with one of the strings. See "hdr"
3930 for more information on header matching.
3931
3932hdr_sub <string>
3933hdr_sub(header) <string>
3934 Returns true when one of the headers contains one of the strings. See "hdr"
3935 for more information on header matching.
3936
3937hdr_dir <string>
3938hdr_dir(header) <string>
3939 Returns true when one of the headers contains one of the strings either
3940 isolated or delimited by slashes. This is used to perform filename or
3941 directory name matching, and may be used with Referer. See "hdr" for more
3942 information on header matching.
3943
3944hdr_dom <string>
3945hdr_dom(header) <string>
3946 Returns true when one of the headers contains one of the strings either
3947 isolated or delimited by dots. This is used to perform domain name matching,
3948 and may be used with the Host header. See "hdr" for more information on
3949 header matching.
3950
3951hdr_reg <regex>
3952hdr_reg(header) <regex>
3953 Returns true when one of the headers matches of the regular expressions. It
3954 can be used at any time, but it is important to remember that regex matching
3955 is slower than other methods. See also other "hdr_" criteria, as well as
3956 "hdr" for more information on header matching.
3957
3958hdr_val <integer>
3959hdr_val(header) <integer>
3960 Returns true when one of the headers starts with a number which matches the
3961 values or ranges specified. This may be used to limit content-length to
3962 acceptable values for example. See "hdr" for more information on header
3963 matching.
3964
3965hdr_cnt <integer>
3966hdr_cnt(header) <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003967 Returns true when the number of occurrence of the specified header matches
3968 the values or ranges specified. It is important to remember that one header
3969 line may count as several headers if it has several values. This is used to
3970 detect presence, absence or abuse of a specific header, as well as to block
3971 request smugling attacks by rejecting requests which contain more than one
3972 of certain headers. See "hdr" for more information on header matching.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003973
3974
Willy Tarreau0ba27502007-12-24 16:55:16 +010039752.3.6) Pre-defined ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003976-----------------------
3977
3978Some predefined ACLs are hard-coded so that they do not have to be declared in
3979every frontend which needs them. They all have their names in upper case in
Willy Tarreau0ba27502007-12-24 16:55:16 +01003980order to avoid confusion. Their equivalence is provided below. Please note that
3981only the first three ones are not layer 7 based.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003982
3983ACL name Equivalent to Usage
3984---------------+-----------------------------+---------------------------------
Willy Tarreau58393e12008-07-20 10:39:22 +02003985TRUE always_true always match
3986FALSE always_false never match
Willy Tarreau6a06a402007-07-15 20:15:28 +02003987LOCALHOST src 127.0.0.1/8 match connection from local host
3988HTTP_1.0 req_ver 1.0 match HTTP version 1.0
3989HTTP_1.1 req_ver 1.1 match HTTP version 1.1
3990METH_CONNECT method CONNECT match HTTP CONNECT method
3991METH_GET method GET HEAD match HTTP GET or HEAD method
3992METH_HEAD method HEAD match HTTP HEAD method
3993METH_OPTIONS method OPTIONS match HTTP OPTIONS method
3994METH_POST method POST match HTTP POST method
3995METH_TRACE method TRACE match HTTP TRACE method
3996HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
3997HTTP_URL_SLASH url_beg / match URL begining with "/"
3998HTTP_URL_STAR url * match URL equal to "*"
3999HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
Willy Tarreauc6317702008-07-20 09:29:50 +02004000REQ_CONTENT req_len gt 0 match data in the request buffer
Willy Tarreaub6fb4202008-07-20 11:18:28 +02004001WAIT_END wait_end wait for end of content analysis
Willy Tarreau6a06a402007-07-15 20:15:28 +02004002---------------+-----------------------------+---------------------------------
4003
4004
Willy Tarreau0ba27502007-12-24 16:55:16 +010040052.3.7) Using ACLs to form conditions
Willy Tarreau6a06a402007-07-15 20:15:28 +02004006------------------------------------
4007
4008Some actions are only performed upon a valid condition. A condition is a
4009combination of ACLs with operators. 3 operators are supported :
4010
4011 - AND (implicit)
4012 - OR (explicit with the "or" keyword or the "||" operator)
4013 - Negation with the exclamation mark ("!")
4014
4015A condition is formed as a disjonctive form :
4016
4017 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
4018
4019Such conditions are generally used after an "if" or "unless" statement,
4020indicating when the condition will trigger the action.
4021
4022For instance, to block HTTP requests to the "*" URL with methods other than
Willy Tarreau0ba27502007-12-24 16:55:16 +01004023"OPTIONS", as well as POST requests without content-length, and GET or HEAD
4024requests with a content-length greater than 0, and finally every request which
4025is not either GET/HEAD/POST/OPTIONS !
Willy Tarreau6a06a402007-07-15 20:15:28 +02004026
4027 acl missing_cl hdr_cnt(Content-length) eq 0
4028 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
4029 block if METH_GET HTTP_CONTENT
4030 block unless METH_GET or METH_POST or METH_OPTIONS
4031
4032To select a different backend for requests to static contents on the "www" site
4033and to every request on the "img", "video", "download" and "ftp" hosts :
4034
4035 acl url_static path_beg /static /images /img /css
4036 acl url_static path_end .gif .png .jpg .css .js
4037 acl host_www hdr_beg(host) -i www
4038 acl host_static hdr_beg(host) -i img. video. download. ftp.
4039
4040 # now use backend "static" for all static-only hosts, and for static urls
4041 # of host "www". Use backend "www" for the rest.
4042 use_backend static if host_static or host_www url_static
4043 use_backend www if host_www
4044
Willy Tarreau844e3c52008-01-11 16:28:18 +01004045See section 2.2 for detailed help on the "block" and "use_backend" keywords.
Willy Tarreaudbc36f62007-11-30 12:29:11 +01004046
4047
Willy Tarreauc7246fc2007-12-02 17:31:20 +010040482.4) Server options
Willy Tarreau5764b382007-11-30 17:46:49 +01004049-------------------
4050
Willy Tarreau198a7442008-01-17 12:05:32 +01004051The "server" keyword supports a certain number of settings which are all passed
4052as arguments on the server line. The order in which those arguments appear does
4053not count, and they are all optional. Some of those settings are single words
4054(booleans) while others expect one or several values after them. In this case,
4055the values must immediately follow the setting name. All those settings must be
4056specified after the server's address if they are used :
4057
4058 server <name> <address>[:port] [settings ...]
4059
4060The currently supported settings are the following ones.
4061
4062addr <ipv4>
4063 Using the "addr" parameter, it becomes possible to use a different IP address
4064 to send health-checks. On some servers, it may be desirable to dedicate an IP
4065 address to specific component able to perform complex tests which are more
4066 suitable to health-checks than the application. This parameter is ignored if
4067 the "check" parameter is not set. See also the "port" parameter.
4068
4069backup
4070 When "backup" is present on a server line, the server is only used in load
4071 balancing when all other non-backup servers are unavailable. Requests coming
4072 with a persistence cookie referencing the server will always be served
4073 though. By default, only the first operational backup server is used, unless
Willy Tarreauaf85d942008-01-30 10:47:10 +01004074 the "allbackups" option is set in the backend. See also the "allbackups"
Willy Tarreau198a7442008-01-17 12:05:32 +01004075 option.
4076
4077check
4078 This option enables health checks on the server. By default, a server is
4079 always considered available. If "check" is set, the server will receive
4080 periodic health checks to ensure that it is really able to serve requests.
4081 The default address and port to send the tests to are those of the server,
4082 and the default source is the same as the one defined in the backend. It is
4083 possible to change the address using the "addr" parameter, the port using the
4084 "port" parameter, the source address using the "source" address, and the
4085 interval and timers using the "inter", "rise" and "fall" parameters. The
4086 request method is define in the backend using the "httpchk", "smtpchk",
4087 and "ssl-hello-chk" options. Please refer to those options and parameters for
4088 more information.
4089
4090cookie <value>
4091 The "cookie" parameter sets the cookie value assigned to the server to
4092 <value>. This value will be checked in incoming requests, and the first
4093 operational server possessing the same value will be selected. In return, in
4094 cookie insertion or rewrite modes, this value will be assigned to the cookie
4095 sent to the client. There is nothing wrong in having several servers sharing
4096 the same cookie value, and it is in fact somewhat common between normal and
4097 backup servers. See also the "cookie" keyword in backend section.
4098
4099fall <count>
4100 The "fall" parameter states that a server will be considered as dead after
4101 <count> consecutive unsuccessful health checks. This value defaults to 3 if
4102 unspecified. See also the "check", "inter" and "rise" parameters.
4103
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004104id <value>
4105 Set a persistent value for server ID. Must be unique and larger than 1000, as
4106 smaller values are reserved for auto-assigned ids.
4107
Willy Tarreau198a7442008-01-17 12:05:32 +01004108inter <delay>
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01004109fastinter <delay>
4110downinter <delay>
Willy Tarreau198a7442008-01-17 12:05:32 +01004111 The "inter" parameter sets the interval between two consecutive health checks
4112 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01004113 It is also possible to use "fastinter" and "downinter" to optimize delays
Willy Tarreau41a340d2008-01-22 12:25:31 +01004114 between checks depending on the server state :
4115
4116 Server state | Interval used
4117 ---------------------------------+-----------------------------------------
4118 UP 100% (non-transitional) | "inter"
4119 ---------------------------------+-----------------------------------------
4120 Transitionally UP (going down), |
4121 Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise.
4122 or yet unchecked. |
4123 ---------------------------------+-----------------------------------------
4124 DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise.
4125 ---------------------------------+-----------------------------------------
4126
4127 Just as with every other time-based parameter, they can be entered in any
4128 other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also
4129 serves as a timeout for health checks sent to servers if "timeout check" is
4130 not set. In order to reduce "resonance" effects when multiple servers are
4131 hosted on the same hardware, the health-checks of all servers are started
4132 with a small time offset between them. It is also possible to add some random
4133 noise in the health checks interval using the global "spread-checks"
4134 keyword. This makes sense for instance when a lot of backends use the same
4135 servers.
Willy Tarreau198a7442008-01-17 12:05:32 +01004136
4137maxconn <maxconn>
4138 The "maxconn" parameter specifies the maximal number of concurrent
4139 connections that will be sent to this server. If the number of incoming
4140 concurrent requests goes higher than this value, they will be queued, waiting
4141 for a connection to be released. This parameter is very important as it can
4142 save fragile servers from going down under extreme loads. If a "minconn"
4143 parameter is specified, the limit becomes dynamic. The default value is "0"
4144 which means unlimited. See also the "minconn" and "maxqueue" parameters, and
4145 the backend's "fullconn" keyword.
4146
4147maxqueue <maxqueue>
4148 The "maxqueue" parameter specifies the maximal number of connections which
4149 will wait in the queue for this server. If this limit is reached, next
4150 requests will be redispatched to other servers instead of indefinitely
4151 waiting to be served. This will break persistence but may allow people to
4152 quickly re-log in when the server they try to connect to is dying. The
4153 default value is "0" which means the queue is unlimited. See also the
4154 "maxconn" and "minconn" parameters.
4155
4156minconn <minconn>
4157 When the "minconn" parameter is set, the maxconn limit becomes a dynamic
4158 limit following the backend's load. The server will always accept at least
4159 <minconn> connections, never more than <maxconn>, and the limit will be on
4160 the ramp between both values when the backend has less than <fullconn>
4161 concurrent connections. This makes it possible to limit the load on the
4162 server during normal loads, but push it further for important loads without
4163 overloading the server during exceptionnal loads. See also the "maxconn"
4164 and "maxqueue" parameters, as well as the "fullconn" backend keyword.
4165
4166port <port>
4167 Using the "port" parameter, it becomes possible to use a different port to
4168 send health-checks. On some servers, it may be desirable to dedicate a port
4169 to a specific component able to perform complex tests which are more suitable
4170 to health-checks than the application. It is common to run a simple script in
4171 inetd for instance. This parameter is ignored if the "check" parameter is not
4172 set. See also the "addr" parameter.
4173
Willy Tarreau21d2af32008-02-14 20:25:24 +01004174redir <prefix>
4175 The "redir" parameter enables the redirection mode for all GET and HEAD
4176 requests addressing this server. This means that instead of having HAProxy
4177 forward the request to the server, it will send an "HTTP 302" response with
4178 the "Location" header composed of this prefix immediately followed by the
4179 requested URI beginning at the leading '/' of the path component. That means
4180 that no trailing slash should be used after <prefix>. All invalid requests
4181 will be rejected, and all non-GET or HEAD requests will be normally served by
4182 the server. Note that since the response is completely forged, no header
4183 mangling nor cookie insertion is possible in the respose. However, cookies in
4184 requests are still analysed, making this solution completely usable to direct
4185 users to a remote location in case of local disaster. Main use consists in
4186 increasing bandwidth for static servers by having the clients directly
4187 connect to them. Note: never use a relative location here, it would cause a
4188 loop between the client and HAProxy!
4189
4190 Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check
4191
Willy Tarreau198a7442008-01-17 12:05:32 +01004192rise <count>
4193 The "rise" parameter states that a server will be considered as operational
4194 after <count> consecutive successful health checks. This value defaults to 2
4195 if unspecified. See also the "check", "inter" and "fall" parameters.
4196
Willy Tarreau5764b382007-11-30 17:46:49 +01004197slowstart <start_time_in_ms>
Willy Tarreau198a7442008-01-17 12:05:32 +01004198 The "slowstart" parameter for a server accepts a value in milliseconds which
Willy Tarreau5764b382007-11-30 17:46:49 +01004199 indicates after how long a server which has just come back up will run at
Willy Tarreaubefdff12007-12-02 22:27:38 +01004200 full speed. Just as with every other time-based parameter, it can be entered
4201 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
4202 linearly from 0 to 100% during this time. The limitation applies to two
4203 parameters :
Willy Tarreau5764b382007-11-30 17:46:49 +01004204
4205 - maxconn: the number of connections accepted by the server will grow from 1
4206 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
4207
4208 - weight: when the backend uses a dynamic weighted algorithm, the weight
4209 grows linearly from 1 to 100%. In this case, the weight is updated at every
Willy Tarreau198a7442008-01-17 12:05:32 +01004210 health-check. For this reason, it is important that the "inter" parameter
4211 is smaller than the "slowstart", in order to maximize the number of steps.
Willy Tarreau5764b382007-11-30 17:46:49 +01004212
4213 The slowstart never applies when haproxy starts, otherwise it would cause
4214 trouble to running servers. It only applies when a server has been previously
4215 seen as failed.
4216
Willy Tarreau198a7442008-01-17 12:05:32 +01004217source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
4218 The "source" parameter sets the source address which will be used when
4219 connecting to the server. It follows the exact same parameters and principle
4220 as the backend "source" keyword, except that it only applies to the server
4221 referencing it. Please consult the "source" keyword for details.
4222
Krzysztof Piotr Oledzkic8b16fc2008-02-18 01:26:35 +01004223track [<proxy>/]<server>
4224 This option enables ability to set the current state of the server by
4225 tracking another one. Only a server with checks enabled can be tracked
4226 so it is not possible for example to track a server that tracks another
4227 one. If <proxy> is omitted the current one is used. If disable-on-404 is
4228 used, it has to be enabled on both proxies.
4229
Willy Tarreau198a7442008-01-17 12:05:32 +01004230weight <weight>
4231 The "weight" parameter is used to adjust the server's weight relative to
4232 other servers. All servers will receive a load proportional to their weight
4233 relative to the sum of all weights, so the higher the weight, the higher the
4234 load. The default weight is 1, and the maximal value is 255. If this
4235 parameter is used to distribute the load according to server's capacity, it
4236 is recommended to start with values which can both grow and shrink, for
4237 instance between 10 and 100 to leave enough room above and below for later
4238 adjustments.
4239
Willy Tarreauced27012008-01-17 20:35:34 +01004240
42412.5) HTTP header manipulation
4242-----------------------------
4243
4244In HTTP mode, it is possible to rewrite, add or delete some of the request and
4245response headers based on regular expressions. It is also possible to block a
4246request or a response if a particular header matches a regular expression,
4247which is enough to stop most elementary protocol attacks, and to protect
4248against information leak from the internal network. But there is a limitation
4249to this : since HAProxy's HTTP engine does not support keep-alive, only headers
4250passed during the first request of a TCP session will be seen. All subsequent
4251headers will be considered data only and not analyzed. Furthermore, HAProxy
4252never touches data contents, it stops analysis at the end of headers.
4253
4254This section covers common usage of the following keywords, described in detail
4255in section 2.2.1 :
4256
4257 - reqadd <string>
4258 - reqallow <search>
4259 - reqiallow <search>
4260 - reqdel <search>
4261 - reqidel <search>
4262 - reqdeny <search>
4263 - reqideny <search>
4264 - reqpass <search>
4265 - reqipass <search>
4266 - reqrep <search> <replace>
4267 - reqirep <search> <replace>
4268 - reqtarpit <search>
4269 - reqitarpit <search>
4270 - rspadd <string>
4271 - rspdel <search>
4272 - rspidel <search>
4273 - rspdeny <search>
4274 - rspideny <search>
4275 - rsprep <search> <replace>
4276 - rspirep <search> <replace>
4277
4278With all these keywords, the same conventions are used. The <search> parameter
4279is a POSIX extended regular expression (regex) which supports grouping through
4280parenthesis (without the backslash). Spaces and other delimiters must be
4281prefixed with a backslash ('\') to avoid confusion with a field delimiter.
4282Other characters may be prefixed with a backslash to change their meaning :
4283
4284 \t for a tab
4285 \r for a carriage return (CR)
4286 \n for a new line (LF)
4287 \ to mark a space and differentiate it from a delimiter
4288 \# to mark a sharp and differentiate it from a comment
4289 \\ to use a backslash in a regex
4290 \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy)
4291 \xXX to write the ASCII hex code XX as in the C language
4292
4293The <replace> parameter contains the string to be used to replace the largest
4294portion of text matching the regex. It can make use of the special characters
4295above, and can reference a substring which is delimited by parenthesis in the
4296regex, by writing a backslash ('\') immediately followed by one digit from 0 to
Willy Tarreaud2a4aa22008-01-31 15:28:22 +010042979 indicating the group position (0 designating the entire line). This practice
Willy Tarreauced27012008-01-17 20:35:34 +01004298is very common to users of the "sed" program.
4299
4300The <string> parameter represents the string which will systematically be added
4301after the last header line. It can also use special character sequences above.
4302
4303Notes related to these keywords :
4304---------------------------------
4305 - these keywords are not always convenient to allow/deny based on header
4306 contents. It is strongly recommended to use ACLs with the "block" keyword
4307 instead, resulting in far more flexible and manageable rules.
4308
4309 - lines are always considered as a whole. It is not possible to reference
4310 a header name only or a value only. This is important because of the way
4311 headers are written (notably the number of spaces after the colon).
4312
4313 - the first line is always considered as a header, which makes it possible to
4314 rewrite or filter HTTP requests URIs or response codes, but in turn makes
4315 it harder to distinguish between headers and request line. The regex prefix
4316 ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix
4317 ^[^ \t:]*: matches any header name followed by a colon.
4318
4319 - for performances reasons, the number of characters added to a request or to
4320 a response is limited at build time to values between 1 and 4 kB. This
4321 should normally be far more than enough for most usages. If it is too short
4322 on occasional usages, it is possible to gain some space by removing some
4323 useless headers before adding new ones.
4324
4325 - keywords beginning with "reqi" and "rspi" are the same as their couterpart
4326 without the 'i' letter except that they ignore case when matching patterns.
4327
4328 - when a request passes through a frontend then a backend, all req* rules
4329 from the frontend will be evaluated, then all req* rules from the backend
4330 will be evaluated. The reverse path is applied to responses.
4331
4332 - req* statements are applied after "block" statements, so that "block" is
4333 always the first one, but before "use_backend" in order to permit rewriting
4334 before switching.
4335
Willy Tarreau5764b382007-11-30 17:46:49 +01004336
Willy Tarreauced27012008-01-17 20:35:34 +010043372.6) Logging
Willy Tarreau844e3c52008-01-11 16:28:18 +01004338------------
4339
4340[to do]
4341
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +010043422.7) CSV format
4343
4344 0. pxname: proxy name
4345 1. svname: service name (FRONTEND for frontend, BACKEND for backend, any name
4346 for server)
4347 2. qcur: current queued requests
4348 3. qmax: max queued requests
4349 4. scur: current sessions
4350 5. smax: max sessions
4351 6. slim: sessions limit
4352 7. stot: total sessions
4353 8. bin: bytes in
4354 9. bout: bytes out
4355 10. dreq: denied requests
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004356 11. dresp: denied responses
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004357 12. ereq: request errors
4358 13. econ: connection errors
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004359 14. eresp: response errors
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004360 15. wretr: retries (warning)
4361 16. wredis: redispatches (warning)
4362 17. status: status (UP/DOWN/...)
4363 18. weight: server weight (server), total weight (backend)
4364 19. act: server is active (server), number of active servers (backend)
4365 20. bck: server is backup (server), number of backup servers (backend)
4366 21. chkfail: number of failed checks
4367 22. chkdown: number of UP->DOWN transitions
4368 23. lastchg: last status change (in seconds)
4369 24. downtime: total downtime (in seconds)
4370 25. qlimit: queue limit
4371 26. pid: process id (0 for first instance, 1 for second, ...)
4372 27. iid: unique proxy id
4373 28. sid: service id (unique inside a proxy)
4374 29. throttle: warm up status
4375 30. lbtot: total number of times a server was selected
4376 31. tracked: id of proxy/server if tracking is enabled
4377 32. type (0=frontend, 1=backend, 2=server)
Willy Tarreau844e3c52008-01-11 16:28:18 +01004378
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010043792.8) Unix Socket commands
4380
4381 - "show stat [<iid> <type> <sid>]": dump statistics in the cvs format. By
4382 passing id, type and sid it is possible to dump only selected items:
4383 - iid is a proxy id, -1 to dump everything
4384 - type selects type of dumpable objects: 1 for frontend, 2 for backend, 4 for
4385 server, -1 for everything. Values can be ORed, for example:
4386 1+2=3 -> frontend+backend.
4387 1+2+4=7 -> frontend+backend+server.
4388 - sid is a service id, -1 to dump everything from the selected proxy.
4389
4390 - "show info": dump info about current haproxy status.
4391
Willy Tarreau0ba27502007-12-24 16:55:16 +01004392/*
4393 * Local variables:
4394 * fill-column: 79
4395 * End:
4396 */