blob: f37981b04417b19845c71d886c241d3da58bc503 [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
572[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 Tarreau844e3c52008-01-11 16:28:18 +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
2317 yes | yes | yes | no
2318 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
2332 Use of this option is really discouraged, and since no really valid use of it
2333 has been reported for years, it will probably be removed in future versions.
2334
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002335 See also: the "usersrc" argument of the "source" keyword, and the
2336 "transparent" option of the "bind" keyword.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002337
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002338
Willy Tarreaub463dfb2008-06-07 23:08:56 +02002339redirect {location | prefix} <to> [code <code>] {if | unless} <condition>
2340 Return an HTTP redirection if/unless a condition is matched
2341 May be used in sections : defaults | frontend | listen | backend
2342 no | yes | yes | yes
2343
2344 If/unless the condition is matched, the HTTP request will lead to a redirect
2345 response. There are currently two types of redirections : "location" and
2346 "prefix". With "location", the exact value in <to> is placed into the HTTP
2347 "Location" header. With "prefix", the "Location" header is built from the
2348 concatenation of <to> and the URI. It is particularly suited for global site
2349 redirections.
2350
2351 The code is optional. It indicates in <code> which type of HTTP redirection
2352 is desired. Only codes 301, 302 and 303 are supported. 302 is used if no code
2353 is specified.
2354
2355 Example: move the login URL only to HTTPS.
2356 acl clear dst_port 80
2357 acl secure dst_port 8080
2358 acl login_page url_beg /login
2359 redirect prefix https://mysite.com if login_page !secure
2360 redirect location http://mysite.com/ if !login_page secure
2361
2362 See section 2.3 about ACL usage.
2363
2364
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002365redisp (deprecated)
2366redispatch (deprecated)
2367 Enable or disable session redistribution in case of connection failure
2368 May be used in sections: defaults | frontend | listen | backend
2369 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002370 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002371
2372 In HTTP mode, if a server designated by a cookie is down, clients may
2373 definitely stick to it because they cannot flush the cookie, so they will not
2374 be able to access the service anymore.
2375
2376 Specifying "redispatch" will allow the proxy to break their persistence and
2377 redistribute them to a working server.
2378
2379 It also allows to retry last connection to another server in case of multiple
2380 connection failures. Of course, it requires having "retries" set to a nonzero
2381 value.
2382
2383 This form is deprecated, do not use it in any new configuration, use the new
2384 "option redispatch" instead.
2385
2386 See also : "option redispatch"
2387
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002388
Willy Tarreau303c0352008-01-17 19:01:39 +01002389reqadd <string>
2390 Add a header at the end of the HTTP request
2391 May be used in sections : defaults | frontend | listen | backend
2392 no | yes | yes | yes
2393 Arguments :
2394 <string> is the complete line to be added. Any space or known delimiter
2395 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002396 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002397
2398 A new line consisting in <string> followed by a line feed will be added after
2399 the last header of an HTTP request.
2400
2401 Header transformations only apply to traffic which passes through HAProxy,
2402 and not to traffic generated by HAProxy, such as health-checks or error
2403 responses.
2404
Willy Tarreauced27012008-01-17 20:35:34 +01002405 See also: "rspadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002406
2407
2408reqallow <search>
2409reqiallow <search> (ignore case)
2410 Definitely allow an HTTP request if a line matches a regular expression
2411 May be used in sections : defaults | frontend | listen | backend
2412 no | yes | yes | yes
2413 Arguments :
2414 <search> is the regular expression applied to HTTP headers and to the
2415 request line. This is an extended regular expression. Parenthesis
2416 grouping is supported and no preliminary backslash is required.
2417 Any space or known delimiter must be escaped using a backslash
2418 ('\'). The pattern applies to a full line at a time. The
2419 "reqallow" keyword strictly matches case while "reqiallow"
2420 ignores case.
2421
2422 A request containing any line which matches extended regular expression
2423 <search> will mark the request as allowed, even if any later test would
2424 result in a deny. The test applies both to the request line and to request
2425 headers. Keep in mind that URLs in request line are case-sensitive while
2426 header names are not.
2427
2428 It is easier, faster and more powerful to use ACLs to write access policies.
2429 Reqdeny, reqallow and reqpass should be avoided in new designs.
2430
2431 Example :
2432 # allow www.* but refuse *.local
2433 reqiallow ^Host:\ www\.
2434 reqideny ^Host:\ .*\.local
2435
Willy Tarreauced27012008-01-17 20:35:34 +01002436 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002437 manipulation
2438
2439
2440reqdel <search>
2441reqidel <search> (ignore case)
2442 Delete all headers matching a regular expression in an HTTP request
2443 May be used in sections : defaults | frontend | listen | backend
2444 no | yes | yes | yes
2445 Arguments :
2446 <search> is the regular expression applied to HTTP headers and to the
2447 request line. This is an extended regular expression. Parenthesis
2448 grouping is supported and no preliminary backslash is required.
2449 Any space or known delimiter must be escaped using a backslash
2450 ('\'). The pattern applies to a full line at a time. The "reqdel"
2451 keyword strictly matches case while "reqidel" ignores case.
2452
2453 Any header line matching extended regular expression <search> in the request
2454 will be completely deleted. Most common use of this is to remove unwanted
2455 and/or dangerous headers or cookies from a request before passing it to the
2456 next servers.
2457
2458 Header transformations only apply to traffic which passes through HAProxy,
2459 and not to traffic generated by HAProxy, such as health-checks or error
2460 responses. Keep in mind that header names are not case-sensitive.
2461
2462 Example :
2463 # remove X-Forwarded-For header and SERVER cookie
2464 reqidel ^X-Forwarded-For:.*
2465 reqidel ^Cookie:.*SERVER=
2466
Willy Tarreauced27012008-01-17 20:35:34 +01002467 See also: "reqadd", "reqrep", "rspdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002468 manipulation
2469
2470
2471reqdeny <search>
2472reqideny <search> (ignore case)
2473 Deny an HTTP request if a line matches a regular expression
2474 May be used in sections : defaults | frontend | listen | backend
2475 no | yes | yes | yes
2476 Arguments :
2477 <search> is the regular expression applied to HTTP headers and to the
2478 request line. This is an extended regular expression. Parenthesis
2479 grouping is supported and no preliminary backslash is required.
2480 Any space or known delimiter must be escaped using a backslash
2481 ('\'). The pattern applies to a full line at a time. The
2482 "reqdeny" keyword strictly matches case while "reqideny" ignores
2483 case.
2484
2485 A request containing any line which matches extended regular expression
2486 <search> will mark the request as denied, even if any later test would
2487 result in an allow. The test applies both to the request line and to request
2488 headers. Keep in mind that URLs in request line are case-sensitive while
2489 header names are not.
2490
Willy Tarreauced27012008-01-17 20:35:34 +01002491 A denied request will generate an "HTTP 403 forbidden" response once the
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002492 complete request has been parsed. This is consistent with what is practiced
Willy Tarreauced27012008-01-17 20:35:34 +01002493 using ACLs.
2494
Willy Tarreau303c0352008-01-17 19:01:39 +01002495 It is easier, faster and more powerful to use ACLs to write access policies.
2496 Reqdeny, reqallow and reqpass should be avoided in new designs.
2497
2498 Example :
2499 # refuse *.local, then allow www.*
2500 reqideny ^Host:\ .*\.local
2501 reqiallow ^Host:\ www\.
2502
Willy Tarreauced27012008-01-17 20:35:34 +01002503 See also: "reqallow", "rspdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002504 header manipulation
2505
2506
2507reqpass <search>
2508reqipass <search> (ignore case)
2509 Ignore any HTTP request line matching a regular expression in next rules
2510 May be used in sections : defaults | frontend | listen | backend
2511 no | yes | yes | yes
2512 Arguments :
2513 <search> is the regular expression applied to HTTP headers and to the
2514 request line. This is an extended regular expression. Parenthesis
2515 grouping is supported and no preliminary backslash is required.
2516 Any space or known delimiter must be escaped using a backslash
2517 ('\'). The pattern applies to a full line at a time. The
2518 "reqpass" keyword strictly matches case while "reqipass" ignores
2519 case.
2520
2521 A request containing any line which matches extended regular expression
2522 <search> will skip next rules, without assigning any deny or allow verdict.
2523 The test applies both to the request line and to request headers. Keep in
2524 mind that URLs in request line are case-sensitive while header names are not.
2525
2526 It is easier, faster and more powerful to use ACLs to write access policies.
2527 Reqdeny, reqallow and reqpass should be avoided in new designs.
2528
2529 Example :
2530 # refuse *.local, then allow www.*, but ignore "www.private.local"
2531 reqipass ^Host:\ www.private\.local
2532 reqideny ^Host:\ .*\.local
2533 reqiallow ^Host:\ www\.
2534
Willy Tarreauced27012008-01-17 20:35:34 +01002535 See also: "reqallow", "reqdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002536 header manipulation
2537
2538
2539reqrep <search> <string>
2540reqirep <search> <string> (ignore case)
2541 Replace a regular expression with a string in an HTTP request line
2542 May be used in sections : defaults | frontend | listen | backend
2543 no | yes | yes | yes
2544 Arguments :
2545 <search> is the regular expression applied to HTTP headers and to the
2546 request line. This is an extended regular expression. Parenthesis
2547 grouping is supported and no preliminary backslash is required.
2548 Any space or known delimiter must be escaped using a backslash
2549 ('\'). The pattern applies to a full line at a time. The "reqrep"
2550 keyword strictly matches case while "reqirep" ignores case.
2551
2552 <string> is the complete line to be added. Any space or known delimiter
2553 must be escaped using a backslash ('\'). References to matched
2554 pattern groups are possible using the common \N form, with N
2555 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002556 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002557
2558 Any line matching extended regular expression <search> in the request (both
2559 the request line and header lines) will be completely replaced with <string>.
2560 Most common use of this is to rewrite URLs or domain names in "Host" headers.
2561
2562 Header transformations only apply to traffic which passes through HAProxy,
2563 and not to traffic generated by HAProxy, such as health-checks or error
2564 responses. Note that for increased readability, it is suggested to add enough
2565 spaces between the request and the response. Keep in mind that URLs in
2566 request line are case-sensitive while header names are not.
2567
2568 Example :
2569 # replace "/static/" with "/" at the beginning of any request path.
2570 reqrep ^([^\ ]*)\ /static/(.*) \1\ /\2
2571 # replace "www.mydomain.com" with "www" in the host name.
2572 reqirep ^Host:\ www.mydomain.com Host:\ www
2573
Willy Tarreauced27012008-01-17 20:35:34 +01002574 See also: "reqadd", "reqdel", "rsprep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002575 manipulation
2576
2577
2578reqtarpit <search>
2579reqitarpit <search> (ignore case)
2580 Tarpit an HTTP request containing a line matching a regular expression
2581 May be used in sections : defaults | frontend | listen | backend
2582 no | yes | yes | yes
2583 Arguments :
2584 <search> is the regular expression applied to HTTP headers and to the
2585 request line. This is an extended regular expression. Parenthesis
2586 grouping is supported and no preliminary backslash is required.
2587 Any space or known delimiter must be escaped using a backslash
2588 ('\'). The pattern applies to a full line at a time. The
2589 "reqtarpit" keyword strictly matches case while "reqitarpit"
2590 ignores case.
2591
2592 A request containing any line which matches extended regular expression
2593 <search> will be tarpitted, which means that it will connect to nowhere, will
Willy Tarreauced27012008-01-17 20:35:34 +01002594 be kept open for a pre-defined time, then will return an HTTP error 500 so
2595 that the attacker does not suspect it has been tarpitted. The status 500 will
2596 be reported in the logs, but the completion flags will indicate "PT". The
Willy Tarreau303c0352008-01-17 19:01:39 +01002597 delay is defined by "timeout tarpit", or "timeout connect" if the former is
2598 not set.
2599
2600 The goal of the tarpit is to slow down robots attacking servers with
2601 identifiable requests. Many robots limit their outgoing number of connections
2602 and stay connected waiting for a reply which can take several minutes to
2603 come. Depending on the environment and attack, it may be particularly
2604 efficient at reducing the load on the network and firewalls.
2605
2606 Example :
2607 # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but
2608 # block all others.
2609 reqipass ^User-Agent:\.*(Mozilla|MSIE)
2610 reqitarpit ^User-Agent:
2611
Willy Tarreauced27012008-01-17 20:35:34 +01002612 See also: "reqallow", "reqdeny", "reqpass", and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002613 manipulation
2614
2615
Willy Tarreaue5c5ce92008-06-20 17:27:19 +02002616retries <value>
2617 Set the number of retries to perform on a server after a connection failure
2618 May be used in sections: defaults | frontend | listen | backend
2619 yes | no | yes | yes
2620 Arguments :
2621 <value> is the number of times a connection attempt should be retried on
2622 a server when a connection either is refused or times out. The
2623 default value is 3.
2624
2625 It is important to understand that this value applies to the number of
2626 connection attempts, not full requests. When a connection has effectively
2627 been established to a server, there will be no more retry.
2628
2629 In order to avoid immediate reconnections to a server which is restarting,
2630 a turn-around timer of 1 second is applied before a retry occurs.
2631
2632 When "option redispatch" is set, the last retry may be performed on another
2633 server even if a cookie references a different server.
2634
2635 See also : "option redispatch"
2636
2637
Willy Tarreau303c0352008-01-17 19:01:39 +01002638rspadd <string>
2639 Add a header at the end of the HTTP response
2640 May be used in sections : defaults | frontend | listen | backend
2641 no | yes | yes | yes
2642 Arguments :
2643 <string> is the complete line to be added. Any space or known delimiter
2644 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002645 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002646
2647 A new line consisting in <string> followed by a line feed will be added after
2648 the last header of an HTTP response.
2649
2650 Header transformations only apply to traffic which passes through HAProxy,
2651 and not to traffic generated by HAProxy, such as health-checks or error
2652 responses.
2653
Willy Tarreauced27012008-01-17 20:35:34 +01002654 See also: "reqadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002655
2656
2657rspdel <search>
2658rspidel <search> (ignore case)
2659 Delete all headers matching a regular expression in an HTTP response
2660 May be used in sections : defaults | frontend | listen | backend
2661 no | yes | yes | yes
2662 Arguments :
2663 <search> is the regular expression applied to HTTP headers and to the
2664 response line. This is an extended regular expression, so
2665 parenthesis grouping is supported and no preliminary backslash
2666 is required. Any space or known delimiter must be escaped using
2667 a backslash ('\'). The pattern applies to a full line at a time.
2668 The "rspdel" keyword strictly matches case while "rspidel"
2669 ignores case.
2670
2671 Any header line matching extended regular expression <search> in the response
2672 will be completely deleted. Most common use of this is to remove unwanted
2673 and/or sensible headers or cookies from a response before passing it to the
2674 client.
2675
2676 Header transformations only apply to traffic which passes through HAProxy,
2677 and not to traffic generated by HAProxy, such as health-checks or error
2678 responses. Keep in mind that header names are not case-sensitive.
2679
2680 Example :
2681 # remove the Server header from responses
2682 reqidel ^Server:.*
2683
Willy Tarreauced27012008-01-17 20:35:34 +01002684 See also: "rspadd", "rsprep", "reqdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002685 manipulation
2686
2687
2688rspdeny <search>
2689rspideny <search> (ignore case)
2690 Block an HTTP response if a line matches a regular expression
2691 May be used in sections : defaults | frontend | listen | backend
2692 no | yes | yes | yes
2693 Arguments :
2694 <search> is the regular expression applied to HTTP headers and to the
2695 response line. This is an extended regular expression, so
2696 parenthesis grouping is supported and no preliminary backslash
2697 is required. Any space or known delimiter must be escaped using
2698 a backslash ('\'). The pattern applies to a full line at a time.
2699 The "rspdeny" keyword strictly matches case while "rspideny"
2700 ignores case.
2701
2702 A response containing any line which matches extended regular expression
2703 <search> will mark the request as denied. The test applies both to the
2704 response line and to response headers. Keep in mind that header names are not
2705 case-sensitive.
2706
2707 Main use of this keyword is to prevent sensitive information leak and to
Willy Tarreauced27012008-01-17 20:35:34 +01002708 block the response before it reaches the client. If a response is denied, it
2709 will be replaced with an HTTP 502 error so that the client never retrieves
2710 any sensitive data.
Willy Tarreau303c0352008-01-17 19:01:39 +01002711
2712 It is easier, faster and more powerful to use ACLs to write access policies.
2713 Rspdeny should be avoided in new designs.
2714
2715 Example :
2716 # Ensure that no content type matching ms-word will leak
2717 rspideny ^Content-type:\.*/ms-word
2718
Willy Tarreauced27012008-01-17 20:35:34 +01002719 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002720 manipulation
2721
2722
2723rsprep <search> <string>
2724rspirep <search> <string> (ignore case)
2725 Replace a regular expression with a string in an HTTP response line
2726 May be used in sections : defaults | frontend | listen | backend
2727 no | yes | yes | yes
2728 Arguments :
2729 <search> is the regular expression applied to HTTP headers and to the
2730 response line. This is an extended regular expression, so
2731 parenthesis grouping is supported and no preliminary backslash
2732 is required. Any space or known delimiter must be escaped using
2733 a backslash ('\'). The pattern applies to a full line at a time.
2734 The "rsprep" keyword strictly matches case while "rspirep"
2735 ignores case.
2736
2737 <string> is the complete line to be added. Any space or known delimiter
2738 must be escaped using a backslash ('\'). References to matched
2739 pattern groups are possible using the common \N form, with N
2740 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002741 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002742
2743 Any line matching extended regular expression <search> in the response (both
2744 the response line and header lines) will be completely replaced with
2745 <string>. Most common use of this is to rewrite Location headers.
2746
2747 Header transformations only apply to traffic which passes through HAProxy,
2748 and not to traffic generated by HAProxy, such as health-checks or error
2749 responses. Note that for increased readability, it is suggested to add enough
2750 spaces between the request and the response. Keep in mind that header names
2751 are not case-sensitive.
2752
2753 Example :
2754 # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com"
2755 rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com
2756
Willy Tarreauced27012008-01-17 20:35:34 +01002757 See also: "rspadd", "rspdel", "reqrep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002758 manipulation
2759
2760
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002761server <name> <address>[:port] [param*]
2762 Declare a server in a backend
2763 May be used in sections : defaults | frontend | listen | backend
2764 no | no | yes | yes
2765 Arguments :
2766 <name> is the internal name assigned to this server. This name will
2767 appear in logs and alerts.
2768
2769 <address> is the IPv4 address of the server. Alternatively, a resolvable
2770 hostname is supported, but this name will be resolved during
2771 start-up.
2772
2773 <ports> is an optional port specification. If set, all connections will
2774 be sent to this port. If unset, the same port the client
2775 connected to will be used. The port may also be prefixed by a "+"
2776 or a "-". In this case, the server's port will be determined by
2777 adding this value to the client's port.
2778
2779 <param*> is a list of parameters for this server. The "server" keywords
2780 accepts an important number of options and has a complete section
2781 dedicated to it. Please refer to section 2.4 for more details.
2782
2783 Examples :
2784 server first 10.1.1.1:1080 cookie first check inter 1000
2785 server second 10.1.1.2:1080 cookie second check inter 1000
2786
2787 See also : section 2.4 about server options
2788
2789
2790source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
2791 Set the source address for outgoing connections
2792 May be used in sections : defaults | frontend | listen | backend
2793 yes | no | yes | yes
2794 Arguments :
2795 <addr> is the IPv4 address HAProxy will bind to before connecting to a
2796 server. This address is also used as a source for health checks.
2797 The default value of 0.0.0.0 means that the system will select
2798 the most appropriate address to reach its destination.
2799
2800 <port> is an optional port. It is normally not needed but may be useful
2801 in some very specific contexts. The default value of zero means
2802 the system will select a free port.
2803
2804 <addr2> is the IP address to present to the server when connections are
2805 forwarded in full transparent proxy mode. This is currently only
2806 supported on some patched Linux kernels. When this address is
2807 specified, clients connecting to the server will be presented
2808 with this address, while health checks will still use the address
2809 <addr>.
2810
2811 <port2> is the optional port to present to the server when connections
2812 are forwarded in full transparent proxy mode (see <addr2> above).
2813 The default value of zero means the system will select a free
2814 port.
2815
2816 The "source" keyword is useful in complex environments where a specific
2817 address only is allowed to connect to the servers. It may be needed when a
2818 private address must be used through a public gateway for instance, and it is
2819 known that the system cannot determine the adequate source address by itself.
2820
2821 An extension which is available on certain patched Linux kernels may be used
2822 through the "usesrc" optional keyword. It makes it possible to connect to the
2823 servers with an IP address which does not belong to the system itself. This
2824 is called "full transparent proxy mode". For this to work, the destination
2825 servers have to route their traffic back to this address through the machine
2826 running HAProxy, and IP forwarding must generally be enabled on this machine.
2827
2828 In this "full transparent proxy" mode, it is possible to force a specific IP
2829 address to be presented to the servers. This is not much used in fact. A more
2830 common use is to tell HAProxy to present the client's IP address. For this,
2831 there are two methods :
2832
2833 - present the client's IP and port addresses. This is the most transparent
2834 mode, but it can cause problems when IP connection tracking is enabled on
2835 the machine, because a same connection may be seen twice with different
2836 states. However, this solution presents the huge advantage of not
2837 limiting the system to the 64k outgoing address+port couples, because all
2838 of the client ranges may be used.
2839
2840 - present only the client's IP address and select a spare port. This
2841 solution is still quite elegant but slightly less transparent (downstream
2842 firewalls logs will not match upstream's). It also presents the downside
2843 of limiting the number of concurrent connections to the usual 64k ports.
2844 However, since the upstream and downstream ports are different, local IP
2845 connection tracking on the machine will not be upset by the reuse of the
2846 same session.
2847
2848 Note that depending on the transparent proxy technology used, it may be
2849 required to force the source address. In fact, cttproxy version 2 requires an
2850 IP address in <addr> above, and does not support setting of "0.0.0.0" as the
2851 IP address because it creates NAT entries which much match the exact outgoing
2852 address. Tproxy version 4 and some other kernel patches which work in pure
2853 forwarding mode generally will not have this limitation.
2854
2855 This option sets the default source for all servers in the backend. It may
2856 also be specified in a "defaults" section. Finer source address specification
2857 is possible at the server level using the "source" server option. Refer to
2858 section 2.4 for more information.
2859
2860 Examples :
2861 backend private
2862 # Connect to the servers using our 192.168.1.200 source address
2863 source 192.168.1.200
2864
2865 backend transparent_ssl1
2866 # Connect to the SSL farm from the client's source address
2867 source 192.168.1.200 usesrc clientip
2868
2869 backend transparent_ssl2
2870 # Connect to the SSL farm from the client's source address and port
2871 # not recommended if IP conntrack is present on the local machine.
2872 source 192.168.1.200 usesrc client
2873
2874 backend transparent_ssl3
2875 # Connect to the SSL farm from the client's source address. It
2876 # is more conntrack-friendly.
2877 source 192.168.1.200 usesrc clientip
2878
2879 backend transparent_smtp
2880 # Connect to the SMTP farm from the client's source address/port
2881 # with Tproxy version 4.
2882 source 0.0.0.0 usesrc clientip
2883
2884 See also : the "source" server option in section 2.4, the Tproxy patches for
2885 the Linux kernel on www.balabit.com, the "bind" keyword.
2886
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002887
Willy Tarreau844e3c52008-01-11 16:28:18 +01002888srvtimeout <timeout> (deprecated)
2889 Set the maximum inactivity time on the server side.
2890 May be used in sections : defaults | frontend | listen | backend
2891 yes | no | yes | yes
2892 Arguments :
2893 <timeout> is the timeout value specified in milliseconds by default, but
2894 can be in any other unit if the number is suffixed by the unit,
2895 as explained at the top of this document.
2896
2897 The inactivity timeout applies when the server is expected to acknowledge or
2898 send data. In HTTP mode, this timeout is particularly important to consider
2899 during the first phase of the server's response, when it has to send the
2900 headers, as it directly represents the server's processing time for the
2901 request. To find out what value to put there, it's often good to start with
2902 what would be considered as unacceptable response times, then check the logs
2903 to observe the response time distribution, and adjust the value accordingly.
2904
2905 The value is specified in milliseconds by default, but can be in any other
2906 unit if the number is suffixed by the unit, as specified at the top of this
2907 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
2908 recommended that the client timeout remains equal to the server timeout in
2909 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002910 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01002911 packet losses by specifying timeouts that are slightly above multiples of 3
2912 seconds (eg: 4 or 5 seconds minimum).
2913
2914 This parameter is specific to backends, but can be specified once for all in
2915 "defaults" sections. This is in fact one of the easiest solutions not to
2916 forget about it. An unspecified timeout results in an infinite timeout, which
2917 is not recommended. Such a usage is accepted and works but reports a warning
2918 during startup because it may results in accumulation of expired sessions in
2919 the system if the system's timeouts are not configured either.
2920
2921 This parameter is provided for compatibility but is currently deprecated.
2922 Please use "timeout server" instead.
2923
2924 See also : "timeout server", "timeout client" and "clitimeout".
2925
2926
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002927stats auth <user>:<passwd>
2928 Enable statistics with authentication and grant access to an account
2929 May be used in sections : defaults | frontend | listen | backend
2930 yes | no | yes | yes
2931 Arguments :
2932 <user> is a user name to grant access to
2933
2934 <passwd> is the cleartext password associated to this user
2935
2936 This statement enables statistics with default settings, and restricts access
2937 to declared users only. It may be repeated as many times as necessary to
2938 allow as many users as desired. When a user tries to access the statistics
2939 without a valid account, a "401 Forbidden" response will be returned so that
2940 the browser asks the user to provide a valid user and password. The real
2941 which will be returned to the browser is configurable using "stats realm".
2942
2943 Since the authentication method is HTTP Basic Authentication, the passwords
2944 circulate in cleartext on the network. Thus, it was decided that the
2945 configuration file would also use cleartext passwords to remind the users
2946 that those ones should not be sensible and not shared with any other account.
2947
2948 It is also possible to reduce the scope of the proxies which appear in the
2949 report using "stats scope".
2950
2951 Though this statement alone is enough to enable statistics reporting, it is
2952 recommended to set all other settings in order to avoid relying on default
2953 unobvious parameters.
2954
2955 Example :
2956 # public access (limited to this backend only)
2957 backend public_www
2958 server srv1 192.168.0.1:80
2959 stats enable
2960 stats hide-version
2961 stats scope .
2962 stats uri /admin?stats
2963 stats realm Haproxy\ Statistics
2964 stats auth admin1:AdMiN123
2965 stats auth admin2:AdMiN321
2966
2967 # internal monitoring access (unlimited)
2968 backend private_monitoring
2969 stats enable
2970 stats uri /admin?stats
2971 stats refresh 5s
2972
2973 See also : "stats enable", "stats realm", "stats scope", "stats uri"
2974
2975
2976stats enable
2977 Enable statistics reporting with default settings
2978 May be used in sections : defaults | frontend | listen | backend
2979 yes | no | yes | yes
2980 Arguments : none
2981
2982 This statement enables statistics reporting with default settings defined
2983 at build time. Unless stated otherwise, these settings are used :
2984 - stats uri : /haproxy?stats
2985 - stats realm : "HAProxy Statistics"
2986 - stats auth : no authentication
2987 - stats scope : no restriction
2988
2989 Though this statement alone is enough to enable statistics reporting, it is
2990 recommended to set all other settings in order to avoid relying on default
2991 unobvious parameters.
2992
2993 Example :
2994 # public access (limited to this backend only)
2995 backend public_www
2996 server srv1 192.168.0.1:80
2997 stats enable
2998 stats hide-version
2999 stats scope .
3000 stats uri /admin?stats
3001 stats realm Haproxy\ Statistics
3002 stats auth admin1:AdMiN123
3003 stats auth admin2:AdMiN321
3004
3005 # internal monitoring access (unlimited)
3006 backend private_monitoring
3007 stats enable
3008 stats uri /admin?stats
3009 stats refresh 5s
3010
3011 See also : "stats auth", "stats realm", "stats uri"
3012
3013
3014stats realm <realm>
3015 Enable statistics and set authentication realm
3016 May be used in sections : defaults | frontend | listen | backend
3017 yes | no | yes | yes
3018 Arguments :
3019 <realm> is the name of the HTTP Basic Authentication realm reported to
3020 the browser. The browser uses it to display it in the pop-up
3021 inviting the user to enter a valid username and password.
3022
3023 The realm is read as a single word, so any spaces in it should be escaped
3024 using a backslash ('\').
3025
3026 This statement is useful only in conjunction with "stats auth" since it is
3027 only related to authentication.
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 enable", "stats uri"
3052
3053
3054stats refresh <delay>
3055 Enable statistics with automatic refresh
3056 May be used in sections : defaults | frontend | listen | backend
3057 yes | no | yes | yes
3058 Arguments :
3059 <delay> is the suggested refresh delay, specified in seconds, which will
3060 be returned to the browser consulting the report page. While the
3061 browser is free to apply any delay, it will generally respect it
3062 and refresh the page this every seconds. The refresh interval may
3063 be specified in any other non-default time unit, by suffixing the
3064 unit after the value, as explained at the top of this document.
3065
3066 This statement is useful on monitoring displays with a permanent page
3067 reporting the load balancer's activity. When set, the HTML report page will
3068 include a link "refresh"/"stop refresh" so that the user can select whether
3069 he wants automatic refresh of the page or not.
3070
3071 Though this statement alone is enough to enable statistics reporting, it is
3072 recommended to set all other settings in order to avoid relying on default
3073 unobvious parameters.
3074
3075 Example :
3076 # public access (limited to this backend only)
3077 backend public_www
3078 server srv1 192.168.0.1:80
3079 stats enable
3080 stats hide-version
3081 stats scope .
3082 stats uri /admin?stats
3083 stats realm Haproxy\ Statistics
3084 stats auth admin1:AdMiN123
3085 stats auth admin2:AdMiN321
3086
3087 # internal monitoring access (unlimited)
3088 backend private_monitoring
3089 stats enable
3090 stats uri /admin?stats
3091 stats refresh 5s
3092
3093 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3094
3095
3096stats scope { <name> | "." }
3097 Enable statistics and limit access scope
3098 May be used in sections : defaults | frontend | listen | backend
3099 yes | no | yes | yes
3100 Arguments :
3101 <name> is the name of a listen, frontend or backend section to be
3102 reported. The special name "." (a single dot) designates the
3103 section in which the statement appears.
3104
3105 When this statement is specified, only the sections enumerated with this
3106 statement will appear in the report. All other ones will be hidden. This
3107 statement may appear as many times as needed if multiple sections need to be
3108 reported. Please note that the name checking is performed as simple string
3109 comparisons, and that it is never checked that a give section name really
3110 exists.
3111
3112 Though this statement alone is enough to enable statistics reporting, it is
3113 recommended to set all other settings in order to avoid relying on default
3114 unobvious parameters.
3115
3116 Example :
3117 # public access (limited to this backend only)
3118 backend public_www
3119 server srv1 192.168.0.1:80
3120 stats enable
3121 stats hide-version
3122 stats scope .
3123 stats uri /admin?stats
3124 stats realm Haproxy\ Statistics
3125 stats auth admin1:AdMiN123
3126 stats auth admin2:AdMiN321
3127
3128 # internal monitoring access (unlimited)
3129 backend private_monitoring
3130 stats enable
3131 stats uri /admin?stats
3132 stats refresh 5s
3133
3134 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3135
3136
3137stats uri <prefix>
3138 Enable statistics and define the URI prefix to access them
3139 May be used in sections : defaults | frontend | listen | backend
3140 yes | no | yes | yes
3141 Arguments :
3142 <prefix> is the prefix of any URI which will be redirected to stats. This
3143 prefix may contain a question mark ('?') to indicate part of a
3144 query string.
3145
3146 The statistics URI is intercepted on the relayed traffic, so it appears as a
3147 page within the normal application. It is strongly advised to ensure that the
3148 selected URI will never appear in the application, otherwise it will never be
3149 possible to reach it in the application.
3150
3151 The default URI compiled in haproxy is "/haproxy?stats", but this may be
3152 changed at build time, so it's better to always explictly specify it here.
3153 It is generally a good idea to include a question mark in the URI so that
3154 intermediate proxies refrain from caching the results. Also, since any string
3155 beginning with the prefix will be accepted as a stats request, the question
3156 mark helps ensuring that no valid URI will begin with the same words.
3157
3158 It is sometimes very convenient to use "/" as the URI prefix, and put that
3159 statement in a "listen" instance of its own. That makes it easy to dedicate
3160 an address or a port to statistics only.
3161
3162 Though this statement alone is enough to enable statistics reporting, it is
3163 recommended to set all other settings in order to avoid relying on default
3164 unobvious parameters.
3165
3166 Example :
3167 # public access (limited to this backend only)
3168 backend public_www
3169 server srv1 192.168.0.1:80
3170 stats enable
3171 stats hide-version
3172 stats scope .
3173 stats uri /admin?stats
3174 stats realm Haproxy\ Statistics
3175 stats auth admin1:AdMiN123
3176 stats auth admin2:AdMiN321
3177
3178 # internal monitoring access (unlimited)
3179 backend private_monitoring
3180 stats enable
3181 stats uri /admin?stats
3182 stats refresh 5s
3183
3184 See also : "stats auth", "stats enable", "stats realm"
3185
3186
3187stats hide-version
3188 Enable statistics and hide HAProxy version reporting
3189 May be used in sections : defaults | frontend | listen | backend
3190 yes | no | yes | yes
3191 Arguments : none
3192
3193 By default, the stats page reports some useful status information along with
3194 the statistics. Among them is HAProxy's version. However, it is generally
3195 considered dangerous to report precise version to anyone, as it can help them
3196 target known weaknesses with specific attacks. The "stats hide-version"
3197 statement removes the version from the statistics report. This is recommended
3198 for public sites or any site with a weak login/password.
3199
3200 Though this statement alone is enough to enable statistics reporting, it is
3201 recommended to set all other settings in order to avoid relying on default
3202 unobvious parameters.
3203
3204 Example :
3205 # public access (limited to this backend only)
3206 backend public_www
3207 server srv1 192.168.0.1:80
3208 stats enable
3209 stats hide-version
3210 stats scope .
3211 stats uri /admin?stats
3212 stats realm Haproxy\ Statistics
3213 stats auth admin1:AdMiN123
3214 stats auth admin2:AdMiN321
3215
3216 # internal monitoring access (unlimited)
3217 backend private_monitoring
3218 stats enable
3219 stats uri /admin?stats
3220 stats refresh 5s
3221
3222 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3223
3224
Willy Tarreau62644772008-07-16 18:36:06 +02003225tcp-request content accept [{if | unless} <condition>]
3226 Accept a connection if/unless a content inspection condition is matched
3227 May be used in sections : defaults | frontend | listen | backend
3228 no | yes | yes | no
3229
3230 During TCP content inspection, the connection is immediately validated if the
3231 condition is true (when used with "if") or false (when used with "unless").
3232 Most of the time during content inspection, a condition will be in an
3233 uncertain state which is neither true nor false. The evaluation immediately
3234 stops when such a condition is encountered. It is important to understand
3235 that "accept" and "reject" rules are evaluated in their exact declaration
3236 order, so that it is possible to build complex rules from them. There is no
3237 specific limit to the number of rules which may be inserted.
3238
3239 Note that the "if/unless" condition is optionnal. If no condition is set on
3240 the action, it is simply performed unconditionally.
3241
3242 If no "tcp-request content" rules are matched, the default action already is
3243 "accept". Thus, this statement alone does not bring anything without another
3244 "reject" statement.
3245
3246 See section 2.3 about ACL usage.
3247
3248 See also : "tcp-request content-reject", "tcp-request inspect-delay"
3249
3250
3251tcp-request content reject [{if | unless} <condition>]
3252 Reject a connection if/unless a content inspection condition is matched
3253 May be used in sections : defaults | frontend | listen | backend
3254 no | yes | yes | no
3255
3256 During TCP content inspection, the connection is immediately rejected if the
3257 condition is true (when used with "if") or false (when used with "unless").
3258 Most of the time during content inspection, a condition will be in an
3259 uncertain state which is neither true nor false. The evaluation immediately
3260 stops when such a condition is encountered. It is important to understand
3261 that "accept" and "reject" rules are evaluated in their exact declaration
3262 order, so that it is possible to build complex rules from them. There is no
3263 specific limit to the number of rules which may be inserted.
3264
3265 Note that the "if/unless" condition is optionnal. If no condition is set on
3266 the action, it is simply performed unconditionally.
3267
3268 If no "tcp-request content" rules are matched, the default action is set to
3269 "accept".
3270
3271 Example:
3272 # reject SMTP connection if client speaks first
3273 tcp-request inspect-delay 30s
3274 acl content_present req_len gt 0
3275 tcp-request reject if content_present
3276
3277 # Forward HTTPS connection only if client speaks
3278 tcp-request inspect-delay 30s
3279 acl content_present req_len gt 0
3280 tcp-request accept if content_present
3281 tcp-request reject
3282
3283 See section 2.3 about ACL usage.
3284
3285 See also : "tcp-request content-accept", "tcp-request inspect-delay"
3286
3287
3288tcp-request inspect-delay <timeout>
3289 Set the maximum allowed time to wait for data during content inspection
3290 May be used in sections : defaults | frontend | listen | backend
3291 no | yes | yes | no
3292 Arguments :
3293 <timeout> is the timeout value specified in milliseconds by default, but
3294 can be in any other unit if the number is suffixed by the unit,
3295 as explained at the top of this document.
3296
3297 People using haproxy primarily as a TCP relay are often worried about the
3298 risk of passing any type of protocol to a server without any analysis. In
3299 order to be able to analyze the request contents, we must first withhold
3300 the data then analyze them. This statement simply enables withholding of
3301 data for at most the specified amount of time.
3302
3303 Note that when performing content inspection, haproxy will evaluate the whole
3304 rules for every new chunk which gets in, taking into account the fact that
3305 those data are partial. If no rule matches before the aforementionned delay,
3306 a last check is performed upon expiration, this time considering that the
3307 contents are definitive.
3308
3309 As soon as a rule matches, the request is released and continues as usual. If
3310 the timeout is reached and no rule matches, the default policy will be to let
3311 it pass through unaffected.
3312
3313 For most protocols, it is enough to set it to a few seconds, as most clients
3314 send the full request immediately upon connection. Add 3 or more seconds to
3315 cover TCP retransmits but that's all. For some protocols, it may make sense
3316 to use large values, for instance to ensure that the client never talks
3317 before the server (eg: SMTP), or to wait for a client to talk before passing
3318 data to the server (eg: SSL). Note that the client timeout must cover at
3319 least the inspection delay, otherwise it will expire first.
3320
3321 See also : "tcp-request content accept", "tcp-request content-reject",
3322 "timeout client".
3323
3324
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003325timeout check <timeout>
3326 Set additional check timeout, but only after a connection has been already
3327 established.
3328
3329 May be used in sections: defaults | frontend | listen | backend
3330 yes | no | yes | yes
3331 Arguments:
3332 <timeout> is the timeout value specified in milliseconds by default, but
3333 can be in any other unit if the number is suffixed by the unit,
3334 as explained at the top of this document.
3335
3336 If set, haproxy uses min("timeout connect", "inter") as a connect timeout
3337 for check and "timeout check" as an additional read timeout. The "min" is
3338 used so that people running with *very* long "timeout connect" (eg. those
3339 who needed this due to the queue or tarpit) do not slow down their checks.
3340 Of course it is better to use "check queue" and "check tarpit" instead of
3341 long "timeout connect".
3342
3343 If "timeout check" is not set haproxy uses "inter" for complete check
3344 timeout (connect + read) exactly like all <1.3.15 version.
3345
3346 In most cases check request is much simpler and faster to handle than normal
3347 requests and people may want to kick out laggy servers so this timeout should
Willy Tarreau41a340d2008-01-22 12:25:31 +01003348 be smaller than "timeout server".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003349
3350 This parameter is specific to backends, but can be specified once for all in
3351 "defaults" sections. This is in fact one of the easiest solutions not to
3352 forget about it.
3353
Willy Tarreau41a340d2008-01-22 12:25:31 +01003354 See also: "timeout connect", "timeout queue", "timeout server",
3355 "timeout tarpit".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003356
3357
Willy Tarreau0ba27502007-12-24 16:55:16 +01003358timeout client <timeout>
3359timeout clitimeout <timeout> (deprecated)
3360 Set the maximum inactivity time on the client side.
3361 May be used in sections : defaults | frontend | listen | backend
3362 yes | yes | yes | no
3363 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003364 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003365 can be in any other unit if the number is suffixed by the unit,
3366 as explained at the top of this document.
3367
3368 The inactivity timeout applies when the client is expected to acknowledge or
3369 send data. In HTTP mode, this timeout is particularly important to consider
3370 during the first phase, when the client sends the request, and during the
3371 response while it is reading data sent by the server. The value is specified
3372 in milliseconds by default, but can be in any other unit if the number is
3373 suffixed by the unit, as specified at the top of this document. In TCP mode
3374 (and to a lesser extent, in HTTP mode), it is highly recommended that the
3375 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003376 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01003377 losses by specifying timeouts that are slightly above multiples of 3 seconds
3378 (eg: 4 or 5 seconds).
3379
3380 This parameter is specific to frontends, but can be specified once for all in
3381 "defaults" sections. This is in fact one of the easiest solutions not to
3382 forget about it. An unspecified timeout results in an infinite timeout, which
3383 is not recommended. Such a usage is accepted and works but reports a warning
3384 during startup because it may results in accumulation of expired sessions in
3385 the system if the system's timeouts are not configured either.
3386
3387 This parameter replaces the old, deprecated "clitimeout". It is recommended
3388 to use it to write new configurations. The form "timeout clitimeout" is
3389 provided only by backwards compatibility but its use is strongly discouraged.
3390
3391 See also : "clitimeout", "timeout server".
3392
3393
3394timeout connect <timeout>
3395timeout contimeout <timeout> (deprecated)
3396 Set the maximum time to wait for a connection attempt to a server to succeed.
3397 May be used in sections : defaults | frontend | listen | backend
3398 yes | no | yes | yes
3399 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003400 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003401 can be in any other unit if the number is suffixed by the unit,
3402 as explained at the top of this document.
3403
3404 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003405 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +01003406 cover one or several TCP packet losses by specifying timeouts that are
3407 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003408 connect timeout also presets both queue and tarpit timeouts to the same value
3409 if these have not been specified.
Willy Tarreau0ba27502007-12-24 16:55:16 +01003410
3411 This parameter is specific to backends, but can be specified once for all in
3412 "defaults" sections. This is in fact one of the easiest solutions not to
3413 forget about it. An unspecified timeout results in an infinite timeout, which
3414 is not recommended. Such a usage is accepted and works but reports a warning
3415 during startup because it may results in accumulation of failed sessions in
3416 the system if the system's timeouts are not configured either.
3417
3418 This parameter replaces the old, deprecated "contimeout". It is recommended
3419 to use it to write new configurations. The form "timeout contimeout" is
3420 provided only by backwards compatibility but its use is strongly discouraged.
3421
Willy Tarreau41a340d2008-01-22 12:25:31 +01003422 See also: "timeout check", "timeout queue", "timeout server", "contimeout",
3423 "timeout tarpit".
Willy Tarreau0ba27502007-12-24 16:55:16 +01003424
3425
Willy Tarreau036fae02008-01-06 13:24:40 +01003426timeout http-request <timeout>
3427 Set the maximum allowed time to wait for a complete HTTP request
3428 May be used in sections : defaults | frontend | listen | backend
3429 yes | yes | yes | no
3430 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003431 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau036fae02008-01-06 13:24:40 +01003432 can be in any other unit if the number is suffixed by the unit,
3433 as explained at the top of this document.
3434
3435 In order to offer DoS protection, it may be required to lower the maximum
3436 accepted time to receive a complete HTTP request without affecting the client
3437 timeout. This helps protecting against established connections on which
3438 nothing is sent. The client timeout cannot offer a good protection against
3439 this abuse because it is an inactivity timeout, which means that if the
3440 attacker sends one character every now and then, the timeout will not
3441 trigger. With the HTTP request timeout, no matter what speed the client
3442 types, the request will be aborted if it does not complete in time.
3443
3444 Note that this timeout only applies to the header part of the request, and
3445 not to any data. As soon as the empty line is received, this timeout is not
3446 used anymore.
3447
3448 Generally it is enough to set it to a few seconds, as most clients send the
3449 full request immediately upon connection. Add 3 or more seconds to cover TCP
3450 retransmits but that's all. Setting it to very low values (eg: 50 ms) will
3451 generally work on local networks as long as there are no packet losses. This
3452 will prevent people from sending bare HTTP requests using telnet.
3453
3454 If this parameter is not set, the client timeout still applies between each
3455 chunk of the incoming request.
3456
3457 See also : "timeout client".
3458
Willy Tarreau844e3c52008-01-11 16:28:18 +01003459
3460timeout queue <timeout>
3461 Set the maximum time to wait in the queue for a connection slot to be free
3462 May be used in sections : defaults | frontend | listen | backend
3463 yes | no | yes | yes
3464 Arguments :
3465 <timeout> is the timeout value specified in milliseconds by default, but
3466 can be in any other unit if the number is suffixed by the unit,
3467 as explained at the top of this document.
3468
3469 When a server's maxconn is reached, connections are left pending in a queue
3470 which may be server-specific or global to the backend. In order not to wait
3471 indefinitely, a timeout is applied to requests pending in the queue. If the
3472 timeout is reached, it is considered that the request will almost never be
3473 served, so it is dropped and a 503 error is returned to the client.
3474
3475 The "timeout queue" statement allows to fix the maximum time for a request to
3476 be left pending in a queue. If unspecified, the same value as the backend's
3477 connection timeout ("timeout connect") is used, for backwards compatibility
3478 with older versions with no "timeout queue" parameter.
3479
3480 See also : "timeout connect", "contimeout".
3481
3482
3483timeout server <timeout>
3484timeout srvtimeout <timeout> (deprecated)
3485 Set the maximum inactivity time on the server side.
3486 May be used in sections : defaults | frontend | listen | backend
3487 yes | no | yes | yes
3488 Arguments :
3489 <timeout> is the timeout value specified in milliseconds by default, but
3490 can be in any other unit if the number is suffixed by the unit,
3491 as explained at the top of this document.
3492
3493 The inactivity timeout applies when the server is expected to acknowledge or
3494 send data. In HTTP mode, this timeout is particularly important to consider
3495 during the first phase of the server's response, when it has to send the
3496 headers, as it directly represents the server's processing time for the
3497 request. To find out what value to put there, it's often good to start with
3498 what would be considered as unacceptable response times, then check the logs
3499 to observe the response time distribution, and adjust the value accordingly.
3500
3501 The value is specified in milliseconds by default, but can be in any other
3502 unit if the number is suffixed by the unit, as specified at the top of this
3503 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
3504 recommended that the client timeout remains equal to the server timeout in
3505 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003506 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01003507 packet losses by specifying timeouts that are slightly above multiples of 3
3508 seconds (eg: 4 or 5 seconds minimum).
3509
3510 This parameter is specific to backends, but can be specified once for all in
3511 "defaults" sections. This is in fact one of the easiest solutions not to
3512 forget about it. An unspecified timeout results in an infinite timeout, which
3513 is not recommended. Such a usage is accepted and works but reports a warning
3514 during startup because it may results in accumulation of expired sessions in
3515 the system if the system's timeouts are not configured either.
3516
3517 This parameter replaces the old, deprecated "srvtimeout". It is recommended
3518 to use it to write new configurations. The form "timeout srvtimeout" is
3519 provided only by backwards compatibility but its use is strongly discouraged.
3520
3521 See also : "srvtimeout", "timeout client".
3522
3523
3524timeout tarpit <timeout>
3525 Set the duration for which tapitted connections will be maintained
3526 May be used in sections : defaults | frontend | listen | backend
3527 yes | yes | yes | yes
3528 Arguments :
3529 <timeout> is the tarpit duration 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 When a connection is tarpitted using "reqtarpit", it is maintained open with
3534 no activity for a certain amount of time, then closed. "timeout tarpit"
3535 defines how long it will be maintained open.
3536
3537 The value is specified in milliseconds by default, but can be in any other
3538 unit if the number is suffixed by the unit, as specified at the top of this
3539 document. If unspecified, the same value as the backend's connection timeout
3540 ("timeout connect") is used, for backwards compatibility with older versions
3541 with no "timeout tapit" parameter.
3542
3543 See also : "timeout connect", "contimeout".
3544
3545
3546transparent (deprecated)
3547 Enable client-side transparent proxying
3548 May be used in sections : defaults | frontend | listen | backend
3549 yes | yes | yes | no
3550 Arguments : none
3551
3552 This keyword was introduced in order to provide layer 7 persistence to layer
3553 3 load balancers. The idea is to use the OS's ability to redirect an incoming
3554 connection for a remote address to a local process (here HAProxy), and let
3555 this process know what address was initially requested. When this option is
3556 used, sessions without cookies will be forwarded to the original destination
3557 IP address of the incoming request (which should match that of another
3558 equipment), while requests with cookies will still be forwarded to the
3559 appropriate server.
3560
3561 The "transparent" keyword is deprecated, use "option transparent" instead.
3562
3563 Note that contrary to a common belief, this option does NOT make HAProxy
3564 present the client's IP to the server when establishing the connection.
3565
3566 Use of this option is really discouraged, and since no really valid use of it
3567 has been reported for years, it will probably be removed in future versions.
3568
3569 See also: "option transparent"
3570
3571
3572use_backend <backend> if <condition>
3573use_backend <backend> unless <condition>
3574 Switch to a specific backend if/unless a Layer 7 condition is matched.
3575 May be used in sections : defaults | frontend | listen | backend
3576 no | yes | yes | no
3577 Arguments :
3578 <backend> is the name of a valid backend or "listen" section.
3579
3580 <condition> is a condition composed of ACLs, as described in section 2.3.
3581
3582 When doing content-switching, connections arrive on a frontend and are then
3583 dispatched to various backends depending on a number of conditions. The
3584 relation between the conditions and the backends is described with the
3585 "use_backend" keyword. This is supported only in HTTP mode.
3586
3587 There may be as many "use_backend" rules as desired. All of these rules are
3588 evaluated in their declaration order, and the first one which matches will
3589 assign the backend.
3590
3591 In the first form, the backend will be used if the condition is met. In the
3592 second form, the backend will be used if the condition is not met. If no
3593 condition is valid, the backend defined with "default_backend" will be used.
3594 If no default backend is defined, either the servers in the same section are
3595 used (in case of a "listen" section) or, in case of a frontend, no server is
3596 used and a 503 service unavailable response is returned.
3597
3598 See also: "default_backend" and section 2.3 about ACLs.
3599
Willy Tarreau036fae02008-01-06 13:24:40 +01003600
Willy Tarreau0ba27502007-12-24 16:55:16 +010036012.3) Using ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003602---------------
3603
3604The use of Access Control Lists (ACL) provides a flexible solution to perform
Willy Tarreau0ba27502007-12-24 16:55:16 +01003605content switching and generally to take decisions based on content extracted
3606from the request, the response or any environmental status. The principle is
3607simple :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003608
3609 - define test criteria with sets of values
3610 - perform actions only if a set of tests is valid
3611
3612The actions generally consist in blocking the request, or selecting a backend.
3613
3614In order to define a test, the "acl" keyword is used. The syntax is :
3615
3616 acl <aclname> <criterion> [flags] [operator] <value> ...
3617
Willy Tarreau0ba27502007-12-24 16:55:16 +01003618This creates a new ACL <aclname> or completes an existing one with new tests.
3619Those tests apply to the portion of request/response specified in <criterion>
Willy Tarreau6a06a402007-07-15 20:15:28 +02003620and may be adjusted with optional flags [flags]. Some criteria also support
3621an operator which may be specified before the set of values. The values are
3622of the type supported by the criterion, and are separated by spaces.
3623
Willy Tarreau0ba27502007-12-24 16:55:16 +01003624ACL names must be formed from upper and lower case letters, digits, '-' (dash),
3625'_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive,
3626which means that "my_acl" and "My_Acl" are two different ACLs.
3627
3628There is no enforced limit to the number of ACLs. The unused ones do not affect
Willy Tarreau6a06a402007-07-15 20:15:28 +02003629performance, they just consume a small amount of memory.
3630
Willy Tarreau0ba27502007-12-24 16:55:16 +01003631The following ACL flags are currently supported :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003632
3633 -i : ignore case during matching.
3634 -- : force end of flags. Useful when a string looks like one of the flags.
3635
3636Supported types of values are :
Willy Tarreau0ba27502007-12-24 16:55:16 +01003637
Willy Tarreau6a06a402007-07-15 20:15:28 +02003638 - integers or integer ranges
3639 - strings
3640 - regular expressions
3641 - IP addresses and networks
3642
3643
Willy Tarreau0ba27502007-12-24 16:55:16 +010036442.3.1) Matching integers
Willy Tarreau6a06a402007-07-15 20:15:28 +02003645------------------------
3646
3647Matching integers is special in that ranges and operators are permitted. Note
3648that integer matching only applies to positive values. A range is a value
3649expressed with a lower and an upper bound separated with a colon, both of which
3650may be omitted.
3651
3652For instance, "1024:65535" is a valid range to represent a range of
3653unprivileged ports, and "1024:" would also work. "0:1023" is a valid
3654representation of privileged ports, and ":1023" would also work.
3655
Willy Tarreau62644772008-07-16 18:36:06 +02003656As a special case, some ACL functions support decimal numbers which are in fact
3657two integers separated by a dot. This is used with some version checks for
3658instance. All integer properties apply to those decimal numbers, including
3659ranges and operators.
3660
Willy Tarreau6a06a402007-07-15 20:15:28 +02003661For an easier usage, comparison operators are also supported. Note that using
Willy Tarreau0ba27502007-12-24 16:55:16 +01003662operators with ranges does not make much sense and is strongly discouraged.
3663Similarly, it does not make much sense to perform order comparisons with a set
3664of values.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003665
Willy Tarreau0ba27502007-12-24 16:55:16 +01003666Available operators for integer matching are :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003667
3668 eq : true if the tested value equals at least one value
3669 ge : true if the tested value is greater than or equal to at least one value
3670 gt : true if the tested value is greater than at least one value
3671 le : true if the tested value is less than or equal to at least one value
3672 lt : true if the tested value is less than at least one value
3673
Willy Tarreau0ba27502007-12-24 16:55:16 +01003674For instance, the following ACL matches any negative Content-Length header :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003675
3676 acl negative-length hdr_val(content-length) lt 0
3677
Willy Tarreau62644772008-07-16 18:36:06 +02003678This one matches SSL versions between 3.0 and 3.1 (inclusive) :
3679
3680 acl sslv3 req_ssl_ver 3:3.1
3681
Willy Tarreau6a06a402007-07-15 20:15:28 +02003682
Willy Tarreau0ba27502007-12-24 16:55:16 +010036832.3.2) Matching strings
Willy Tarreau6a06a402007-07-15 20:15:28 +02003684-----------------------
3685
3686String matching applies to verbatim strings as they are passed, with the
3687exception of the backslash ("\") which makes it possible to escape some
3688characters such as the space. If the "-i" flag is passed before the first
3689string, then the matching will be performed ignoring the case. In order
3690to match the string "-i", either set it second, or pass the "--" flag
Willy Tarreau0ba27502007-12-24 16:55:16 +01003691before the first string. Same applies of course to match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003692
3693
Willy Tarreau0ba27502007-12-24 16:55:16 +010036942.3.3) Matching regular expressions (regexes)
Willy Tarreau6a06a402007-07-15 20:15:28 +02003695---------------------------------------------
3696
3697Just like with string matching, regex matching applies to verbatim strings as
3698they are passed, with the exception of the backslash ("\") which makes it
3699possible to escape some characters such as the space. If the "-i" flag is
3700passed before the first regex, then the matching will be performed ignoring
3701the case. In order to match the string "-i", either set it second, or pass
Willy Tarreau0ba27502007-12-24 16:55:16 +01003702the "--" flag before the first string. Same principle applies of course to
3703match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003704
3705
Willy Tarreau0ba27502007-12-24 16:55:16 +010037062.3.4) Matching IPv4 addresses
3707------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02003708
3709IPv4 addresses values can be specified either as plain addresses or with a
3710netmask appended, in which case the IPv4 address matches whenever it is
3711within the network. Plain addresses may also be replaced with a resolvable
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003712host name, but this practice is generally discouraged as it makes it more
Willy Tarreau0ba27502007-12-24 16:55:16 +01003713difficult to read and debug configurations. If hostnames are used, you should
3714at least ensure that they are present in /etc/hosts so that the configuration
3715does not depend on any random DNS match at the moment the configuration is
3716parsed.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003717
3718
Willy Tarreau0ba27502007-12-24 16:55:16 +010037192.3.5) Available matching criteria
Willy Tarreau6a06a402007-07-15 20:15:28 +02003720----------------------------------
3721
Willy Tarreau0ba27502007-12-24 16:55:16 +010037222.3.5.1) Matching at Layer 4 and below
3723--------------------------------------
3724
3725A first set of criteria applies to information which does not require any
3726analysis of the request or response contents. Those generally include TCP/IP
3727addresses and ports, as well as internal values independant on the stream.
3728
Willy Tarreau6a06a402007-07-15 20:15:28 +02003729always_false
3730 This one never matches. All values and flags are ignored. It may be used as
3731 a temporary replacement for another one when adjusting configurations.
3732
3733always_true
3734 This one always matches. All values and flags are ignored. It may be used as
3735 a temporary replacement for another one when adjusting configurations.
3736
3737src <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003738 Applies to the client's IPv4 address. It is usually used to limit access to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003739 certain resources such as statistics. Note that it is the TCP-level source
3740 address which is used, and not the address of a client behind a proxy.
3741
3742src_port <integer>
3743 Applies to the client's TCP source port. This has a very limited usage.
3744
3745dst <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003746 Applies to the local IPv4 address the client connected to. It can be used to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003747 switch to a different backend for some alternative addresses.
3748
3749dst_port <integer>
3750 Applies to the local port the client connected to. It can be used to switch
3751 to a different backend for some alternative ports.
3752
3753dst_conn <integer>
3754 Applies to the number of currently established connections on the frontend,
3755 including the one being evaluated. It can be used to either return a sorry
Willy Tarreau0ba27502007-12-24 16:55:16 +01003756 page before hard-blocking, or to use a specific backend to drain new requests
Willy Tarreau6a06a402007-07-15 20:15:28 +02003757 when the farm is considered saturated.
3758
Willy Tarreau0ba27502007-12-24 16:55:16 +01003759nbsrv <integer>
3760nbsrv(backend) <integer>
3761 Returns true when the number of usable servers of either the current backend
3762 or the named backend matches the values or ranges specified. This is used to
3763 switch to an alternate backend when the number of servers is too low to
3764 to handle some load. It is useful to report a failure when combined with
3765 "monitor fail".
3766
Jeffrey 'jf' Lim5051d7b2008-09-04 01:03:03 +08003767connslots <integer>
3768connslots(backend) <integer>
3769 The basic idea here is to be able to measure the number of connection "slots"
3770 still available (connection, + queue) - so that anything beyond that (intended
3771 usage; see "use_backend" keyword) can be redirected to a different backend.
3772
3773 'connslots' = number of available server connection slots, + number of available
3774 server queue slots.
3775
3776 *Note that while "dst_conn" may be used, "connslots" comes in especially useful
3777 when you have a case of traffic going to one single ip, splitting into multiple
3778 backends (perhaps using acls to do name-based load balancing) - and you want to
3779 be able to differentiate between different backends, and their "connslots"
3780 available. Also, whereas "nbsrv" only measures servers that are actually *down*,
3781 this acl is more fine-grained - and looks into the number of conn slots available
3782 as well.
3783
3784 *OTHER CAVEATS AND NOTES: at this point in time, the code does not take care of
3785 dynamic connections. Also, if any of the server maxconn, or maxqueue is 0, then
3786 this acl clearly does not make sense - in which case the value returned will be -1.
3787
Willy Tarreau0ba27502007-12-24 16:55:16 +01003788
Willy Tarreau62644772008-07-16 18:36:06 +020037892.3.5.2) Matching contents at Layer 4
3790-------------------------------------
3791
3792A second set of criteria depends on data found in buffers, but which can change
3793during analysis. This requires that some data has been buffered, for instance
3794through TCP request content inspection. Please see the "tcp-request" keyword
3795for more detailed information on the subject.
3796
3797req_len <integer>
3798 Returns true when the lenght of the data in the request buffer matches the
3799 specified range. It is important to understand that this test does not
3800 return false as long as the buffer is changing. This means that a check with
3801 equality to zero will almost always immediately match at the beginning of the
3802 session, while a test for more data will wait for that data to come in and
3803 return false only when haproxy is certain that no more data will come in.
3804 This test was designed to be used with TCP request content inspection.
3805
3806req_ssl_ver <decimal>
3807 Returns true when data in the request buffer look like SSL, with a protocol
3808 version matching the specified range. Both SSLv2 hello messages and SSLv3
3809 messages are supported. The test tries to be strict enough to avoid being
3810 easily fooled. In particular, it waits for as many bytes as announced in the
3811 message header if this header looks valid (bound to the buffer size). Note
3812 that TLSv1 is announced as SSL version 3.1. This test was designed to be used
3813 with TCP request content inspection.
3814
Willy Tarreaub6fb4202008-07-20 11:18:28 +02003815wait_end
3816 Waits for the end of the analysis period to return true. This may be used in
3817 conjunction with content analysis to avoid returning a wrong verdict early.
3818 It may also be used to delay some actions, such as a delayed reject for some
3819 special addresses. Since it either stops the rules evaluation or immediately
3820 returns true, it is recommended to use this acl as the last one in a rule.
3821 Please note that the default ACL "WAIT_END" is always usable without prior
3822 declaration. This test was designed to be used with TCP request content
3823 inspection.
3824
3825 Examples :
3826 # delay every incoming request by 2 seconds
3827 tcp-request inspect-delay 2s
3828 tcp-request content accept if WAIT_END
3829
3830 # don't immediately tell bad guys they are rejected
3831 tcp-request inspect-delay 10s
3832 acl goodguys src 10.0.0.0/24
3833 acl badguys src 10.0.1.0/24
3834 tcp-request content accept if goodguys
3835 tcp-request content reject if badguys WAIT_END
3836 tcp-request content reject
3837
Willy Tarreau62644772008-07-16 18:36:06 +02003838
38392.3.5.3) Matching at Layer 7
Willy Tarreau0ba27502007-12-24 16:55:16 +01003840----------------------------
3841
Willy Tarreau62644772008-07-16 18:36:06 +02003842A third set of criteria applies to information which can be found at the
Willy Tarreau0ba27502007-12-24 16:55:16 +01003843application layer (layer 7). Those require that a full HTTP request has been
3844read, and are only evaluated then. They may require slightly more CPU resources
3845than the layer 4 ones, but not much since the request and response are indexed.
3846
Willy Tarreau6a06a402007-07-15 20:15:28 +02003847method <string>
3848 Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
3849 already check for most common methods.
3850
3851req_ver <string>
3852 Applies to the version string in the HTTP request, eg: "1.0". Some predefined
3853 ACL already check for versions 1.0 and 1.1.
3854
3855path <string>
3856 Returns true when the path part of the request, which starts at the first
3857 slash and ends before the question mark, equals one of the strings. It may be
3858 used to match known files, such as /favicon.ico.
3859
3860path_beg <string>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003861 Returns true when the path begins with one of the strings. This can be used
3862 to send certain directory names to alternative backends.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003863
3864path_end <string>
3865 Returns true when the path ends with one of the strings. This may be used to
3866 control file name extension.
3867
3868path_sub <string>
3869 Returns true when the path contains one of the strings. It can be used to
3870 detect particular patterns in paths, such as "../" for example. See also
3871 "path_dir".
3872
3873path_dir <string>
3874 Returns true when one of the strings is found isolated or delimited with
3875 slashes in the path. This is used to perform filename or directory name
3876 matching without the risk of wrong match due to colliding prefixes. See also
3877 "url_dir" and "path_sub".
3878
3879path_dom <string>
3880 Returns true when one of the strings is found isolated or delimited with dots
3881 in the path. This may be used to perform domain name matching in proxy
3882 requests. See also "path_sub" and "url_dom".
3883
3884path_reg <regex>
3885 Returns true when the path matches one of the regular expressions. It can be
3886 used any time, but it is important to remember that regex matching is slower
3887 than other methods. See also "url_reg" and all "path_" criteria.
3888
3889url <string>
3890 Applies to the whole URL passed in the request. The only real use is to match
3891 "*", for which there already is a predefined ACL.
3892
3893url_beg <string>
3894 Returns true when the URL begins with one of the strings. This can be used to
3895 check whether a URL begins with a slash or with a protocol scheme.
3896
3897url_end <string>
3898 Returns true when the URL ends with one of the strings. It has very limited
3899 use. "path_end" should be used instead for filename matching.
3900
3901url_sub <string>
3902 Returns true when the URL contains one of the strings. It can be used to
3903 detect particular patterns in query strings for example. See also "path_sub".
3904
3905url_dir <string>
3906 Returns true when one of the strings is found isolated or delimited with
3907 slashes in the URL. This is used to perform filename or directory name
3908 matching without the risk of wrong match due to colliding prefixes. See also
3909 "path_dir" and "url_sub".
3910
3911url_dom <string>
3912 Returns true when one of the strings is found isolated or delimited with dots
3913 in the URL. This is used to perform domain name matching without the risk of
3914 wrong match due to colliding prefixes. See also "url_sub".
3915
3916url_reg <regex>
3917 Returns true when the URL matches one of the regular expressions. It can be
3918 used any time, but it is important to remember that regex matching is slower
3919 than other methods. See also "path_reg" and all "url_" criteria.
3920
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003921url_ip <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003922 Applies to the IP address specified in the absolute URI in an HTTP request.
3923 It can be used to prevent access to certain resources such as local network.
Willy Tarreau198a7442008-01-17 12:05:32 +01003924 It is useful with option "http_proxy".
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003925
3926url_port <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003927 Applies to the port specified in the absolute URI in an HTTP request. It can
3928 be used to prevent access to certain resources. It is useful with option
Willy Tarreau198a7442008-01-17 12:05:32 +01003929 "http_proxy". Note that if the port is not specified in the request, port 80
Willy Tarreau0ba27502007-12-24 16:55:16 +01003930 is assumed.
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003931
Willy Tarreau6a06a402007-07-15 20:15:28 +02003932hdr <string>
3933hdr(header) <string>
3934 Note: all the "hdr*" matching criteria either apply to all headers, or to a
3935 particular header whose name is passed between parenthesis and without any
Willy Tarreau0ba27502007-12-24 16:55:16 +01003936 space. The header name is not case-sensitive. The header matching complies
3937 with RFC2616, and treats as separate headers all values delimited by commas.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003938
3939 The "hdr" criteria returns true if any of the headers matching the criteria
Willy Tarreau0ba27502007-12-24 16:55:16 +01003940 match any of the strings. This can be used to check exact for values. For
Willy Tarreau6a06a402007-07-15 20:15:28 +02003941 instance, checking that "connection: close" is set :
3942
3943 hdr(Connection) -i close
3944
3945hdr_beg <string>
3946hdr_beg(header) <string>
3947 Returns true when one of the headers begins with one of the strings. See
3948 "hdr" for more information on header matching.
3949
3950hdr_end <string>
3951hdr_end(header) <string>
3952 Returns true when one of the headers ends with one of the strings. See "hdr"
3953 for more information on header matching.
3954
3955hdr_sub <string>
3956hdr_sub(header) <string>
3957 Returns true when one of the headers contains one of the strings. See "hdr"
3958 for more information on header matching.
3959
3960hdr_dir <string>
3961hdr_dir(header) <string>
3962 Returns true when one of the headers contains one of the strings either
3963 isolated or delimited by slashes. This is used to perform filename or
3964 directory name matching, and may be used with Referer. See "hdr" for more
3965 information on header matching.
3966
3967hdr_dom <string>
3968hdr_dom(header) <string>
3969 Returns true when one of the headers contains one of the strings either
3970 isolated or delimited by dots. This is used to perform domain name matching,
3971 and may be used with the Host header. See "hdr" for more information on
3972 header matching.
3973
3974hdr_reg <regex>
3975hdr_reg(header) <regex>
3976 Returns true when one of the headers matches of the regular expressions. It
3977 can be used at any time, but it is important to remember that regex matching
3978 is slower than other methods. See also other "hdr_" criteria, as well as
3979 "hdr" for more information on header matching.
3980
3981hdr_val <integer>
3982hdr_val(header) <integer>
3983 Returns true when one of the headers starts with a number which matches the
3984 values or ranges specified. This may be used to limit content-length to
3985 acceptable values for example. See "hdr" for more information on header
3986 matching.
3987
3988hdr_cnt <integer>
3989hdr_cnt(header) <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003990 Returns true when the number of occurrence of the specified header matches
3991 the values or ranges specified. It is important to remember that one header
3992 line may count as several headers if it has several values. This is used to
3993 detect presence, absence or abuse of a specific header, as well as to block
3994 request smugling attacks by rejecting requests which contain more than one
3995 of certain headers. See "hdr" for more information on header matching.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003996
3997
Willy Tarreau0ba27502007-12-24 16:55:16 +010039982.3.6) Pre-defined ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003999-----------------------
4000
4001Some predefined ACLs are hard-coded so that they do not have to be declared in
4002every frontend which needs them. They all have their names in upper case in
Willy Tarreau0ba27502007-12-24 16:55:16 +01004003order to avoid confusion. Their equivalence is provided below. Please note that
4004only the first three ones are not layer 7 based.
Willy Tarreau6a06a402007-07-15 20:15:28 +02004005
4006ACL name Equivalent to Usage
4007---------------+-----------------------------+---------------------------------
Willy Tarreau58393e12008-07-20 10:39:22 +02004008TRUE always_true always match
4009FALSE always_false never match
Willy Tarreau6a06a402007-07-15 20:15:28 +02004010LOCALHOST src 127.0.0.1/8 match connection from local host
4011HTTP_1.0 req_ver 1.0 match HTTP version 1.0
4012HTTP_1.1 req_ver 1.1 match HTTP version 1.1
4013METH_CONNECT method CONNECT match HTTP CONNECT method
4014METH_GET method GET HEAD match HTTP GET or HEAD method
4015METH_HEAD method HEAD match HTTP HEAD method
4016METH_OPTIONS method OPTIONS match HTTP OPTIONS method
4017METH_POST method POST match HTTP POST method
4018METH_TRACE method TRACE match HTTP TRACE method
4019HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
4020HTTP_URL_SLASH url_beg / match URL begining with "/"
4021HTTP_URL_STAR url * match URL equal to "*"
4022HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
Willy Tarreauc6317702008-07-20 09:29:50 +02004023REQ_CONTENT req_len gt 0 match data in the request buffer
Willy Tarreaub6fb4202008-07-20 11:18:28 +02004024WAIT_END wait_end wait for end of content analysis
Willy Tarreau6a06a402007-07-15 20:15:28 +02004025---------------+-----------------------------+---------------------------------
4026
4027
Willy Tarreau0ba27502007-12-24 16:55:16 +010040282.3.7) Using ACLs to form conditions
Willy Tarreau6a06a402007-07-15 20:15:28 +02004029------------------------------------
4030
4031Some actions are only performed upon a valid condition. A condition is a
4032combination of ACLs with operators. 3 operators are supported :
4033
4034 - AND (implicit)
4035 - OR (explicit with the "or" keyword or the "||" operator)
4036 - Negation with the exclamation mark ("!")
4037
4038A condition is formed as a disjonctive form :
4039
4040 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
4041
4042Such conditions are generally used after an "if" or "unless" statement,
4043indicating when the condition will trigger the action.
4044
4045For instance, to block HTTP requests to the "*" URL with methods other than
Willy Tarreau0ba27502007-12-24 16:55:16 +01004046"OPTIONS", as well as POST requests without content-length, and GET or HEAD
4047requests with a content-length greater than 0, and finally every request which
4048is not either GET/HEAD/POST/OPTIONS !
Willy Tarreau6a06a402007-07-15 20:15:28 +02004049
4050 acl missing_cl hdr_cnt(Content-length) eq 0
4051 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
4052 block if METH_GET HTTP_CONTENT
4053 block unless METH_GET or METH_POST or METH_OPTIONS
4054
4055To select a different backend for requests to static contents on the "www" site
4056and to every request on the "img", "video", "download" and "ftp" hosts :
4057
4058 acl url_static path_beg /static /images /img /css
4059 acl url_static path_end .gif .png .jpg .css .js
4060 acl host_www hdr_beg(host) -i www
4061 acl host_static hdr_beg(host) -i img. video. download. ftp.
4062
4063 # now use backend "static" for all static-only hosts, and for static urls
4064 # of host "www". Use backend "www" for the rest.
4065 use_backend static if host_static or host_www url_static
4066 use_backend www if host_www
4067
Willy Tarreau844e3c52008-01-11 16:28:18 +01004068See section 2.2 for detailed help on the "block" and "use_backend" keywords.
Willy Tarreaudbc36f62007-11-30 12:29:11 +01004069
4070
Willy Tarreauc7246fc2007-12-02 17:31:20 +010040712.4) Server options
Willy Tarreau5764b382007-11-30 17:46:49 +01004072-------------------
4073
Willy Tarreau198a7442008-01-17 12:05:32 +01004074The "server" keyword supports a certain number of settings which are all passed
4075as arguments on the server line. The order in which those arguments appear does
4076not count, and they are all optional. Some of those settings are single words
4077(booleans) while others expect one or several values after them. In this case,
4078the values must immediately follow the setting name. All those settings must be
4079specified after the server's address if they are used :
4080
4081 server <name> <address>[:port] [settings ...]
4082
4083The currently supported settings are the following ones.
4084
4085addr <ipv4>
4086 Using the "addr" parameter, it becomes possible to use a different IP address
4087 to send health-checks. On some servers, it may be desirable to dedicate an IP
4088 address to specific component able to perform complex tests which are more
4089 suitable to health-checks than the application. This parameter is ignored if
4090 the "check" parameter is not set. See also the "port" parameter.
4091
4092backup
4093 When "backup" is present on a server line, the server is only used in load
4094 balancing when all other non-backup servers are unavailable. Requests coming
4095 with a persistence cookie referencing the server will always be served
4096 though. By default, only the first operational backup server is used, unless
Willy Tarreauaf85d942008-01-30 10:47:10 +01004097 the "allbackups" option is set in the backend. See also the "allbackups"
Willy Tarreau198a7442008-01-17 12:05:32 +01004098 option.
4099
4100check
4101 This option enables health checks on the server. By default, a server is
4102 always considered available. If "check" is set, the server will receive
4103 periodic health checks to ensure that it is really able to serve requests.
4104 The default address and port to send the tests to are those of the server,
4105 and the default source is the same as the one defined in the backend. It is
4106 possible to change the address using the "addr" parameter, the port using the
4107 "port" parameter, the source address using the "source" address, and the
4108 interval and timers using the "inter", "rise" and "fall" parameters. The
4109 request method is define in the backend using the "httpchk", "smtpchk",
4110 and "ssl-hello-chk" options. Please refer to those options and parameters for
4111 more information.
4112
4113cookie <value>
4114 The "cookie" parameter sets the cookie value assigned to the server to
4115 <value>. This value will be checked in incoming requests, and the first
4116 operational server possessing the same value will be selected. In return, in
4117 cookie insertion or rewrite modes, this value will be assigned to the cookie
4118 sent to the client. There is nothing wrong in having several servers sharing
4119 the same cookie value, and it is in fact somewhat common between normal and
4120 backup servers. See also the "cookie" keyword in backend section.
4121
4122fall <count>
4123 The "fall" parameter states that a server will be considered as dead after
4124 <count> consecutive unsuccessful health checks. This value defaults to 3 if
4125 unspecified. See also the "check", "inter" and "rise" parameters.
4126
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004127id <value>
4128 Set a persistent value for server ID. Must be unique and larger than 1000, as
4129 smaller values are reserved for auto-assigned ids.
4130
Willy Tarreau198a7442008-01-17 12:05:32 +01004131inter <delay>
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01004132fastinter <delay>
4133downinter <delay>
Willy Tarreau198a7442008-01-17 12:05:32 +01004134 The "inter" parameter sets the interval between two consecutive health checks
4135 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01004136 It is also possible to use "fastinter" and "downinter" to optimize delays
Willy Tarreau41a340d2008-01-22 12:25:31 +01004137 between checks depending on the server state :
4138
4139 Server state | Interval used
4140 ---------------------------------+-----------------------------------------
4141 UP 100% (non-transitional) | "inter"
4142 ---------------------------------+-----------------------------------------
4143 Transitionally UP (going down), |
4144 Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise.
4145 or yet unchecked. |
4146 ---------------------------------+-----------------------------------------
4147 DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise.
4148 ---------------------------------+-----------------------------------------
4149
4150 Just as with every other time-based parameter, they can be entered in any
4151 other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also
4152 serves as a timeout for health checks sent to servers if "timeout check" is
4153 not set. In order to reduce "resonance" effects when multiple servers are
4154 hosted on the same hardware, the health-checks of all servers are started
4155 with a small time offset between them. It is also possible to add some random
4156 noise in the health checks interval using the global "spread-checks"
4157 keyword. This makes sense for instance when a lot of backends use the same
4158 servers.
Willy Tarreau198a7442008-01-17 12:05:32 +01004159
4160maxconn <maxconn>
4161 The "maxconn" parameter specifies the maximal number of concurrent
4162 connections that will be sent to this server. If the number of incoming
4163 concurrent requests goes higher than this value, they will be queued, waiting
4164 for a connection to be released. This parameter is very important as it can
4165 save fragile servers from going down under extreme loads. If a "minconn"
4166 parameter is specified, the limit becomes dynamic. The default value is "0"
4167 which means unlimited. See also the "minconn" and "maxqueue" parameters, and
4168 the backend's "fullconn" keyword.
4169
4170maxqueue <maxqueue>
4171 The "maxqueue" parameter specifies the maximal number of connections which
4172 will wait in the queue for this server. If this limit is reached, next
4173 requests will be redispatched to other servers instead of indefinitely
4174 waiting to be served. This will break persistence but may allow people to
4175 quickly re-log in when the server they try to connect to is dying. The
4176 default value is "0" which means the queue is unlimited. See also the
4177 "maxconn" and "minconn" parameters.
4178
4179minconn <minconn>
4180 When the "minconn" parameter is set, the maxconn limit becomes a dynamic
4181 limit following the backend's load. The server will always accept at least
4182 <minconn> connections, never more than <maxconn>, and the limit will be on
4183 the ramp between both values when the backend has less than <fullconn>
4184 concurrent connections. This makes it possible to limit the load on the
4185 server during normal loads, but push it further for important loads without
4186 overloading the server during exceptionnal loads. See also the "maxconn"
4187 and "maxqueue" parameters, as well as the "fullconn" backend keyword.
4188
4189port <port>
4190 Using the "port" parameter, it becomes possible to use a different port to
4191 send health-checks. On some servers, it may be desirable to dedicate a port
4192 to a specific component able to perform complex tests which are more suitable
4193 to health-checks than the application. It is common to run a simple script in
4194 inetd for instance. This parameter is ignored if the "check" parameter is not
4195 set. See also the "addr" parameter.
4196
Willy Tarreau21d2af32008-02-14 20:25:24 +01004197redir <prefix>
4198 The "redir" parameter enables the redirection mode for all GET and HEAD
4199 requests addressing this server. This means that instead of having HAProxy
4200 forward the request to the server, it will send an "HTTP 302" response with
4201 the "Location" header composed of this prefix immediately followed by the
4202 requested URI beginning at the leading '/' of the path component. That means
4203 that no trailing slash should be used after <prefix>. All invalid requests
4204 will be rejected, and all non-GET or HEAD requests will be normally served by
4205 the server. Note that since the response is completely forged, no header
4206 mangling nor cookie insertion is possible in the respose. However, cookies in
4207 requests are still analysed, making this solution completely usable to direct
4208 users to a remote location in case of local disaster. Main use consists in
4209 increasing bandwidth for static servers by having the clients directly
4210 connect to them. Note: never use a relative location here, it would cause a
4211 loop between the client and HAProxy!
4212
4213 Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check
4214
Willy Tarreau198a7442008-01-17 12:05:32 +01004215rise <count>
4216 The "rise" parameter states that a server will be considered as operational
4217 after <count> consecutive successful health checks. This value defaults to 2
4218 if unspecified. See also the "check", "inter" and "fall" parameters.
4219
Willy Tarreau5764b382007-11-30 17:46:49 +01004220slowstart <start_time_in_ms>
Willy Tarreau198a7442008-01-17 12:05:32 +01004221 The "slowstart" parameter for a server accepts a value in milliseconds which
Willy Tarreau5764b382007-11-30 17:46:49 +01004222 indicates after how long a server which has just come back up will run at
Willy Tarreaubefdff12007-12-02 22:27:38 +01004223 full speed. Just as with every other time-based parameter, it can be entered
4224 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
4225 linearly from 0 to 100% during this time. The limitation applies to two
4226 parameters :
Willy Tarreau5764b382007-11-30 17:46:49 +01004227
4228 - maxconn: the number of connections accepted by the server will grow from 1
4229 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
4230
4231 - weight: when the backend uses a dynamic weighted algorithm, the weight
4232 grows linearly from 1 to 100%. In this case, the weight is updated at every
Willy Tarreau198a7442008-01-17 12:05:32 +01004233 health-check. For this reason, it is important that the "inter" parameter
4234 is smaller than the "slowstart", in order to maximize the number of steps.
Willy Tarreau5764b382007-11-30 17:46:49 +01004235
4236 The slowstart never applies when haproxy starts, otherwise it would cause
4237 trouble to running servers. It only applies when a server has been previously
4238 seen as failed.
4239
Willy Tarreau198a7442008-01-17 12:05:32 +01004240source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
4241 The "source" parameter sets the source address which will be used when
4242 connecting to the server. It follows the exact same parameters and principle
4243 as the backend "source" keyword, except that it only applies to the server
4244 referencing it. Please consult the "source" keyword for details.
4245
Krzysztof Piotr Oledzkic8b16fc2008-02-18 01:26:35 +01004246track [<proxy>/]<server>
4247 This option enables ability to set the current state of the server by
4248 tracking another one. Only a server with checks enabled can be tracked
4249 so it is not possible for example to track a server that tracks another
4250 one. If <proxy> is omitted the current one is used. If disable-on-404 is
4251 used, it has to be enabled on both proxies.
4252
Willy Tarreau198a7442008-01-17 12:05:32 +01004253weight <weight>
4254 The "weight" parameter is used to adjust the server's weight relative to
4255 other servers. All servers will receive a load proportional to their weight
4256 relative to the sum of all weights, so the higher the weight, the higher the
4257 load. The default weight is 1, and the maximal value is 255. If this
4258 parameter is used to distribute the load according to server's capacity, it
4259 is recommended to start with values which can both grow and shrink, for
4260 instance between 10 and 100 to leave enough room above and below for later
4261 adjustments.
4262
Willy Tarreauced27012008-01-17 20:35:34 +01004263
42642.5) HTTP header manipulation
4265-----------------------------
4266
4267In HTTP mode, it is possible to rewrite, add or delete some of the request and
4268response headers based on regular expressions. It is also possible to block a
4269request or a response if a particular header matches a regular expression,
4270which is enough to stop most elementary protocol attacks, and to protect
4271against information leak from the internal network. But there is a limitation
4272to this : since HAProxy's HTTP engine does not support keep-alive, only headers
4273passed during the first request of a TCP session will be seen. All subsequent
4274headers will be considered data only and not analyzed. Furthermore, HAProxy
4275never touches data contents, it stops analysis at the end of headers.
4276
4277This section covers common usage of the following keywords, described in detail
4278in section 2.2.1 :
4279
4280 - reqadd <string>
4281 - reqallow <search>
4282 - reqiallow <search>
4283 - reqdel <search>
4284 - reqidel <search>
4285 - reqdeny <search>
4286 - reqideny <search>
4287 - reqpass <search>
4288 - reqipass <search>
4289 - reqrep <search> <replace>
4290 - reqirep <search> <replace>
4291 - reqtarpit <search>
4292 - reqitarpit <search>
4293 - rspadd <string>
4294 - rspdel <search>
4295 - rspidel <search>
4296 - rspdeny <search>
4297 - rspideny <search>
4298 - rsprep <search> <replace>
4299 - rspirep <search> <replace>
4300
4301With all these keywords, the same conventions are used. The <search> parameter
4302is a POSIX extended regular expression (regex) which supports grouping through
4303parenthesis (without the backslash). Spaces and other delimiters must be
4304prefixed with a backslash ('\') to avoid confusion with a field delimiter.
4305Other characters may be prefixed with a backslash to change their meaning :
4306
4307 \t for a tab
4308 \r for a carriage return (CR)
4309 \n for a new line (LF)
4310 \ to mark a space and differentiate it from a delimiter
4311 \# to mark a sharp and differentiate it from a comment
4312 \\ to use a backslash in a regex
4313 \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy)
4314 \xXX to write the ASCII hex code XX as in the C language
4315
4316The <replace> parameter contains the string to be used to replace the largest
4317portion of text matching the regex. It can make use of the special characters
4318above, and can reference a substring which is delimited by parenthesis in the
4319regex, by writing a backslash ('\') immediately followed by one digit from 0 to
Willy Tarreaud2a4aa22008-01-31 15:28:22 +010043209 indicating the group position (0 designating the entire line). This practice
Willy Tarreauced27012008-01-17 20:35:34 +01004321is very common to users of the "sed" program.
4322
4323The <string> parameter represents the string which will systematically be added
4324after the last header line. It can also use special character sequences above.
4325
4326Notes related to these keywords :
4327---------------------------------
4328 - these keywords are not always convenient to allow/deny based on header
4329 contents. It is strongly recommended to use ACLs with the "block" keyword
4330 instead, resulting in far more flexible and manageable rules.
4331
4332 - lines are always considered as a whole. It is not possible to reference
4333 a header name only or a value only. This is important because of the way
4334 headers are written (notably the number of spaces after the colon).
4335
4336 - the first line is always considered as a header, which makes it possible to
4337 rewrite or filter HTTP requests URIs or response codes, but in turn makes
4338 it harder to distinguish between headers and request line. The regex prefix
4339 ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix
4340 ^[^ \t:]*: matches any header name followed by a colon.
4341
4342 - for performances reasons, the number of characters added to a request or to
4343 a response is limited at build time to values between 1 and 4 kB. This
4344 should normally be far more than enough for most usages. If it is too short
4345 on occasional usages, it is possible to gain some space by removing some
4346 useless headers before adding new ones.
4347
4348 - keywords beginning with "reqi" and "rspi" are the same as their couterpart
4349 without the 'i' letter except that they ignore case when matching patterns.
4350
4351 - when a request passes through a frontend then a backend, all req* rules
4352 from the frontend will be evaluated, then all req* rules from the backend
4353 will be evaluated. The reverse path is applied to responses.
4354
4355 - req* statements are applied after "block" statements, so that "block" is
4356 always the first one, but before "use_backend" in order to permit rewriting
4357 before switching.
4358
Willy Tarreau5764b382007-11-30 17:46:49 +01004359
Willy Tarreauced27012008-01-17 20:35:34 +010043602.6) Logging
Willy Tarreau844e3c52008-01-11 16:28:18 +01004361------------
4362
4363[to do]
4364
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004365
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +010043662.7) CSV format
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004367---------------
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004368
4369 0. pxname: proxy name
4370 1. svname: service name (FRONTEND for frontend, BACKEND for backend, any name
4371 for server)
4372 2. qcur: current queued requests
4373 3. qmax: max queued requests
4374 4. scur: current sessions
4375 5. smax: max sessions
4376 6. slim: sessions limit
4377 7. stot: total sessions
4378 8. bin: bytes in
4379 9. bout: bytes out
4380 10. dreq: denied requests
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004381 11. dresp: denied responses
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004382 12. ereq: request errors
4383 13. econ: connection errors
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004384 14. eresp: response errors
Krzysztof Piotr Oledzkif58a9622008-02-23 01:19:10 +01004385 15. wretr: retries (warning)
4386 16. wredis: redispatches (warning)
4387 17. status: status (UP/DOWN/...)
4388 18. weight: server weight (server), total weight (backend)
4389 19. act: server is active (server), number of active servers (backend)
4390 20. bck: server is backup (server), number of backup servers (backend)
4391 21. chkfail: number of failed checks
4392 22. chkdown: number of UP->DOWN transitions
4393 23. lastchg: last status change (in seconds)
4394 24. downtime: total downtime (in seconds)
4395 25. qlimit: queue limit
4396 26. pid: process id (0 for first instance, 1 for second, ...)
4397 27. iid: unique proxy id
4398 28. sid: service id (unique inside a proxy)
4399 29. throttle: warm up status
4400 30. lbtot: total number of times a server was selected
4401 31. tracked: id of proxy/server if tracking is enabled
4402 32. type (0=frontend, 1=backend, 2=server)
Willy Tarreau844e3c52008-01-11 16:28:18 +01004403
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004404
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010044052.8) Unix Socket commands
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004406-------------------------
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004407
Willy Tarreau3dfe6cd2008-12-07 22:29:48 +01004408The following commands are supported on the UNIX stats socket ; all of them
4409must be terminated by a line feed. It is important to understand that when
4410multiple haproxy processes are started on the same sockets, any process may
4411pick up the request and will output its own stats.
4412
4413show stat [<iid> <type> <sid>]
4414 Dump statistics in the CSV format. By passing <id>, <type> and <sid>, it is
4415 possible to dump only selected items :
4416 - <iid> is a proxy ID, -1 to dump everything
4417 - <type> selects the type of dumpable objects : 1 for frontends, 2 for
4418 backends, 4 for servers, -1 for everything. These values can be ORed,
4419 for example:
4420 1 + 2 = 3 -> frontend + backend.
4421 1 + 2 + 4 = 7 -> frontend + backend + server.
4422 - <sid> is a server ID, -1 to dump everything from the selected proxy.
4423
4424show info
4425 Dump info about haproxy status on current process.
4426
4427show sess
4428 Dump all known sessions. Avoid doing this on slow connections as this can
4429 be huge.
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004430
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +01004431
Willy Tarreau0ba27502007-12-24 16:55:16 +01004432/*
4433 * Local variables:
4434 * fill-column: 79
4435 * End:
4436 */