blob: b2cb48fed676236d9ba037abebec013b95549b3d [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 Tarreau3dfe6cd2008-12-07 22:29:48 +0100154 "show stat" command followed by a line feed, more general process information
155 in response to the "show info" command followed by a line feed, and a
156 complete list of all existing sessions in response to the "show sess" command
157 followed by a line feed.
Willy Tarreaua8efd362008-01-03 10:19:15 +0100158
159 On platforms which support it, it is possible to restrict access to this
160 socket by specifying numerical IDs after "uid" and "gid", or valid user and
161 group names after the "user" and "group" keywords. It is also possible to
162 restrict permissions on the socket by passing an octal value after the "mode"
163 keyword (same syntax as chmod). Depending on the platform, the permissions on
164 the socket will be inherited from the directory which hosts it, or from the
165 user the process is started with.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200166
167stats timeout <timeout, in milliseconds>
168 The default timeout on the stats socket is set to 10 seconds. It is possible
169 to change this value with "stats timeout". The value must be passed in
Willy Tarreaubefdff12007-12-02 22:27:38 +0100170 milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200171
172stats maxconn <connections>
173 By default, the stats socket is limited to 10 concurrent connections. It is
174 possible to change this value with "stats maxconn".
175
Willy Tarreau6a06a402007-07-15 20:15:28 +0200176uid <number>
177 Changes the process' user ID to <number>. It is recommended that the user ID
178 is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
179 be started with superuser privileges in order to be able to switch to another
180 one. See also "gid" and "user".
181
182ulimit-n <number>
183 Sets the maximum number of per-process file-descriptors to <number>. By
184 default, it is automatically computed, so it is recommended not to use this
185 option.
186
187user <user name>
188 Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
189 See also "uid" and "group".
190
191
1921.2) Performance tuning
193-----------------------
194
195maxconn <number>
196 Sets the maximum per-process number of concurrent connections to <number>. It
197 is equivalent to the command-line argument "-n". Proxies will stop accepting
198 connections when this limit is reached. The "ulimit-n" parameter is
199 automatically adjusted according to this value. See also "ulimit-n".
200
201noepoll
202 Disables the use of the "epoll" event polling system on Linux. It is
203 equivalent to the command-line argument "-de". The next polling system
204 used will generally be "poll". See also "nosepoll", and "nopoll".
205
206nokqueue
207 Disables the use of the "kqueue" event polling system on BSD. It is
208 equivalent to the command-line argument "-dk". The next polling system
209 used will generally be "poll". See also "nopoll".
210
211nopoll
212 Disables the use of the "poll" event polling system. It is equivalent to the
213 command-line argument "-dp". The next polling system used will be "select".
Willy Tarreau0ba27502007-12-24 16:55:16 +0100214 It should never be needed to disable "poll" since it's available on all
Willy Tarreau6a06a402007-07-15 20:15:28 +0200215 platforms supported by HAProxy. See also "nosepoll", and "nopoll" and
216 "nokqueue".
217
218nosepoll
219 Disables the use of the "speculative epoll" event polling system on Linux. It
220 is equivalent to the command-line argument "-ds". The next polling system
221 used will generally be "epoll". See also "nosepoll", and "nopoll".
222
Willy Tarreaufe255b72007-10-14 23:09:26 +0200223spread-checks <0..50, in percent>
224 Sometimes it is desirable to avoid sending health checks to servers at exact
225 intervals, for instance when many logical servers are located on the same
226 physical server. With the help of this parameter, it becomes possible to add
227 some randomness in the check interval between 0 and +/- 50%. A value between
228 2 and 5 seems to show good results. The default value remains at 0.
229
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100230tune.maxaccept <number>
231 Sets the maximum number of consecutive accepts that a process may perform on
232 a single wake up. High values give higher priority to high connection rates,
233 while lower values give higher priority to already established connections.
234 This value is unlimited by default in single process mode. However, in
235 multi-process mode (nbproc > 1), it defaults to 8 so that when one process
236 wakes up, it does not take all incoming connections for itself and leaves a
237 part of them to other processes. Setting this value to zero or less disables
238 the limitation. It should normally not be needed to tweak this value.
239
240tune.maxpollevents <number>
241 Sets the maximum amount of events that can be processed at once in a call to
242 the polling system. The default value is adapted to the operating system. It
243 has been noticed that reducing it below 200 tends to slightly decrease
244 latency at the expense of network bandwidth, and increasing it above 200
245 tends to trade latency for slightly increased bandwidth.
246
Willy Tarreau6a06a402007-07-15 20:15:28 +0200247
2481.3) Debugging
249---------------
250
251debug
252 Enables debug mode which dumps to stdout all exchanges, and disables forking
253 into background. It is the equivalent of the command-line argument "-d". It
254 should never be used in a production configuration since it may prevent full
255 system startup.
256
257quiet
258 Do not display any message during startup. It is equivalent to the command-
259 line argument "-q".
260
Willy Tarreau6a06a402007-07-15 20:15:28 +0200261
2622) Proxies
263----------
Willy Tarreau0ba27502007-12-24 16:55:16 +0100264
Willy Tarreau6a06a402007-07-15 20:15:28 +0200265Proxy configuration can be located in a set of sections :
266 - defaults <name>
267 - frontend <name>
268 - backend <name>
269 - listen <name>
270
271A "defaults" section sets default parameters for all other sections following
272its declaration. Those default parameters are reset by the next "defaults"
273section. See below for the list of parameters which can be set in a "defaults"
Willy Tarreau0ba27502007-12-24 16:55:16 +0100274section. The name is optional but its use is encouraged for better readability.
Willy Tarreau6a06a402007-07-15 20:15:28 +0200275
276A "frontend" section describes a set of listening sockets accepting client
277connections.
278
279A "backend" section describes a set of servers to which the proxy will connect
280to forward incoming connections.
281
282A "listen" section defines a complete proxy with its frontend and backend
283parts combined in one section. It is generally useful for TCP-only traffic.
284
Willy Tarreau0ba27502007-12-24 16:55:16 +0100285All proxy names must be formed from upper and lower case letters, digits,
286'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
287case-sensitive, which means that "www" and "WWW" are two different proxies.
288
289Historically, all proxy names could overlap, it just caused troubles in the
290logs. Since the introduction of content switching, it is mandatory that two
291proxies with overlapping capabilities (frontend/backend) have different names.
292However, it is still permitted that a frontend and a backend share the same
293name, as this configuration seems to be commonly encountered.
294
295Right now, two major proxy modes are supported : "tcp", also known as layer 4,
296and "http", also known as layer 7. In layer 4 mode, HAProxy simply forwards
297bidirectionnal traffic between two sides. In layer 7 mode, HAProxy analyzes the
298protocol, and can interact with it by allowing, blocking, switching, adding,
299modifying, or removing arbitrary contents in requests or responses, based on
300arbitrary criteria.
301
302
3032.1) Quick reminder about HTTP
304------------------------------
305
306When a proxy is running in HTTP mode, both the request and the response are
307fully analyzed and indexed, thus it becomes possible to build matching criteria
308on almost anything found in the contents.
309
310However, it is important to understand how HTTP requests and responses are
311formed, and how HAProxy decomposes them. It will then become easier to write
312correct rules and to debug existing configurations.
313
314
3152.1.1) The HTTP transaction model
316---------------------------------
317
318The HTTP protocol is transaction-driven. This means that each request will lead
319to one and only one response. Traditionnally, a TCP connection is established
320from the client to the server, a request is sent by the client on the
321connection, the server responds and the connection is closed. A new request
322will involve a new connection :
323
324 [CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ...
325
326In this mode, called the "HTTP close" mode, there are as many connection
327establishments as there are HTTP transactions. Since the connection is closed
328by the server after the response, the client does not need to know the content
329length.
330
331Due to the transactional nature of the protocol, it was possible to improve it
332to avoid closing a connection between two subsequent transactions. In this mode
333however, it is mandatory that the server indicates the content length for each
334response so that the client does not wait indefinitely. For this, a special
335header is used: "Content-length". This mode is called the "keep-alive" mode :
336
337 [CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ...
338
339Its advantages are a reduced latency between transactions, and less processing
340power required on the server side. It is generally better than the close mode,
341but not always because the clients often limit their concurrent connections to
342a smaller value. HAProxy currently does not support the HTTP keep-alive mode,
343but knows how to transform it to the close mode.
344
345A last improvement in the communications is the pipelining mode. It still uses
346keep-alive, but the client does not wait for the first response to send the
347second request. This is useful for fetching large number of images composing a
348page :
349
350 [CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ...
351
352This can obviously have a tremendous benefit on performance because the network
353latency is eliminated between subsequent requests. Many HTTP agents do not
354correctly support pipelining since there is no way to associate a response with
355the corresponding request in HTTP. For this reason, it is mandatory for the
356server to reply in the exact same order as the requests were received.
357
358Right now, HAProxy only supports the first mode (HTTP close) if it needs to
359process the request. This means that for each request, there will be one TCP
360connection. If keep-alive or pipelining are required, HAProxy will still
361support them, but will only see the first request and the first response of
362each transaction. While this is generally problematic with regards to logs,
363content switching or filtering, it most often causes no problem for persistence
364with cookie insertion.
365
366
3672.1.2) HTTP request
368-------------------
369
370First, let's consider this HTTP request :
371
372 Line Contents
373 number
374 1 GET /serv/login.php?lang=en&profile=2 HTTP/1.1
375 2 Host: www.mydomain.com
376 3 User-agent: my small browser
377 4 Accept: image/jpeg, image/gif
378 5 Accept: image/png
379
380
3812.1.2.1) The Request line
382-------------------------
383
384Line 1 is the "request line". It is always composed of 3 fields :
385
386 - a METHOD : GET
387 - a URI : /serv/login.php?lang=en&profile=2
388 - a version tag : HTTP/1.1
389
390All of them are delimited by what the standard calls LWS (linear white spaces),
391which are commonly spaces, but can also be tabs or line feeds/carriage returns
392followed by spaces/tabs. The method itself cannot contain any colon (':') and
393is limited to alphabetic letters. All those various combinations make it
394desirable that HAProxy performs the splitting itself rather than leaving it to
395the user to write a complex or inaccurate regular expression.
396
397The URI itself can have several forms :
398
399 - A "relative URI" :
400
401 /serv/login.php?lang=en&profile=2
402
403 It is a complete URL without the host part. This is generally what is
404 received by servers, reverse proxies and transparent proxies.
405
406 - An "absolute URI", also called a "URL" :
407
408 http://192.168.0.12:8080/serv/login.php?lang=en&profile=2
409
410 It is composed of a "scheme" (the protocol name followed by '://'), a host
411 name or address, optionally a colon (':') followed by a port number, then
412 a relative URI beginning at the first slash ('/') after the address part.
413 This is generally what proxies receive, but a server supporting HTTP/1.1
414 must accept this form too.
415
416 - a star ('*') : this form is only accepted in association with the OPTIONS
417 method and is not relayable. It is used to inquiry a next hop's
418 capabilities.
419
420 - an address:port combination : 192.168.0.12:80
421 This is used with the CONNECT method, which is used to establish TCP
422 tunnels through HTTP proxies, generally for HTTPS, but sometimes for
423 other protocols too.
424
425In a relative URI, two sub-parts are identified. The part before the question
426mark is called the "path". It is typically the relative path to static objects
427on the server. The part after the question mark is called the "query string".
428It is mostly used with GET requests sent to dynamic scripts and is very
429specific to the language, framework or application in use.
430
431
4322.1.2.2) The request headers
433----------------------------
434
435The headers start at the second line. They are composed of a name at the
436beginning of the line, immediately followed by a colon (':'). Traditionally,
437an LWS is added after the colon but that's not required. Then come the values.
438Multiple identical headers may be folded into one single line, delimiting the
439values with commas, provided that their order is respected. This is commonly
Willy Tarreau198a7442008-01-17 12:05:32 +0100440encountered in the "Cookie:" field. A header may span over multiple lines if
Willy Tarreau0ba27502007-12-24 16:55:16 +0100441the subsequent lines begin with an LWS. In the example in 2.1.2, lines 4 and 5
Willy Tarreau198a7442008-01-17 12:05:32 +0100442define a total of 3 values for the "Accept:" header.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100443
444Contrary to a common mis-conception, header names are not case-sensitive, and
445their values are not either if they refer to other header names (such as the
Willy Tarreau198a7442008-01-17 12:05:32 +0100446"Connection:" header).
Willy Tarreau0ba27502007-12-24 16:55:16 +0100447
448The end of the headers is indicated by the first empty line. People often say
449that it's a double line feed, which is not exact, even if a double line feed
450is one valid form of empty line.
451
452Fortunately, HAProxy takes care of all these complex combinations when indexing
453headers, checking values and counting them, so there is no reason to worry
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100454about the way they could be written, but it is important not to accuse an
Willy Tarreau0ba27502007-12-24 16:55:16 +0100455application of being buggy if it does unusual, valid things.
456
457Important note:
458 As suggested by RFC2616, HAProxy normalizes headers by replacing line breaks
459 in the middle of headers by LWS in order to join multi-line headers. This
460 is necessary for proper analysis and helps less capable HTTP parsers to work
461 correctly and not to be fooled by such complex constructs.
462
463
4642.1.3) HTTP response
465--------------------
466
467An HTTP response looks very much like an HTTP request. Both are called HTTP
468messages. Let's consider this HTTP response :
469
470 Line Contents
471 number
472 1 HTTP/1.1 200 OK
473 2 Content-length: 350
474 3 Content-Type: text/html
475
476
4772.1.3.1) The Response line
478--------------------------
479
480Line 1 is the "response line". It is always composed of 3 fields :
481
482 - a version tag : HTTP/1.1
483 - a status code : 200
484 - a reason : OK
485
486The status code is always 3-digit. The first digit indicates a general status :
487 - 2xx = OK, content is following (eg: 200, 206)
488 - 3xx = OK, no content following (eg: 302, 304)
489 - 4xx = error caused by the client (eg: 401, 403, 404)
490 - 5xx = error caused by the server (eg: 500, 502, 503)
491
492Please refer to RFC2616 for the detailed meaning of all such codes. The
493"reason" field is just a hint, but is not parsed by clients. Anything can be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100494found there, but it's a common practice to respect the well-established
Willy Tarreau0ba27502007-12-24 16:55:16 +0100495messages. It can be composed of one or multiple words, such as "OK", "Found",
496or "Authentication Required".
497
498
4992.1.3.2) The response headers
500-----------------------------
501
502Response headers work exactly like request headers, and as such, HAProxy uses
503the same parsing function for both. Please refer to paragraph 2.1.2.2 for more
504details.
505
506
5072.2) Proxy keywords matrix
508----------------------------
509
Willy Tarreau6a06a402007-07-15 20:15:28 +0200510The following list of keywords is supported. Most of them may only be used in a
Willy Tarreau0ba27502007-12-24 16:55:16 +0100511limited set of section types. Some of them are marked as "deprecated" because
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100512they are inherited from an old syntax which may be confusing or functionally
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100513limited, and there are new recommended keywords to replace them. Keywords
514listed with [no] can be optionally inverted using the "no" prefix, ex. "no
515option contstats". This makes sense when the option has been enabled by default
516and must be disabled for a specific instance.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100517
Willy Tarreau6a06a402007-07-15 20:15:28 +0200518
519keyword defaults frontend listen backend
520----------------------+----------+----------+---------+---------
521acl - X X X
522appsession - - X X
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100523backlog X X X -
Willy Tarreau0ba27502007-12-24 16:55:16 +0100524balance X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200525bind - X X -
526block - X X X
Willy Tarreau0ba27502007-12-24 16:55:16 +0100527capture cookie - X X -
528capture request header - X X -
529capture response header - X X -
Willy Tarreaue219db72007-12-03 01:30:13 +0100530clitimeout X X X - (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +0100531contimeout X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200532cookie X - X X
533default_backend - X X -
Willy Tarreau0ba27502007-12-24 16:55:16 +0100534disabled X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200535dispatch - - X X
Willy Tarreau0ba27502007-12-24 16:55:16 +0100536enabled X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200537errorfile X X X X
538errorloc X X X X
539errorloc302 X X X X
540errorloc303 X X X X
541fullconn X - X X
542grace - X X X
Willy Tarreaudbc36f62007-11-30 12:29:11 +0100543http-check disable-on-404 X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200544log X X X X
545maxconn X X X -
546mode X X X X
Willy Tarreauc7246fc2007-12-02 17:31:20 +0100547monitor fail - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200548monitor-net X X X -
549monitor-uri X X X -
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100550[no] option abortonclose X - X X
551[no] option allbackups X - X X
552[no] option checkcache X - X X
553[no] option clitcpka X X X -
554[no] option contstats X X X -
555[no] option dontlognull X X X -
556[no] option forceclose X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200557option forwardfor X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100558[no] option http_proxy X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200559option httpchk X - X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100560[no] option httpclose X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200561option httplog X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100562[no] option logasap X X X -
563[no] option nolinger X X X X
564[no] option persist X - X X
565[no] option redispatch X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200566option smtpchk X - X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100567[no] option srvtcpka X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200568option ssl-hello-chk X - X X
569option tcpka X X X X
570option tcplog X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100571[no] option tcpsplice X X X X
Willy Tarreau4b1f8592008-12-23 23:13:55 +0100572[no] option transparent X - X X
Willy Tarreaub463dfb2008-06-07 23:08:56 +0200573redirect - X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100574redisp X - X X (deprecated)
575redispatch X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200576reqadd - X X X
577reqallow - X X X
578reqdel - X X X
579reqdeny - X X X
580reqiallow - X X X
581reqidel - X X X
582reqideny - X X X
583reqipass - X X X
584reqirep - X X X
585reqisetbe - X X X
586reqitarpit - X X X
587reqpass - X X X
588reqrep - X X X
589reqsetbe - X X X
590reqtarpit - X X X
591retries X - X X
592rspadd - X X X
593rspdel - X X X
594rspdeny - X X X
595rspidel - X X X
596rspideny - X X X
597rspirep - X X X
598rsprep - X X X
599server - - X X
600source X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100601srvtimeout X - X X (deprecated)
Willy Tarreau24e779b2007-07-24 23:43:37 +0200602stats auth X - X X
603stats enable X - X X
604stats realm X - X X
Willy Tarreaubbd42122007-07-25 07:26:38 +0200605stats refresh X - X X
Willy Tarreau24e779b2007-07-24 23:43:37 +0200606stats scope X - X X
607stats uri X - X X
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +0200608stats hide-version X - X X
Willy Tarreau62644772008-07-16 18:36:06 +0200609tcp-request content accept - X X -
610tcp-request content reject - X X -
611tcp-request inspect-delay - X X -
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +0100612timeout check X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100613timeout client X X X -
614timeout clitimeout X X X - (deprecated)
615timeout connect X - X X
616timeout contimeout X - X X (deprecated)
Willy Tarreau844e3c52008-01-11 16:28:18 +0100617timeout http-request X X X -
Willy Tarreaue219db72007-12-03 01:30:13 +0100618timeout queue X - X X
619timeout server X - X X
620timeout srvtimeout X - X X (deprecated)
Willy Tarreau51c9bde2008-01-06 13:40:03 +0100621timeout tarpit X X X X
Willy Tarreau4b1f8592008-12-23 23:13:55 +0100622transparent X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200623use_backend - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200624----------------------+----------+----------+---------+---------
625keyword defaults frontend listen backend
626
Willy Tarreau0ba27502007-12-24 16:55:16 +0100627
6282.2.1) Alphabetically sorted keywords reference
629-----------------------------------------------
630
631This section provides a description of each keyword and its usage.
632
633
634acl <aclname> <criterion> [flags] [operator] <value> ...
635 Declare or complete an access list.
636 May be used in sections : defaults | frontend | listen | backend
637 no | yes | yes | yes
638 Example:
639 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
640 acl invalid_src src_port 0:1023
641 acl local_dst hdr(host) -i localhost
642
643 See section 2.3 about ACL usage.
644
645
646appsession <cookie> len <length> timeout <holdtime>
647 Define session stickiness on an existing application cookie.
648 May be used in sections : defaults | frontend | listen | backend
649 no | no | yes | yes
650 Arguments :
651 <cookie> this is the name of the cookie used by the application and which
652 HAProxy will have to learn for each new session.
653
654 <length> this is the number of characters that will be memorized and
655 checked in each cookie value.
656
657 <holdtime> this is the time after which the cookie will be removed from
658 memory if unused. If no unit is specified, this time is in
659 milliseconds.
660
661 When an application cookie is defined in a backend, HAProxy will check when
662 the server sets such a cookie, and will store its value in a table, and
663 associate it with the server's identifier. Up to <length> characters from
664 the value will be retained. On each connection, haproxy will look for this
665 cookie both in the "Cookie:" headers, and as a URL parameter in the query
666 string. If a known value is found, the client will be directed to the server
667 associated with this value. Otherwise, the load balancing algorithm is
668 applied. Cookies are automatically removed from memory when they have been
669 unused for a duration longer than <holdtime>.
670
671 The definition of an application cookie is limited to one per backend.
672
673 Example :
674 appsession JSESSIONID len 52 timeout 3h
675
676 See also : "cookie", "capture cookie" and "balance".
677
678
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100679backlog <conns>
680 Give hints to the system about the approximate listen backlog desired size
681 May be used in sections : defaults | frontend | listen | backend
682 yes | yes | yes | no
683 Arguments :
684 <conns> is the number of pending connections. Depending on the operating
685 system, it may represent the number of already acknowledged
686 connections, of non-acknowledged ones, or both.
687
688 In order to protect against SYN flood attacks, one solution is to increase
689 the system's SYN backlog size. Depending on the system, sometimes it is just
690 tunable via a system parameter, sometimes it is not adjustable at all, and
691 sometimes the system relies on hints given by the application at the time of
692 the listen() syscall. By default, HAProxy passes the frontend's maxconn value
693 to the listen() syscall. On systems which can make use of this value, it can
694 sometimes be useful to be able to specify a different value, hence this
695 backlog parameter.
696
697 On Linux 2.4, the parameter is ignored by the system. On Linux 2.6, it is
698 used as a hint and the system accepts up to the smallest greater power of
699 two, and never more than some limits (usually 32768).
700
701 See also : "maxconn" and the target operating system's tuning guide.
702
703
Willy Tarreau0ba27502007-12-24 16:55:16 +0100704balance <algorithm> [ <arguments> ]
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200705balance url_param <param> [check_post [<max_wait>]]
Willy Tarreau0ba27502007-12-24 16:55:16 +0100706 Define the load balancing algorithm to be used in a backend.
707 May be used in sections : defaults | frontend | listen | backend
708 yes | no | yes | yes
709 Arguments :
710 <algorithm> is the algorithm used to select a server when doing load
711 balancing. This only applies when no persistence information
712 is available, or when a connection is redispatched to another
713 server. <algorithm> may be one of the following :
714
715 roundrobin Each server is used in turns, according to their weights.
716 This is the smoothest and fairest algorithm when the server's
717 processing time remains equally distributed. This algorithm
718 is dynamic, which means that server weights may be adjusted
719 on the fly for slow starts for instance.
720
Willy Tarreau2d2a7f82008-03-17 12:07:56 +0100721 leastconn The server with the lowest number of connections receives the
722 connection. Round-robin is performed within groups of servers
723 of the same load to ensure that all servers will be used. Use
724 of this algorithm is recommended where very long sessions are
725 expected, such as LDAP, SQL, TSE, etc... but is not very well
726 suited for protocols using short sessions such as HTTP. This
727 algorithm is dynamic, which means that server weights may be
728 adjusted on the fly for slow starts for instance.
729
Willy Tarreau0ba27502007-12-24 16:55:16 +0100730 source The source IP address is hashed and divided by the total
731 weight of the running servers to designate which server will
732 receive the request. This ensures that the same client IP
733 address will always reach the same server as long as no
734 server goes down or up. If the hash result changes due to the
735 number of running servers changing, many clients will be
736 directed to a different server. This algorithm is generally
737 used in TCP mode where no cookie may be inserted. It may also
738 be used on the Internet to provide a best-effort stickyness
739 to clients which refuse session cookies. This algorithm is
740 static, which means that changing a server's weight on the
741 fly will have no effect.
742
743 uri The left part of the URI (before the question mark) is hashed
744 and divided by the total weight of the running servers. The
745 result designates which server will receive the request. This
746 ensures that a same URI will always be directed to the same
747 server as long as no server goes up or down. This is used
748 with proxy caches and anti-virus proxies in order to maximize
749 the cache hit rate. Note that this algorithm may only be used
750 in an HTTP backend. This algorithm is static, which means
751 that changing a server's weight on the fly will have no
752 effect.
753
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200754 This algorithm support two optional parameters "len" and
755 "depth", both followed by a positive integer number. These
756 options may be helpful when it is needed to balance servers
757 based on the beginning of the URI only. The "len" parameter
758 indicates that the algorithm should only consider that many
759 characters at the beginning of the URI to compute the hash.
760 Note that having "len" set to 1 rarely makes sense since most
761 URIs start with a leading "/".
762
763 The "depth" parameter indicates the maximum directory depth
764 to be used to compute the hash. One level is counted for each
765 slash in the request. If both parameters are specified, the
766 evaluation stops when either is reached.
767
Willy Tarreau0ba27502007-12-24 16:55:16 +0100768 url_param The URL parameter specified in argument will be looked up in
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200769 the query string of each HTTP GET request.
770
771 If the modifier "check_post" is used, then an HTTP POST
772 request entity will be searched for the parameter argument,
773 when the question mark indicating a query string ('?') is not
774 present in the URL. Optionally, specify a number of octets to
775 wait for before attempting to search the message body. If the
776 entity can not be searched, then round robin is used for each
777 request. For instance, if your clients always send the LB
778 parameter in the first 128 bytes, then specify that. The
779 default is 48. The entity data will not be scanned until the
780 required number of octets have arrived at the gateway, this
781 is the minimum of: (default/max_wait, Content-Length or first
782 chunk length). If Content-Length is missing or zero, it does
783 not need to wait for more data than the client promised to
784 send. When Content-Length is present and larger than
785 <max_wait>, then waiting is limited to <max_wait> and it is
786 assumed that this will be enough data to search for the
787 presence of the parameter. In the unlikely event that
788 Transfer-Encoding: chunked is used, only the first chunk is
789 scanned. Parameter values separated by a chunk boundary, may
790 be randomly balanced if at all.
791
792 If the parameter is found followed by an equal sign ('=') and
793 a value, then the value is hashed and divided by the total
794 weight of the running servers. The result designates which
795 server will receive the request.
796
797 This is used to track user identifiers in requests and ensure
798 that a same user ID will always be sent to the same server as
799 long as no server goes up or down. If no value is found or if
800 the parameter is not found, then a round robin algorithm is
801 applied. Note that this algorithm may only be used in an HTTP
802 backend. This algorithm is static, which means that changing a
803 server's weight on the fly will have no effect.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100804
805 <arguments> is an optional list of arguments which may be needed by some
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200806 algorithms. Right now, only "url_param" and "uri" support an
807 optional argument.
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200808
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200809 balance uri [len <len>] [depth <depth>]
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200810 balance url_param <param> [check_post [<max_wait>]]
Willy Tarreau0ba27502007-12-24 16:55:16 +0100811
812 The definition of the load balancing algorithm is mandatory for a backend
813 and limited to one per backend.
814
815 Examples :
816 balance roundrobin
817 balance url_param userid
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200818 balance url_param session_id check_post 64
819
820 Note: the following caveats and limitations on using the "check_post"
821 extension with "url_param" must be considered :
822
823 - all POST requests are eligable for consideration, because there is no way
824 to determine if the parameters will be found in the body or entity which
825 may contain binary data. Therefore another method may be required to
826 restrict consideration of POST requests that have no URL parameters in
827 the body. (see acl reqideny http_end)
828
829 - using a <max_wait> value larger than the request buffer size does not
830 make sense and is useless. The buffer size is set at build time, and
831 defaults to 16 kB.
832
833 - Content-Encoding is not supported, the parameter search will probably
834 fail; and load balancing will fall back to Round Robin.
835
836 - Expect: 100-continue is not supported, load balancing will fall back to
837 Round Robin.
838
839 - Transfer-Encoding (RFC2616 3.6.1) is only supported in the first chunk.
840 If the entire parameter value is not present in the first chunk, the
841 selection of server is undefined (actually, defined by how little
842 actually appeared in the first chunk).
843
844 - This feature does not support generation of a 100, 411 or 501 response.
845
846 - In some cases, requesting "check_post" MAY attempt to scan the entire
847 contents of a message body. Scaning normally terminates when linear
848 white space or control characters are found, indicating the end of what
849 might be a URL parameter list. This is probably not a concern with SGML
850 type message bodies.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100851
852 See also : "dispatch", "cookie", "appsession", "transparent" and "http_proxy".
853
854
855bind [<address>]:<port> [, ...]
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100856bind [<address>]:<port> [, ...] transparent
Willy Tarreau0ba27502007-12-24 16:55:16 +0100857 Define one or several listening addresses and/or ports in a frontend.
858 May be used in sections : defaults | frontend | listen | backend
859 no | yes | yes | no
860 Arguments :
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100861 <address> is optional and can be a host name, an IPv4 address, an IPv6
862 address, or '*'. It designates the address the frontend will
863 listen on. If unset, all IPv4 addresses of the system will be
864 listened on. The same will apply for '*' or the system's
865 special address "0.0.0.0".
866
867 <port> is the TCP port number the proxy will listen on. The port is
868 mandatory. Note that in the case of an IPv6 address, the port
869 is always the number after the last colon (':').
Willy Tarreau0ba27502007-12-24 16:55:16 +0100870
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100871 transparent is an optional keyword which is supported only on certain
872 Linux kernels. It indicates that the addresses will be bound
873 even if they do not belong to the local machine. Any packet
874 targetting any of these addresses will be caught just as if
875 the address was locally configured. This normally requires
876 that IP forwarding is enabled. Caution! do not use this with
877 the default address '*', as it would redirect any traffic for
878 the specified port. This keyword is available only when
879 HAProxy is built with USE_LINUX_TPROXY=1.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100880
881 It is possible to specify a list of address:port combinations delimited by
882 commas. The frontend will then listen on all of these addresses. There is no
883 fixed limit to the number of addresses and ports which can be listened on in
884 a frontend, as well as there is no limit to the number of "bind" statements
885 in a frontend.
886
887 Example :
888 listen http_proxy
889 bind :80,:443
890 bind 10.0.0.1:10080,10.0.0.1:10443
891
892 See also : "source".
893
894
895block { if | unless } <condition>
896 Block a layer 7 request if/unless a condition is matched
897 May be used in sections : defaults | frontend | listen | backend
898 no | yes | yes | yes
899
900 The HTTP request will be blocked very early in the layer 7 processing
901 if/unless <condition> is matched. A 403 error will be returned if the request
902 is blocked. The condition has to reference ACLs (see section 2.3). This is
903 typically used to deny access to certain sensible resources if some
904 conditions are met or not met. There is no fixed limit to the number of
905 "block" statements per instance.
906
907 Example:
908 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
909 acl invalid_src src_port 0:1023
910 acl local_dst hdr(host) -i localhost
911 block if invalid_src || local_dst
912
913 See section 2.3 about ACL usage.
914
915
916capture cookie <name> len <length>
917 Capture and log a cookie in the request and in the response.
918 May be used in sections : defaults | frontend | listen | backend
919 no | yes | yes | no
920 Arguments :
921 <name> is the beginning of the name of the cookie to capture. In order
922 to match the exact name, simply suffix the name with an equal
923 sign ('='). The full name will appear in the logs, which is
924 useful with application servers which adjust both the cookie name
925 and value (eg: ASPSESSIONXXXXX).
926
927 <length> is the maximum number of characters to report in the logs, which
928 include the cookie name, the equal sign and the value, all in the
929 standard "name=value" form. The string will be truncated on the
930 right if it exceeds <length>.
931
932 Only the first cookie is captured. Both the "cookie" request headers and the
933 "set-cookie" response headers are monitored. This is particularly useful to
934 check for application bugs causing session crossing or stealing between
935 users, because generally the user's cookies can only change on a login page.
936
937 When the cookie was not presented by the client, the associated log column
938 will report "-". When a request does not cause a cookie to be assigned by the
939 server, a "-" is reported in the response column.
940
941 The capture is performed in the frontend only because it is necessary that
942 the log format does not change for a given frontend depending on the
943 backends. This may change in the future. Note that there can be only one
944 "capture cookie" statement in a frontend. The maximum capture length is
945 configured in the souces by default to 64 characters. It is not possible to
946 specify a capture in a "defaults" section.
947
948 Example:
949 capture cookie ASPSESSION len 32
950
951 See also : "capture request header", "capture response header" as well as
Willy Tarreauced27012008-01-17 20:35:34 +0100952 section 2.6 about logging.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100953
954
955capture request header <name> len <length>
956 Capture and log the first occurrence of the specified request header.
957 May be used in sections : defaults | frontend | listen | backend
958 no | yes | yes | no
959 Arguments :
960 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100961 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +0100962 appear in the requests, with the first letter of each word in
963 upper case. The header name will not appear in the logs, only the
964 value is reported, but the position in the logs is respected.
965
966 <length> is the maximum number of characters to extract from the value and
967 report in the logs. The string will be truncated on the right if
968 it exceeds <length>.
969
970 Only the first value of the first occurrence of the header is captured. The
971 value will be added to the logs between braces ('{}'). If multiple headers
972 are captured, they will be delimited by a vertical bar ('|') and will appear
973 in the same order they were declared in the configuration. Common uses for
974 request header captures include the "Host" field in virtual hosting
975 environments, the "Content-length" when uploads are supported, "User-agent"
976 to quickly differenciate between real users and robots, and "X-Forwarded-For"
977 in proxied environments to find where the request came from.
978
979 There is no limit to the number of captured request headers, but each capture
980 is limited to 64 characters. In order to keep log format consistent for a
981 same frontend, header captures can only be declared in a frontend. It is not
982 possible to specify a capture in a "defaults" section.
983
984 Example:
985 capture request header Host len 15
986 capture request header X-Forwarded-For len 15
987 capture request header Referrer len 15
988
Willy Tarreauced27012008-01-17 20:35:34 +0100989 See also : "capture cookie", "capture response header" as well as section 2.6
Willy Tarreau0ba27502007-12-24 16:55:16 +0100990 about logging.
991
992
993capture response header <name> len <length>
994 Capture and log the first occurrence of the specified response header.
995 May be used in sections : defaults | frontend | listen | backend
996 no | yes | yes | no
997 Arguments :
998 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100999 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +01001000 appear in the response, with the first letter of each word in
1001 upper case. The header name will not appear in the logs, only the
1002 value is reported, but the position in the logs is respected.
1003
1004 <length> is the maximum number of characters to extract from the value and
1005 report in the logs. The string will be truncated on the right if
1006 it exceeds <length>.
1007
1008 Only the first value of the first occurrence of the header is captured. The
1009 result will be added to the logs between braces ('{}') after the captured
1010 request headers. If multiple headers are captured, they will be delimited by
1011 a vertical bar ('|') and will appear in the same order they were declared in
1012 the configuration. Common uses for response header captures include the
1013 "Content-length" header which indicates how many bytes are expected to be
1014 returned, the "Location" header to track redirections.
1015
1016 There is no limit to the number of captured response headers, but each
1017 capture is limited to 64 characters. In order to keep log format consistent
1018 for a same frontend, header captures can only be declared in a frontend. It
1019 is not possible to specify a capture in a "defaults" section.
1020
1021 Example:
1022 capture response header Content-length len 9
1023 capture response header Location len 15
1024
Willy Tarreauced27012008-01-17 20:35:34 +01001025 See also : "capture cookie", "capture request header" as well as section 2.6
Willy Tarreau0ba27502007-12-24 16:55:16 +01001026 about logging.
1027
1028
1029clitimeout <timeout>
1030 Set the maximum inactivity time on the client side.
1031 May be used in sections : defaults | frontend | listen | backend
1032 yes | yes | yes | no
1033 Arguments :
1034 <timeout> is the timeout value is specified in milliseconds by default, but
1035 can be in any other unit if the number is suffixed by the unit,
1036 as explained at the top of this document.
1037
1038 The inactivity timeout applies when the client is expected to acknowledge or
1039 send data. In HTTP mode, this timeout is particularly important to consider
1040 during the first phase, when the client sends the request, and during the
1041 response while it is reading data sent by the server. The value is specified
1042 in milliseconds by default, but can be in any other unit if the number is
1043 suffixed by the unit, as specified at the top of this document. In TCP mode
1044 (and to a lesser extent, in HTTP mode), it is highly recommended that the
1045 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001046 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01001047 losses by specifying timeouts that are slightly above multiples of 3 seconds
1048 (eg: 4 or 5 seconds).
1049
1050 This parameter is specific to frontends, but can be specified once for all in
1051 "defaults" sections. This is in fact one of the easiest solutions not to
1052 forget about it. An unspecified timeout results in an infinite timeout, which
1053 is not recommended. Such a usage is accepted and works but reports a warning
1054 during startup because it may results in accumulation of expired sessions in
1055 the system if the system's timeouts are not configured either.
1056
1057 This parameter is provided for compatibility but is currently deprecated.
1058 Please use "timeout client" instead.
1059
Willy Tarreau036fae02008-01-06 13:24:40 +01001060 See also : "timeout client", "timeout http-request", "timeout server", and
1061 "srvtimeout".
Willy Tarreau0ba27502007-12-24 16:55:16 +01001062
1063
1064contimeout <timeout>
1065 Set the maximum time to wait for a connection attempt to a server to succeed.
1066 May be used in sections : defaults | frontend | listen | backend
1067 yes | no | yes | yes
1068 Arguments :
1069 <timeout> is the timeout value is specified in milliseconds by default, but
1070 can be in any other unit if the number is suffixed by the unit,
1071 as explained at the top of this document.
1072
1073 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001074 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +01001075 cover one or several TCP packet losses by specifying timeouts that are
1076 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
1077 connect timeout also presets the queue timeout to the same value if this one
1078 has not been specified. Historically, the contimeout was also used to set the
1079 tarpit timeout in a listen section, which is not possible in a pure frontend.
1080
1081 This parameter is specific to backends, but can be specified once for all in
1082 "defaults" sections. This is in fact one of the easiest solutions not to
1083 forget about it. An unspecified timeout results in an infinite timeout, which
1084 is not recommended. Such a usage is accepted and works but reports a warning
1085 during startup because it may results in accumulation of failed sessions in
1086 the system if the system's timeouts are not configured either.
1087
1088 This parameter is provided for backwards compatibility but is currently
1089 deprecated. Please use "timeout connect", "timeout queue" or "timeout tarpit"
1090 instead.
1091
1092 See also : "timeout connect", "timeout queue", "timeout tarpit",
1093 "timeout server", "contimeout".
1094
1095
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02001096cookie <name> [ rewrite|insert|prefix ] [ indirect ] [ nocache ] [ postonly ] [domain <domain>]
Willy Tarreau0ba27502007-12-24 16:55:16 +01001097 Enable cookie-based persistence in a backend.
1098 May be used in sections : defaults | frontend | listen | backend
1099 yes | no | yes | yes
1100 Arguments :
1101 <name> is the name of the cookie which will be monitored, modified or
1102 inserted in order to bring persistence. This cookie is sent to
1103 the client via a "Set-Cookie" header in the response, and is
1104 brought back by the client in a "Cookie" header in all requests.
1105 Special care should be taken to choose a name which does not
1106 conflict with any likely application cookie. Also, if the same
1107 backends are subject to be used by the same clients (eg:
1108 HTTP/HTTPS), care should be taken to use different cookie names
1109 between all backends if persistence between them is not desired.
1110
1111 rewrite This keyword indicates that the cookie will be provided by the
1112 server and that haproxy will have to modify its value to set the
1113 server's identifier in it. This mode is handy when the management
1114 of complex combinations of "Set-cookie" and "Cache-control"
1115 headers is left to the application. The application can then
1116 decide whether or not it is appropriate to emit a persistence
1117 cookie. Since all responses should be monitored, this mode only
1118 works in HTTP close mode. Unless the application behaviour is
1119 very complex and/or broken, it is advised not to start with this
1120 mode for new deployments. This keyword is incompatible with
1121 "insert" and "prefix".
1122
1123 insert This keyword indicates that the persistence cookie will have to
1124 be inserted by haproxy in the responses. If the server emits a
1125 cookie with the same name, it will be replaced anyway. For this
1126 reason, this mode can be used to upgrade existing configurations
1127 running in the "rewrite" mode. The cookie will only be a session
1128 cookie and will not be stored on the client's disk. Due to
1129 caching effects, it is generally wise to add the "indirect" and
1130 "nocache" or "postonly" keywords (see below). The "insert"
1131 keyword is not compatible with "rewrite" and "prefix".
1132
1133 prefix This keyword indicates that instead of relying on a dedicated
1134 cookie for the persistence, an existing one will be completed.
1135 This may be needed in some specific environments where the client
1136 does not support more than one single cookie and the application
1137 already needs it. In this case, whenever the server sets a cookie
1138 named <name>, it will be prefixed with the server's identifier
1139 and a delimiter. The prefix will be removed from all client
1140 requests so that the server still finds the cookie it emitted.
1141 Since all requests and responses are subject to being modified,
1142 this mode requires the HTTP close mode. The "prefix" keyword is
1143 not compatible with "rewrite" and "insert".
1144
1145 indirect When this option is specified in insert mode, cookies will only
1146 be added when the server was not reached after a direct access,
1147 which means that only when a server is elected after applying a
1148 load-balancing algorithm, or after a redispatch, then the cookie
1149 will be inserted. If the client has all the required information
1150 to connect to the same server next time, no further cookie will
1151 be inserted. In all cases, when the "indirect" option is used in
1152 insert mode, the cookie is always removed from the requests
1153 transmitted to the server. The persistence mechanism then becomes
1154 totally transparent from the application point of view.
1155
1156 nocache This option is recommended in conjunction with the insert mode
1157 when there is a cache between the client and HAProxy, as it
1158 ensures that a cacheable response will be tagged non-cacheable if
1159 a cookie needs to be inserted. This is important because if all
1160 persistence cookies are added on a cacheable home page for
1161 instance, then all customers will then fetch the page from an
1162 outer cache and will all share the same persistence cookie,
1163 leading to one server receiving much more traffic than others.
1164 See also the "insert" and "postonly" options.
1165
1166 postonly This option ensures that cookie insertion will only be performed
1167 on responses to POST requests. It is an alternative to the
1168 "nocache" option, because POST responses are not cacheable, so
1169 this ensures that the persistence cookie will never get cached.
1170 Since most sites do not need any sort of persistence before the
1171 first POST which generally is a login request, this is a very
1172 efficient method to optimize caching without risking to find a
1173 persistence cookie in the cache.
1174 See also the "insert" and "nocache" options.
1175
Krzysztof Piotr Oledzkiefe3b6f2008-05-23 23:49:32 +02001176 domain This option allows to specify the domain at which a cookie is
1177 inserted. It requires exactly one paramater: a valid domain
1178 name.
1179
Willy Tarreau0ba27502007-12-24 16:55:16 +01001180 There can be only one persistence cookie per HTTP backend, and it can be
1181 declared in a defaults section. The value of the cookie will be the value
1182 indicated after the "cookie" keyword in a "server" statement. If no cookie
1183 is declared for a given server, the cookie is not set.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001184
Willy Tarreau0ba27502007-12-24 16:55:16 +01001185 Examples :
1186 cookie JSESSIONID prefix
1187 cookie SRV insert indirect nocache
1188 cookie SRV insert postonly indirect
1189
1190 See also : "appsession", "balance source", "capture cookie", "server".
1191
1192
1193default_backend <backend>
1194 Specify the backend to use when no "use_backend" rule has been matched.
1195 May be used in sections : defaults | frontend | listen | backend
1196 yes | yes | yes | no
1197 Arguments :
1198 <backend> is the name of the backend to use.
1199
1200 When doing content-switching between frontend and backends using the
1201 "use_backend" keyword, it is often useful to indicate which backend will be
1202 used when no rule has matched. It generally is the dynamic backend which
1203 will catch all undetermined requests.
1204
1205 The "default_backend" keyword is also supported in TCP mode frontends to
1206 facilitate the ordering of configurations in frontends and backends,
1207 eventhough it does not make much more sense in case of TCP due to the fact
1208 that use_backend currently does not work in TCP mode.
1209
1210 Example :
1211
1212 use_backend dynamic if url_dyn
1213 use_backend static if url_css url_img extension_img
1214 default_backend dynamic
1215
Willy Tarreau2769aa02007-12-27 18:26:09 +01001216 See also : "use_backend", "reqsetbe", "reqisetbe"
1217
Willy Tarreau0ba27502007-12-24 16:55:16 +01001218
1219disabled
1220 Disable a proxy, frontend or backend.
1221 May be used in sections : defaults | frontend | listen | backend
1222 yes | yes | yes | yes
1223 Arguments : none
1224
1225 The "disabled" keyword is used to disable an instance, mainly in order to
1226 liberate a listening port or to temporarily disable a service. The instance
1227 will still be created and its configuration will be checked, but it will be
1228 created in the "stopped" state and will appear as such in the statistics. It
1229 will not receive any traffic nor will it send any health-checks or logs. It
1230 is possible to disable many instances at once by adding the "disabled"
1231 keyword in a "defaults" section.
1232
1233 See also : "enabled"
1234
1235
1236enabled
1237 Enable a proxy, frontend or backend.
1238 May be used in sections : defaults | frontend | listen | backend
1239 yes | yes | yes | yes
1240 Arguments : none
1241
1242 The "enabled" keyword is used to explicitly enable an instance, when the
1243 defaults has been set to "disabled". This is very rarely used.
1244
1245 See also : "disabled"
1246
1247
1248errorfile <code> <file>
1249 Return a file contents instead of errors generated by HAProxy
1250 May be used in sections : defaults | frontend | listen | backend
1251 yes | yes | yes | yes
1252 Arguments :
1253 <code> is the HTTP status code. Currently, HAProxy is capable of
1254 generating codes 400, 403, 408, 500, 502, 503, and 504.
1255
1256 <file> designates a file containing the full HTTP response. It is
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001257 recommended to follow the common practice of appending ".http" to
Willy Tarreau0ba27502007-12-24 16:55:16 +01001258 the filename so that people do not confuse the response with HTML
1259 error pages.
1260
1261 It is important to understand that this keyword is not meant to rewrite
1262 errors returned by the server, but errors detected and returned by HAProxy.
1263 This is why the list of supported errors is limited to a small set.
1264
1265 The files are returned verbatim on the TCP socket. This allows any trick such
1266 as redirections to another URL or site, as well as tricks to clean cookies,
1267 force enable or disable caching, etc... The package provides default error
1268 files returning the same contents as default errors.
1269
1270 The files are read at the same time as the configuration and kept in memory.
1271 For this reason, the errors continue to be returned even when the process is
1272 chrooted, and no file change is considered while the process is running. A
Willy Tarreauc27debf2008-01-06 08:57:02 +01001273 simple method for developing those files consists in associating them to the
Willy Tarreau0ba27502007-12-24 16:55:16 +01001274 403 status code and interrogating a blocked URL.
1275
1276 See also : "errorloc", "errorloc302", "errorloc303"
1277
Willy Tarreau2769aa02007-12-27 18:26:09 +01001278
1279errorloc <code> <url>
1280errorloc302 <code> <url>
1281 Return an HTTP redirection to a URL instead of errors generated by HAProxy
1282 May be used in sections : defaults | frontend | listen | backend
1283 yes | yes | yes | yes
1284 Arguments :
1285 <code> is the HTTP status code. Currently, HAProxy is capable of
1286 generating codes 400, 403, 408, 500, 502, 503, and 504.
1287
1288 <url> it is the exact contents of the "Location" header. It may contain
1289 either a relative URI to an error page hosted on the same site,
1290 or an absolute URI designating an error page on another site.
1291 Special care should be given to relative URIs to avoid redirect
1292 loops if the URI itself may generate the same error (eg: 500).
1293
1294 It is important to understand that this keyword is not meant to rewrite
1295 errors returned by the server, but errors detected and returned by HAProxy.
1296 This is why the list of supported errors is limited to a small set.
1297
1298 Note that both keyword return the HTTP 302 status code, which tells the
1299 client to fetch the designated URL using the same HTTP method. This can be
1300 quite problematic in case of non-GET methods such as POST, because the URL
1301 sent to the client might not be allowed for something other than GET. To
1302 workaround this problem, please use "errorloc303" which send the HTTP 303
1303 status code, indicating to the client that the URL must be fetched with a GET
1304 request.
1305
1306 See also : "errorfile", "errorloc303"
1307
1308
1309errorloc303 <code> <url>
1310 Return an HTTP redirection to a URL instead of errors generated by HAProxy
1311 May be used in sections : defaults | frontend | listen | backend
1312 yes | yes | yes | yes
1313 Arguments :
1314 <code> is the HTTP status code. Currently, HAProxy is capable of
1315 generating codes 400, 403, 408, 500, 502, 503, and 504.
1316
1317 <url> it is the exact contents of the "Location" header. It may contain
1318 either a relative URI to an error page hosted on the same site,
1319 or an absolute URI designating an error page on another site.
1320 Special care should be given to relative URIs to avoid redirect
1321 loops if the URI itself may generate the same error (eg: 500).
1322
1323 It is important to understand that this keyword is not meant to rewrite
1324 errors returned by the server, but errors detected and returned by HAProxy.
1325 This is why the list of supported errors is limited to a small set.
1326
1327 Note that both keyword return the HTTP 303 status code, which tells the
1328 client to fetch the designated URL using the same HTTP GET method. This
1329 solves the usual problems associated with "errorloc" and the 302 code. It is
1330 possible that some very old browsers designed before HTTP/1.1 do not support
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001331 it, but no such problem has been reported till now.
Willy Tarreau2769aa02007-12-27 18:26:09 +01001332
1333 See also : "errorfile", "errorloc", "errorloc302"
1334
1335
1336fullconn <conns>
1337 Specify at what backend load the servers will reach their maxconn
1338 May be used in sections : defaults | frontend | listen | backend
1339 yes | no | yes | yes
1340 Arguments :
1341 <conns> is the number of connections on the backend which will make the
1342 servers use the maximal number of connections.
1343
Willy Tarreau198a7442008-01-17 12:05:32 +01001344 When a server has a "maxconn" parameter specified, it means that its number
Willy Tarreau2769aa02007-12-27 18:26:09 +01001345 of concurrent connections will never go higher. Additionally, if it has a
Willy Tarreau198a7442008-01-17 12:05:32 +01001346 "minconn" parameter, it indicates a dynamic limit following the backend's
Willy Tarreau2769aa02007-12-27 18:26:09 +01001347 load. The server will then always accept at least <minconn> connections,
1348 never more than <maxconn>, and the limit will be on the ramp between both
1349 values when the backend has less than <conns> concurrent connections. This
1350 makes it possible to limit the load on the servers during normal loads, but
1351 push it further for important loads without overloading the servers during
1352 exceptionnal loads.
1353
1354 Example :
1355 # The servers will accept between 100 and 1000 concurrent connections each
1356 # and the maximum of 1000 will be reached when the backend reaches 10000
1357 # connections.
1358 backend dynamic
1359 fullconn 10000
1360 server srv1 dyn1:80 minconn 100 maxconn 1000
1361 server srv2 dyn2:80 minconn 100 maxconn 1000
1362
1363 See also : "maxconn", "server"
1364
1365
1366grace <time>
1367 Maintain a proxy operational for some time after a soft stop
1368 May be used in sections : defaults | frontend | listen | backend
1369 no | yes | yes | yes
1370 Arguments :
1371 <time> is the time (by default in milliseconds) for which the instance
1372 will remain operational with the frontend sockets still listening
1373 when a soft-stop is received via the SIGUSR1 signal.
1374
1375 This may be used to ensure that the services disappear in a certain order.
1376 This was designed so that frontends which are dedicated to monitoring by an
1377 external equipement fail immediately while other ones remain up for the time
1378 needed by the equipment to detect the failure.
1379
1380 Note that currently, there is very little benefit in using this parameter,
1381 and it may in fact complicate the soft-reconfiguration process more than
1382 simplify it.
1383
Willy Tarreau0ba27502007-12-24 16:55:16 +01001384
1385http-check disable-on-404
1386 Enable a maintenance mode upon HTTP/404 response to health-checks
1387 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau2769aa02007-12-27 18:26:09 +01001388 yes | no | yes | yes
Willy Tarreau0ba27502007-12-24 16:55:16 +01001389 Arguments : none
1390
1391 When this option is set, a server which returns an HTTP code 404 will be
1392 excluded from further load-balancing, but will still receive persistent
1393 connections. This provides a very convenient method for Web administrators
1394 to perform a graceful shutdown of their servers. It is also important to note
1395 that a server which is detected as failed while it was in this mode will not
1396 generate an alert, just a notice. If the server responds 2xx or 3xx again, it
1397 will immediately be reinserted into the farm. The status on the stats page
1398 reports "NOLB" for a server in this mode. It is important to note that this
1399 option only works in conjunction with the "httpchk" option.
1400
Willy Tarreau2769aa02007-12-27 18:26:09 +01001401 See also : "option httpchk"
1402
1403
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01001404id <value>
1405 Set a persistent value for proxy ID. Must be unique and larger than 1000, as
1406 smaller values are reserved for auto-assigned ids.
1407
1408
Willy Tarreau2769aa02007-12-27 18:26:09 +01001409log global
1410log <address> <facility> [<level>]
1411 Enable per-instance logging of events and traffic.
1412 May be used in sections : defaults | frontend | listen | backend
1413 yes | yes | yes | yes
1414 Arguments :
1415 global should be used when the instance's logging parameters are the
1416 same as the global ones. This is the most common usage. "global"
1417 replaces <address>, <facility> and <level> with those of the log
1418 entries found in the "global" section. Only one "log global"
1419 statement may be used per instance, and this form takes no other
1420 parameter.
1421
1422 <address> indicates where to send the logs. It takes the same format as
1423 for the "global" section's logs, and can be one of :
1424
1425 - An IPv4 address optionally followed by a colon (':') and a UDP
1426 port. If no port is specified, 514 is used by default (the
1427 standard syslog port).
1428
1429 - A filesystem path to a UNIX domain socket, keeping in mind
1430 considerations for chroot (be sure the path is accessible
1431 inside the chroot) and uid/gid (be sure the path is
1432 appropriately writeable).
1433
1434 <facility> must be one of the 24 standard syslog facilities :
1435
1436 kern user mail daemon auth syslog lpr news
1437 uucp cron auth2 ftp ntp audit alert cron2
1438 local0 local1 local2 local3 local4 local5 local6 local7
1439
1440 <level> is optional and can be specified to filter outgoing messages. By
1441 default, all messages are sent. If a level is specified, only
1442 messages with a severity at least as important as this level
1443 will be sent. 8 levels are known :
1444
1445 emerg alert crit err warning notice info debug
1446
1447 Note that up to two "log" entries may be specified per instance. However, if
1448 "log global" is used and if the "global" section already contains 2 log
1449 entries, then additional log entries will be ignored.
1450
1451 Also, it is important to keep in mind that it is the frontend which decides
1452 what to log, and that in case of content switching, the log entries from the
1453 backend will be ignored.
1454
1455 Example :
1456 log global
1457 log 127.0.0.1:514 local0 notice
1458
1459
1460maxconn <conns>
1461 Fix the maximum number of concurrent connections on a frontend
1462 May be used in sections : defaults | frontend | listen | backend
1463 yes | yes | yes | no
1464 Arguments :
1465 <conns> is the maximum number of concurrent connections the frontend will
1466 accept to serve. Excess connections will be queued by the system
1467 in the socket's listen queue and will be served once a connection
1468 closes.
1469
1470 If the system supports it, it can be useful on big sites to raise this limit
1471 very high so that haproxy manages connection queues, instead of leaving the
1472 clients with unanswered connection attempts. This value should not exceed the
1473 global maxconn. Also, keep in mind that a connection contains two buffers
1474 of 8kB each, as well as some other data resulting in about 17 kB of RAM being
1475 consumed per established connection. That means that a medium system equipped
1476 with 1GB of RAM can withstand around 40000-50000 concurrent connections if
1477 properly tuned.
1478
1479 Also, when <conns> is set to large values, it is possible that the servers
1480 are not sized to accept such loads, and for this reason it is generally wise
1481 to assign them some reasonable connection limits.
1482
1483 See also : "server", global section's "maxconn", "fullconn"
1484
1485
1486mode { tcp|http|health }
1487 Set the running mode or protocol of the instance
1488 May be used in sections : defaults | frontend | listen | backend
1489 yes | yes | yes | yes
1490 Arguments :
1491 tcp The instance will work in pure TCP mode. A full-duplex connection
1492 will be established between clients and servers, and no layer 7
1493 examination will be performed. This is the default mode. It
1494 should be used for SSL, SSH, SMTP, ...
1495
1496 http The instance will work in HTTP mode. The client request will be
1497 analyzed in depth before connecting to any server. Any request
1498 which is not RFC-compliant will be rejected. Layer 7 filtering,
1499 processing and switching will be possible. This is the mode which
1500 brings HAProxy most of its value.
1501
1502 health The instance will work in "health" mode. It will just reply "OK"
1503 to incoming connections and close the connection. Nothing will be
1504 logged. This mode is used to reply to external components health
1505 checks. This mode is deprecated and should not be used anymore as
1506 it is possible to do the same and even better by combining TCP or
1507 HTTP modes with the "monitor" keyword.
1508
1509 When doing content switching, it is mandatory that the frontend and the
1510 backend are in the same mode (generally HTTP), otherwise the configuration
1511 will be refused.
1512
1513 Example :
1514 defaults http_instances
1515 mode http
1516
1517 See also : "monitor", "monitor-net"
1518
Willy Tarreau0ba27502007-12-24 16:55:16 +01001519
1520monitor fail [if | unless] <condition>
Willy Tarreau2769aa02007-12-27 18:26:09 +01001521 Add a condition to report a failure to a monitor HTTP request.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001522 May be used in sections : defaults | frontend | listen | backend
1523 no | yes | yes | no
Willy Tarreau0ba27502007-12-24 16:55:16 +01001524 Arguments :
1525 if <cond> the monitor request will fail if the condition is satisfied,
1526 and will succeed otherwise. The condition should describe a
1527 combinated test which must induce a failure if all conditions
1528 are met, for instance a low number of servers both in a
1529 backend and its backup.
1530
1531 unless <cond> the monitor request will succeed only if the condition is
1532 satisfied, and will fail otherwise. Such a condition may be
1533 based on a test on the presence of a minimum number of active
1534 servers in a list of backends.
1535
1536 This statement adds a condition which can force the response to a monitor
1537 request to report a failure. By default, when an external component queries
1538 the URI dedicated to monitoring, a 200 response is returned. When one of the
1539 conditions above is met, haproxy will return 503 instead of 200. This is
1540 very useful to report a site failure to an external component which may base
1541 routing advertisements between multiple sites on the availability reported by
1542 haproxy. In this case, one would rely on an ACL involving the "nbsrv"
Willy Tarreau2769aa02007-12-27 18:26:09 +01001543 criterion. Note that "monitor fail" only works in HTTP mode.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001544
1545 Example:
1546 frontend www
Willy Tarreau2769aa02007-12-27 18:26:09 +01001547 mode http
Willy Tarreau0ba27502007-12-24 16:55:16 +01001548 acl site_dead nbsrv(dynamic) lt 2
1549 acl site_dead nbsrv(static) lt 2
1550 monitor-uri /site_alive
1551 monitor fail if site_dead
1552
Willy Tarreau2769aa02007-12-27 18:26:09 +01001553 See also : "monitor-net", "monitor-uri"
1554
1555
1556monitor-net <source>
1557 Declare a source network which is limited to monitor requests
1558 May be used in sections : defaults | frontend | listen | backend
1559 yes | yes | yes | no
1560 Arguments :
1561 <source> is the source IPv4 address or network which will only be able to
1562 get monitor responses to any request. It can be either an IPv4
1563 address, a host name, or an address followed by a slash ('/')
1564 followed by a mask.
1565
1566 In TCP mode, any connection coming from a source matching <source> will cause
1567 the connection to be immediately closed without any log. This allows another
1568 equipement to probe the port and verify that it is still listening, without
1569 forwarding the connection to a remote server.
1570
1571 In HTTP mode, a connection coming from a source matching <source> will be
1572 accepted, the following response will be sent without waiting for a request,
1573 then the connection will be closed : "HTTP/1.0 200 OK". This is normally
1574 enough for any front-end HTTP probe to detect that the service is UP and
1575 running without forwarding the request to a backend server.
1576
1577 Monitor requests are processed very early. It is not possible to block nor
1578 divert them using ACLs. They cannot be logged either, and it is the intended
1579 purpose. They are only used to report HAProxy's health to an upper component,
1580 nothing more. Right now, it is not possible to set failure conditions on
1581 requests caught by "monitor-net".
1582
1583 Example :
1584 # addresses .252 and .253 are just probing us.
1585 frontend www
1586 monitor-net 192.168.0.252/31
1587
1588 See also : "monitor fail", "monitor-uri"
1589
1590
1591monitor-uri <uri>
1592 Intercept a URI used by external components' monitor requests
1593 May be used in sections : defaults | frontend | listen | backend
1594 yes | yes | yes | no
1595 Arguments :
1596 <uri> is the exact URI which we want to intercept to return HAProxy's
1597 health status instead of forwarding the request.
1598
1599 When an HTTP request referencing <uri> will be received on a frontend,
1600 HAProxy will not forward it nor log it, but instead will return either
1601 "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure
1602 conditions defined with "monitor fail". This is normally enough for any
1603 front-end HTTP probe to detect that the service is UP and running without
1604 forwarding the request to a backend server. Note that the HTTP method, the
1605 version and all headers are ignored, but the request must at least be valid
1606 at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
1607
1608 Monitor requests are processed very early. It is not possible to block nor
1609 divert them using ACLs. They cannot be logged either, and it is the intended
1610 purpose. They are only used to report HAProxy's health to an upper component,
1611 nothing more. However, it is possible to add any number of conditions using
1612 "monitor fail" and ACLs so that the result can be adjusted to whatever check
1613 can be imagined (most often the number of available servers in a backend).
1614
1615 Example :
1616 # Use /haproxy_test to report haproxy's status
1617 frontend www
1618 mode http
1619 monitor-uri /haproxy_test
1620
1621 See also : "monitor fail", "monitor-net"
1622
Willy Tarreau0ba27502007-12-24 16:55:16 +01001623
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001624option abortonclose
1625no option abortonclose
1626 Enable or disable early dropping of aborted requests pending in queues.
1627 May be used in sections : defaults | frontend | listen | backend
1628 yes | no | yes | yes
1629 Arguments : none
1630
1631 In presence of very high loads, the servers will take some time to respond.
1632 The per-instance connection queue will inflate, and the response time will
1633 increase respective to the size of the queue times the average per-session
1634 response time. When clients will wait for more than a few seconds, they will
Willy Tarreau198a7442008-01-17 12:05:32 +01001635 often hit the "STOP" button on their browser, leaving a useless request in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001636 the queue, and slowing down other users, and the servers as well, because the
1637 request will eventually be served, then aborted at the first error
1638 encountered while delivering the response.
1639
1640 As there is no way to distinguish between a full STOP and a simple output
1641 close on the client side, HTTP agents should be conservative and consider
1642 that the client might only have closed its output channel while waiting for
1643 the response. However, this introduces risks of congestion when lots of users
1644 do the same, and is completely useless nowadays because probably no client at
1645 all will close the session while waiting for the response. Some HTTP agents
1646 support this behaviour (Squid, Apache, HAProxy), and others do not (TUX, most
1647 hardware-based load balancers). So the probability for a closed input channel
Willy Tarreau198a7442008-01-17 12:05:32 +01001648 to represent a user hitting the "STOP" button is close to 100%, and the risk
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001649 of being the single component to break rare but valid traffic is extremely
1650 low, which adds to the temptation to be able to abort a session early while
1651 still not served and not pollute the servers.
1652
1653 In HAProxy, the user can choose the desired behaviour using the option
1654 "abortonclose". By default (without the option) the behaviour is HTTP
1655 compliant and aborted requests will be served. But when the option is
1656 specified, a session with an incoming channel closed will be aborted while
1657 it is still possible, either pending in the queue for a connection slot, or
1658 during the connection establishment if the server has not yet acknowledged
1659 the connection request. This considerably reduces the queue size and the load
1660 on saturated servers when users are tempted to click on STOP, which in turn
1661 reduces the response time for other users.
1662
1663 If this option has been enabled in a "defaults" section, it can be disabled
1664 in a specific instance by prepending the "no" keyword before it.
1665
1666 See also : "timeout queue" and server's "maxconn" and "maxqueue" parameters
1667
1668
1669option allbackups
1670no option allbackups
1671 Use either all backup servers at a time or only the first one
1672 May be used in sections : defaults | frontend | listen | backend
1673 yes | no | yes | yes
1674 Arguments : none
1675
1676 By default, the first operational backup server gets all traffic when normal
1677 servers are all down. Sometimes, it may be preferred to use multiple backups
1678 at once, because one will not be enough. When "option allbackups" is enabled,
1679 the load balancing will be performed among all backup servers when all normal
1680 ones are unavailable. The same load balancing algorithm will be used and the
1681 servers' weights will be respected. Thus, there will not be any priority
1682 order between the backup servers anymore.
1683
1684 This option is mostly used with static server farms dedicated to return a
1685 "sorry" page when an application is completely offline.
1686
1687 If this option has been enabled in a "defaults" section, it can be disabled
1688 in a specific instance by prepending the "no" keyword before it.
1689
1690
1691option checkcache
1692no option checkcache
1693 Analyze all server responses and block requests with cachable cookies
1694 May be used in sections : defaults | frontend | listen | backend
1695 yes | no | yes | yes
1696 Arguments : none
1697
1698 Some high-level frameworks set application cookies everywhere and do not
1699 always let enough control to the developer to manage how the responses should
1700 be cached. When a session cookie is returned on a cachable object, there is a
1701 high risk of session crossing or stealing between users traversing the same
1702 caches. In some situations, it is better to block the response than to let
1703 some sensible session information go in the wild.
1704
1705 The option "checkcache" enables deep inspection of all server responses for
1706 strict compliance with HTTP specification in terms of cachability. It
Willy Tarreau198a7442008-01-17 12:05:32 +01001707 carefully checks "Cache-control", "Pragma" and "Set-cookie" headers in server
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001708 response to check if there's a risk of caching a cookie on a client-side
1709 proxy. When this option is enabled, the only responses which can be delivered
Willy Tarreau198a7442008-01-17 12:05:32 +01001710 to the client are :
1711 - all those without "Set-Cookie" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001712 - all those with a return code other than 200, 203, 206, 300, 301, 410,
Willy Tarreau198a7442008-01-17 12:05:32 +01001713 provided that the server has not set a "Cache-control: public" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001714 - all those that come from a POST request, provided that the server has not
1715 set a 'Cache-Control: public' header ;
1716 - those with a 'Pragma: no-cache' header
1717 - those with a 'Cache-control: private' header
1718 - those with a 'Cache-control: no-store' header
1719 - those with a 'Cache-control: max-age=0' header
1720 - those with a 'Cache-control: s-maxage=0' header
1721 - those with a 'Cache-control: no-cache' header
1722 - those with a 'Cache-control: no-cache="set-cookie"' header
1723 - those with a 'Cache-control: no-cache="set-cookie,' header
1724 (allowing other fields after set-cookie)
1725
1726 If a response doesn't respect these requirements, then it will be blocked
Willy Tarreau198a7442008-01-17 12:05:32 +01001727 just as if it was from an "rspdeny" filter, with an "HTTP 502 bad gateway".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001728 The session state shows "PH--" meaning that the proxy blocked the response
1729 during headers processing. Additionnaly, an alert will be sent in the logs so
1730 that admins are informed that there's something to be fixed.
1731
1732 Due to the high impact on the application, the application should be tested
1733 in depth with the option enabled before going to production. It is also a
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001734 good practice to always activate it during tests, even if it is not used in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001735 production, as it will report potentially dangerous application behaviours.
1736
1737 If this option has been enabled in a "defaults" section, it can be disabled
1738 in a specific instance by prepending the "no" keyword before it.
1739
1740
1741option clitcpka
1742no option clitcpka
1743 Enable or disable the sending of TCP keepalive packets on the client side
1744 May be used in sections : defaults | frontend | listen | backend
1745 yes | yes | yes | no
1746 Arguments : none
1747
1748 When there is a firewall or any session-aware component between a client and
1749 a server, and when the protocol involves very long sessions with long idle
1750 periods (eg: remote desktops), there is a risk that one of the intermediate
1751 components decides to expire a session which has remained idle for too long.
1752
1753 Enabling socket-level TCP keep-alives makes the system regularly send packets
1754 to the other end of the connection, leaving it active. The delay between
1755 keep-alive probes is controlled by the system only and depends both on the
1756 operating system and its tuning parameters.
1757
1758 It is important to understand that keep-alive packets are neither emitted nor
1759 received at the application level. It is only the network stacks which sees
1760 them. For this reason, even if one side of the proxy already uses keep-alives
1761 to maintain its connection alive, those keep-alive packets will not be
1762 forwarded to the other side of the proxy.
1763
1764 Please note that this has nothing to do with HTTP keep-alive.
1765
1766 Using option "clitcpka" enables the emission of TCP keep-alive probes on the
1767 client side of a connection, which should help when session expirations are
1768 noticed between HAProxy and a client.
1769
1770 If this option has been enabled in a "defaults" section, it can be disabled
1771 in a specific instance by prepending the "no" keyword before it.
1772
1773 See also : "option srvtcpka", "option tcpka"
1774
1775
Willy Tarreau0ba27502007-12-24 16:55:16 +01001776option contstats
1777 Enable continuous traffic statistics updates
1778 May be used in sections : defaults | frontend | listen | backend
1779 yes | yes | yes | no
1780 Arguments : none
1781
1782 By default, counters used for statistics calculation are incremented
1783 only when a session finishes. It works quite well when serving small
1784 objects, but with big ones (for example large images or archives) or
1785 with A/V streaming, a graph generated from haproxy counters looks like
1786 a hedgehog. With this option enabled counters get incremented continuously,
1787 during a whole session. Recounting touches a hotpath directly so
1788 it is not enabled by default, as it has small performance impact (~0.5%).
1789
1790
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001791option dontlognull
1792no option dontlognull
1793 Enable or disable logging of null connections
1794 May be used in sections : defaults | frontend | listen | backend
1795 yes | yes | yes | no
1796 Arguments : none
1797
1798 In certain environments, there are components which will regularly connect to
1799 various systems to ensure that they are still alive. It can be the case from
1800 another load balancer as well as from monitoring systems. By default, even a
1801 simple port probe or scan will produce a log. If those connections pollute
1802 the logs too much, it is possible to enable option "dontlognull" to indicate
1803 that a connection on which no data has been transferred will not be logged,
1804 which typically corresponds to those probes.
1805
1806 It is generally recommended not to use this option in uncontrolled
1807 environments (eg: internet), otherwise scans and other malicious activities
1808 would not be logged.
1809
1810 If this option has been enabled in a "defaults" section, it can be disabled
1811 in a specific instance by prepending the "no" keyword before it.
1812
Willy Tarreauced27012008-01-17 20:35:34 +01001813 See also : "log", "monitor-net", "monitor-uri" and section 2.6 about logging.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001814
1815
1816option forceclose
1817no option forceclose
1818 Enable or disable active connection closing after response is transferred.
1819 May be used in sections : defaults | frontend | listen | backend
1820 yes | no | yes | yes
1821 Arguments : none
1822
1823 Some HTTP servers do not necessarily close the connections when they receive
1824 the "Connection: close" set by "option httpclose", and if the client does not
1825 close either, then the connection remains open till the timeout expires. This
1826 causes high number of simultaneous connections on the servers and shows high
1827 global session times in the logs.
1828
1829 When this happens, it is possible to use "option forceclose". It will
1830 actively close the outgoing server channel as soon as the server begins to
1831 reply and only if the request buffer is empty. Note that this should NOT be
1832 used if CONNECT requests are expected between the client and the server. This
1833 option implicitly enables the "httpclose" option.
1834
1835 If this option has been enabled in a "defaults" section, it can be disabled
1836 in a specific instance by prepending the "no" keyword before it.
1837
1838 See also : "option httpclose"
1839
1840
Ross Westaf72a1d2008-08-03 10:51:45 +02001841option forwardfor [ except <network> ] [ header <name> ]
Willy Tarreauc27debf2008-01-06 08:57:02 +01001842 Enable insertion of the X-Forwarded-For header to requests sent to servers
1843 May be used in sections : defaults | frontend | listen | backend
1844 yes | yes | yes | yes
1845 Arguments :
1846 <network> is an optional argument used to disable this option for sources
1847 matching <network>
Ross Westaf72a1d2008-08-03 10:51:45 +02001848 <name> an optional argument to specify a different "X-Forwarded-For"
1849 header name.
Willy Tarreauc27debf2008-01-06 08:57:02 +01001850
1851 Since HAProxy works in reverse-proxy mode, the servers see its IP address as
1852 their client address. This is sometimes annoying when the client's IP address
1853 is expected in server logs. To solve this problem, the well-known HTTP header
1854 "X-Forwarded-For" may be added by HAProxy to all requests sent to the server.
1855 This header contains a value representing the client's IP address. Since this
1856 header is always appended at the end of the existing header list, the server
1857 must be configured to always use the last occurrence of this header only. See
Ross Westaf72a1d2008-08-03 10:51:45 +02001858 the server's manual to find how to enable use of this standard header. Note
1859 that only the last occurrence of the header must be used, since it is really
1860 possible that the client has already brought one.
1861
1862 The keyword "header" may be used to supply a different header name to replace
1863 the default "X-Forwarded-For". This can be useful where you might already
1864 have a "X-Forwarded-For" header from a different application (eg: stunnel),
1865 and you need preserve it. Also if your backend server doesn't use the
1866 "X-Forwarded-For" header and requires different one (eg: Zeus Web Servers
1867 require "X-Cluster-Client-IP").
Willy Tarreauc27debf2008-01-06 08:57:02 +01001868
1869 Sometimes, a same HAProxy instance may be shared between a direct client
1870 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
1871 used to decrypt HTTPS traffic). It is possible to disable the addition of the
1872 header for a known source address or network by adding the "except" keyword
1873 followed by the network address. In this case, any source IP matching the
1874 network will not cause an addition of this header. Most common uses are with
1875 private networks or 127.0.0.1.
1876
1877 This option may be specified either in the frontend or in the backend. If at
Ross Westaf72a1d2008-08-03 10:51:45 +02001878 least one of them uses it, the header will be added. Note that the backend's
1879 setting of the header subargument takes precedence over the frontend's if
1880 both are defined.
Willy Tarreauc27debf2008-01-06 08:57:02 +01001881
1882 It is important to note that as long as HAProxy does not support keep-alive
1883 connections, only the first request of a connection will receive the header.
1884 For this reason, it is important to ensure that "option httpclose" is set
1885 when using this option.
1886
Ross Westaf72a1d2008-08-03 10:51:45 +02001887 Examples :
Willy Tarreauc27debf2008-01-06 08:57:02 +01001888 # Public HTTP address also used by stunnel on the same machine
1889 frontend www
1890 mode http
1891 option forwardfor except 127.0.0.1 # stunnel already adds the header
1892
Ross Westaf72a1d2008-08-03 10:51:45 +02001893 # Those servers want the IP Address in X-Client
1894 backend www
1895 mode http
1896 option forwardfor header X-Client
1897
Willy Tarreauc27debf2008-01-06 08:57:02 +01001898 See also : "option httpclose"
1899
1900
1901option http_proxy
1902no option http_proxy
1903 Enable or disable plain HTTP proxy mode
1904 May be used in sections : defaults | frontend | listen | backend
1905 yes | yes | yes | yes
1906 Arguments : none
1907
1908 It sometimes happens that people need a pure HTTP proxy which understands
1909 basic proxy requests without caching nor any fancy feature. In this case,
1910 it may be worth setting up an HAProxy instance with the "option http_proxy"
1911 set. In this mode, no server is declared, and the connection is forwarded to
1912 the IP address and port found in the URL after the "http://" scheme.
1913
1914 No host address resolution is performed, so this only works when pure IP
1915 addresses are passed. Since this option's usage perimeter is rather limited,
1916 it will probably be used only by experts who know they need exactly it. Last,
1917 if the clients are susceptible of sending keep-alive requests, it will be
1918 needed to add "option http_close" to ensure that all requests will correctly
1919 be analyzed.
1920
1921 If this option has been enabled in a "defaults" section, it can be disabled
1922 in a specific instance by prepending the "no" keyword before it.
1923
1924 Example :
1925 # this backend understands HTTP proxy requests and forwards them directly.
1926 backend direct_forward
1927 option httpclose
1928 option http_proxy
1929
1930 See also : "option httpclose"
1931
1932
1933option httpchk
1934option httpchk <uri>
1935option httpchk <method> <uri>
1936option httpchk <method> <uri> <version>
1937 Enable HTTP protocol to check on the servers health
1938 May be used in sections : defaults | frontend | listen | backend
1939 yes | no | yes | yes
1940 Arguments :
1941 <method> is the optional HTTP method used with the requests. When not set,
1942 the "OPTIONS" method is used, as it generally requires low server
1943 processing and is easy to filter out from the logs. Any method
1944 may be used, though it is not recommended to invent non-standard
1945 ones.
1946
1947 <uri> is the URI referenced in the HTTP requests. It defaults to " / "
1948 which is accessible by default on almost any server, but may be
1949 changed to any other URI. Query strings are permitted.
1950
1951 <version> is the optional HTTP version string. It defaults to "HTTP/1.0"
1952 but some servers might behave incorrectly in HTTP 1.0, so turning
1953 it to HTTP/1.1 may sometimes help. Note that the Host field is
1954 mandatory in HTTP/1.1, and as a trick, it is possible to pass it
1955 after "\r\n" following the version string.
1956
1957 By default, server health checks only consist in trying to establish a TCP
1958 connection. When "option httpchk" is specified, a complete HTTP request is
1959 sent once the TCP connection is established, and responses 2xx and 3xx are
1960 considered valid, while all other ones indicate a server failure, including
1961 the lack of any response.
1962
1963 The port and interval are specified in the server configuration.
1964
1965 This option does not necessarily require an HTTP backend, it also works with
1966 plain TCP backends. This is particularly useful to check simple scripts bound
1967 to some dedicated ports using the inetd daemon.
1968
1969 Examples :
1970 # Relay HTTPS traffic to Apache instance and check service availability
1971 # using HTTP request "OPTIONS * HTTP/1.1" on port 80.
1972 backend https_relay
1973 mode tcp
Willy Tarreauebaf21a2008-03-21 20:17:14 +01001974 option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
Willy Tarreauc27debf2008-01-06 08:57:02 +01001975 server apache1 192.168.1.1:443 check port 80
1976
1977 See also : "option ssl-hello-chk", "option smtpchk", "http-check" and the
1978 "check", "port" and "interval" server options.
1979
1980
1981option httpclose
1982no option httpclose
1983 Enable or disable passive HTTP connection closing
1984 May be used in sections : defaults | frontend | listen | backend
1985 yes | yes | yes | yes
1986 Arguments : none
1987
1988 As stated in section 2.1, HAProxy does not yes support the HTTP keep-alive
1989 mode. So by default, if a client communicates with a server in this mode, it
1990 will only analyze, log, and process the first request of each connection. To
1991 workaround this limitation, it is possible to specify "option httpclose". It
1992 will check if a "Connection: close" header is already set in each direction,
1993 and will add one if missing. Each end should react to this by actively
1994 closing the TCP connection after each transfer, thus resulting in a switch to
1995 the HTTP close mode. Any "Connection" header different from "close" will also
1996 be removed.
1997
1998 It seldom happens that some servers incorrectly ignore this header and do not
1999 close the connection eventough they reply "Connection: close". For this
2000 reason, they are not compatible with older HTTP 1.0 browsers. If this
2001 happens it is possible to use the "option forceclose" which actively closes
2002 the request connection once the server responds.
2003
2004 This option may be set both in a frontend and in a backend. It is enabled if
2005 at least one of the frontend or backend holding a connection has it enabled.
2006 If "option forceclose" is specified too, it has precedence over "httpclose".
2007
2008 If this option has been enabled in a "defaults" section, it can be disabled
2009 in a specific instance by prepending the "no" keyword before it.
2010
2011 See also : "option forceclose"
2012
2013
2014option httplog
2015 Enable logging of HTTP request, session state and timers
2016 May be used in sections : defaults | frontend | listen | backend
2017 yes | yes | yes | yes
2018 Arguments : none
2019
2020 By default, the log output format is very poor, as it only contains the
2021 source and destination addresses, and the instance name. By specifying
2022 "option httplog", each log line turns into a much richer format including,
2023 but not limited to, the HTTP request, the connection timers, the session
2024 status, the connections numbers, the captured headers and cookies, the
2025 frontend, backend and server name, and of course the source address and
2026 ports.
2027
2028 This option may be set either in the frontend or the backend.
2029
Willy Tarreauced27012008-01-17 20:35:34 +01002030 See also : section 2.6 about logging.
Willy Tarreauc27debf2008-01-06 08:57:02 +01002031
Willy Tarreauc27debf2008-01-06 08:57:02 +01002032
2033option logasap
2034no option logasap
2035 Enable or disable early logging of HTTP requests
2036 May be used in sections : defaults | frontend | listen | backend
2037 yes | yes | yes | no
2038 Arguments : none
2039
2040 By default, HTTP requests are logged upon termination so that the total
2041 transfer time and the number of bytes appear in the logs. When large objects
2042 are being transferred, it may take a while before the request appears in the
2043 logs. Using "option logasap", the request gets logged as soon as the server
2044 sends the complete headers. The only missing information in the logs will be
2045 the total number of bytes which will indicate everything except the amount
2046 of data transferred, and the total time which will not take the transfer
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002047 time into account. In such a situation, it's a good practice to capture the
Willy Tarreauc27debf2008-01-06 08:57:02 +01002048 "Content-Length" response header so that the logs at least indicate how many
2049 bytes are expected to be transferred.
2050
Willy Tarreauced27012008-01-17 20:35:34 +01002051 See also : "option httplog", "capture response header", and section 2.6 about
Willy Tarreauc27debf2008-01-06 08:57:02 +01002052 logging.
2053
2054
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002055option nolinger
2056no option nolinger
2057 Enable or disable immediate session ressource cleaning after close
2058 May be used in sections: defaults | frontend | listen | backend
2059 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002060 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002061
2062 When clients or servers abort connections in a dirty way (eg: they are
2063 physically disconnected), the session timeouts triggers and the session is
2064 closed. But it will remain in FIN_WAIT1 state for some time in the system,
2065 using some resources and possibly limiting the ability to establish newer
2066 connections.
2067
2068 When this happens, it is possible to activate "option nolinger" which forces
2069 the system to immediately remove any socket's pending data on close. Thus,
2070 the session is instantly purged from the system's tables. This usually has
2071 side effects such as increased number of TCP resets due to old retransmits
2072 getting immediately rejected. Some firewalls may sometimes complain about
2073 this too.
2074
2075 For this reason, it is not recommended to use this option when not absolutely
2076 needed. You know that you need it when you have thousands of FIN_WAIT1
2077 sessions on your system (TIME_WAIT ones do not count).
2078
2079 This option may be used both on frontends and backends, depending on the side
2080 where it is required. Use it on the frontend for clients, and on the backend
2081 for servers.
2082
2083 If this option has been enabled in a "defaults" section, it can be disabled
2084 in a specific instance by prepending the "no" keyword before it.
2085
2086
2087option persist
2088no option persist
2089 Enable or disable forced persistence on down servers
2090 May be used in sections: defaults | frontend | listen | backend
2091 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002092 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002093
2094 When an HTTP request reaches a backend with a cookie which references a dead
2095 server, by default it is redispatched to another server. It is possible to
2096 force the request to be sent to the dead server first using "option persist"
2097 if absolutely needed. A common use case is when servers are under extreme
2098 load and spend their time flapping. In this case, the users would still be
2099 directed to the server they opened the session on, in the hope they would be
2100 correctly served. It is recommended to use "option redispatch" in conjunction
2101 with this option so that in the event it would not be possible to connect to
2102 the server at all (server definitely dead), the client would finally be
2103 redirected to another valid server.
2104
2105 If this option has been enabled in a "defaults" section, it can be disabled
2106 in a specific instance by prepending the "no" keyword before it.
2107
2108 See also : "option redispatch", "retries"
2109
2110
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002111option redispatch
2112no option redispatch
2113 Enable or disable session redistribution in case of connection failure
2114 May be used in sections: defaults | frontend | listen | backend
2115 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002116 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002117
2118 In HTTP mode, if a server designated by a cookie is down, clients may
2119 definitely stick to it because they cannot flush the cookie, so they will not
2120 be able to access the service anymore.
2121
2122 Specifying "option redispatch" will allow the proxy to break their
2123 persistence and redistribute them to a working server.
2124
2125 It also allows to retry last connection to another server in case of multiple
2126 connection failures. Of course, it requires having "retries" set to a nonzero
2127 value.
2128
2129 This form is the preferred form, which replaces both the "redispatch" and
2130 "redisp" keywords.
2131
2132 If this option has been enabled in a "defaults" section, it can be disabled
2133 in a specific instance by prepending the "no" keyword before it.
2134
2135 See also : "redispatch", "retries"
2136
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002137
2138option smtpchk
2139option smtpchk <hello> <domain>
2140 Use SMTP health checks for server testing
2141 May be used in sections : defaults | frontend | listen | backend
2142 yes | no | yes | yes
2143 Arguments :
2144 <hello> is an optional argument. It is the "hello" command to use. It can
2145 be either "HELO" (for SMTP) or "EHLO" (for ESTMP). All other
2146 values will be turned into the default command ("HELO").
2147
2148 <domain> is the domain name to present to the server. It may only be
2149 specified (and is mandatory) if the hello command has been
2150 specified. By default, "localhost" is used.
2151
2152 When "option smtpchk" is set, the health checks will consist in TCP
2153 connections followed by an SMTP command. By default, this command is
2154 "HELO localhost". The server's return code is analyzed and only return codes
2155 starting with a "2" will be considered as valid. All other responses,
2156 including a lack of response will constitute an error and will indicate a
2157 dead server.
2158
2159 This test is meant to be used with SMTP servers or relays. Depending on the
2160 request, it is possible that some servers do not log each connection attempt,
2161 so you may want to experiment to improve the behaviour. Using telnet on port
2162 25 is often easier than adjusting the configuration.
2163
2164 Most often, an incoming SMTP server needs to see the client's IP address for
2165 various purposes, including spam filtering, anti-spoofing and logging. When
2166 possible, it is often wise to masquerade the client's IP address when
2167 connecting to the server using the "usesrc" argument of the "source" keyword,
2168 which requires the cttproxy feature to be compiled in.
2169
2170 Example :
2171 option smtpchk HELO mydomain.org
2172
2173 See also : "option httpchk", "source"
2174
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002175
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002176option srvtcpka
2177no option srvtcpka
2178 Enable or disable the sending of TCP keepalive packets on the server side
2179 May be used in sections : defaults | frontend | listen | backend
2180 yes | no | yes | yes
2181 Arguments : none
2182
2183 When there is a firewall or any session-aware component between a client and
2184 a server, and when the protocol involves very long sessions with long idle
2185 periods (eg: remote desktops), there is a risk that one of the intermediate
2186 components decides to expire a session which has remained idle for too long.
2187
2188 Enabling socket-level TCP keep-alives makes the system regularly send packets
2189 to the other end of the connection, leaving it active. The delay between
2190 keep-alive probes is controlled by the system only and depends both on the
2191 operating system and its tuning parameters.
2192
2193 It is important to understand that keep-alive packets are neither emitted nor
2194 received at the application level. It is only the network stacks which sees
2195 them. For this reason, even if one side of the proxy already uses keep-alives
2196 to maintain its connection alive, those keep-alive packets will not be
2197 forwarded to the other side of the proxy.
2198
2199 Please note that this has nothing to do with HTTP keep-alive.
2200
2201 Using option "srvtcpka" enables the emission of TCP keep-alive probes on the
2202 server side of a connection, which should help when session expirations are
2203 noticed between HAProxy and a server.
2204
2205 If this option has been enabled in a "defaults" section, it can be disabled
2206 in a specific instance by prepending the "no" keyword before it.
2207
2208 See also : "option clitcpka", "option tcpka"
2209
2210
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002211option ssl-hello-chk
2212 Use SSLv3 client hello health checks for server testing
2213 May be used in sections : defaults | frontend | listen | backend
2214 yes | no | yes | yes
2215 Arguments : none
2216
2217 When some SSL-based protocols are relayed in TCP mode through HAProxy, it is
2218 possible to test that the server correctly talks SSL instead of just testing
2219 that it accepts the TCP connection. When "option ssl-hello-chk" is set, pure
2220 SSLv3 client hello messages are sent once the connection is established to
2221 the server, and the response is analyzed to find an SSL server hello message.
2222 The server is considered valid only when the response contains this server
2223 hello message.
2224
2225 All servers tested till there correctly reply to SSLv3 client hello messages,
2226 and most servers tested do not even log the requests containing only hello
2227 messages, which is appreciable.
2228
2229 See also: "option httpchk"
2230
2231
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002232option tcpka
2233 Enable or disable the sending of TCP keepalive packets on both sides
2234 May be used in sections : defaults | frontend | listen | backend
2235 yes | yes | yes | yes
2236 Arguments : none
2237
2238 When there is a firewall or any session-aware component between a client and
2239 a server, and when the protocol involves very long sessions with long idle
2240 periods (eg: remote desktops), there is a risk that one of the intermediate
2241 components decides to expire a session which has remained idle for too long.
2242
2243 Enabling socket-level TCP keep-alives makes the system regularly send packets
2244 to the other end of the connection, leaving it active. The delay between
2245 keep-alive probes is controlled by the system only and depends both on the
2246 operating system and its tuning parameters.
2247
2248 It is important to understand that keep-alive packets are neither emitted nor
2249 received at the application level. It is only the network stacks which sees
2250 them. For this reason, even if one side of the proxy already uses keep-alives
2251 to maintain its connection alive, those keep-alive packets will not be
2252 forwarded to the other side of the proxy.
2253
2254 Please note that this has nothing to do with HTTP keep-alive.
2255
2256 Using option "tcpka" enables the emission of TCP keep-alive probes on both
2257 the client and server sides of a connection. Note that this is meaningful
2258 only in "defaults" or "listen" sections. If this option is used in a
2259 frontend, only the client side will get keep-alives, and if this option is
2260 used in a backend, only the server side will get keep-alives. For this
2261 reason, it is strongly recommended to explicitly use "option clitcpka" and
2262 "option srvtcpka" when the configuration is split between frontends and
2263 backends.
2264
2265 See also : "option clitcpka", "option srvtcpka"
2266
Willy Tarreau844e3c52008-01-11 16:28:18 +01002267
2268option tcplog
2269 Enable advanced logging of TCP connections with session state and timers
2270 May be used in sections : defaults | frontend | listen | backend
2271 yes | yes | yes | yes
2272 Arguments : none
2273
2274 By default, the log output format is very poor, as it only contains the
2275 source and destination addresses, and the instance name. By specifying
2276 "option tcplog", each log line turns into a much richer format including, but
2277 not limited to, the connection timers, the session status, the connections
2278 numbers, the frontend, backend and server name, and of course the source
2279 address and ports. This option is useful for pure TCP proxies in order to
2280 find which of the client or server disconnects or times out. For normal HTTP
2281 proxies, it's better to use "option httplog" which is even more complete.
2282
2283 This option may be set either in the frontend or the backend.
2284
Willy Tarreauced27012008-01-17 20:35:34 +01002285 See also : "option httplog", and section 2.6 about logging.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002286
2287
2288option tcpsplice [ experimental ]
2289 Enable linux kernel-based acceleration of data relaying
2290 May be used in sections : defaults | frontend | listen | backend
2291 yes | yes | yes | yes
2292 Arguments : none
2293
2294 This option is only available when HAProxy has been built for use on Linux
2295 with USE_TCPSPLICE=1. This option requires a kernel patch which is available
2296 on http://www.linux-l7sw.org/.
2297
2298 When "option tcpsplice" is set, as soon as the server's response headers have
2299 been transferred, the session handling is transferred to the kernel which
2300 will forward all subsequent data from the server to the client untill the
2301 session closes. This leads to much faster data transfers between client and
2302 server since the data is not copied twice between kernel and user space, but
2303 there are some limitations such as the lack of information about the number
2304 of bytes transferred and the total transfer time.
2305
2306 This is an experimental feature. It happens to reliably work but issues
2307 caused by corner cases are to be expected.
2308
2309 Note that this option requires that the process permanently runs with
2310 CAP_NETADMIN privileges, which most often translates into running as root.
2311
2312
2313option transparent
2314no option transparent
2315 Enable client-side transparent proxying
2316 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau4b1f8592008-12-23 23:13:55 +01002317 yes | no | yes | yes
Willy Tarreau844e3c52008-01-11 16:28:18 +01002318 Arguments : none
2319
2320 This option was introduced in order to provide layer 7 persistence to layer 3
2321 load balancers. The idea is to use the OS's ability to redirect an incoming
2322 connection for a remote address to a local process (here HAProxy), and let
2323 this process know what address was initially requested. When this option is
2324 used, sessions without cookies will be forwarded to the original destination
2325 IP address of the incoming request (which should match that of another
2326 equipment), while requests with cookies will still be forwarded to the
2327 appropriate server.
2328
2329 Note that contrary to a common belief, this option does NOT make HAProxy
2330 present the client's IP to the server when establishing the connection.
2331
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002332 See also: the "usersrc" argument of the "source" keyword, and the
2333 "transparent" option of the "bind" keyword.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002334
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002335
Willy Tarreau0140f252008-11-19 21:07:09 +01002336redirect location <to> [code <code>] <option> {if | unless} <condition>
2337redirect prefix <to> [code <code>] <option> {if | unless} <condition>
Willy Tarreaub463dfb2008-06-07 23:08:56 +02002338 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
Willy Tarreau0140f252008-11-19 21:07:09 +01002343 response.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02002344
Willy Tarreau0140f252008-11-19 21:07:09 +01002345 Arguments :
2346 <to> With "redirect location", the exact value in <to> is placed into
2347 the HTTP "Location" header. In case of "redirect prefix", the
2348 "Location" header is built from the concatenation of <to> and the
2349 complete URI, including the query string, unless the "drop-query"
Willy Tarreaufe651a52008-11-19 21:15:17 +01002350 option is specified (see below). As a special case, if <to>
2351 equals exactly "/" in prefix mode, then nothing is inserted
2352 before the original URI. It allows one to redirect to the same
2353 URL.
Willy Tarreau0140f252008-11-19 21:07:09 +01002354
2355 <code> The code is optional. It indicates which type of HTTP redirection
2356 is desired. Only codes 301, 302 and 303 are supported, and 302 is
2357 used if no code is specified. 301 means "Moved permanently", and
2358 a browser may cache the Location. 302 means "Moved permanently"
2359 and means that the browser should not cache the redirection. 303
2360 is equivalent to 302 except that the browser will fetch the
2361 location with a GET method.
2362
2363 <option> There are several options which can be specified to adjust the
2364 expected behaviour of a redirection :
2365
2366 - "drop-query"
2367 When this keyword is used in a prefix-based redirection, then the
2368 location will be set without any possible query-string, which is useful
2369 for directing users to a non-secure page for instance. It has no effect
2370 with a location-type redirect.
2371
2372 - "set-cookie NAME[=value]"
2373 A "Set-Cookie" header will be added with NAME (and optionally "=value")
2374 to the response. This is sometimes used to indicate that a user has
2375 been seen, for instance to protect against some types of DoS. No other
2376 cookie option is added, so the cookie will be a session cookie. Note
2377 that for a browser, a sole cookie name without an equal sign is
2378 different from a cookie with an equal sign.
2379
2380 - "clear-cookie NAME[=]"
2381 A "Set-Cookie" header will be added with NAME (and optionally "="), but
2382 with the "Max-Age" attribute set to zero. This will tell the browser to
2383 delete this cookie. It is useful for instance on logout pages. It is
2384 important to note that clearing the cookie "NAME" will not remove a
2385 cookie set with "NAME=value". You have to clear the cookie "NAME=" for
2386 that, because the browser makes the difference.
Willy Tarreaub463dfb2008-06-07 23:08:56 +02002387
2388 Example: move the login URL only to HTTPS.
2389 acl clear dst_port 80
2390 acl secure dst_port 8080
2391 acl login_page url_beg /login
Willy Tarreau0140f252008-11-19 21:07:09 +01002392 acl logout url_beg /logout
Willy Tarreau79da4692008-11-19 20:03:04 +01002393 acl uid_given url_reg /login?userid=[^&]+
Willy Tarreau0140f252008-11-19 21:07:09 +01002394 acl cookie_set hdr_sub(cookie) SEEN=1
2395
2396 redirect prefix https://mysite.com set-cookie SEEN=1 if !cookie_set
Willy Tarreau79da4692008-11-19 20:03:04 +01002397 redirect prefix https://mysite.com if login_page !secure
2398 redirect prefix http://mysite.com drop-query if login_page !uid_given
2399 redirect location http://mysite.com/ if !login_page secure
Willy Tarreau0140f252008-11-19 21:07:09 +01002400 redirect location / clear-cookie USERID= if logout
Willy Tarreaub463dfb2008-06-07 23:08:56 +02002401
2402 See section 2.3 about ACL usage.
2403
2404
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002405redisp (deprecated)
2406redispatch (deprecated)
2407 Enable or disable session redistribution in case of connection failure
2408 May be used in sections: defaults | frontend | listen | backend
2409 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002410 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002411
2412 In HTTP mode, if a server designated by a cookie is down, clients may
2413 definitely stick to it because they cannot flush the cookie, so they will not
2414 be able to access the service anymore.
2415
2416 Specifying "redispatch" will allow the proxy to break their persistence and
2417 redistribute them to a working server.
2418
2419 It also allows to retry last connection to another server in case of multiple
2420 connection failures. Of course, it requires having "retries" set to a nonzero
2421 value.
2422
2423 This form is deprecated, do not use it in any new configuration, use the new
2424 "option redispatch" instead.
2425
2426 See also : "option redispatch"
2427
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002428
Willy Tarreau303c0352008-01-17 19:01:39 +01002429reqadd <string>
2430 Add a header at the end of the HTTP request
2431 May be used in sections : defaults | frontend | listen | backend
2432 no | yes | yes | yes
2433 Arguments :
2434 <string> is the complete line to be added. Any space or known delimiter
2435 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002436 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002437
2438 A new line consisting in <string> followed by a line feed will be added after
2439 the last header of an HTTP request.
2440
2441 Header transformations only apply to traffic which passes through HAProxy,
2442 and not to traffic generated by HAProxy, such as health-checks or error
2443 responses.
2444
Willy Tarreauced27012008-01-17 20:35:34 +01002445 See also: "rspadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002446
2447
2448reqallow <search>
2449reqiallow <search> (ignore case)
2450 Definitely allow an HTTP request if a line matches a regular expression
2451 May be used in sections : defaults | frontend | listen | backend
2452 no | yes | yes | yes
2453 Arguments :
2454 <search> is the regular expression applied to HTTP headers and to the
2455 request line. This is an extended regular expression. Parenthesis
2456 grouping is supported and no preliminary backslash is required.
2457 Any space or known delimiter must be escaped using a backslash
2458 ('\'). The pattern applies to a full line at a time. The
2459 "reqallow" keyword strictly matches case while "reqiallow"
2460 ignores case.
2461
2462 A request containing any line which matches extended regular expression
2463 <search> will mark the request as allowed, even if any later test would
2464 result in a deny. The test applies both to the request line and to request
2465 headers. Keep in mind that URLs in request line are case-sensitive while
2466 header names are not.
2467
2468 It is easier, faster and more powerful to use ACLs to write access policies.
2469 Reqdeny, reqallow and reqpass should be avoided in new designs.
2470
2471 Example :
2472 # allow www.* but refuse *.local
2473 reqiallow ^Host:\ www\.
2474 reqideny ^Host:\ .*\.local
2475
Willy Tarreauced27012008-01-17 20:35:34 +01002476 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002477 manipulation
2478
2479
2480reqdel <search>
2481reqidel <search> (ignore case)
2482 Delete all headers matching a regular expression in an HTTP request
2483 May be used in sections : defaults | frontend | listen | backend
2484 no | yes | yes | yes
2485 Arguments :
2486 <search> is the regular expression applied to HTTP headers and to the
2487 request line. This is an extended regular expression. Parenthesis
2488 grouping is supported and no preliminary backslash is required.
2489 Any space or known delimiter must be escaped using a backslash
2490 ('\'). The pattern applies to a full line at a time. The "reqdel"
2491 keyword strictly matches case while "reqidel" ignores case.
2492
2493 Any header line matching extended regular expression <search> in the request
2494 will be completely deleted. Most common use of this is to remove unwanted
2495 and/or dangerous headers or cookies from a request before passing it to the
2496 next servers.
2497
2498 Header transformations only apply to traffic which passes through HAProxy,
2499 and not to traffic generated by HAProxy, such as health-checks or error
2500 responses. Keep in mind that header names are not case-sensitive.
2501
2502 Example :
2503 # remove X-Forwarded-For header and SERVER cookie
2504 reqidel ^X-Forwarded-For:.*
2505 reqidel ^Cookie:.*SERVER=
2506
Willy Tarreauced27012008-01-17 20:35:34 +01002507 See also: "reqadd", "reqrep", "rspdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002508 manipulation
2509
2510
2511reqdeny <search>
2512reqideny <search> (ignore case)
2513 Deny an HTTP request if a line matches a regular expression
2514 May be used in sections : defaults | frontend | listen | backend
2515 no | yes | yes | yes
2516 Arguments :
2517 <search> is the regular expression applied to HTTP headers and to the
2518 request line. This is an extended regular expression. Parenthesis
2519 grouping is supported and no preliminary backslash is required.
2520 Any space or known delimiter must be escaped using a backslash
2521 ('\'). The pattern applies to a full line at a time. The
2522 "reqdeny" keyword strictly matches case while "reqideny" ignores
2523 case.
2524
2525 A request containing any line which matches extended regular expression
2526 <search> will mark the request as denied, even if any later test would
2527 result in an allow. The test applies both to the request line and to request
2528 headers. Keep in mind that URLs in request line are case-sensitive while
2529 header names are not.
2530
Willy Tarreauced27012008-01-17 20:35:34 +01002531 A denied request will generate an "HTTP 403 forbidden" response once the
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002532 complete request has been parsed. This is consistent with what is practiced
Willy Tarreauced27012008-01-17 20:35:34 +01002533 using ACLs.
2534
Willy Tarreau303c0352008-01-17 19:01:39 +01002535 It is easier, faster and more powerful to use ACLs to write access policies.
2536 Reqdeny, reqallow and reqpass should be avoided in new designs.
2537
2538 Example :
2539 # refuse *.local, then allow www.*
2540 reqideny ^Host:\ .*\.local
2541 reqiallow ^Host:\ www\.
2542
Willy Tarreauced27012008-01-17 20:35:34 +01002543 See also: "reqallow", "rspdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002544 header manipulation
2545
2546
2547reqpass <search>
2548reqipass <search> (ignore case)
2549 Ignore any HTTP request line matching a regular expression in next rules
2550 May be used in sections : defaults | frontend | listen | backend
2551 no | yes | yes | yes
2552 Arguments :
2553 <search> is the regular expression applied to HTTP headers and to the
2554 request line. This is an extended regular expression. Parenthesis
2555 grouping is supported and no preliminary backslash is required.
2556 Any space or known delimiter must be escaped using a backslash
2557 ('\'). The pattern applies to a full line at a time. The
2558 "reqpass" keyword strictly matches case while "reqipass" ignores
2559 case.
2560
2561 A request containing any line which matches extended regular expression
2562 <search> will skip next rules, without assigning any deny or allow verdict.
2563 The test applies both to the request line and to request headers. Keep in
2564 mind that URLs in request line are case-sensitive while header names are not.
2565
2566 It is easier, faster and more powerful to use ACLs to write access policies.
2567 Reqdeny, reqallow and reqpass should be avoided in new designs.
2568
2569 Example :
2570 # refuse *.local, then allow www.*, but ignore "www.private.local"
2571 reqipass ^Host:\ www.private\.local
2572 reqideny ^Host:\ .*\.local
2573 reqiallow ^Host:\ www\.
2574
Willy Tarreauced27012008-01-17 20:35:34 +01002575 See also: "reqallow", "reqdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002576 header manipulation
2577
2578
2579reqrep <search> <string>
2580reqirep <search> <string> (ignore case)
2581 Replace a regular expression with a string in an HTTP request line
2582 May be used in sections : defaults | frontend | listen | backend
2583 no | yes | yes | yes
2584 Arguments :
2585 <search> is the regular expression applied to HTTP headers and to the
2586 request line. This is an extended regular expression. Parenthesis
2587 grouping is supported and no preliminary backslash is required.
2588 Any space or known delimiter must be escaped using a backslash
2589 ('\'). The pattern applies to a full line at a time. The "reqrep"
2590 keyword strictly matches case while "reqirep" ignores case.
2591
2592 <string> is the complete line to be added. Any space or known delimiter
2593 must be escaped using a backslash ('\'). References to matched
2594 pattern groups are possible using the common \N form, with N
2595 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002596 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002597
2598 Any line matching extended regular expression <search> in the request (both
2599 the request line and header lines) will be completely replaced with <string>.
2600 Most common use of this is to rewrite URLs or domain names in "Host" headers.
2601
2602 Header transformations only apply to traffic which passes through HAProxy,
2603 and not to traffic generated by HAProxy, such as health-checks or error
2604 responses. Note that for increased readability, it is suggested to add enough
2605 spaces between the request and the response. Keep in mind that URLs in
2606 request line are case-sensitive while header names are not.
2607
2608 Example :
2609 # replace "/static/" with "/" at the beginning of any request path.
2610 reqrep ^([^\ ]*)\ /static/(.*) \1\ /\2
2611 # replace "www.mydomain.com" with "www" in the host name.
2612 reqirep ^Host:\ www.mydomain.com Host:\ www
2613
Willy Tarreauced27012008-01-17 20:35:34 +01002614 See also: "reqadd", "reqdel", "rsprep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002615 manipulation
2616
2617
2618reqtarpit <search>
2619reqitarpit <search> (ignore case)
2620 Tarpit an HTTP request containing a line matching a regular expression
2621 May be used in sections : defaults | frontend | listen | backend
2622 no | yes | yes | yes
2623 Arguments :
2624 <search> is the regular expression applied to HTTP headers and to the
2625 request line. This is an extended regular expression. Parenthesis
2626 grouping is supported and no preliminary backslash is required.
2627 Any space or known delimiter must be escaped using a backslash
2628 ('\'). The pattern applies to a full line at a time. The
2629 "reqtarpit" keyword strictly matches case while "reqitarpit"
2630 ignores case.
2631
2632 A request containing any line which matches extended regular expression
2633 <search> will be tarpitted, which means that it will connect to nowhere, will
Willy Tarreauced27012008-01-17 20:35:34 +01002634 be kept open for a pre-defined time, then will return an HTTP error 500 so
2635 that the attacker does not suspect it has been tarpitted. The status 500 will
2636 be reported in the logs, but the completion flags will indicate "PT". The
Willy Tarreau303c0352008-01-17 19:01:39 +01002637 delay is defined by "timeout tarpit", or "timeout connect" if the former is
2638 not set.
2639
2640 The goal of the tarpit is to slow down robots attacking servers with
2641 identifiable requests. Many robots limit their outgoing number of connections
2642 and stay connected waiting for a reply which can take several minutes to
2643 come. Depending on the environment and attack, it may be particularly
2644 efficient at reducing the load on the network and firewalls.
2645
2646 Example :
2647 # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but
2648 # block all others.
2649 reqipass ^User-Agent:\.*(Mozilla|MSIE)
2650 reqitarpit ^User-Agent:
2651
Willy Tarreauced27012008-01-17 20:35:34 +01002652 See also: "reqallow", "reqdeny", "reqpass", and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002653 manipulation
2654
2655
Willy Tarreaue5c5ce92008-06-20 17:27:19 +02002656retries <value>
2657 Set the number of retries to perform on a server after a connection failure
2658 May be used in sections: defaults | frontend | listen | backend
2659 yes | no | yes | yes
2660 Arguments :
2661 <value> is the number of times a connection attempt should be retried on
2662 a server when a connection either is refused or times out. The
2663 default value is 3.
2664
2665 It is important to understand that this value applies to the number of
2666 connection attempts, not full requests. When a connection has effectively
2667 been established to a server, there will be no more retry.
2668
2669 In order to avoid immediate reconnections to a server which is restarting,
2670 a turn-around timer of 1 second is applied before a retry occurs.
2671
2672 When "option redispatch" is set, the last retry may be performed on another
2673 server even if a cookie references a different server.
2674
2675 See also : "option redispatch"
2676
2677
Willy Tarreau303c0352008-01-17 19:01:39 +01002678rspadd <string>
2679 Add a header at the end of the HTTP response
2680 May be used in sections : defaults | frontend | listen | backend
2681 no | yes | yes | yes
2682 Arguments :
2683 <string> is the complete line to be added. Any space or known delimiter
2684 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002685 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002686
2687 A new line consisting in <string> followed by a line feed will be added after
2688 the last header of an HTTP response.
2689
2690 Header transformations only apply to traffic which passes through HAProxy,
2691 and not to traffic generated by HAProxy, such as health-checks or error
2692 responses.
2693
Willy Tarreauced27012008-01-17 20:35:34 +01002694 See also: "reqadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002695
2696
2697rspdel <search>
2698rspidel <search> (ignore case)
2699 Delete all headers matching a regular expression in an HTTP response
2700 May be used in sections : defaults | frontend | listen | backend
2701 no | yes | yes | yes
2702 Arguments :
2703 <search> is the regular expression applied to HTTP headers and to the
2704 response line. This is an extended regular expression, so
2705 parenthesis grouping is supported and no preliminary backslash
2706 is required. Any space or known delimiter must be escaped using
2707 a backslash ('\'). The pattern applies to a full line at a time.
2708 The "rspdel" keyword strictly matches case while "rspidel"
2709 ignores case.
2710
2711 Any header line matching extended regular expression <search> in the response
2712 will be completely deleted. Most common use of this is to remove unwanted
2713 and/or sensible headers or cookies from a response before passing it to the
2714 client.
2715
2716 Header transformations only apply to traffic which passes through HAProxy,
2717 and not to traffic generated by HAProxy, such as health-checks or error
2718 responses. Keep in mind that header names are not case-sensitive.
2719
2720 Example :
2721 # remove the Server header from responses
2722 reqidel ^Server:.*
2723
Willy Tarreauced27012008-01-17 20:35:34 +01002724 See also: "rspadd", "rsprep", "reqdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002725 manipulation
2726
2727
2728rspdeny <search>
2729rspideny <search> (ignore case)
2730 Block an HTTP response if a line matches a regular expression
2731 May be used in sections : defaults | frontend | listen | backend
2732 no | yes | yes | yes
2733 Arguments :
2734 <search> is the regular expression applied to HTTP headers and to the
2735 response line. This is an extended regular expression, so
2736 parenthesis grouping is supported and no preliminary backslash
2737 is required. Any space or known delimiter must be escaped using
2738 a backslash ('\'). The pattern applies to a full line at a time.
2739 The "rspdeny" keyword strictly matches case while "rspideny"
2740 ignores case.
2741
2742 A response containing any line which matches extended regular expression
2743 <search> will mark the request as denied. The test applies both to the
2744 response line and to response headers. Keep in mind that header names are not
2745 case-sensitive.
2746
2747 Main use of this keyword is to prevent sensitive information leak and to
Willy Tarreauced27012008-01-17 20:35:34 +01002748 block the response before it reaches the client. If a response is denied, it
2749 will be replaced with an HTTP 502 error so that the client never retrieves
2750 any sensitive data.
Willy Tarreau303c0352008-01-17 19:01:39 +01002751
2752 It is easier, faster and more powerful to use ACLs to write access policies.
2753 Rspdeny should be avoided in new designs.
2754
2755 Example :
2756 # Ensure that no content type matching ms-word will leak
2757 rspideny ^Content-type:\.*/ms-word
2758
Willy Tarreauced27012008-01-17 20:35:34 +01002759 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002760 manipulation
2761
2762
2763rsprep <search> <string>
2764rspirep <search> <string> (ignore case)
2765 Replace a regular expression with a string in an HTTP response line
2766 May be used in sections : defaults | frontend | listen | backend
2767 no | yes | yes | yes
2768 Arguments :
2769 <search> is the regular expression applied to HTTP headers and to the
2770 response line. This is an extended regular expression, so
2771 parenthesis grouping is supported and no preliminary backslash
2772 is required. Any space or known delimiter must be escaped using
2773 a backslash ('\'). The pattern applies to a full line at a time.
2774 The "rsprep" keyword strictly matches case while "rspirep"
2775 ignores case.
2776
2777 <string> is the complete line to be added. Any space or known delimiter
2778 must be escaped using a backslash ('\'). References to matched
2779 pattern groups are possible using the common \N form, with N
2780 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002781 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002782
2783 Any line matching extended regular expression <search> in the response (both
2784 the response line and header lines) will be completely replaced with
2785 <string>. Most common use of this is to rewrite Location headers.
2786
2787 Header transformations only apply to traffic which passes through HAProxy,
2788 and not to traffic generated by HAProxy, such as health-checks or error
2789 responses. Note that for increased readability, it is suggested to add enough
2790 spaces between the request and the response. Keep in mind that header names
2791 are not case-sensitive.
2792
2793 Example :
2794 # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com"
2795 rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com
2796
Willy Tarreauced27012008-01-17 20:35:34 +01002797 See also: "rspadd", "rspdel", "reqrep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002798 manipulation
2799
2800
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002801server <name> <address>[:port] [param*]
2802 Declare a server in a backend
2803 May be used in sections : defaults | frontend | listen | backend
2804 no | no | yes | yes
2805 Arguments :
2806 <name> is the internal name assigned to this server. This name will
2807 appear in logs and alerts.
2808
2809 <address> is the IPv4 address of the server. Alternatively, a resolvable
2810 hostname is supported, but this name will be resolved during
2811 start-up.
2812
2813 <ports> is an optional port specification. If set, all connections will
2814 be sent to this port. If unset, the same port the client
2815 connected to will be used. The port may also be prefixed by a "+"
2816 or a "-". In this case, the server's port will be determined by
2817 adding this value to the client's port.
2818
2819 <param*> is a list of parameters for this server. The "server" keywords
2820 accepts an important number of options and has a complete section
2821 dedicated to it. Please refer to section 2.4 for more details.
2822
2823 Examples :
2824 server first 10.1.1.1:1080 cookie first check inter 1000
2825 server second 10.1.1.2:1080 cookie second check inter 1000
2826
2827 See also : section 2.4 about server options
2828
2829
2830source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
2831 Set the source address for outgoing connections
2832 May be used in sections : defaults | frontend | listen | backend
2833 yes | no | yes | yes
2834 Arguments :
2835 <addr> is the IPv4 address HAProxy will bind to before connecting to a
2836 server. This address is also used as a source for health checks.
2837 The default value of 0.0.0.0 means that the system will select
2838 the most appropriate address to reach its destination.
2839
2840 <port> is an optional port. It is normally not needed but may be useful
2841 in some very specific contexts. The default value of zero means
2842 the system will select a free port.
2843
2844 <addr2> is the IP address to present to the server when connections are
2845 forwarded in full transparent proxy mode. This is currently only
2846 supported on some patched Linux kernels. When this address is
2847 specified, clients connecting to the server will be presented
2848 with this address, while health checks will still use the address
2849 <addr>.
2850
2851 <port2> is the optional port to present to the server when connections
2852 are forwarded in full transparent proxy mode (see <addr2> above).
2853 The default value of zero means the system will select a free
2854 port.
2855
2856 The "source" keyword is useful in complex environments where a specific
2857 address only is allowed to connect to the servers. It may be needed when a
2858 private address must be used through a public gateway for instance, and it is
2859 known that the system cannot determine the adequate source address by itself.
2860
2861 An extension which is available on certain patched Linux kernels may be used
2862 through the "usesrc" optional keyword. It makes it possible to connect to the
2863 servers with an IP address which does not belong to the system itself. This
2864 is called "full transparent proxy mode". For this to work, the destination
2865 servers have to route their traffic back to this address through the machine
2866 running HAProxy, and IP forwarding must generally be enabled on this machine.
2867
2868 In this "full transparent proxy" mode, it is possible to force a specific IP
2869 address to be presented to the servers. This is not much used in fact. A more
2870 common use is to tell HAProxy to present the client's IP address. For this,
2871 there are two methods :
2872
2873 - present the client's IP and port addresses. This is the most transparent
2874 mode, but it can cause problems when IP connection tracking is enabled on
2875 the machine, because a same connection may be seen twice with different
2876 states. However, this solution presents the huge advantage of not
2877 limiting the system to the 64k outgoing address+port couples, because all
2878 of the client ranges may be used.
2879
2880 - present only the client's IP address and select a spare port. This
2881 solution is still quite elegant but slightly less transparent (downstream
2882 firewalls logs will not match upstream's). It also presents the downside
2883 of limiting the number of concurrent connections to the usual 64k ports.
2884 However, since the upstream and downstream ports are different, local IP
2885 connection tracking on the machine will not be upset by the reuse of the
2886 same session.
2887
2888 Note that depending on the transparent proxy technology used, it may be
2889 required to force the source address. In fact, cttproxy version 2 requires an
2890 IP address in <addr> above, and does not support setting of "0.0.0.0" as the
2891 IP address because it creates NAT entries which much match the exact outgoing
2892 address. Tproxy version 4 and some other kernel patches which work in pure
2893 forwarding mode generally will not have this limitation.
2894
2895 This option sets the default source for all servers in the backend. It may
2896 also be specified in a "defaults" section. Finer source address specification
2897 is possible at the server level using the "source" server option. Refer to
2898 section 2.4 for more information.
2899
2900 Examples :
2901 backend private
2902 # Connect to the servers using our 192.168.1.200 source address
2903 source 192.168.1.200
2904
2905 backend transparent_ssl1
2906 # Connect to the SSL farm from the client's source address
2907 source 192.168.1.200 usesrc clientip
2908
2909 backend transparent_ssl2
2910 # Connect to the SSL farm from the client's source address and port
2911 # not recommended if IP conntrack is present on the local machine.
2912 source 192.168.1.200 usesrc client
2913
2914 backend transparent_ssl3
2915 # Connect to the SSL farm from the client's source address. It
2916 # is more conntrack-friendly.
2917 source 192.168.1.200 usesrc clientip
2918
2919 backend transparent_smtp
2920 # Connect to the SMTP farm from the client's source address/port
2921 # with Tproxy version 4.
2922 source 0.0.0.0 usesrc clientip
2923
2924 See also : the "source" server option in section 2.4, the Tproxy patches for
2925 the Linux kernel on www.balabit.com, the "bind" keyword.
2926
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002927
Willy Tarreau844e3c52008-01-11 16:28:18 +01002928srvtimeout <timeout> (deprecated)
2929 Set the maximum inactivity time on the server side.
2930 May be used in sections : defaults | frontend | listen | backend
2931 yes | no | yes | yes
2932 Arguments :
2933 <timeout> is the timeout value specified in milliseconds by default, but
2934 can be in any other unit if the number is suffixed by the unit,
2935 as explained at the top of this document.
2936
2937 The inactivity timeout applies when the server is expected to acknowledge or
2938 send data. In HTTP mode, this timeout is particularly important to consider
2939 during the first phase of the server's response, when it has to send the
2940 headers, as it directly represents the server's processing time for the
2941 request. To find out what value to put there, it's often good to start with
2942 what would be considered as unacceptable response times, then check the logs
2943 to observe the response time distribution, and adjust the value accordingly.
2944
2945 The value is specified in milliseconds by default, but can be in any other
2946 unit if the number is suffixed by the unit, as specified at the top of this
2947 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
2948 recommended that the client timeout remains equal to the server timeout in
2949 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002950 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01002951 packet losses by specifying timeouts that are slightly above multiples of 3
2952 seconds (eg: 4 or 5 seconds minimum).
2953
2954 This parameter is specific to backends, but can be specified once for all in
2955 "defaults" sections. This is in fact one of the easiest solutions not to
2956 forget about it. An unspecified timeout results in an infinite timeout, which
2957 is not recommended. Such a usage is accepted and works but reports a warning
2958 during startup because it may results in accumulation of expired sessions in
2959 the system if the system's timeouts are not configured either.
2960
2961 This parameter is provided for compatibility but is currently deprecated.
2962 Please use "timeout server" instead.
2963
2964 See also : "timeout server", "timeout client" and "clitimeout".
2965
2966
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002967stats auth <user>:<passwd>
2968 Enable statistics with authentication and grant access to an account
2969 May be used in sections : defaults | frontend | listen | backend
2970 yes | no | yes | yes
2971 Arguments :
2972 <user> is a user name to grant access to
2973
2974 <passwd> is the cleartext password associated to this user
2975
2976 This statement enables statistics with default settings, and restricts access
2977 to declared users only. It may be repeated as many times as necessary to
2978 allow as many users as desired. When a user tries to access the statistics
2979 without a valid account, a "401 Forbidden" response will be returned so that
2980 the browser asks the user to provide a valid user and password. The real
2981 which will be returned to the browser is configurable using "stats realm".
2982
2983 Since the authentication method is HTTP Basic Authentication, the passwords
2984 circulate in cleartext on the network. Thus, it was decided that the
2985 configuration file would also use cleartext passwords to remind the users
2986 that those ones should not be sensible and not shared with any other account.
2987
2988 It is also possible to reduce the scope of the proxies which appear in the
2989 report using "stats scope".
2990
2991 Though this statement alone is enough to enable statistics reporting, it is
2992 recommended to set all other settings in order to avoid relying on default
2993 unobvious parameters.
2994
2995 Example :
2996 # public access (limited to this backend only)
2997 backend public_www
2998 server srv1 192.168.0.1:80
2999 stats enable
3000 stats hide-version
3001 stats scope .
3002 stats uri /admin?stats
3003 stats realm Haproxy\ Statistics
3004 stats auth admin1:AdMiN123
3005 stats auth admin2:AdMiN321
3006
3007 # internal monitoring access (unlimited)
3008 backend private_monitoring
3009 stats enable
3010 stats uri /admin?stats
3011 stats refresh 5s
3012
3013 See also : "stats enable", "stats realm", "stats scope", "stats uri"
3014
3015
3016stats enable
3017 Enable statistics reporting with default settings
3018 May be used in sections : defaults | frontend | listen | backend
3019 yes | no | yes | yes
3020 Arguments : none
3021
3022 This statement enables statistics reporting with default settings defined
3023 at build time. Unless stated otherwise, these settings are used :
3024 - stats uri : /haproxy?stats
3025 - stats realm : "HAProxy Statistics"
3026 - stats auth : no authentication
3027 - stats scope : no restriction
3028
3029 Though this statement alone is enough to enable statistics reporting, it is
3030 recommended to set all other settings in order to avoid relying on default
3031 unobvious parameters.
3032
3033 Example :
3034 # public access (limited to this backend only)
3035 backend public_www
3036 server srv1 192.168.0.1:80
3037 stats enable
3038 stats hide-version
3039 stats scope .
3040 stats uri /admin?stats
3041 stats realm Haproxy\ Statistics
3042 stats auth admin1:AdMiN123
3043 stats auth admin2:AdMiN321
3044
3045 # internal monitoring access (unlimited)
3046 backend private_monitoring
3047 stats enable
3048 stats uri /admin?stats
3049 stats refresh 5s
3050
3051 See also : "stats auth", "stats realm", "stats uri"
3052
3053
3054stats realm <realm>
3055 Enable statistics and set authentication realm
3056 May be used in sections : defaults | frontend | listen | backend
3057 yes | no | yes | yes
3058 Arguments :
3059 <realm> is the name of the HTTP Basic Authentication realm reported to
3060 the browser. The browser uses it to display it in the pop-up
3061 inviting the user to enter a valid username and password.
3062
3063 The realm is read as a single word, so any spaces in it should be escaped
3064 using a backslash ('\').
3065
3066 This statement is useful only in conjunction with "stats auth" since it is
3067 only related to authentication.
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 uri"
3092
3093
3094stats refresh <delay>
3095 Enable statistics with automatic refresh
3096 May be used in sections : defaults | frontend | listen | backend
3097 yes | no | yes | yes
3098 Arguments :
3099 <delay> is the suggested refresh delay, specified in seconds, which will
3100 be returned to the browser consulting the report page. While the
3101 browser is free to apply any delay, it will generally respect it
3102 and refresh the page this every seconds. The refresh interval may
3103 be specified in any other non-default time unit, by suffixing the
3104 unit after the value, as explained at the top of this document.
3105
3106 This statement is useful on monitoring displays with a permanent page
3107 reporting the load balancer's activity. When set, the HTML report page will
3108 include a link "refresh"/"stop refresh" so that the user can select whether
3109 he wants automatic refresh of the page or not.
3110
3111 Though this statement alone is enough to enable statistics reporting, it is
3112 recommended to set all other settings in order to avoid relying on default
3113 unobvious parameters.
3114
3115 Example :
3116 # public access (limited to this backend only)
3117 backend public_www
3118 server srv1 192.168.0.1:80
3119 stats enable
3120 stats hide-version
3121 stats scope .
3122 stats uri /admin?stats
3123 stats realm Haproxy\ Statistics
3124 stats auth admin1:AdMiN123
3125 stats auth admin2:AdMiN321
3126
3127 # internal monitoring access (unlimited)
3128 backend private_monitoring
3129 stats enable
3130 stats uri /admin?stats
3131 stats refresh 5s
3132
3133 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3134
3135
3136stats scope { <name> | "." }
3137 Enable statistics and limit access scope
3138 May be used in sections : defaults | frontend | listen | backend
3139 yes | no | yes | yes
3140 Arguments :
3141 <name> is the name of a listen, frontend or backend section to be
3142 reported. The special name "." (a single dot) designates the
3143 section in which the statement appears.
3144
3145 When this statement is specified, only the sections enumerated with this
3146 statement will appear in the report. All other ones will be hidden. This
3147 statement may appear as many times as needed if multiple sections need to be
3148 reported. Please note that the name checking is performed as simple string
3149 comparisons, and that it is never checked that a give section name really
3150 exists.
3151
3152 Though this statement alone is enough to enable statistics reporting, it is
3153 recommended to set all other settings in order to avoid relying on default
3154 unobvious parameters.
3155
3156 Example :
3157 # public access (limited to this backend only)
3158 backend public_www
3159 server srv1 192.168.0.1:80
3160 stats enable
3161 stats hide-version
3162 stats scope .
3163 stats uri /admin?stats
3164 stats realm Haproxy\ Statistics
3165 stats auth admin1:AdMiN123
3166 stats auth admin2:AdMiN321
3167
3168 # internal monitoring access (unlimited)
3169 backend private_monitoring
3170 stats enable
3171 stats uri /admin?stats
3172 stats refresh 5s
3173
3174 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3175
3176
3177stats uri <prefix>
3178 Enable statistics and define the URI prefix to access them
3179 May be used in sections : defaults | frontend | listen | backend
3180 yes | no | yes | yes
3181 Arguments :
3182 <prefix> is the prefix of any URI which will be redirected to stats. This
3183 prefix may contain a question mark ('?') to indicate part of a
3184 query string.
3185
3186 The statistics URI is intercepted on the relayed traffic, so it appears as a
3187 page within the normal application. It is strongly advised to ensure that the
3188 selected URI will never appear in the application, otherwise it will never be
3189 possible to reach it in the application.
3190
3191 The default URI compiled in haproxy is "/haproxy?stats", but this may be
3192 changed at build time, so it's better to always explictly specify it here.
3193 It is generally a good idea to include a question mark in the URI so that
3194 intermediate proxies refrain from caching the results. Also, since any string
3195 beginning with the prefix will be accepted as a stats request, the question
3196 mark helps ensuring that no valid URI will begin with the same words.
3197
3198 It is sometimes very convenient to use "/" as the URI prefix, and put that
3199 statement in a "listen" instance of its own. That makes it easy to dedicate
3200 an address or a port to statistics only.
3201
3202 Though this statement alone is enough to enable statistics reporting, it is
3203 recommended to set all other settings in order to avoid relying on default
3204 unobvious parameters.
3205
3206 Example :
3207 # public access (limited to this backend only)
3208 backend public_www
3209 server srv1 192.168.0.1:80
3210 stats enable
3211 stats hide-version
3212 stats scope .
3213 stats uri /admin?stats
3214 stats realm Haproxy\ Statistics
3215 stats auth admin1:AdMiN123
3216 stats auth admin2:AdMiN321
3217
3218 # internal monitoring access (unlimited)
3219 backend private_monitoring
3220 stats enable
3221 stats uri /admin?stats
3222 stats refresh 5s
3223
3224 See also : "stats auth", "stats enable", "stats realm"
3225
3226
3227stats hide-version
3228 Enable statistics and hide HAProxy version reporting
3229 May be used in sections : defaults | frontend | listen | backend
3230 yes | no | yes | yes
3231 Arguments : none
3232
3233 By default, the stats page reports some useful status information along with
3234 the statistics. Among them is HAProxy's version. However, it is generally
3235 considered dangerous to report precise version to anyone, as it can help them
3236 target known weaknesses with specific attacks. The "stats hide-version"
3237 statement removes the version from the statistics report. This is recommended
3238 for public sites or any site with a weak login/password.
3239
3240 Though this statement alone is enough to enable statistics reporting, it is
3241 recommended to set all other settings in order to avoid relying on default
3242 unobvious parameters.
3243
3244 Example :
3245 # public access (limited to this backend only)
3246 backend public_www
3247 server srv1 192.168.0.1:80
3248 stats enable
3249 stats hide-version
3250 stats scope .
3251 stats uri /admin?stats
3252 stats realm Haproxy\ Statistics
3253 stats auth admin1:AdMiN123
3254 stats auth admin2:AdMiN321
3255
3256 # internal monitoring access (unlimited)
3257 backend private_monitoring
3258 stats enable
3259 stats uri /admin?stats
3260 stats refresh 5s
3261
3262 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3263
3264
Willy Tarreau62644772008-07-16 18:36:06 +02003265tcp-request content accept [{if | unless} <condition>]
3266 Accept a connection if/unless a content inspection condition is matched
3267 May be used in sections : defaults | frontend | listen | backend
3268 no | yes | yes | no
3269
3270 During TCP content inspection, the connection is immediately validated if the
3271 condition is true (when used with "if") or false (when used with "unless").
3272 Most of the time during content inspection, a condition will be in an
3273 uncertain state which is neither true nor false. The evaluation immediately
3274 stops when such a condition is encountered. It is important to understand
3275 that "accept" and "reject" rules are evaluated in their exact declaration
3276 order, so that it is possible to build complex rules from them. There is no
3277 specific limit to the number of rules which may be inserted.
3278
3279 Note that the "if/unless" condition is optionnal. If no condition is set on
3280 the action, it is simply performed unconditionally.
3281
3282 If no "tcp-request content" rules are matched, the default action already is
3283 "accept". Thus, this statement alone does not bring anything without another
3284 "reject" statement.
3285
3286 See section 2.3 about ACL usage.
3287
3288 See also : "tcp-request content-reject", "tcp-request inspect-delay"
3289
3290
3291tcp-request content reject [{if | unless} <condition>]
3292 Reject a connection if/unless a content inspection condition is matched
3293 May be used in sections : defaults | frontend | listen | backend
3294 no | yes | yes | no
3295
3296 During TCP content inspection, the connection is immediately rejected if the
3297 condition is true (when used with "if") or false (when used with "unless").
3298 Most of the time during content inspection, a condition will be in an
3299 uncertain state which is neither true nor false. The evaluation immediately
3300 stops when such a condition is encountered. It is important to understand
3301 that "accept" and "reject" rules are evaluated in their exact declaration
3302 order, so that it is possible to build complex rules from them. There is no
3303 specific limit to the number of rules which may be inserted.
3304
3305 Note that the "if/unless" condition is optionnal. If no condition is set on
3306 the action, it is simply performed unconditionally.
3307
3308 If no "tcp-request content" rules are matched, the default action is set to
3309 "accept".
3310
3311 Example:
3312 # reject SMTP connection if client speaks first
3313 tcp-request inspect-delay 30s
3314 acl content_present req_len gt 0
3315 tcp-request reject if content_present
3316
3317 # Forward HTTPS connection only if client speaks
3318 tcp-request inspect-delay 30s
3319 acl content_present req_len gt 0
3320 tcp-request accept if content_present
3321 tcp-request reject
3322
3323 See section 2.3 about ACL usage.
3324
3325 See also : "tcp-request content-accept", "tcp-request inspect-delay"
3326
3327
3328tcp-request inspect-delay <timeout>
3329 Set the maximum allowed time to wait for data during content inspection
3330 May be used in sections : defaults | frontend | listen | backend
3331 no | yes | yes | no
3332 Arguments :
3333 <timeout> is the timeout value specified in milliseconds by default, but
3334 can be in any other unit if the number is suffixed by the unit,
3335 as explained at the top of this document.
3336
3337 People using haproxy primarily as a TCP relay are often worried about the
3338 risk of passing any type of protocol to a server without any analysis. In
3339 order to be able to analyze the request contents, we must first withhold
3340 the data then analyze them. This statement simply enables withholding of
3341 data for at most the specified amount of time.
3342
3343 Note that when performing content inspection, haproxy will evaluate the whole
3344 rules for every new chunk which gets in, taking into account the fact that
3345 those data are partial. If no rule matches before the aforementionned delay,
3346 a last check is performed upon expiration, this time considering that the
3347 contents are definitive.
3348
3349 As soon as a rule matches, the request is released and continues as usual. If
3350 the timeout is reached and no rule matches, the default policy will be to let
3351 it pass through unaffected.
3352
3353 For most protocols, it is enough to set it to a few seconds, as most clients
3354 send the full request immediately upon connection. Add 3 or more seconds to
3355 cover TCP retransmits but that's all. For some protocols, it may make sense
3356 to use large values, for instance to ensure that the client never talks
3357 before the server (eg: SMTP), or to wait for a client to talk before passing
3358 data to the server (eg: SSL). Note that the client timeout must cover at
3359 least the inspection delay, otherwise it will expire first.
3360
3361 See also : "tcp-request content accept", "tcp-request content-reject",
3362 "timeout client".
3363
3364
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003365timeout check <timeout>
3366 Set additional check timeout, but only after a connection has been already
3367 established.
3368
3369 May be used in sections: defaults | frontend | listen | backend
3370 yes | no | yes | yes
3371 Arguments:
3372 <timeout> is the timeout value specified in milliseconds by default, but
3373 can be in any other unit if the number is suffixed by the unit,
3374 as explained at the top of this document.
3375
3376 If set, haproxy uses min("timeout connect", "inter") as a connect timeout
3377 for check and "timeout check" as an additional read timeout. The "min" is
3378 used so that people running with *very* long "timeout connect" (eg. those
3379 who needed this due to the queue or tarpit) do not slow down their checks.
3380 Of course it is better to use "check queue" and "check tarpit" instead of
3381 long "timeout connect".
3382
3383 If "timeout check" is not set haproxy uses "inter" for complete check
3384 timeout (connect + read) exactly like all <1.3.15 version.
3385
3386 In most cases check request is much simpler and faster to handle than normal
3387 requests and people may want to kick out laggy servers so this timeout should
Willy Tarreau41a340d2008-01-22 12:25:31 +01003388 be smaller than "timeout server".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003389
3390 This parameter is specific to backends, but can be specified once for all in
3391 "defaults" sections. This is in fact one of the easiest solutions not to
3392 forget about it.
3393
Willy Tarreau41a340d2008-01-22 12:25:31 +01003394 See also: "timeout connect", "timeout queue", "timeout server",
3395 "timeout tarpit".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003396
3397
Willy Tarreau0ba27502007-12-24 16:55:16 +01003398timeout client <timeout>
3399timeout clitimeout <timeout> (deprecated)
3400 Set the maximum inactivity time on the client side.
3401 May be used in sections : defaults | frontend | listen | backend
3402 yes | yes | yes | no
3403 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003404 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003405 can be in any other unit if the number is suffixed by the unit,
3406 as explained at the top of this document.
3407
3408 The inactivity timeout applies when the client is expected to acknowledge or
3409 send data. In HTTP mode, this timeout is particularly important to consider
3410 during the first phase, when the client sends the request, and during the
3411 response while it is reading data sent by the server. The value is specified
3412 in milliseconds by default, but can be in any other unit if the number is
3413 suffixed by the unit, as specified at the top of this document. In TCP mode
3414 (and to a lesser extent, in HTTP mode), it is highly recommended that the
3415 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003416 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01003417 losses by specifying timeouts that are slightly above multiples of 3 seconds
3418 (eg: 4 or 5 seconds).
3419
3420 This parameter is specific to frontends, but can be specified once for all in
3421 "defaults" sections. This is in fact one of the easiest solutions not to
3422 forget about it. An unspecified timeout results in an infinite timeout, which
3423 is not recommended. Such a usage is accepted and works but reports a warning
3424 during startup because it may results in accumulation of expired sessions in
3425 the system if the system's timeouts are not configured either.
3426
3427 This parameter replaces the old, deprecated "clitimeout". It is recommended
3428 to use it to write new configurations. The form "timeout clitimeout" is
3429 provided only by backwards compatibility but its use is strongly discouraged.
3430
3431 See also : "clitimeout", "timeout server".
3432
3433
3434timeout connect <timeout>
3435timeout contimeout <timeout> (deprecated)
3436 Set the maximum time to wait for a connection attempt to a server to succeed.
3437 May be used in sections : defaults | frontend | listen | backend
3438 yes | no | yes | yes
3439 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003440 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003441 can be in any other unit if the number is suffixed by the unit,
3442 as explained at the top of this document.
3443
3444 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003445 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +01003446 cover one or several TCP packet losses by specifying timeouts that are
3447 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003448 connect timeout also presets both queue and tarpit timeouts to the same value
3449 if these have not been specified.
Willy Tarreau0ba27502007-12-24 16:55:16 +01003450
3451 This parameter is specific to backends, but can be specified once for all in
3452 "defaults" sections. This is in fact one of the easiest solutions not to
3453 forget about it. An unspecified timeout results in an infinite timeout, which
3454 is not recommended. Such a usage is accepted and works but reports a warning
3455 during startup because it may results in accumulation of failed sessions in
3456 the system if the system's timeouts are not configured either.
3457
3458 This parameter replaces the old, deprecated "contimeout". It is recommended
3459 to use it to write new configurations. The form "timeout contimeout" is
3460 provided only by backwards compatibility but its use is strongly discouraged.
3461
Willy Tarreau41a340d2008-01-22 12:25:31 +01003462 See also: "timeout check", "timeout queue", "timeout server", "contimeout",
3463 "timeout tarpit".
Willy Tarreau0ba27502007-12-24 16:55:16 +01003464
3465
Willy Tarreau036fae02008-01-06 13:24:40 +01003466timeout http-request <timeout>
3467 Set the maximum allowed time to wait for a complete HTTP request
3468 May be used in sections : defaults | frontend | listen | backend
3469 yes | yes | yes | no
3470 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003471 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau036fae02008-01-06 13:24:40 +01003472 can be in any other unit if the number is suffixed by the unit,
3473 as explained at the top of this document.
3474
3475 In order to offer DoS protection, it may be required to lower the maximum
3476 accepted time to receive a complete HTTP request without affecting the client
3477 timeout. This helps protecting against established connections on which
3478 nothing is sent. The client timeout cannot offer a good protection against
3479 this abuse because it is an inactivity timeout, which means that if the
3480 attacker sends one character every now and then, the timeout will not
3481 trigger. With the HTTP request timeout, no matter what speed the client
3482 types, the request will be aborted if it does not complete in time.
3483
3484 Note that this timeout only applies to the header part of the request, and
3485 not to any data. As soon as the empty line is received, this timeout is not
3486 used anymore.
3487
3488 Generally it is enough to set it to a few seconds, as most clients send the
3489 full request immediately upon connection. Add 3 or more seconds to cover TCP
3490 retransmits but that's all. Setting it to very low values (eg: 50 ms) will
3491 generally work on local networks as long as there are no packet losses. This
3492 will prevent people from sending bare HTTP requests using telnet.
3493
3494 If this parameter is not set, the client timeout still applies between each
3495 chunk of the incoming request.
3496
3497 See also : "timeout client".
3498
Willy Tarreau844e3c52008-01-11 16:28:18 +01003499
3500timeout queue <timeout>
3501 Set the maximum time to wait in the queue for a connection slot to be free
3502 May be used in sections : defaults | frontend | listen | backend
3503 yes | no | yes | yes
3504 Arguments :
3505 <timeout> is the timeout value specified in milliseconds by default, but
3506 can be in any other unit if the number is suffixed by the unit,
3507 as explained at the top of this document.
3508
3509 When a server's maxconn is reached, connections are left pending in a queue
3510 which may be server-specific or global to the backend. In order not to wait
3511 indefinitely, a timeout is applied to requests pending in the queue. If the
3512 timeout is reached, it is considered that the request will almost never be
3513 served, so it is dropped and a 503 error is returned to the client.
3514
3515 The "timeout queue" statement allows to fix the maximum time for a request to
3516 be left pending in a queue. If unspecified, the same value as the backend's
3517 connection timeout ("timeout connect") is used, for backwards compatibility
3518 with older versions with no "timeout queue" parameter.
3519
3520 See also : "timeout connect", "contimeout".
3521
3522
3523timeout server <timeout>
3524timeout srvtimeout <timeout> (deprecated)
3525 Set the maximum inactivity time on the server side.
3526 May be used in sections : defaults | frontend | listen | backend
3527 yes | no | yes | yes
3528 Arguments :
3529 <timeout> is the timeout value specified in milliseconds by default, but
3530 can be in any other unit if the number is suffixed by the unit,
3531 as explained at the top of this document.
3532
3533 The inactivity timeout applies when the server is expected to acknowledge or
3534 send data. In HTTP mode, this timeout is particularly important to consider
3535 during the first phase of the server's response, when it has to send the
3536 headers, as it directly represents the server's processing time for the
3537 request. To find out what value to put there, it's often good to start with
3538 what would be considered as unacceptable response times, then check the logs
3539 to observe the response time distribution, and adjust the value accordingly.
3540
3541 The value is specified in milliseconds by default, but can be in any other
3542 unit if the number is suffixed by the unit, as specified at the top of this
3543 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
3544 recommended that the client timeout remains equal to the server timeout in
3545 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003546 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01003547 packet losses by specifying timeouts that are slightly above multiples of 3
3548 seconds (eg: 4 or 5 seconds minimum).
3549
3550 This parameter is specific to backends, but can be specified once for all in
3551 "defaults" sections. This is in fact one of the easiest solutions not to
3552 forget about it. An unspecified timeout results in an infinite timeout, which
3553 is not recommended. Such a usage is accepted and works but reports a warning
3554 during startup because it may results in accumulation of expired sessions in
3555 the system if the system's timeouts are not configured either.
3556
3557 This parameter replaces the old, deprecated "srvtimeout". It is recommended
3558 to use it to write new configurations. The form "timeout srvtimeout" is
3559 provided only by backwards compatibility but its use is strongly discouraged.
3560
3561 See also : "srvtimeout", "timeout client".
3562
3563
3564timeout tarpit <timeout>
3565 Set the duration for which tapitted connections will be maintained
3566 May be used in sections : defaults | frontend | listen | backend
3567 yes | yes | yes | yes
3568 Arguments :
3569 <timeout> is the tarpit duration specified in milliseconds by default, but
3570 can be in any other unit if the number is suffixed by the unit,
3571 as explained at the top of this document.
3572
3573 When a connection is tarpitted using "reqtarpit", it is maintained open with
3574 no activity for a certain amount of time, then closed. "timeout tarpit"
3575 defines how long it will be maintained open.
3576
3577 The value is specified in milliseconds by default, but can be in any other
3578 unit if the number is suffixed by the unit, as specified at the top of this
3579 document. If unspecified, the same value as the backend's connection timeout
3580 ("timeout connect") is used, for backwards compatibility with older versions
3581 with no "timeout tapit" parameter.
3582
3583 See also : "timeout connect", "contimeout".
3584
3585
3586transparent (deprecated)
3587 Enable client-side transparent proxying
3588 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau4b1f8592008-12-23 23:13:55 +01003589 yes | no | yes | yes
Willy Tarreau844e3c52008-01-11 16:28:18 +01003590 Arguments : none
3591
3592 This keyword was introduced in order to provide layer 7 persistence to layer
3593 3 load balancers. The idea is to use the OS's ability to redirect an incoming
3594 connection for a remote address to a local process (here HAProxy), and let
3595 this process know what address was initially requested. When this option is
3596 used, sessions without cookies will be forwarded to the original destination
3597 IP address of the incoming request (which should match that of another
3598 equipment), while requests with cookies will still be forwarded to the
3599 appropriate server.
3600
3601 The "transparent" keyword is deprecated, use "option transparent" instead.
3602
3603 Note that contrary to a common belief, this option does NOT make HAProxy
3604 present the client's IP to the server when establishing the connection.
3605
Willy Tarreau844e3c52008-01-11 16:28:18 +01003606 See also: "option transparent"
3607
3608
3609use_backend <backend> if <condition>
3610use_backend <backend> unless <condition>
3611 Switch to a specific backend if/unless a Layer 7 condition is matched.
3612 May be used in sections : defaults | frontend | listen | backend
3613 no | yes | yes | no
3614 Arguments :
3615 <backend> is the name of a valid backend or "listen" section.
3616
3617 <condition> is a condition composed of ACLs, as described in section 2.3.
3618
3619 When doing content-switching, connections arrive on a frontend and are then
3620 dispatched to various backends depending on a number of conditions. The
3621 relation between the conditions and the backends is described with the
3622 "use_backend" keyword. This is supported only in HTTP mode.
3623
3624 There may be as many "use_backend" rules as desired. All of these rules are
3625 evaluated in their declaration order, and the first one which matches will
3626 assign the backend.
3627
3628 In the first form, the backend will be used if the condition is met. In the
3629 second form, the backend will be used if the condition is not met. If no
3630 condition is valid, the backend defined with "default_backend" will be used.
3631 If no default backend is defined, either the servers in the same section are
3632 used (in case of a "listen" section) or, in case of a frontend, no server is
3633 used and a 503 service unavailable response is returned.
3634
3635 See also: "default_backend" and section 2.3 about ACLs.
3636
Willy Tarreau036fae02008-01-06 13:24:40 +01003637
Willy Tarreau0ba27502007-12-24 16:55:16 +010036382.3) Using ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003639---------------
3640
3641The use of Access Control Lists (ACL) provides a flexible solution to perform
Willy Tarreau0ba27502007-12-24 16:55:16 +01003642content switching and generally to take decisions based on content extracted
3643from the request, the response or any environmental status. The principle is
3644simple :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003645
3646 - define test criteria with sets of values
3647 - perform actions only if a set of tests is valid
3648
3649The actions generally consist in blocking the request, or selecting a backend.
3650
3651In order to define a test, the "acl" keyword is used. The syntax is :
3652
3653 acl <aclname> <criterion> [flags] [operator] <value> ...
3654
Willy Tarreau0ba27502007-12-24 16:55:16 +01003655This creates a new ACL <aclname> or completes an existing one with new tests.
3656Those tests apply to the portion of request/response specified in <criterion>
Willy Tarreau6a06a402007-07-15 20:15:28 +02003657and may be adjusted with optional flags [flags]. Some criteria also support
3658an operator which may be specified before the set of values. The values are
3659of the type supported by the criterion, and are separated by spaces.
3660
Willy Tarreau0ba27502007-12-24 16:55:16 +01003661ACL names must be formed from upper and lower case letters, digits, '-' (dash),
3662'_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive,
3663which means that "my_acl" and "My_Acl" are two different ACLs.
3664
3665There is no enforced limit to the number of ACLs. The unused ones do not affect
Willy Tarreau6a06a402007-07-15 20:15:28 +02003666performance, they just consume a small amount of memory.
3667
Willy Tarreau0ba27502007-12-24 16:55:16 +01003668The following ACL flags are currently supported :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003669
3670 -i : ignore case during matching.
3671 -- : force end of flags. Useful when a string looks like one of the flags.
3672
3673Supported types of values are :
Willy Tarreau0ba27502007-12-24 16:55:16 +01003674
Willy Tarreau6a06a402007-07-15 20:15:28 +02003675 - integers or integer ranges
3676 - strings
3677 - regular expressions
3678 - IP addresses and networks
3679
3680
Willy Tarreau0ba27502007-12-24 16:55:16 +010036812.3.1) Matching integers
Willy Tarreau6a06a402007-07-15 20:15:28 +02003682------------------------
3683
3684Matching integers is special in that ranges and operators are permitted. Note
3685that integer matching only applies to positive values. A range is a value
3686expressed with a lower and an upper bound separated with a colon, both of which
3687may be omitted.
3688
3689For instance, "1024:65535" is a valid range to represent a range of
3690unprivileged ports, and "1024:" would also work. "0:1023" is a valid
3691representation of privileged ports, and ":1023" would also work.
3692
Willy Tarreau62644772008-07-16 18:36:06 +02003693As a special case, some ACL functions support decimal numbers which are in fact
3694two integers separated by a dot. This is used with some version checks for
3695instance. All integer properties apply to those decimal numbers, including
3696ranges and operators.
3697
Willy Tarreau6a06a402007-07-15 20:15:28 +02003698For an easier usage, comparison operators are also supported. Note that using
Willy Tarreau0ba27502007-12-24 16:55:16 +01003699operators with ranges does not make much sense and is strongly discouraged.
3700Similarly, it does not make much sense to perform order comparisons with a set
3701of values.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003702
Willy Tarreau0ba27502007-12-24 16:55:16 +01003703Available operators for integer matching are :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003704
3705 eq : true if the tested value equals at least one value
3706 ge : true if the tested value is greater than or equal to at least one value
3707 gt : true if the tested value is greater than at least one value
3708 le : true if the tested value is less than or equal to at least one value
3709 lt : true if the tested value is less than at least one value
3710
Willy Tarreau0ba27502007-12-24 16:55:16 +01003711For instance, the following ACL matches any negative Content-Length header :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003712
3713 acl negative-length hdr_val(content-length) lt 0
3714
Willy Tarreau62644772008-07-16 18:36:06 +02003715This one matches SSL versions between 3.0 and 3.1 (inclusive) :
3716
3717 acl sslv3 req_ssl_ver 3:3.1
3718
Willy Tarreau6a06a402007-07-15 20:15:28 +02003719
Willy Tarreau0ba27502007-12-24 16:55:16 +010037202.3.2) Matching strings
Willy Tarreau6a06a402007-07-15 20:15:28 +02003721-----------------------
3722
3723String matching applies to verbatim strings as they are passed, with the
3724exception of the backslash ("\") which makes it possible to escape some
3725characters such as the space. If the "-i" flag is passed before the first
3726string, then the matching will be performed ignoring the case. In order
3727to match the string "-i", either set it second, or pass the "--" flag
Willy Tarreau0ba27502007-12-24 16:55:16 +01003728before the first string. Same applies of course to match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003729
3730
Willy Tarreau0ba27502007-12-24 16:55:16 +010037312.3.3) Matching regular expressions (regexes)
Willy Tarreau6a06a402007-07-15 20:15:28 +02003732---------------------------------------------
3733
3734Just like with string matching, regex matching applies to verbatim strings as
3735they are passed, with the exception of the backslash ("\") which makes it
3736possible to escape some characters such as the space. If the "-i" flag is
3737passed before the first regex, then the matching will be performed ignoring
3738the case. In order to match the string "-i", either set it second, or pass
Willy Tarreau0ba27502007-12-24 16:55:16 +01003739the "--" flag before the first string. Same principle applies of course to
3740match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003741
3742
Willy Tarreau0ba27502007-12-24 16:55:16 +010037432.3.4) Matching IPv4 addresses
3744------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02003745
3746IPv4 addresses values can be specified either as plain addresses or with a
3747netmask appended, in which case the IPv4 address matches whenever it is
3748within the network. Plain addresses may also be replaced with a resolvable
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003749host name, but this practice is generally discouraged as it makes it more
Willy Tarreau0ba27502007-12-24 16:55:16 +01003750difficult to read and debug configurations. If hostnames are used, you should
3751at least ensure that they are present in /etc/hosts so that the configuration
3752does not depend on any random DNS match at the moment the configuration is
3753parsed.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003754
3755
Willy Tarreau0ba27502007-12-24 16:55:16 +010037562.3.5) Available matching criteria
Willy Tarreau6a06a402007-07-15 20:15:28 +02003757----------------------------------
3758
Willy Tarreau0ba27502007-12-24 16:55:16 +010037592.3.5.1) Matching at Layer 4 and below
3760--------------------------------------
3761
3762A first set of criteria applies to information which does not require any
3763analysis of the request or response contents. Those generally include TCP/IP
3764addresses and ports, as well as internal values independant on the stream.
3765
Willy Tarreau6a06a402007-07-15 20:15:28 +02003766always_false
3767 This one never matches. All values and flags are ignored. It may be used as
3768 a temporary replacement for another one when adjusting configurations.
3769
3770always_true
3771 This one always matches. All values and flags are ignored. It may be used as
3772 a temporary replacement for another one when adjusting configurations.
3773
3774src <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003775 Applies to the client's IPv4 address. It is usually used to limit access to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003776 certain resources such as statistics. Note that it is the TCP-level source
3777 address which is used, and not the address of a client behind a proxy.
3778
3779src_port <integer>
3780 Applies to the client's TCP source port. This has a very limited usage.
3781
3782dst <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003783 Applies to the local IPv4 address the client connected to. It can be used to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003784 switch to a different backend for some alternative addresses.
3785
3786dst_port <integer>
3787 Applies to the local port the client connected to. It can be used to switch
3788 to a different backend for some alternative ports.
3789
3790dst_conn <integer>
3791 Applies to the number of currently established connections on the frontend,
3792 including the one being evaluated. It can be used to either return a sorry
Willy Tarreau0ba27502007-12-24 16:55:16 +01003793 page before hard-blocking, or to use a specific backend to drain new requests
Willy Tarreau6a06a402007-07-15 20:15:28 +02003794 when the farm is considered saturated.
3795
Willy Tarreau0ba27502007-12-24 16:55:16 +01003796nbsrv <integer>
3797nbsrv(backend) <integer>
3798 Returns true when the number of usable servers of either the current backend
3799 or the named backend matches the values or ranges specified. This is used to
3800 switch to an alternate backend when the number of servers is too low to
3801 to handle some load. It is useful to report a failure when combined with
3802 "monitor fail".
3803
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +08003804connslots <integer>
3805connslots(backend) <integer>
3806 The basic idea here is to be able to measure the number of connection "slots"
3807 still available (connection, + queue) - so that anything beyond that (intended
3808 usage; see "use_backend" keyword) can be redirected to a different backend.
3809
3810 'connslots' = number of available server connection slots, + number of available
3811 server queue slots.
3812
3813 *Note that while "dst_conn" may be used, "connslots" comes in especially useful
3814 when you have a case of traffic going to one single ip, splitting into multiple
3815 backends (perhaps using acls to do name-based load balancing) - and you want to
3816 be able to differentiate between different backends, and their "connslots"
3817 available. Also, whereas "nbsrv" only measures servers that are actually *down*,
3818 this acl is more fine-grained - and looks into the number of conn slots available
3819 as well.
3820
3821 *OTHER CAVEATS AND NOTES: at this point in time, the code does not take care of
3822 dynamic connections. Also, if any of the server maxconn, or maxqueue is 0, then
3823 this acl clearly does not make sense - in which case the value returned will be -1.
3824
Willy Tarreau0ba27502007-12-24 16:55:16 +01003825
Willy Tarreau62644772008-07-16 18:36:06 +020038262.3.5.2) Matching contents at Layer 4
3827-------------------------------------
3828
3829A second set of criteria depends on data found in buffers, but which can change
3830during analysis. This requires that some data has been buffered, for instance
3831through TCP request content inspection. Please see the "tcp-request" keyword
3832for more detailed information on the subject.
3833
3834req_len <integer>
3835 Returns true when the lenght of the data in the request buffer matches the
3836 specified range. It is important to understand that this test does not
3837 return false as long as the buffer is changing. This means that a check with
3838 equality to zero will almost always immediately match at the beginning of the
3839 session, while a test for more data will wait for that data to come in and
3840 return false only when haproxy is certain that no more data will come in.
3841 This test was designed to be used with TCP request content inspection.
3842
3843req_ssl_ver <decimal>
3844 Returns true when data in the request buffer look like SSL, with a protocol
3845 version matching the specified range. Both SSLv2 hello messages and SSLv3
3846 messages are supported. The test tries to be strict enough to avoid being
3847 easily fooled. In particular, it waits for as many bytes as announced in the
3848 message header if this header looks valid (bound to the buffer size). Note
3849 that TLSv1 is announced as SSL version 3.1. This test was designed to be used
3850 with TCP request content inspection.
3851
Willy Tarreaub6fb4202008-07-20 11:18:28 +02003852wait_end
3853 Waits for the end of the analysis period to return true. This may be used in
3854 conjunction with content analysis to avoid returning a wrong verdict early.
3855 It may also be used to delay some actions, such as a delayed reject for some
3856 special addresses. Since it either stops the rules evaluation or immediately
3857 returns true, it is recommended to use this acl as the last one in a rule.
3858 Please note that the default ACL "WAIT_END" is always usable without prior
3859 declaration. This test was designed to be used with TCP request content
3860 inspection.
3861
3862 Examples :
3863 # delay every incoming request by 2 seconds
3864 tcp-request inspect-delay 2s
3865 tcp-request content accept if WAIT_END
3866
3867 # don't immediately tell bad guys they are rejected
3868 tcp-request inspect-delay 10s
3869 acl goodguys src 10.0.0.0/24
3870 acl badguys src 10.0.1.0/24
3871 tcp-request content accept if goodguys
3872 tcp-request content reject if badguys WAIT_END
3873 tcp-request content reject
3874
Willy Tarreau62644772008-07-16 18:36:06 +02003875
38762.3.5.3) Matching at Layer 7
Willy Tarreau0ba27502007-12-24 16:55:16 +01003877----------------------------
3878
Willy Tarreau62644772008-07-16 18:36:06 +02003879A third set of criteria applies to information which can be found at the
Willy Tarreau0ba27502007-12-24 16:55:16 +01003880application layer (layer 7). Those require that a full HTTP request has been
3881read, and are only evaluated then. They may require slightly more CPU resources
3882than the layer 4 ones, but not much since the request and response are indexed.
3883
Willy Tarreau6a06a402007-07-15 20:15:28 +02003884method <string>
3885 Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
3886 already check for most common methods.
3887
3888req_ver <string>
3889 Applies to the version string in the HTTP request, eg: "1.0". Some predefined
3890 ACL already check for versions 1.0 and 1.1.
3891
3892path <string>
3893 Returns true when the path part of the request, which starts at the first
3894 slash and ends before the question mark, equals one of the strings. It may be
3895 used to match known files, such as /favicon.ico.
3896
3897path_beg <string>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003898 Returns true when the path begins with one of the strings. This can be used
3899 to send certain directory names to alternative backends.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003900
3901path_end <string>
3902 Returns true when the path ends with one of the strings. This may be used to
3903 control file name extension.
3904
3905path_sub <string>
3906 Returns true when the path contains one of the strings. It can be used to
3907 detect particular patterns in paths, such as "../" for example. See also
3908 "path_dir".
3909
3910path_dir <string>
3911 Returns true when one of the strings is found isolated or delimited with
3912 slashes in the path. This is used to perform filename or directory name
3913 matching without the risk of wrong match due to colliding prefixes. See also
3914 "url_dir" and "path_sub".
3915
3916path_dom <string>
3917 Returns true when one of the strings is found isolated or delimited with dots
3918 in the path. This may be used to perform domain name matching in proxy
3919 requests. See also "path_sub" and "url_dom".
3920
3921path_reg <regex>
3922 Returns true when the path matches one of the regular expressions. It can be
3923 used any time, but it is important to remember that regex matching is slower
3924 than other methods. See also "url_reg" and all "path_" criteria.
3925
3926url <string>
3927 Applies to the whole URL passed in the request. The only real use is to match
3928 "*", for which there already is a predefined ACL.
3929
3930url_beg <string>
3931 Returns true when the URL begins with one of the strings. This can be used to
3932 check whether a URL begins with a slash or with a protocol scheme.
3933
3934url_end <string>
3935 Returns true when the URL ends with one of the strings. It has very limited
3936 use. "path_end" should be used instead for filename matching.
3937
3938url_sub <string>
3939 Returns true when the URL contains one of the strings. It can be used to
3940 detect particular patterns in query strings for example. See also "path_sub".
3941
3942url_dir <string>
3943 Returns true when one of the strings is found isolated or delimited with
3944 slashes in the URL. This is used to perform filename or directory name
3945 matching without the risk of wrong match due to colliding prefixes. See also
3946 "path_dir" and "url_sub".
3947
3948url_dom <string>
3949 Returns true when one of the strings is found isolated or delimited with dots
3950 in the URL. This is used to perform domain name matching without the risk of
3951 wrong match due to colliding prefixes. See also "url_sub".
3952
3953url_reg <regex>
3954 Returns true when the URL matches one of the regular expressions. It can be
3955 used any time, but it is important to remember that regex matching is slower
3956 than other methods. See also "path_reg" and all "url_" criteria.
3957
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003958url_ip <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003959 Applies to the IP address specified in the absolute URI in an HTTP request.
3960 It can be used to prevent access to certain resources such as local network.
Willy Tarreau198a7442008-01-17 12:05:32 +01003961 It is useful with option "http_proxy".
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003962
3963url_port <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003964 Applies to the port specified in the absolute URI in an HTTP request. It can
3965 be used to prevent access to certain resources. It is useful with option
Willy Tarreau198a7442008-01-17 12:05:32 +01003966 "http_proxy". Note that if the port is not specified in the request, port 80
Willy Tarreau0ba27502007-12-24 16:55:16 +01003967 is assumed.
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003968
Willy Tarreau6a06a402007-07-15 20:15:28 +02003969hdr <string>
3970hdr(header) <string>
3971 Note: all the "hdr*" matching criteria either apply to all headers, or to a
3972 particular header whose name is passed between parenthesis and without any
Willy Tarreau0ba27502007-12-24 16:55:16 +01003973 space. The header name is not case-sensitive. The header matching complies
3974 with RFC2616, and treats as separate headers all values delimited by commas.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003975
3976 The "hdr" criteria returns true if any of the headers matching the criteria
Willy Tarreau0ba27502007-12-24 16:55:16 +01003977 match any of the strings. This can be used to check exact for values. For
Willy Tarreau6a06a402007-07-15 20:15:28 +02003978 instance, checking that "connection: close" is set :
3979
3980 hdr(Connection) -i close
3981
3982hdr_beg <string>
3983hdr_beg(header) <string>
3984 Returns true when one of the headers begins with one of the strings. See
3985 "hdr" for more information on header matching.
3986
3987hdr_end <string>
3988hdr_end(header) <string>
3989 Returns true when one of the headers ends with one of the strings. See "hdr"
3990 for more information on header matching.
3991
3992hdr_sub <string>
3993hdr_sub(header) <string>
3994 Returns true when one of the headers contains one of the strings. See "hdr"
3995 for more information on header matching.
3996
3997hdr_dir <string>
3998hdr_dir(header) <string>
3999 Returns true when one of the headers contains one of the strings either
4000 isolated or delimited by slashes. This is used to perform filename or
4001 directory name matching, and may be used with Referer. See "hdr" for more
4002 information on header matching.
4003
4004hdr_dom <string>
4005hdr_dom(header) <string>
4006 Returns true when one of the headers contains one of the strings either
4007 isolated or delimited by dots. This is used to perform domain name matching,
4008 and may be used with the Host header. See "hdr" for more information on
4009 header matching.
4010
4011hdr_reg <regex>
4012hdr_reg(header) <regex>
4013 Returns true when one of the headers matches of the regular expressions. It
4014 can be used at any time, but it is important to remember that regex matching
4015 is slower than other methods. See also other "hdr_" criteria, as well as
4016 "hdr" for more information on header matching.
4017
4018hdr_val <integer>
4019hdr_val(header) <integer>
4020 Returns true when one of the headers starts with a number which matches the
4021 values or ranges specified. This may be used to limit content-length to
4022 acceptable values for example. See "hdr" for more information on header
4023 matching.
4024
4025hdr_cnt <integer>
4026hdr_cnt(header) <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01004027 Returns true when the number of occurrence of the specified header matches
4028 the values or ranges specified. It is important to remember that one header
4029 line may count as several headers if it has several values. This is used to
4030 detect presence, absence or abuse of a specific header, as well as to block
4031 request smugling attacks by rejecting requests which contain more than one
4032 of certain headers. See "hdr" for more information on header matching.
Willy Tarreau6a06a402007-07-15 20:15:28 +02004033
4034
Willy Tarreau0ba27502007-12-24 16:55:16 +010040352.3.6) Pre-defined ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02004036-----------------------
4037
4038Some predefined ACLs are hard-coded so that they do not have to be declared in
4039every frontend which needs them. They all have their names in upper case in
Willy Tarreau0ba27502007-12-24 16:55:16 +01004040order to avoid confusion. Their equivalence is provided below. Please note that
4041only the first three ones are not layer 7 based.
Willy Tarreau6a06a402007-07-15 20:15:28 +02004042
4043ACL name Equivalent to Usage
4044---------------+-----------------------------+---------------------------------
Willy Tarreau58393e12008-07-20 10:39:22 +02004045TRUE always_true always match
4046FALSE always_false never match
Willy Tarreau6a06a402007-07-15 20:15:28 +02004047LOCALHOST src 127.0.0.1/8 match connection from local host
4048HTTP_1.0 req_ver 1.0 match HTTP version 1.0
4049HTTP_1.1 req_ver 1.1 match HTTP version 1.1
4050METH_CONNECT method CONNECT match HTTP CONNECT method
4051METH_GET method GET HEAD match HTTP GET or HEAD method
4052METH_HEAD method HEAD match HTTP HEAD method
4053METH_OPTIONS method OPTIONS match HTTP OPTIONS method
4054METH_POST method POST match HTTP POST method
4055METH_TRACE method TRACE match HTTP TRACE method
4056HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
4057HTTP_URL_SLASH url_beg / match URL begining with "/"
4058HTTP_URL_STAR url * match URL equal to "*"
4059HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
Willy Tarreauc6317702008-07-20 09:29:50 +02004060REQ_CONTENT req_len gt 0 match data in the request buffer
Willy Tarreaub6fb4202008-07-20 11:18:28 +02004061WAIT_END wait_end wait for end of content analysis
Willy Tarreau6a06a402007-07-15 20:15:28 +02004062---------------+-----------------------------+---------------------------------
4063
4064
Willy Tarreau0ba27502007-12-24 16:55:16 +010040652.3.7) Using ACLs to form conditions
Willy Tarreau6a06a402007-07-15 20:15:28 +02004066------------------------------------
4067
4068Some actions are only performed upon a valid condition. A condition is a
4069combination of ACLs with operators. 3 operators are supported :
4070
4071 - AND (implicit)
4072 - OR (explicit with the "or" keyword or the "||" operator)
4073 - Negation with the exclamation mark ("!")
4074
4075A condition is formed as a disjonctive form :
4076
4077 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
4078
4079Such conditions are generally used after an "if" or "unless" statement,
4080indicating when the condition will trigger the action.
4081
4082For instance, to block HTTP requests to the "*" URL with methods other than
Willy Tarreau0ba27502007-12-24 16:55:16 +01004083"OPTIONS", as well as POST requests without content-length, and GET or HEAD
4084requests with a content-length greater than 0, and finally every request which
4085is not either GET/HEAD/POST/OPTIONS !
Willy Tarreau6a06a402007-07-15 20:15:28 +02004086
4087 acl missing_cl hdr_cnt(Content-length) eq 0
4088 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
4089 block if METH_GET HTTP_CONTENT
4090 block unless METH_GET or METH_POST or METH_OPTIONS
4091
4092To select a different backend for requests to static contents on the "www" site
4093and to every request on the "img", "video", "download" and "ftp" hosts :
4094
4095 acl url_static path_beg /static /images /img /css
4096 acl url_static path_end .gif .png .jpg .css .js
4097 acl host_www hdr_beg(host) -i www
4098 acl host_static hdr_beg(host) -i img. video. download. ftp.
4099
4100 # now use backend "static" for all static-only hosts, and for static urls
4101 # of host "www". Use backend "www" for the rest.
4102 use_backend static if host_static or host_www url_static
4103 use_backend www if host_www
4104
Willy Tarreau844e3c52008-01-11 16:28:18 +01004105See section 2.2 for detailed help on the "block" and "use_backend" keywords.
Willy Tarreaudbc36f62007-11-30 12:29:11 +01004106
4107
Willy Tarreauc7246fc2007-12-02 17:31:20 +010041082.4) Server options
Willy Tarreau5764b382007-11-30 17:46:49 +01004109-------------------
4110
Willy Tarreau198a7442008-01-17 12:05:32 +01004111The "server" keyword supports a certain number of settings which are all passed
4112as arguments on the server line. The order in which those arguments appear does
4113not count, and they are all optional. Some of those settings are single words
4114(booleans) while others expect one or several values after them. In this case,
4115the values must immediately follow the setting name. All those settings must be
4116specified after the server's address if they are used :
4117
4118 server <name> <address>[:port] [settings ...]
4119
4120The currently supported settings are the following ones.
4121
4122addr <ipv4>
4123 Using the "addr" parameter, it becomes possible to use a different IP address
4124 to send health-checks. On some servers, it may be desirable to dedicate an IP
4125 address to specific component able to perform complex tests which are more
4126 suitable to health-checks than the application. This parameter is ignored if
4127 the "check" parameter is not set. See also the "port" parameter.
4128
4129backup
4130 When "backup" is present on a server line, the server is only used in load
4131 balancing when all other non-backup servers are unavailable. Requests coming
4132 with a persistence cookie referencing the server will always be served
4133 though. By default, only the first operational backup server is used, unless
Willy Tarreauaf85d942008-01-30 10:47:10 +01004134 the "allbackups" option is set in the backend. See also the "allbackups"
Willy Tarreau198a7442008-01-17 12:05:32 +01004135 option.
4136
4137check
4138 This option enables health checks on the server. By default, a server is
4139 always considered available. If "check" is set, the server will receive
4140 periodic health checks to ensure that it is really able to serve requests.
4141 The default address and port to send the tests to are those of the server,
4142 and the default source is the same as the one defined in the backend. It is
4143 possible to change the address using the "addr" parameter, the port using the
4144 "port" parameter, the source address using the "source" address, and the
4145 interval and timers using the "inter", "rise" and "fall" parameters. The
4146 request method is define in the backend using the "httpchk", "smtpchk",
4147 and "ssl-hello-chk" options. Please refer to those options and parameters for
4148 more information.
4149
4150cookie <value>
4151 The "cookie" parameter sets the cookie value assigned to the server to
4152 <value>. This value will be checked in incoming requests, and the first
4153 operational server possessing the same value will be selected. In return, in
4154 cookie insertion or rewrite modes, this value will be assigned to the cookie
4155 sent to the client. There is nothing wrong in having several servers sharing
4156 the same cookie value, and it is in fact somewhat common between normal and
4157 backup servers. See also the "cookie" keyword in backend section.
4158
4159fall <count>
4160 The "fall" parameter states that a server will be considered as dead after
4161 <count> consecutive unsuccessful health checks. This value defaults to 3 if
4162 unspecified. See also the "check", "inter" and "rise" parameters.
4163
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004164id <value>
4165 Set a persistent value for server ID. Must be unique and larger than 1000, as
4166 smaller values are reserved for auto-assigned ids.
4167
Willy Tarreau198a7442008-01-17 12:05:32 +01004168inter <delay>
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01004169fastinter <delay>
4170downinter <delay>
Willy Tarreau198a7442008-01-17 12:05:32 +01004171 The "inter" parameter sets the interval between two consecutive health checks
4172 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01004173 It is also possible to use "fastinter" and "downinter" to optimize delays
Willy Tarreau41a340d2008-01-22 12:25:31 +01004174 between checks depending on the server state :
4175
4176 Server state | Interval used
4177 ---------------------------------+-----------------------------------------
4178 UP 100% (non-transitional) | "inter"
4179 ---------------------------------+-----------------------------------------
4180 Transitionally UP (going down), |
4181 Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise.
4182 or yet unchecked. |
4183 ---------------------------------+-----------------------------------------
4184 DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise.
4185 ---------------------------------+-----------------------------------------
4186
4187 Just as with every other time-based parameter, they can be entered in any
4188 other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also
4189 serves as a timeout for health checks sent to servers if "timeout check" is
4190 not set. In order to reduce "resonance" effects when multiple servers are
4191 hosted on the same hardware, the health-checks of all servers are started
4192 with a small time offset between them. It is also possible to add some random
4193 noise in the health checks interval using the global "spread-checks"
4194 keyword. This makes sense for instance when a lot of backends use the same
4195 servers.
Willy Tarreau198a7442008-01-17 12:05:32 +01004196
4197maxconn <maxconn>
4198 The "maxconn" parameter specifies the maximal number of concurrent
4199 connections that will be sent to this server. If the number of incoming
4200 concurrent requests goes higher than this value, they will be queued, waiting
4201 for a connection to be released. This parameter is very important as it can
4202 save fragile servers from going down under extreme loads. If a "minconn"
4203 parameter is specified, the limit becomes dynamic. The default value is "0"
4204 which means unlimited. See also the "minconn" and "maxqueue" parameters, and
4205 the backend's "fullconn" keyword.
4206
4207maxqueue <maxqueue>
4208 The "maxqueue" parameter specifies the maximal number of connections which
4209 will wait in the queue for this server. If this limit is reached, next
4210 requests will be redispatched to other servers instead of indefinitely
4211 waiting to be served. This will break persistence but may allow people to
4212 quickly re-log in when the server they try to connect to is dying. The
4213 default value is "0" which means the queue is unlimited. See also the
4214 "maxconn" and "minconn" parameters.
4215
4216minconn <minconn>
4217 When the "minconn" parameter is set, the maxconn limit becomes a dynamic
4218 limit following the backend's load. The server will always accept at least
4219 <minconn> connections, never more than <maxconn>, and the limit will be on
4220 the ramp between both values when the backend has less than <fullconn>
4221 concurrent connections. This makes it possible to limit the load on the
4222 server during normal loads, but push it further for important loads without
4223 overloading the server during exceptionnal loads. See also the "maxconn"
4224 and "maxqueue" parameters, as well as the "fullconn" backend keyword.
4225
4226port <port>
4227 Using the "port" parameter, it becomes possible to use a different port to
4228 send health-checks. On some servers, it may be desirable to dedicate a port
4229 to a specific component able to perform complex tests which are more suitable
4230 to health-checks than the application. It is common to run a simple script in
4231 inetd for instance. This parameter is ignored if the "check" parameter is not
4232 set. See also the "addr" parameter.
4233
Willy Tarreau21d2af32008-02-14 20:25:24 +01004234redir <prefix>
4235 The "redir" parameter enables the redirection mode for all GET and HEAD
4236 requests addressing this server. This means that instead of having HAProxy
4237 forward the request to the server, it will send an "HTTP 302" response with
4238 the "Location" header composed of this prefix immediately followed by the
4239 requested URI beginning at the leading '/' of the path component. That means
4240 that no trailing slash should be used after <prefix>. All invalid requests
4241 will be rejected, and all non-GET or HEAD requests will be normally served by
4242 the server. Note that since the response is completely forged, no header
4243 mangling nor cookie insertion is possible in the respose. However, cookies in
4244 requests are still analysed, making this solution completely usable to direct
4245 users to a remote location in case of local disaster. Main use consists in
4246 increasing bandwidth for static servers by having the clients directly
4247 connect to them. Note: never use a relative location here, it would cause a
4248 loop between the client and HAProxy!
4249
4250 Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check
4251
Willy Tarreau198a7442008-01-17 12:05:32 +01004252rise <count>
4253 The "rise" parameter states that a server will be considered as operational
4254 after <count> consecutive successful health checks. This value defaults to 2
4255 if unspecified. See also the "check", "inter" and "fall" parameters.
4256
Willy Tarreau5764b382007-11-30 17:46:49 +01004257slowstart <start_time_in_ms>
Willy Tarreau198a7442008-01-17 12:05:32 +01004258 The "slowstart" parameter for a server accepts a value in milliseconds which
Willy Tarreau5764b382007-11-30 17:46:49 +01004259 indicates after how long a server which has just come back up will run at
Willy Tarreaubefdff12007-12-02 22:27:38 +01004260 full speed. Just as with every other time-based parameter, it can be entered
4261 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
4262 linearly from 0 to 100% during this time. The limitation applies to two
4263 parameters :
Willy Tarreau5764b382007-11-30 17:46:49 +01004264
4265 - maxconn: the number of connections accepted by the server will grow from 1
4266 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
4267
4268 - weight: when the backend uses a dynamic weighted algorithm, the weight
4269 grows linearly from 1 to 100%. In this case, the weight is updated at every
Willy Tarreau198a7442008-01-17 12:05:32 +01004270 health-check. For this reason, it is important that the "inter" parameter
4271 is smaller than the "slowstart", in order to maximize the number of steps.
Willy Tarreau5764b382007-11-30 17:46:49 +01004272
4273 The slowstart never applies when haproxy starts, otherwise it would cause
4274 trouble to running servers. It only applies when a server has been previously
4275 seen as failed.
4276
Willy Tarreau198a7442008-01-17 12:05:32 +01004277source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
4278 The "source" parameter sets the source address which will be used when
4279 connecting to the server. It follows the exact same parameters and principle
4280 as the backend "source" keyword, except that it only applies to the server
4281 referencing it. Please consult the "source" keyword for details.
4282
Krzysztof Piotr Oledzkic8b16fc2008-02-18 01:26:35 +01004283track [<proxy>/]<server>
4284 This option enables ability to set the current state of the server by
4285 tracking another one. Only a server with checks enabled can be tracked
4286 so it is not possible for example to track a server that tracks another
4287 one. If <proxy> is omitted the current one is used. If disable-on-404 is
4288 used, it has to be enabled on both proxies.
4289
Willy Tarreau198a7442008-01-17 12:05:32 +01004290weight <weight>
4291 The "weight" parameter is used to adjust the server's weight relative to
4292 other servers. All servers will receive a load proportional to their weight
4293 relative to the sum of all weights, so the higher the weight, the higher the
4294 load. The default weight is 1, and the maximal value is 255. If this
4295 parameter is used to distribute the load according to server's capacity, it
4296 is recommended to start with values which can both grow and shrink, for
4297 instance between 10 and 100 to leave enough room above and below for later
4298 adjustments.
4299
Willy Tarreauced27012008-01-17 20:35:34 +01004300
43012.5) HTTP header manipulation
4302-----------------------------
4303
4304In HTTP mode, it is possible to rewrite, add or delete some of the request and
4305response headers based on regular expressions. It is also possible to block a
4306request or a response if a particular header matches a regular expression,
4307which is enough to stop most elementary protocol attacks, and to protect
4308against information leak from the internal network. But there is a limitation
4309to this : since HAProxy's HTTP engine does not support keep-alive, only headers
4310passed during the first request of a TCP session will be seen. All subsequent
4311headers will be considered data only and not analyzed. Furthermore, HAProxy
4312never touches data contents, it stops analysis at the end of headers.
4313
4314This section covers common usage of the following keywords, described in detail
4315in section 2.2.1 :
4316
4317 - reqadd <string>
4318 - reqallow <search>
4319 - reqiallow <search>
4320 - reqdel <search>
4321 - reqidel <search>
4322 - reqdeny <search>
4323 - reqideny <search>
4324 - reqpass <search>
4325 - reqipass <search>
4326 - reqrep <search> <replace>
4327 - reqirep <search> <replace>
4328 - reqtarpit <search>
4329 - reqitarpit <search>
4330 - rspadd <string>
4331 - rspdel <search>
4332 - rspidel <search>
4333 - rspdeny <search>
4334 - rspideny <search>
4335 - rsprep <search> <replace>
4336 - rspirep <search> <replace>
4337
4338With all these keywords, the same conventions are used. The <search> parameter
4339is a POSIX extended regular expression (regex) which supports grouping through
4340parenthesis (without the backslash). Spaces and other delimiters must be
4341prefixed with a backslash ('\') to avoid confusion with a field delimiter.
4342Other characters may be prefixed with a backslash to change their meaning :
4343
4344 \t for a tab
4345 \r for a carriage return (CR)
4346 \n for a new line (LF)
4347 \ to mark a space and differentiate it from a delimiter
4348 \# to mark a sharp and differentiate it from a comment
4349 \\ to use a backslash in a regex
4350 \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy)
4351 \xXX to write the ASCII hex code XX as in the C language
4352
4353The <replace> parameter contains the string to be used to replace the largest
4354portion of text matching the regex. It can make use of the special characters
4355above, and can reference a substring which is delimited by parenthesis in the
4356regex, by writing a backslash ('\') immediately followed by one digit from 0 to
Willy Tarreaud2a4aa22008-01-31 15:28:22 +010043579 indicating the group position (0 designating the entire line). This practice
Willy Tarreauced27012008-01-17 20:35:34 +01004358is very common to users of the "sed" program.
4359
4360The <string> parameter represents the string which will systematically be added
4361after the last header line. It can also use special character sequences above.
4362
4363Notes related to these keywords :
4364---------------------------------
4365 - these keywords are not always convenient to allow/deny based on header
4366 contents. It is strongly recommended to use ACLs with the "block" keyword
4367 instead, resulting in far more flexible and manageable rules.
4368
4369 - lines are always considered as a whole. It is not possible to reference
4370 a header name only or a value only. This is important because of the way
4371 headers are written (notably the number of spaces after the colon).
4372
4373 - the first line is always considered as a header, which makes it possible to
4374 rewrite or filter HTTP requests URIs or response codes, but in turn makes
4375 it harder to distinguish between headers and request line. The regex prefix
4376 ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix
4377 ^[^ \t:]*: matches any header name followed by a colon.
4378
4379 - for performances reasons, the number of characters added to a request or to
4380 a response is limited at build time to values between 1 and 4 kB. This
4381 should normally be far more than enough for most usages. If it is too short
4382 on occasional usages, it is possible to gain some space by removing some
4383 useless headers before adding new ones.
4384
4385 - keywords beginning with "reqi" and "rspi" are the same as their couterpart
4386 without the 'i' letter except that they ignore case when matching patterns.
4387
4388 - when a request passes through a frontend then a backend, all req* rules
4389 from the frontend will be evaluated, then all req* rules from the backend
4390 will be evaluated. The reverse path is applied to responses.
4391
4392 - req* statements are applied after "block" statements, so that "block" is
4393 always the first one, but before "use_backend" in order to permit rewriting
4394 before switching.
4395
Willy Tarreau5764b382007-11-30 17:46:49 +01004396
Willy Tarreauced27012008-01-17 20:35:34 +010043972.6) Logging
Willy Tarreau844e3c52008-01-11 16:28:18 +01004398------------
4399
4400[to do]
4401
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004402
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +010044032.7) CSV format
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004404---------------
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004405
4406 0. pxname: proxy name
4407 1. svname: service name (FRONTEND for frontend, BACKEND for backend, any name
4408 for server)
4409 2. qcur: current queued requests
4410 3. qmax: max queued requests
4411 4. scur: current sessions
4412 5. smax: max sessions
4413 6. slim: sessions limit
4414 7. stot: total sessions
4415 8. bin: bytes in
4416 9. bout: bytes out
4417 10. dreq: denied requests
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004418 11. dresp: denied responses
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004419 12. ereq: request errors
4420 13. econ: connection errors
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004421 14. eresp: response errors
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004422 15. wretr: retries (warning)
4423 16. wredis: redispatches (warning)
4424 17. status: status (UP/DOWN/...)
4425 18. weight: server weight (server), total weight (backend)
4426 19. act: server is active (server), number of active servers (backend)
4427 20. bck: server is backup (server), number of backup servers (backend)
4428 21. chkfail: number of failed checks
4429 22. chkdown: number of UP->DOWN transitions
4430 23. lastchg: last status change (in seconds)
4431 24. downtime: total downtime (in seconds)
4432 25. qlimit: queue limit
4433 26. pid: process id (0 for first instance, 1 for second, ...)
4434 27. iid: unique proxy id
4435 28. sid: service id (unique inside a proxy)
4436 29. throttle: warm up status
4437 30. lbtot: total number of times a server was selected
4438 31. tracked: id of proxy/server if tracking is enabled
4439 32. type (0=frontend, 1=backend, 2=server)
Willy Tarreau844e3c52008-01-11 16:28:18 +01004440
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004441
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010044422.8) Unix Socket commands
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004443-------------------------
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004444
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004445The following commands are supported on the UNIX stats socket ; all of them
4446must be terminated by a line feed. It is important to understand that when
4447multiple haproxy processes are started on the same sockets, any process may
4448pick up the request and will output its own stats.
4449
4450show stat [<iid> <type> <sid>]
4451 Dump statistics in the CSV format. By passing <id>, <type> and <sid>, it is
4452 possible to dump only selected items :
4453 - <iid> is a proxy ID, -1 to dump everything
4454 - <type> selects the type of dumpable objects : 1 for frontends, 2 for
4455 backends, 4 for servers, -1 for everything. These values can be ORed,
4456 for example:
4457 1 + 2 = 3 -> frontend + backend.
4458 1 + 2 + 4 = 7 -> frontend + backend + server.
4459 - <sid> is a server ID, -1 to dump everything from the selected proxy.
4460
4461show info
4462 Dump info about haproxy status on current process.
4463
4464show sess
4465 Dump all known sessions. Avoid doing this on slow connections as this can
4466 be huge.
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004467
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004468
Willy Tarreau0ba27502007-12-24 16:55:16 +01004469/*
4470 * Local variables:
4471 * fill-column: 79
4472 * End:
4473 */