blob: 900b9a719d8d4ac1019ea15960bdb3f53d163913 [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 Tarreau41a340d2008-01-22 12:25:31 +01007 2008/01/22
Willy Tarreau6a06a402007-07-15 20:15:28 +02008
9
10This document covers the configuration language as implemented in the version
11specified above. It does not provide any hint, example or advice. For such
Willy Tarreau0ba27502007-12-24 16:55:16 +010012documentation, please refer to the Reference Manual or the Architecture Manual.
Willy Tarreau6a06a402007-07-15 20:15:28 +020013
Willy Tarreau41a340d2008-01-22 12:25:31 +010014Note to documentation contributors : this document is formated with 80 columns
15per line, with even number of spaces for indentation and without tabs. Please
16follow these rules strictly so that it remains easily printable everywhere. If
17a line needs to be printed verbatim and does not fit, please end each line with
18a backslash ('\') and continue on next line.
Willy Tarreau6a06a402007-07-15 20:15:28 +020019
20HAProxy's configuration process involves 3 major sources of parameters :
21
22 - the arguments from the command-line, which always take precedence
23 - the "global" section, which sets process-wide parameters
24 - the proxies sections which can take form of "defaults", "listen",
25 "frontend" and "backend".
26
Willy Tarreau0ba27502007-12-24 16:55:16 +010027The configuration file syntax consists in lines beginning with a keyword
28referenced in this manual, optionally followed by one or several parameters
29delimited by spaces. If spaces have to be entered in strings, then they must be
30preceeded by a backslash ('\') to be escaped. Backslashes also have to be
31escaped by doubling them.
32
33Some parameters involve values representating time, such as timeouts. These
34values are generally expressed in milliseconds (unless explicitly stated
35otherwise) but may be expressed in any other unit by suffixing the unit to the
36numeric value. It is important to consider this because it will not be repeated
37for every keyword. Supported units are :
38
39 - us : microseconds. 1 microsecond = 1/1000000 second
40 - ms : milliseconds. 1 millisecond = 1/1000 second. This is the default.
41 - s : seconds. 1s = 1000ms
42 - m : minutes. 1m = 60s = 60000ms
43 - h : hours. 1h = 60m = 3600s = 3600000ms
44 - d : days. 1d = 24h = 1440m = 86400s = 86400000ms
45
46
Willy Tarreau6a06a402007-07-15 20:15:28 +0200471. Global parameters
48--------------------
49
50Parameters in the "global" section are process-wide and often OS-specific. They
51are generally set once for all and do not need being changed once correct. Some
52of them have command-line equivalents.
53
54The following keywords are supported in the "global" section :
55
56 * Process management and security
57 - chroot
58 - daemon
59 - gid
60 - group
61 - log
62 - nbproc
63 - pidfile
64 - uid
65 - ulimit-n
66 - user
Willy Tarreaufbee7132007-10-18 13:53:22 +020067 - stats
Willy Tarreau6a06a402007-07-15 20:15:28 +020068
69 * Performance tuning
70 - maxconn
71 - noepoll
72 - nokqueue
73 - nopoll
74 - nosepoll
Willy Tarreaufe255b72007-10-14 23:09:26 +020075 - spread-checks
Willy Tarreaua0250ba2008-01-06 11:22:57 +010076 - tune.maxaccept
77 - tune.maxpollevents
Willy Tarreau6a06a402007-07-15 20:15:28 +020078
79 * Debugging
80 - debug
81 - quiet
Willy Tarreau6a06a402007-07-15 20:15:28 +020082
83
841.1) Process management and security
85------------------------------------
86
87chroot <jail dir>
88 Changes current directory to <jail dir> and performs a chroot() there before
89 dropping privileges. This increases the security level in case an unknown
90 vulnerability would be exploited, since it would make it very hard for the
91 attacker to exploit the system. This only works when the process is started
92 with superuser privileges. It is important to ensure that <jail_dir> is both
93 empty and unwritable to anyone.
94
95daemon
96 Makes the process fork into background. This is the recommended mode of
97 operation. It is equivalent to the command line "-D" argument. It can be
98 disabled by the command line "-db" argument.
99
100gid <number>
101 Changes the process' group ID to <number>. It is recommended that the group
102 ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
103 be started with a user belonging to this group, or with superuser privileges.
104 See also "group" and "uid".
105
106group <group name>
107 Similar to "gid" but uses the GID of group name <group name> from /etc/group.
108 See also "gid" and "user".
109
110log <address> <facility> [max level]
111 Adds a global syslog server. Up to two global servers can be defined. They
112 will receive logs for startups and exits, as well as all logs from proxies
Robert Tsai81ae1952007-12-05 10:47:29 +0100113 configured with "log global".
114
115 <address> can be one of:
116
Willy Tarreau2769aa02007-12-27 18:26:09 +0100117 - An IPv4 address optionally followed by a colon and a UDP port. If
Robert Tsai81ae1952007-12-05 10:47:29 +0100118 no port is specified, 514 is used by default (the standard syslog
119 port).
120
121 - A filesystem path to a UNIX domain socket, keeping in mind
122 considerations for chroot (be sure the path is accessible inside
123 the chroot) and uid/gid (be sure the path is appropriately
124 writeable).
125
126 <facility> must be one of the 24 standard syslog facilities :
Willy Tarreau6a06a402007-07-15 20:15:28 +0200127
128 kern user mail daemon auth syslog lpr news
129 uucp cron auth2 ftp ntp audit alert cron2
130 local0 local1 local2 local3 local4 local5 local6 local7
131
132 An optional level can be specified to filter outgoing messages. By default,
133 all messages are sent. If a level is specified, only messages with a severity
134 at least as important as this level will be sent. 8 levels are known :
135
136 emerg alert crit err warning notice info debug
137
138nbproc <number>
139 Creates <number> processes when going daemon. This requires the "daemon"
140 mode. By default, only one process is created, which is the recommended mode
141 of operation. For systems limited to small sets of file descriptors per
142 process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
143 IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
144
145pidfile <pidfile>
146 Writes pids of all daemons into file <pidfile>. This option is equivalent to
147 the "-p" command line argument. The file must be accessible to the user
148 starting the process. See also "daemon".
149
Willy Tarreaufbee7132007-10-18 13:53:22 +0200150stats socket <path> [{uid | user} <uid>] [{gid | group} <gid>] [mode <mode>]
151 Creates a UNIX socket in stream mode at location <path>. Any previously
152 existing socket will be backed up then replaced. Connections to this socket
153 will get a CSV-formated output of the process statistics in response to the
Willy Tarreaua8efd362008-01-03 10:19:15 +0100154 "show stat" command followed by a line feed, and more general process
155 information in response to the "show info" command followed by a line feed.
156
157 On platforms which support it, it is possible to restrict access to this
158 socket by specifying numerical IDs after "uid" and "gid", or valid user and
159 group names after the "user" and "group" keywords. It is also possible to
160 restrict permissions on the socket by passing an octal value after the "mode"
161 keyword (same syntax as chmod). Depending on the platform, the permissions on
162 the socket will be inherited from the directory which hosts it, or from the
163 user the process is started with.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200164
165stats timeout <timeout, in milliseconds>
166 The default timeout on the stats socket is set to 10 seconds. It is possible
167 to change this value with "stats timeout". The value must be passed in
Willy Tarreaubefdff12007-12-02 22:27:38 +0100168 milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200169
170stats maxconn <connections>
171 By default, the stats socket is limited to 10 concurrent connections. It is
172 possible to change this value with "stats maxconn".
173
Willy Tarreau6a06a402007-07-15 20:15:28 +0200174uid <number>
175 Changes the process' user ID to <number>. It is recommended that the user ID
176 is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
177 be started with superuser privileges in order to be able to switch to another
178 one. See also "gid" and "user".
179
180ulimit-n <number>
181 Sets the maximum number of per-process file-descriptors to <number>. By
182 default, it is automatically computed, so it is recommended not to use this
183 option.
184
185user <user name>
186 Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
187 See also "uid" and "group".
188
189
1901.2) Performance tuning
191-----------------------
192
193maxconn <number>
194 Sets the maximum per-process number of concurrent connections to <number>. It
195 is equivalent to the command-line argument "-n". Proxies will stop accepting
196 connections when this limit is reached. The "ulimit-n" parameter is
197 automatically adjusted according to this value. See also "ulimit-n".
198
199noepoll
200 Disables the use of the "epoll" event polling system on Linux. It is
201 equivalent to the command-line argument "-de". The next polling system
202 used will generally be "poll". See also "nosepoll", and "nopoll".
203
204nokqueue
205 Disables the use of the "kqueue" event polling system on BSD. It is
206 equivalent to the command-line argument "-dk". The next polling system
207 used will generally be "poll". See also "nopoll".
208
209nopoll
210 Disables the use of the "poll" event polling system. It is equivalent to the
211 command-line argument "-dp". The next polling system used will be "select".
Willy Tarreau0ba27502007-12-24 16:55:16 +0100212 It should never be needed to disable "poll" since it's available on all
Willy Tarreau6a06a402007-07-15 20:15:28 +0200213 platforms supported by HAProxy. See also "nosepoll", and "nopoll" and
214 "nokqueue".
215
216nosepoll
217 Disables the use of the "speculative epoll" event polling system on Linux. It
218 is equivalent to the command-line argument "-ds". The next polling system
219 used will generally be "epoll". See also "nosepoll", and "nopoll".
220
Willy Tarreaufe255b72007-10-14 23:09:26 +0200221spread-checks <0..50, in percent>
222 Sometimes it is desirable to avoid sending health checks to servers at exact
223 intervals, for instance when many logical servers are located on the same
224 physical server. With the help of this parameter, it becomes possible to add
225 some randomness in the check interval between 0 and +/- 50%. A value between
226 2 and 5 seems to show good results. The default value remains at 0.
227
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100228tune.maxaccept <number>
229 Sets the maximum number of consecutive accepts that a process may perform on
230 a single wake up. High values give higher priority to high connection rates,
231 while lower values give higher priority to already established connections.
232 This value is unlimited by default in single process mode. However, in
233 multi-process mode (nbproc > 1), it defaults to 8 so that when one process
234 wakes up, it does not take all incoming connections for itself and leaves a
235 part of them to other processes. Setting this value to zero or less disables
236 the limitation. It should normally not be needed to tweak this value.
237
238tune.maxpollevents <number>
239 Sets the maximum amount of events that can be processed at once in a call to
240 the polling system. The default value is adapted to the operating system. It
241 has been noticed that reducing it below 200 tends to slightly decrease
242 latency at the expense of network bandwidth, and increasing it above 200
243 tends to trade latency for slightly increased bandwidth.
244
Willy Tarreau6a06a402007-07-15 20:15:28 +0200245
2461.3) Debugging
247---------------
248
249debug
250 Enables debug mode which dumps to stdout all exchanges, and disables forking
251 into background. It is the equivalent of the command-line argument "-d". It
252 should never be used in a production configuration since it may prevent full
253 system startup.
254
255quiet
256 Do not display any message during startup. It is equivalent to the command-
257 line argument "-q".
258
Willy Tarreau6a06a402007-07-15 20:15:28 +0200259
2602) Proxies
261----------
Willy Tarreau0ba27502007-12-24 16:55:16 +0100262
Willy Tarreau6a06a402007-07-15 20:15:28 +0200263Proxy configuration can be located in a set of sections :
264 - defaults <name>
265 - frontend <name>
266 - backend <name>
267 - listen <name>
268
269A "defaults" section sets default parameters for all other sections following
270its declaration. Those default parameters are reset by the next "defaults"
271section. See below for the list of parameters which can be set in a "defaults"
Willy Tarreau0ba27502007-12-24 16:55:16 +0100272section. The name is optional but its use is encouraged for better readability.
Willy Tarreau6a06a402007-07-15 20:15:28 +0200273
274A "frontend" section describes a set of listening sockets accepting client
275connections.
276
277A "backend" section describes a set of servers to which the proxy will connect
278to forward incoming connections.
279
280A "listen" section defines a complete proxy with its frontend and backend
281parts combined in one section. It is generally useful for TCP-only traffic.
282
Willy Tarreau0ba27502007-12-24 16:55:16 +0100283All proxy names must be formed from upper and lower case letters, digits,
284'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
285case-sensitive, which means that "www" and "WWW" are two different proxies.
286
287Historically, all proxy names could overlap, it just caused troubles in the
288logs. Since the introduction of content switching, it is mandatory that two
289proxies with overlapping capabilities (frontend/backend) have different names.
290However, it is still permitted that a frontend and a backend share the same
291name, as this configuration seems to be commonly encountered.
292
293Right now, two major proxy modes are supported : "tcp", also known as layer 4,
294and "http", also known as layer 7. In layer 4 mode, HAProxy simply forwards
295bidirectionnal traffic between two sides. In layer 7 mode, HAProxy analyzes the
296protocol, and can interact with it by allowing, blocking, switching, adding,
297modifying, or removing arbitrary contents in requests or responses, based on
298arbitrary criteria.
299
300
3012.1) Quick reminder about HTTP
302------------------------------
303
304When a proxy is running in HTTP mode, both the request and the response are
305fully analyzed and indexed, thus it becomes possible to build matching criteria
306on almost anything found in the contents.
307
308However, it is important to understand how HTTP requests and responses are
309formed, and how HAProxy decomposes them. It will then become easier to write
310correct rules and to debug existing configurations.
311
312
3132.1.1) The HTTP transaction model
314---------------------------------
315
316The HTTP protocol is transaction-driven. This means that each request will lead
317to one and only one response. Traditionnally, a TCP connection is established
318from the client to the server, a request is sent by the client on the
319connection, the server responds and the connection is closed. A new request
320will involve a new connection :
321
322 [CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ...
323
324In this mode, called the "HTTP close" mode, there are as many connection
325establishments as there are HTTP transactions. Since the connection is closed
326by the server after the response, the client does not need to know the content
327length.
328
329Due to the transactional nature of the protocol, it was possible to improve it
330to avoid closing a connection between two subsequent transactions. In this mode
331however, it is mandatory that the server indicates the content length for each
332response so that the client does not wait indefinitely. For this, a special
333header is used: "Content-length". This mode is called the "keep-alive" mode :
334
335 [CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ...
336
337Its advantages are a reduced latency between transactions, and less processing
338power required on the server side. It is generally better than the close mode,
339but not always because the clients often limit their concurrent connections to
340a smaller value. HAProxy currently does not support the HTTP keep-alive mode,
341but knows how to transform it to the close mode.
342
343A last improvement in the communications is the pipelining mode. It still uses
344keep-alive, but the client does not wait for the first response to send the
345second request. This is useful for fetching large number of images composing a
346page :
347
348 [CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ...
349
350This can obviously have a tremendous benefit on performance because the network
351latency is eliminated between subsequent requests. Many HTTP agents do not
352correctly support pipelining since there is no way to associate a response with
353the corresponding request in HTTP. For this reason, it is mandatory for the
354server to reply in the exact same order as the requests were received.
355
356Right now, HAProxy only supports the first mode (HTTP close) if it needs to
357process the request. This means that for each request, there will be one TCP
358connection. If keep-alive or pipelining are required, HAProxy will still
359support them, but will only see the first request and the first response of
360each transaction. While this is generally problematic with regards to logs,
361content switching or filtering, it most often causes no problem for persistence
362with cookie insertion.
363
364
3652.1.2) HTTP request
366-------------------
367
368First, let's consider this HTTP request :
369
370 Line Contents
371 number
372 1 GET /serv/login.php?lang=en&profile=2 HTTP/1.1
373 2 Host: www.mydomain.com
374 3 User-agent: my small browser
375 4 Accept: image/jpeg, image/gif
376 5 Accept: image/png
377
378
3792.1.2.1) The Request line
380-------------------------
381
382Line 1 is the "request line". It is always composed of 3 fields :
383
384 - a METHOD : GET
385 - a URI : /serv/login.php?lang=en&profile=2
386 - a version tag : HTTP/1.1
387
388All of them are delimited by what the standard calls LWS (linear white spaces),
389which are commonly spaces, but can also be tabs or line feeds/carriage returns
390followed by spaces/tabs. The method itself cannot contain any colon (':') and
391is limited to alphabetic letters. All those various combinations make it
392desirable that HAProxy performs the splitting itself rather than leaving it to
393the user to write a complex or inaccurate regular expression.
394
395The URI itself can have several forms :
396
397 - A "relative URI" :
398
399 /serv/login.php?lang=en&profile=2
400
401 It is a complete URL without the host part. This is generally what is
402 received by servers, reverse proxies and transparent proxies.
403
404 - An "absolute URI", also called a "URL" :
405
406 http://192.168.0.12:8080/serv/login.php?lang=en&profile=2
407
408 It is composed of a "scheme" (the protocol name followed by '://'), a host
409 name or address, optionally a colon (':') followed by a port number, then
410 a relative URI beginning at the first slash ('/') after the address part.
411 This is generally what proxies receive, but a server supporting HTTP/1.1
412 must accept this form too.
413
414 - a star ('*') : this form is only accepted in association with the OPTIONS
415 method and is not relayable. It is used to inquiry a next hop's
416 capabilities.
417
418 - an address:port combination : 192.168.0.12:80
419 This is used with the CONNECT method, which is used to establish TCP
420 tunnels through HTTP proxies, generally for HTTPS, but sometimes for
421 other protocols too.
422
423In a relative URI, two sub-parts are identified. The part before the question
424mark is called the "path". It is typically the relative path to static objects
425on the server. The part after the question mark is called the "query string".
426It is mostly used with GET requests sent to dynamic scripts and is very
427specific to the language, framework or application in use.
428
429
4302.1.2.2) The request headers
431----------------------------
432
433The headers start at the second line. They are composed of a name at the
434beginning of the line, immediately followed by a colon (':'). Traditionally,
435an LWS is added after the colon but that's not required. Then come the values.
436Multiple identical headers may be folded into one single line, delimiting the
437values with commas, provided that their order is respected. This is commonly
Willy Tarreau198a7442008-01-17 12:05:32 +0100438encountered in the "Cookie:" field. A header may span over multiple lines if
Willy Tarreau0ba27502007-12-24 16:55:16 +0100439the subsequent lines begin with an LWS. In the example in 2.1.2, lines 4 and 5
Willy Tarreau198a7442008-01-17 12:05:32 +0100440define a total of 3 values for the "Accept:" header.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100441
442Contrary to a common mis-conception, header names are not case-sensitive, and
443their values are not either if they refer to other header names (such as the
Willy Tarreau198a7442008-01-17 12:05:32 +0100444"Connection:" header).
Willy Tarreau0ba27502007-12-24 16:55:16 +0100445
446The end of the headers is indicated by the first empty line. People often say
447that it's a double line feed, which is not exact, even if a double line feed
448is one valid form of empty line.
449
450Fortunately, HAProxy takes care of all these complex combinations when indexing
451headers, checking values and counting them, so there is no reason to worry
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100452about the way they could be written, but it is important not to accuse an
Willy Tarreau0ba27502007-12-24 16:55:16 +0100453application of being buggy if it does unusual, valid things.
454
455Important note:
456 As suggested by RFC2616, HAProxy normalizes headers by replacing line breaks
457 in the middle of headers by LWS in order to join multi-line headers. This
458 is necessary for proper analysis and helps less capable HTTP parsers to work
459 correctly and not to be fooled by such complex constructs.
460
461
4622.1.3) HTTP response
463--------------------
464
465An HTTP response looks very much like an HTTP request. Both are called HTTP
466messages. Let's consider this HTTP response :
467
468 Line Contents
469 number
470 1 HTTP/1.1 200 OK
471 2 Content-length: 350
472 3 Content-Type: text/html
473
474
4752.1.3.1) The Response line
476--------------------------
477
478Line 1 is the "response line". It is always composed of 3 fields :
479
480 - a version tag : HTTP/1.1
481 - a status code : 200
482 - a reason : OK
483
484The status code is always 3-digit. The first digit indicates a general status :
485 - 2xx = OK, content is following (eg: 200, 206)
486 - 3xx = OK, no content following (eg: 302, 304)
487 - 4xx = error caused by the client (eg: 401, 403, 404)
488 - 5xx = error caused by the server (eg: 500, 502, 503)
489
490Please refer to RFC2616 for the detailed meaning of all such codes. The
491"reason" field is just a hint, but is not parsed by clients. Anything can be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100492found there, but it's a common practice to respect the well-established
Willy Tarreau0ba27502007-12-24 16:55:16 +0100493messages. It can be composed of one or multiple words, such as "OK", "Found",
494or "Authentication Required".
495
496
4972.1.3.2) The response headers
498-----------------------------
499
500Response headers work exactly like request headers, and as such, HAProxy uses
501the same parsing function for both. Please refer to paragraph 2.1.2.2 for more
502details.
503
504
5052.2) Proxy keywords matrix
506----------------------------
507
Willy Tarreau6a06a402007-07-15 20:15:28 +0200508The following list of keywords is supported. Most of them may only be used in a
Willy Tarreau0ba27502007-12-24 16:55:16 +0100509limited set of section types. Some of them are marked as "deprecated" because
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100510they are inherited from an old syntax which may be confusing or functionally
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100511limited, and there are new recommended keywords to replace them. Keywords
512listed with [no] can be optionally inverted using the "no" prefix, ex. "no
513option contstats". This makes sense when the option has been enabled by default
514and must be disabled for a specific instance.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100515
Willy Tarreau6a06a402007-07-15 20:15:28 +0200516
517keyword defaults frontend listen backend
518----------------------+----------+----------+---------+---------
519acl - X X X
520appsession - - X X
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100521backlog X X X -
Willy Tarreau0ba27502007-12-24 16:55:16 +0100522balance X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200523bind - X X -
524block - X X X
Willy Tarreau0ba27502007-12-24 16:55:16 +0100525capture cookie - X X -
526capture request header - X X -
527capture response header - X X -
Willy Tarreaue219db72007-12-03 01:30:13 +0100528clitimeout X X X - (deprecated)
Willy Tarreau0ba27502007-12-24 16:55:16 +0100529contimeout X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200530cookie X - X X
531default_backend - X X -
Willy Tarreau0ba27502007-12-24 16:55:16 +0100532disabled X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200533dispatch - - X X
Willy Tarreau0ba27502007-12-24 16:55:16 +0100534enabled X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200535errorfile X X X X
536errorloc X X X X
537errorloc302 X X X X
538errorloc303 X X X X
539fullconn X - X X
540grace - X X X
Willy Tarreaudbc36f62007-11-30 12:29:11 +0100541http-check disable-on-404 X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200542log X X X X
543maxconn X X X -
544mode X X X X
Willy Tarreauc7246fc2007-12-02 17:31:20 +0100545monitor fail - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200546monitor-net X X X -
547monitor-uri X X X -
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100548[no] option abortonclose X - X X
549[no] option allbackups X - X X
550[no] option checkcache X - X X
551[no] option clitcpka X X X -
552[no] option contstats X X X -
553[no] option dontlognull X X X -
554[no] option forceclose X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200555option forwardfor X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100556[no] option http_proxy X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200557option httpchk X - X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100558[no] option httpclose X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200559option httplog X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100560[no] option logasap X X X -
561[no] option nolinger X X X X
562[no] option persist X - X X
563[no] option redispatch X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200564option smtpchk X - X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100565[no] option srvtcpka X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200566option ssl-hello-chk X - X X
567option tcpka X X X X
568option tcplog X X X X
Krzysztof Oledzki336d4752007-12-25 02:40:22 +0100569[no] option tcpsplice X X X X
570[no] option transparent X X X -
571redisp X - X X (deprecated)
572redispatch X - X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200573reqadd - X X X
574reqallow - X X X
575reqdel - X X X
576reqdeny - X X X
577reqiallow - X X X
578reqidel - X X X
579reqideny - X X X
580reqipass - X X X
581reqirep - X X X
582reqisetbe - X X X
583reqitarpit - X X X
584reqpass - X X X
585reqrep - X X X
586reqsetbe - X X X
587reqtarpit - X X X
588retries X - X X
589rspadd - X X X
590rspdel - X X X
591rspdeny - X X X
592rspidel - X X X
593rspideny - X X X
594rspirep - X X X
595rsprep - X X X
596server - - X X
597source X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100598srvtimeout X - X X (deprecated)
Willy Tarreau24e779b2007-07-24 23:43:37 +0200599stats auth X - X X
600stats enable X - X X
601stats realm X - X X
Willy Tarreaubbd42122007-07-25 07:26:38 +0200602stats refresh X - X X
Willy Tarreau24e779b2007-07-24 23:43:37 +0200603stats scope X - X X
604stats uri X - X X
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +0200605stats hide-version X - X X
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +0100606timeout check X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100607timeout client X X X -
608timeout clitimeout X X X - (deprecated)
609timeout connect X - X X
610timeout contimeout X - X X (deprecated)
Willy Tarreau844e3c52008-01-11 16:28:18 +0100611timeout http-request X X X -
Willy Tarreaue219db72007-12-03 01:30:13 +0100612timeout queue X - X X
613timeout server X - X X
614timeout srvtimeout X - X X (deprecated)
Willy Tarreau51c9bde2008-01-06 13:40:03 +0100615timeout tarpit X X X X
Willy Tarreau844e3c52008-01-11 16:28:18 +0100616transparent X X X - (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200617use_backend - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200618----------------------+----------+----------+---------+---------
619keyword defaults frontend listen backend
620
Willy Tarreau0ba27502007-12-24 16:55:16 +0100621
6222.2.1) Alphabetically sorted keywords reference
623-----------------------------------------------
624
625This section provides a description of each keyword and its usage.
626
627
628acl <aclname> <criterion> [flags] [operator] <value> ...
629 Declare or complete an access list.
630 May be used in sections : defaults | frontend | listen | backend
631 no | yes | yes | yes
632 Example:
633 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
634 acl invalid_src src_port 0:1023
635 acl local_dst hdr(host) -i localhost
636
637 See section 2.3 about ACL usage.
638
639
640appsession <cookie> len <length> timeout <holdtime>
641 Define session stickiness on an existing application cookie.
642 May be used in sections : defaults | frontend | listen | backend
643 no | no | yes | yes
644 Arguments :
645 <cookie> this is the name of the cookie used by the application and which
646 HAProxy will have to learn for each new session.
647
648 <length> this is the number of characters that will be memorized and
649 checked in each cookie value.
650
651 <holdtime> this is the time after which the cookie will be removed from
652 memory if unused. If no unit is specified, this time is in
653 milliseconds.
654
655 When an application cookie is defined in a backend, HAProxy will check when
656 the server sets such a cookie, and will store its value in a table, and
657 associate it with the server's identifier. Up to <length> characters from
658 the value will be retained. On each connection, haproxy will look for this
659 cookie both in the "Cookie:" headers, and as a URL parameter in the query
660 string. If a known value is found, the client will be directed to the server
661 associated with this value. Otherwise, the load balancing algorithm is
662 applied. Cookies are automatically removed from memory when they have been
663 unused for a duration longer than <holdtime>.
664
665 The definition of an application cookie is limited to one per backend.
666
667 Example :
668 appsession JSESSIONID len 52 timeout 3h
669
670 See also : "cookie", "capture cookie" and "balance".
671
672
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100673backlog <conns>
674 Give hints to the system about the approximate listen backlog desired size
675 May be used in sections : defaults | frontend | listen | backend
676 yes | yes | yes | no
677 Arguments :
678 <conns> is the number of pending connections. Depending on the operating
679 system, it may represent the number of already acknowledged
680 connections, of non-acknowledged ones, or both.
681
682 In order to protect against SYN flood attacks, one solution is to increase
683 the system's SYN backlog size. Depending on the system, sometimes it is just
684 tunable via a system parameter, sometimes it is not adjustable at all, and
685 sometimes the system relies on hints given by the application at the time of
686 the listen() syscall. By default, HAProxy passes the frontend's maxconn value
687 to the listen() syscall. On systems which can make use of this value, it can
688 sometimes be useful to be able to specify a different value, hence this
689 backlog parameter.
690
691 On Linux 2.4, the parameter is ignored by the system. On Linux 2.6, it is
692 used as a hint and the system accepts up to the smallest greater power of
693 two, and never more than some limits (usually 32768).
694
695 See also : "maxconn" and the target operating system's tuning guide.
696
697
Willy Tarreau0ba27502007-12-24 16:55:16 +0100698balance <algorithm> [ <arguments> ]
699 Define the load balancing algorithm to be used in a backend.
700 May be used in sections : defaults | frontend | listen | backend
701 yes | no | yes | yes
702 Arguments :
703 <algorithm> is the algorithm used to select a server when doing load
704 balancing. This only applies when no persistence information
705 is available, or when a connection is redispatched to another
706 server. <algorithm> may be one of the following :
707
708 roundrobin Each server is used in turns, according to their weights.
709 This is the smoothest and fairest algorithm when the server's
710 processing time remains equally distributed. This algorithm
711 is dynamic, which means that server weights may be adjusted
712 on the fly for slow starts for instance.
713
714 source The source IP address is hashed and divided by the total
715 weight of the running servers to designate which server will
716 receive the request. This ensures that the same client IP
717 address will always reach the same server as long as no
718 server goes down or up. If the hash result changes due to the
719 number of running servers changing, many clients will be
720 directed to a different server. This algorithm is generally
721 used in TCP mode where no cookie may be inserted. It may also
722 be used on the Internet to provide a best-effort stickyness
723 to clients which refuse session cookies. This algorithm is
724 static, which means that changing a server's weight on the
725 fly will have no effect.
726
727 uri The left part of the URI (before the question mark) is hashed
728 and divided by the total weight of the running servers. The
729 result designates which server will receive the request. This
730 ensures that a same URI will always be directed to the same
731 server as long as no server goes up or down. This is used
732 with proxy caches and anti-virus proxies in order to maximize
733 the cache hit rate. Note that this algorithm may only be used
734 in an HTTP backend. This algorithm is static, which means
735 that changing a server's weight on the fly will have no
736 effect.
737
738 url_param The URL parameter specified in argument will be looked up in
739 the query string of each HTTP request. If it is found
740 followed by an equal sign ('=') and a value, then the value
741 is hashed and divided by the total weight of the running
742 servers. The result designates which server will receive the
743 request. This is used to track user identifiers in requests
744 and ensure that a same user ID will always be sent to the
745 same server as long as no server goes up or down. If no value
746 is found or if the parameter is not found, then a round robin
747 algorithm is applied. Note that this algorithm may only be
748 used in an HTTP backend. This algorithm is static, which
749 means that changing a server's weight on the fly will have no
750 effect.
751
752 <arguments> is an optional list of arguments which may be needed by some
753 algorithms. Right now, only the "url_param" algorithm supports
754 a mandatory argument.
755
756 The definition of the load balancing algorithm is mandatory for a backend
757 and limited to one per backend.
758
759 Examples :
760 balance roundrobin
761 balance url_param userid
762
763 See also : "dispatch", "cookie", "appsession", "transparent" and "http_proxy".
764
765
766bind [<address>]:<port> [, ...]
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100767bind [<address>]:<port> [, ...] transparent
Willy Tarreau0ba27502007-12-24 16:55:16 +0100768 Define one or several listening addresses and/or ports in a frontend.
769 May be used in sections : defaults | frontend | listen | backend
770 no | yes | yes | no
771 Arguments :
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100772 <address> is optional and can be a host name, an IPv4 address, an IPv6
773 address, or '*'. It designates the address the frontend will
774 listen on. If unset, all IPv4 addresses of the system will be
775 listened on. The same will apply for '*' or the system's
776 special address "0.0.0.0".
777
778 <port> is the TCP port number the proxy will listen on. The port is
779 mandatory. Note that in the case of an IPv6 address, the port
780 is always the number after the last colon (':').
Willy Tarreau0ba27502007-12-24 16:55:16 +0100781
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100782 transparent is an optional keyword which is supported only on certain
783 Linux kernels. It indicates that the addresses will be bound
784 even if they do not belong to the local machine. Any packet
785 targetting any of these addresses will be caught just as if
786 the address was locally configured. This normally requires
787 that IP forwarding is enabled. Caution! do not use this with
788 the default address '*', as it would redirect any traffic for
789 the specified port. This keyword is available only when
790 HAProxy is built with USE_LINUX_TPROXY=1.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100791
792 It is possible to specify a list of address:port combinations delimited by
793 commas. The frontend will then listen on all of these addresses. There is no
794 fixed limit to the number of addresses and ports which can be listened on in
795 a frontend, as well as there is no limit to the number of "bind" statements
796 in a frontend.
797
798 Example :
799 listen http_proxy
800 bind :80,:443
801 bind 10.0.0.1:10080,10.0.0.1:10443
802
803 See also : "source".
804
805
806block { if | unless } <condition>
807 Block a layer 7 request if/unless a condition is matched
808 May be used in sections : defaults | frontend | listen | backend
809 no | yes | yes | yes
810
811 The HTTP request will be blocked very early in the layer 7 processing
812 if/unless <condition> is matched. A 403 error will be returned if the request
813 is blocked. The condition has to reference ACLs (see section 2.3). This is
814 typically used to deny access to certain sensible resources if some
815 conditions are met or not met. There is no fixed limit to the number of
816 "block" statements per instance.
817
818 Example:
819 acl invalid_src src 0.0.0.0/7 224.0.0.0/3
820 acl invalid_src src_port 0:1023
821 acl local_dst hdr(host) -i localhost
822 block if invalid_src || local_dst
823
824 See section 2.3 about ACL usage.
825
826
827capture cookie <name> len <length>
828 Capture and log a cookie in the request and in the response.
829 May be used in sections : defaults | frontend | listen | backend
830 no | yes | yes | no
831 Arguments :
832 <name> is the beginning of the name of the cookie to capture. In order
833 to match the exact name, simply suffix the name with an equal
834 sign ('='). The full name will appear in the logs, which is
835 useful with application servers which adjust both the cookie name
836 and value (eg: ASPSESSIONXXXXX).
837
838 <length> is the maximum number of characters to report in the logs, which
839 include the cookie name, the equal sign and the value, all in the
840 standard "name=value" form. The string will be truncated on the
841 right if it exceeds <length>.
842
843 Only the first cookie is captured. Both the "cookie" request headers and the
844 "set-cookie" response headers are monitored. This is particularly useful to
845 check for application bugs causing session crossing or stealing between
846 users, because generally the user's cookies can only change on a login page.
847
848 When the cookie was not presented by the client, the associated log column
849 will report "-". When a request does not cause a cookie to be assigned by the
850 server, a "-" is reported in the response column.
851
852 The capture is performed in the frontend only because it is necessary that
853 the log format does not change for a given frontend depending on the
854 backends. This may change in the future. Note that there can be only one
855 "capture cookie" statement in a frontend. The maximum capture length is
856 configured in the souces by default to 64 characters. It is not possible to
857 specify a capture in a "defaults" section.
858
859 Example:
860 capture cookie ASPSESSION len 32
861
862 See also : "capture request header", "capture response header" as well as
Willy Tarreauced27012008-01-17 20:35:34 +0100863 section 2.6 about logging.
Willy Tarreau0ba27502007-12-24 16:55:16 +0100864
865
866capture request header <name> len <length>
867 Capture and log the first occurrence of the specified request header.
868 May be used in sections : defaults | frontend | listen | backend
869 no | yes | yes | no
870 Arguments :
871 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100872 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +0100873 appear in the requests, with the first letter of each word in
874 upper case. The header name will not appear in the logs, only the
875 value is reported, but the position in the logs is respected.
876
877 <length> is the maximum number of characters to extract from the value and
878 report in the logs. The string will be truncated on the right if
879 it exceeds <length>.
880
881 Only the first value of the first occurrence of the header is captured. The
882 value will be added to the logs between braces ('{}'). If multiple headers
883 are captured, they will be delimited by a vertical bar ('|') and will appear
884 in the same order they were declared in the configuration. Common uses for
885 request header captures include the "Host" field in virtual hosting
886 environments, the "Content-length" when uploads are supported, "User-agent"
887 to quickly differenciate between real users and robots, and "X-Forwarded-For"
888 in proxied environments to find where the request came from.
889
890 There is no limit to the number of captured request headers, but each capture
891 is limited to 64 characters. In order to keep log format consistent for a
892 same frontend, header captures can only be declared in a frontend. It is not
893 possible to specify a capture in a "defaults" section.
894
895 Example:
896 capture request header Host len 15
897 capture request header X-Forwarded-For len 15
898 capture request header Referrer len 15
899
Willy Tarreauced27012008-01-17 20:35:34 +0100900 See also : "capture cookie", "capture response header" as well as section 2.6
Willy Tarreau0ba27502007-12-24 16:55:16 +0100901 about logging.
902
903
904capture response header <name> len <length>
905 Capture and log the first occurrence of the specified response header.
906 May be used in sections : defaults | frontend | listen | backend
907 no | yes | yes | no
908 Arguments :
909 <name> is the name of the header to capture. The header names are not
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100910 case-sensitive, but it is a common practice to write them as they
Willy Tarreau0ba27502007-12-24 16:55:16 +0100911 appear in the response, with the first letter of each word in
912 upper case. The header name will not appear in the logs, only the
913 value is reported, but the position in the logs is respected.
914
915 <length> is the maximum number of characters to extract from the value and
916 report in the logs. The string will be truncated on the right if
917 it exceeds <length>.
918
919 Only the first value of the first occurrence of the header is captured. The
920 result will be added to the logs between braces ('{}') after the captured
921 request headers. If multiple headers are captured, they will be delimited by
922 a vertical bar ('|') and will appear in the same order they were declared in
923 the configuration. Common uses for response header captures include the
924 "Content-length" header which indicates how many bytes are expected to be
925 returned, the "Location" header to track redirections.
926
927 There is no limit to the number of captured response headers, but each
928 capture is limited to 64 characters. In order to keep log format consistent
929 for a same frontend, header captures can only be declared in a frontend. It
930 is not possible to specify a capture in a "defaults" section.
931
932 Example:
933 capture response header Content-length len 9
934 capture response header Location len 15
935
Willy Tarreauced27012008-01-17 20:35:34 +0100936 See also : "capture cookie", "capture request header" as well as section 2.6
Willy Tarreau0ba27502007-12-24 16:55:16 +0100937 about logging.
938
939
940clitimeout <timeout>
941 Set the maximum inactivity time on the client side.
942 May be used in sections : defaults | frontend | listen | backend
943 yes | yes | yes | no
944 Arguments :
945 <timeout> is the timeout value is specified in milliseconds by default, but
946 can be in any other unit if the number is suffixed by the unit,
947 as explained at the top of this document.
948
949 The inactivity timeout applies when the client is expected to acknowledge or
950 send data. In HTTP mode, this timeout is particularly important to consider
951 during the first phase, when the client sends the request, and during the
952 response while it is reading data sent by the server. The value is specified
953 in milliseconds by default, but can be in any other unit if the number is
954 suffixed by the unit, as specified at the top of this document. In TCP mode
955 (and to a lesser extent, in HTTP mode), it is highly recommended that the
956 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100957 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +0100958 losses by specifying timeouts that are slightly above multiples of 3 seconds
959 (eg: 4 or 5 seconds).
960
961 This parameter is specific to frontends, but can be specified once for all in
962 "defaults" sections. This is in fact one of the easiest solutions not to
963 forget about it. An unspecified timeout results in an infinite timeout, which
964 is not recommended. Such a usage is accepted and works but reports a warning
965 during startup because it may results in accumulation of expired sessions in
966 the system if the system's timeouts are not configured either.
967
968 This parameter is provided for compatibility but is currently deprecated.
969 Please use "timeout client" instead.
970
Willy Tarreau036fae02008-01-06 13:24:40 +0100971 See also : "timeout client", "timeout http-request", "timeout server", and
972 "srvtimeout".
Willy Tarreau0ba27502007-12-24 16:55:16 +0100973
974
975contimeout <timeout>
976 Set the maximum time to wait for a connection attempt to a server to succeed.
977 May be used in sections : defaults | frontend | listen | backend
978 yes | no | yes | yes
979 Arguments :
980 <timeout> is the timeout value is specified in milliseconds by default, but
981 can be in any other unit if the number is suffixed by the unit,
982 as explained at the top of this document.
983
984 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +0100985 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +0100986 cover one or several TCP packet losses by specifying timeouts that are
987 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
988 connect timeout also presets the queue timeout to the same value if this one
989 has not been specified. Historically, the contimeout was also used to set the
990 tarpit timeout in a listen section, which is not possible in a pure frontend.
991
992 This parameter is specific to backends, but can be specified once for all in
993 "defaults" sections. This is in fact one of the easiest solutions not to
994 forget about it. An unspecified timeout results in an infinite timeout, which
995 is not recommended. Such a usage is accepted and works but reports a warning
996 during startup because it may results in accumulation of failed sessions in
997 the system if the system's timeouts are not configured either.
998
999 This parameter is provided for backwards compatibility but is currently
1000 deprecated. Please use "timeout connect", "timeout queue" or "timeout tarpit"
1001 instead.
1002
1003 See also : "timeout connect", "timeout queue", "timeout tarpit",
1004 "timeout server", "contimeout".
1005
1006
1007cookie <name> [ rewrite|insert|prefix ] [ indirect ] [ nocache ] [ postonly ]
1008 Enable cookie-based persistence in a backend.
1009 May be used in sections : defaults | frontend | listen | backend
1010 yes | no | yes | yes
1011 Arguments :
1012 <name> is the name of the cookie which will be monitored, modified or
1013 inserted in order to bring persistence. This cookie is sent to
1014 the client via a "Set-Cookie" header in the response, and is
1015 brought back by the client in a "Cookie" header in all requests.
1016 Special care should be taken to choose a name which does not
1017 conflict with any likely application cookie. Also, if the same
1018 backends are subject to be used by the same clients (eg:
1019 HTTP/HTTPS), care should be taken to use different cookie names
1020 between all backends if persistence between them is not desired.
1021
1022 rewrite This keyword indicates that the cookie will be provided by the
1023 server and that haproxy will have to modify its value to set the
1024 server's identifier in it. This mode is handy when the management
1025 of complex combinations of "Set-cookie" and "Cache-control"
1026 headers is left to the application. The application can then
1027 decide whether or not it is appropriate to emit a persistence
1028 cookie. Since all responses should be monitored, this mode only
1029 works in HTTP close mode. Unless the application behaviour is
1030 very complex and/or broken, it is advised not to start with this
1031 mode for new deployments. This keyword is incompatible with
1032 "insert" and "prefix".
1033
1034 insert This keyword indicates that the persistence cookie will have to
1035 be inserted by haproxy in the responses. If the server emits a
1036 cookie with the same name, it will be replaced anyway. For this
1037 reason, this mode can be used to upgrade existing configurations
1038 running in the "rewrite" mode. The cookie will only be a session
1039 cookie and will not be stored on the client's disk. Due to
1040 caching effects, it is generally wise to add the "indirect" and
1041 "nocache" or "postonly" keywords (see below). The "insert"
1042 keyword is not compatible with "rewrite" and "prefix".
1043
1044 prefix This keyword indicates that instead of relying on a dedicated
1045 cookie for the persistence, an existing one will be completed.
1046 This may be needed in some specific environments where the client
1047 does not support more than one single cookie and the application
1048 already needs it. In this case, whenever the server sets a cookie
1049 named <name>, it will be prefixed with the server's identifier
1050 and a delimiter. The prefix will be removed from all client
1051 requests so that the server still finds the cookie it emitted.
1052 Since all requests and responses are subject to being modified,
1053 this mode requires the HTTP close mode. The "prefix" keyword is
1054 not compatible with "rewrite" and "insert".
1055
1056 indirect When this option is specified in insert mode, cookies will only
1057 be added when the server was not reached after a direct access,
1058 which means that only when a server is elected after applying a
1059 load-balancing algorithm, or after a redispatch, then the cookie
1060 will be inserted. If the client has all the required information
1061 to connect to the same server next time, no further cookie will
1062 be inserted. In all cases, when the "indirect" option is used in
1063 insert mode, the cookie is always removed from the requests
1064 transmitted to the server. The persistence mechanism then becomes
1065 totally transparent from the application point of view.
1066
1067 nocache This option is recommended in conjunction with the insert mode
1068 when there is a cache between the client and HAProxy, as it
1069 ensures that a cacheable response will be tagged non-cacheable if
1070 a cookie needs to be inserted. This is important because if all
1071 persistence cookies are added on a cacheable home page for
1072 instance, then all customers will then fetch the page from an
1073 outer cache and will all share the same persistence cookie,
1074 leading to one server receiving much more traffic than others.
1075 See also the "insert" and "postonly" options.
1076
1077 postonly This option ensures that cookie insertion will only be performed
1078 on responses to POST requests. It is an alternative to the
1079 "nocache" option, because POST responses are not cacheable, so
1080 this ensures that the persistence cookie will never get cached.
1081 Since most sites do not need any sort of persistence before the
1082 first POST which generally is a login request, this is a very
1083 efficient method to optimize caching without risking to find a
1084 persistence cookie in the cache.
1085 See also the "insert" and "nocache" options.
1086
1087 There can be only one persistence cookie per HTTP backend, and it can be
1088 declared in a defaults section. The value of the cookie will be the value
1089 indicated after the "cookie" keyword in a "server" statement. If no cookie
1090 is declared for a given server, the cookie is not set.
Willy Tarreau6a06a402007-07-15 20:15:28 +02001091
Willy Tarreau0ba27502007-12-24 16:55:16 +01001092 Examples :
1093 cookie JSESSIONID prefix
1094 cookie SRV insert indirect nocache
1095 cookie SRV insert postonly indirect
1096
1097 See also : "appsession", "balance source", "capture cookie", "server".
1098
1099
1100default_backend <backend>
1101 Specify the backend to use when no "use_backend" rule has been matched.
1102 May be used in sections : defaults | frontend | listen | backend
1103 yes | yes | yes | no
1104 Arguments :
1105 <backend> is the name of the backend to use.
1106
1107 When doing content-switching between frontend and backends using the
1108 "use_backend" keyword, it is often useful to indicate which backend will be
1109 used when no rule has matched. It generally is the dynamic backend which
1110 will catch all undetermined requests.
1111
1112 The "default_backend" keyword is also supported in TCP mode frontends to
1113 facilitate the ordering of configurations in frontends and backends,
1114 eventhough it does not make much more sense in case of TCP due to the fact
1115 that use_backend currently does not work in TCP mode.
1116
1117 Example :
1118
1119 use_backend dynamic if url_dyn
1120 use_backend static if url_css url_img extension_img
1121 default_backend dynamic
1122
Willy Tarreau2769aa02007-12-27 18:26:09 +01001123 See also : "use_backend", "reqsetbe", "reqisetbe"
1124
Willy Tarreau0ba27502007-12-24 16:55:16 +01001125
1126disabled
1127 Disable a proxy, frontend or backend.
1128 May be used in sections : defaults | frontend | listen | backend
1129 yes | yes | yes | yes
1130 Arguments : none
1131
1132 The "disabled" keyword is used to disable an instance, mainly in order to
1133 liberate a listening port or to temporarily disable a service. The instance
1134 will still be created and its configuration will be checked, but it will be
1135 created in the "stopped" state and will appear as such in the statistics. It
1136 will not receive any traffic nor will it send any health-checks or logs. It
1137 is possible to disable many instances at once by adding the "disabled"
1138 keyword in a "defaults" section.
1139
1140 See also : "enabled"
1141
1142
1143enabled
1144 Enable a proxy, frontend or backend.
1145 May be used in sections : defaults | frontend | listen | backend
1146 yes | yes | yes | yes
1147 Arguments : none
1148
1149 The "enabled" keyword is used to explicitly enable an instance, when the
1150 defaults has been set to "disabled". This is very rarely used.
1151
1152 See also : "disabled"
1153
1154
1155errorfile <code> <file>
1156 Return a file contents instead of errors generated by HAProxy
1157 May be used in sections : defaults | frontend | listen | backend
1158 yes | yes | yes | yes
1159 Arguments :
1160 <code> is the HTTP status code. Currently, HAProxy is capable of
1161 generating codes 400, 403, 408, 500, 502, 503, and 504.
1162
1163 <file> designates a file containing the full HTTP response. It is
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001164 recommended to follow the common practice of appending ".http" to
Willy Tarreau0ba27502007-12-24 16:55:16 +01001165 the filename so that people do not confuse the response with HTML
1166 error pages.
1167
1168 It is important to understand that this keyword is not meant to rewrite
1169 errors returned by the server, but errors detected and returned by HAProxy.
1170 This is why the list of supported errors is limited to a small set.
1171
1172 The files are returned verbatim on the TCP socket. This allows any trick such
1173 as redirections to another URL or site, as well as tricks to clean cookies,
1174 force enable or disable caching, etc... The package provides default error
1175 files returning the same contents as default errors.
1176
1177 The files are read at the same time as the configuration and kept in memory.
1178 For this reason, the errors continue to be returned even when the process is
1179 chrooted, and no file change is considered while the process is running. A
Willy Tarreauc27debf2008-01-06 08:57:02 +01001180 simple method for developing those files consists in associating them to the
Willy Tarreau0ba27502007-12-24 16:55:16 +01001181 403 status code and interrogating a blocked URL.
1182
1183 See also : "errorloc", "errorloc302", "errorloc303"
1184
Willy Tarreau2769aa02007-12-27 18:26:09 +01001185
1186errorloc <code> <url>
1187errorloc302 <code> <url>
1188 Return an HTTP redirection to a URL instead of errors generated by HAProxy
1189 May be used in sections : defaults | frontend | listen | backend
1190 yes | yes | yes | yes
1191 Arguments :
1192 <code> is the HTTP status code. Currently, HAProxy is capable of
1193 generating codes 400, 403, 408, 500, 502, 503, and 504.
1194
1195 <url> it is the exact contents of the "Location" header. It may contain
1196 either a relative URI to an error page hosted on the same site,
1197 or an absolute URI designating an error page on another site.
1198 Special care should be given to relative URIs to avoid redirect
1199 loops if the URI itself may generate the same error (eg: 500).
1200
1201 It is important to understand that this keyword is not meant to rewrite
1202 errors returned by the server, but errors detected and returned by HAProxy.
1203 This is why the list of supported errors is limited to a small set.
1204
1205 Note that both keyword return the HTTP 302 status code, which tells the
1206 client to fetch the designated URL using the same HTTP method. This can be
1207 quite problematic in case of non-GET methods such as POST, because the URL
1208 sent to the client might not be allowed for something other than GET. To
1209 workaround this problem, please use "errorloc303" which send the HTTP 303
1210 status code, indicating to the client that the URL must be fetched with a GET
1211 request.
1212
1213 See also : "errorfile", "errorloc303"
1214
1215
1216errorloc303 <code> <url>
1217 Return an HTTP redirection to a URL instead of errors generated by HAProxy
1218 May be used in sections : defaults | frontend | listen | backend
1219 yes | yes | yes | yes
1220 Arguments :
1221 <code> is the HTTP status code. Currently, HAProxy is capable of
1222 generating codes 400, 403, 408, 500, 502, 503, and 504.
1223
1224 <url> it is the exact contents of the "Location" header. It may contain
1225 either a relative URI to an error page hosted on the same site,
1226 or an absolute URI designating an error page on another site.
1227 Special care should be given to relative URIs to avoid redirect
1228 loops if the URI itself may generate the same error (eg: 500).
1229
1230 It is important to understand that this keyword is not meant to rewrite
1231 errors returned by the server, but errors detected and returned by HAProxy.
1232 This is why the list of supported errors is limited to a small set.
1233
1234 Note that both keyword return the HTTP 303 status code, which tells the
1235 client to fetch the designated URL using the same HTTP GET method. This
1236 solves the usual problems associated with "errorloc" and the 302 code. It is
1237 possible that some very old browsers designed before HTTP/1.1 do not support
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001238 it, but no such problem has been reported till now.
Willy Tarreau2769aa02007-12-27 18:26:09 +01001239
1240 See also : "errorfile", "errorloc", "errorloc302"
1241
1242
1243fullconn <conns>
1244 Specify at what backend load the servers will reach their maxconn
1245 May be used in sections : defaults | frontend | listen | backend
1246 yes | no | yes | yes
1247 Arguments :
1248 <conns> is the number of connections on the backend which will make the
1249 servers use the maximal number of connections.
1250
Willy Tarreau198a7442008-01-17 12:05:32 +01001251 When a server has a "maxconn" parameter specified, it means that its number
Willy Tarreau2769aa02007-12-27 18:26:09 +01001252 of concurrent connections will never go higher. Additionally, if it has a
Willy Tarreau198a7442008-01-17 12:05:32 +01001253 "minconn" parameter, it indicates a dynamic limit following the backend's
Willy Tarreau2769aa02007-12-27 18:26:09 +01001254 load. The server will then always accept at least <minconn> connections,
1255 never more than <maxconn>, and the limit will be on the ramp between both
1256 values when the backend has less than <conns> concurrent connections. This
1257 makes it possible to limit the load on the servers during normal loads, but
1258 push it further for important loads without overloading the servers during
1259 exceptionnal loads.
1260
1261 Example :
1262 # The servers will accept between 100 and 1000 concurrent connections each
1263 # and the maximum of 1000 will be reached when the backend reaches 10000
1264 # connections.
1265 backend dynamic
1266 fullconn 10000
1267 server srv1 dyn1:80 minconn 100 maxconn 1000
1268 server srv2 dyn2:80 minconn 100 maxconn 1000
1269
1270 See also : "maxconn", "server"
1271
1272
1273grace <time>
1274 Maintain a proxy operational for some time after a soft stop
1275 May be used in sections : defaults | frontend | listen | backend
1276 no | yes | yes | yes
1277 Arguments :
1278 <time> is the time (by default in milliseconds) for which the instance
1279 will remain operational with the frontend sockets still listening
1280 when a soft-stop is received via the SIGUSR1 signal.
1281
1282 This may be used to ensure that the services disappear in a certain order.
1283 This was designed so that frontends which are dedicated to monitoring by an
1284 external equipement fail immediately while other ones remain up for the time
1285 needed by the equipment to detect the failure.
1286
1287 Note that currently, there is very little benefit in using this parameter,
1288 and it may in fact complicate the soft-reconfiguration process more than
1289 simplify it.
1290
Willy Tarreau0ba27502007-12-24 16:55:16 +01001291
1292http-check disable-on-404
1293 Enable a maintenance mode upon HTTP/404 response to health-checks
1294 May be used in sections : defaults | frontend | listen | backend
Willy Tarreau2769aa02007-12-27 18:26:09 +01001295 yes | no | yes | yes
Willy Tarreau0ba27502007-12-24 16:55:16 +01001296 Arguments : none
1297
1298 When this option is set, a server which returns an HTTP code 404 will be
1299 excluded from further load-balancing, but will still receive persistent
1300 connections. This provides a very convenient method for Web administrators
1301 to perform a graceful shutdown of their servers. It is also important to note
1302 that a server which is detected as failed while it was in this mode will not
1303 generate an alert, just a notice. If the server responds 2xx or 3xx again, it
1304 will immediately be reinserted into the farm. The status on the stats page
1305 reports "NOLB" for a server in this mode. It is important to note that this
1306 option only works in conjunction with the "httpchk" option.
1307
Willy Tarreau2769aa02007-12-27 18:26:09 +01001308 See also : "option httpchk"
1309
1310
1311log global
1312log <address> <facility> [<level>]
1313 Enable per-instance logging of events and traffic.
1314 May be used in sections : defaults | frontend | listen | backend
1315 yes | yes | yes | yes
1316 Arguments :
1317 global should be used when the instance's logging parameters are the
1318 same as the global ones. This is the most common usage. "global"
1319 replaces <address>, <facility> and <level> with those of the log
1320 entries found in the "global" section. Only one "log global"
1321 statement may be used per instance, and this form takes no other
1322 parameter.
1323
1324 <address> indicates where to send the logs. It takes the same format as
1325 for the "global" section's logs, and can be one of :
1326
1327 - An IPv4 address optionally followed by a colon (':') and a UDP
1328 port. If no port is specified, 514 is used by default (the
1329 standard syslog port).
1330
1331 - A filesystem path to a UNIX domain socket, keeping in mind
1332 considerations for chroot (be sure the path is accessible
1333 inside the chroot) and uid/gid (be sure the path is
1334 appropriately writeable).
1335
1336 <facility> must be one of the 24 standard syslog facilities :
1337
1338 kern user mail daemon auth syslog lpr news
1339 uucp cron auth2 ftp ntp audit alert cron2
1340 local0 local1 local2 local3 local4 local5 local6 local7
1341
1342 <level> is optional and can be specified to filter outgoing messages. By
1343 default, all messages are sent. If a level is specified, only
1344 messages with a severity at least as important as this level
1345 will be sent. 8 levels are known :
1346
1347 emerg alert crit err warning notice info debug
1348
1349 Note that up to two "log" entries may be specified per instance. However, if
1350 "log global" is used and if the "global" section already contains 2 log
1351 entries, then additional log entries will be ignored.
1352
1353 Also, it is important to keep in mind that it is the frontend which decides
1354 what to log, and that in case of content switching, the log entries from the
1355 backend will be ignored.
1356
1357 Example :
1358 log global
1359 log 127.0.0.1:514 local0 notice
1360
1361
1362maxconn <conns>
1363 Fix the maximum number of concurrent connections on a frontend
1364 May be used in sections : defaults | frontend | listen | backend
1365 yes | yes | yes | no
1366 Arguments :
1367 <conns> is the maximum number of concurrent connections the frontend will
1368 accept to serve. Excess connections will be queued by the system
1369 in the socket's listen queue and will be served once a connection
1370 closes.
1371
1372 If the system supports it, it can be useful on big sites to raise this limit
1373 very high so that haproxy manages connection queues, instead of leaving the
1374 clients with unanswered connection attempts. This value should not exceed the
1375 global maxconn. Also, keep in mind that a connection contains two buffers
1376 of 8kB each, as well as some other data resulting in about 17 kB of RAM being
1377 consumed per established connection. That means that a medium system equipped
1378 with 1GB of RAM can withstand around 40000-50000 concurrent connections if
1379 properly tuned.
1380
1381 Also, when <conns> is set to large values, it is possible that the servers
1382 are not sized to accept such loads, and for this reason it is generally wise
1383 to assign them some reasonable connection limits.
1384
1385 See also : "server", global section's "maxconn", "fullconn"
1386
1387
1388mode { tcp|http|health }
1389 Set the running mode or protocol of the instance
1390 May be used in sections : defaults | frontend | listen | backend
1391 yes | yes | yes | yes
1392 Arguments :
1393 tcp The instance will work in pure TCP mode. A full-duplex connection
1394 will be established between clients and servers, and no layer 7
1395 examination will be performed. This is the default mode. It
1396 should be used for SSL, SSH, SMTP, ...
1397
1398 http The instance will work in HTTP mode. The client request will be
1399 analyzed in depth before connecting to any server. Any request
1400 which is not RFC-compliant will be rejected. Layer 7 filtering,
1401 processing and switching will be possible. This is the mode which
1402 brings HAProxy most of its value.
1403
1404 health The instance will work in "health" mode. It will just reply "OK"
1405 to incoming connections and close the connection. Nothing will be
1406 logged. This mode is used to reply to external components health
1407 checks. This mode is deprecated and should not be used anymore as
1408 it is possible to do the same and even better by combining TCP or
1409 HTTP modes with the "monitor" keyword.
1410
1411 When doing content switching, it is mandatory that the frontend and the
1412 backend are in the same mode (generally HTTP), otherwise the configuration
1413 will be refused.
1414
1415 Example :
1416 defaults http_instances
1417 mode http
1418
1419 See also : "monitor", "monitor-net"
1420
Willy Tarreau0ba27502007-12-24 16:55:16 +01001421
1422monitor fail [if | unless] <condition>
Willy Tarreau2769aa02007-12-27 18:26:09 +01001423 Add a condition to report a failure to a monitor HTTP request.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001424 May be used in sections : defaults | frontend | listen | backend
1425 no | yes | yes | no
Willy Tarreau0ba27502007-12-24 16:55:16 +01001426 Arguments :
1427 if <cond> the monitor request will fail if the condition is satisfied,
1428 and will succeed otherwise. The condition should describe a
1429 combinated test which must induce a failure if all conditions
1430 are met, for instance a low number of servers both in a
1431 backend and its backup.
1432
1433 unless <cond> the monitor request will succeed only if the condition is
1434 satisfied, and will fail otherwise. Such a condition may be
1435 based on a test on the presence of a minimum number of active
1436 servers in a list of backends.
1437
1438 This statement adds a condition which can force the response to a monitor
1439 request to report a failure. By default, when an external component queries
1440 the URI dedicated to monitoring, a 200 response is returned. When one of the
1441 conditions above is met, haproxy will return 503 instead of 200. This is
1442 very useful to report a site failure to an external component which may base
1443 routing advertisements between multiple sites on the availability reported by
1444 haproxy. In this case, one would rely on an ACL involving the "nbsrv"
Willy Tarreau2769aa02007-12-27 18:26:09 +01001445 criterion. Note that "monitor fail" only works in HTTP mode.
Willy Tarreau0ba27502007-12-24 16:55:16 +01001446
1447 Example:
1448 frontend www
Willy Tarreau2769aa02007-12-27 18:26:09 +01001449 mode http
Willy Tarreau0ba27502007-12-24 16:55:16 +01001450 acl site_dead nbsrv(dynamic) lt 2
1451 acl site_dead nbsrv(static) lt 2
1452 monitor-uri /site_alive
1453 monitor fail if site_dead
1454
Willy Tarreau2769aa02007-12-27 18:26:09 +01001455 See also : "monitor-net", "monitor-uri"
1456
1457
1458monitor-net <source>
1459 Declare a source network which is limited to monitor requests
1460 May be used in sections : defaults | frontend | listen | backend
1461 yes | yes | yes | no
1462 Arguments :
1463 <source> is the source IPv4 address or network which will only be able to
1464 get monitor responses to any request. It can be either an IPv4
1465 address, a host name, or an address followed by a slash ('/')
1466 followed by a mask.
1467
1468 In TCP mode, any connection coming from a source matching <source> will cause
1469 the connection to be immediately closed without any log. This allows another
1470 equipement to probe the port and verify that it is still listening, without
1471 forwarding the connection to a remote server.
1472
1473 In HTTP mode, a connection coming from a source matching <source> will be
1474 accepted, the following response will be sent without waiting for a request,
1475 then the connection will be closed : "HTTP/1.0 200 OK". This is normally
1476 enough for any front-end HTTP probe to detect that the service is UP and
1477 running without forwarding the request to a backend server.
1478
1479 Monitor requests are processed very early. It is not possible to block nor
1480 divert them using ACLs. They cannot be logged either, and it is the intended
1481 purpose. They are only used to report HAProxy's health to an upper component,
1482 nothing more. Right now, it is not possible to set failure conditions on
1483 requests caught by "monitor-net".
1484
1485 Example :
1486 # addresses .252 and .253 are just probing us.
1487 frontend www
1488 monitor-net 192.168.0.252/31
1489
1490 See also : "monitor fail", "monitor-uri"
1491
1492
1493monitor-uri <uri>
1494 Intercept a URI used by external components' monitor requests
1495 May be used in sections : defaults | frontend | listen | backend
1496 yes | yes | yes | no
1497 Arguments :
1498 <uri> is the exact URI which we want to intercept to return HAProxy's
1499 health status instead of forwarding the request.
1500
1501 When an HTTP request referencing <uri> will be received on a frontend,
1502 HAProxy will not forward it nor log it, but instead will return either
1503 "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure
1504 conditions defined with "monitor fail". This is normally enough for any
1505 front-end HTTP probe to detect that the service is UP and running without
1506 forwarding the request to a backend server. Note that the HTTP method, the
1507 version and all headers are ignored, but the request must at least be valid
1508 at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
1509
1510 Monitor requests are processed very early. It is not possible to block nor
1511 divert them using ACLs. They cannot be logged either, and it is the intended
1512 purpose. They are only used to report HAProxy's health to an upper component,
1513 nothing more. However, it is possible to add any number of conditions using
1514 "monitor fail" and ACLs so that the result can be adjusted to whatever check
1515 can be imagined (most often the number of available servers in a backend).
1516
1517 Example :
1518 # Use /haproxy_test to report haproxy's status
1519 frontend www
1520 mode http
1521 monitor-uri /haproxy_test
1522
1523 See also : "monitor fail", "monitor-net"
1524
Willy Tarreau0ba27502007-12-24 16:55:16 +01001525
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001526option abortonclose
1527no option abortonclose
1528 Enable or disable early dropping of aborted requests pending in queues.
1529 May be used in sections : defaults | frontend | listen | backend
1530 yes | no | yes | yes
1531 Arguments : none
1532
1533 In presence of very high loads, the servers will take some time to respond.
1534 The per-instance connection queue will inflate, and the response time will
1535 increase respective to the size of the queue times the average per-session
1536 response time. When clients will wait for more than a few seconds, they will
Willy Tarreau198a7442008-01-17 12:05:32 +01001537 often hit the "STOP" button on their browser, leaving a useless request in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001538 the queue, and slowing down other users, and the servers as well, because the
1539 request will eventually be served, then aborted at the first error
1540 encountered while delivering the response.
1541
1542 As there is no way to distinguish between a full STOP and a simple output
1543 close on the client side, HTTP agents should be conservative and consider
1544 that the client might only have closed its output channel while waiting for
1545 the response. However, this introduces risks of congestion when lots of users
1546 do the same, and is completely useless nowadays because probably no client at
1547 all will close the session while waiting for the response. Some HTTP agents
1548 support this behaviour (Squid, Apache, HAProxy), and others do not (TUX, most
1549 hardware-based load balancers). So the probability for a closed input channel
Willy Tarreau198a7442008-01-17 12:05:32 +01001550 to represent a user hitting the "STOP" button is close to 100%, and the risk
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001551 of being the single component to break rare but valid traffic is extremely
1552 low, which adds to the temptation to be able to abort a session early while
1553 still not served and not pollute the servers.
1554
1555 In HAProxy, the user can choose the desired behaviour using the option
1556 "abortonclose". By default (without the option) the behaviour is HTTP
1557 compliant and aborted requests will be served. But when the option is
1558 specified, a session with an incoming channel closed will be aborted while
1559 it is still possible, either pending in the queue for a connection slot, or
1560 during the connection establishment if the server has not yet acknowledged
1561 the connection request. This considerably reduces the queue size and the load
1562 on saturated servers when users are tempted to click on STOP, which in turn
1563 reduces the response time for other users.
1564
1565 If this option has been enabled in a "defaults" section, it can be disabled
1566 in a specific instance by prepending the "no" keyword before it.
1567
1568 See also : "timeout queue" and server's "maxconn" and "maxqueue" parameters
1569
1570
1571option allbackups
1572no option allbackups
1573 Use either all backup servers at a time or only the first one
1574 May be used in sections : defaults | frontend | listen | backend
1575 yes | no | yes | yes
1576 Arguments : none
1577
1578 By default, the first operational backup server gets all traffic when normal
1579 servers are all down. Sometimes, it may be preferred to use multiple backups
1580 at once, because one will not be enough. When "option allbackups" is enabled,
1581 the load balancing will be performed among all backup servers when all normal
1582 ones are unavailable. The same load balancing algorithm will be used and the
1583 servers' weights will be respected. Thus, there will not be any priority
1584 order between the backup servers anymore.
1585
1586 This option is mostly used with static server farms dedicated to return a
1587 "sorry" page when an application is completely offline.
1588
1589 If this option has been enabled in a "defaults" section, it can be disabled
1590 in a specific instance by prepending the "no" keyword before it.
1591
1592
1593option checkcache
1594no option checkcache
1595 Analyze all server responses and block requests with cachable cookies
1596 May be used in sections : defaults | frontend | listen | backend
1597 yes | no | yes | yes
1598 Arguments : none
1599
1600 Some high-level frameworks set application cookies everywhere and do not
1601 always let enough control to the developer to manage how the responses should
1602 be cached. When a session cookie is returned on a cachable object, there is a
1603 high risk of session crossing or stealing between users traversing the same
1604 caches. In some situations, it is better to block the response than to let
1605 some sensible session information go in the wild.
1606
1607 The option "checkcache" enables deep inspection of all server responses for
1608 strict compliance with HTTP specification in terms of cachability. It
Willy Tarreau198a7442008-01-17 12:05:32 +01001609 carefully checks "Cache-control", "Pragma" and "Set-cookie" headers in server
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001610 response to check if there's a risk of caching a cookie on a client-side
1611 proxy. When this option is enabled, the only responses which can be delivered
Willy Tarreau198a7442008-01-17 12:05:32 +01001612 to the client are :
1613 - all those without "Set-Cookie" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001614 - all those with a return code other than 200, 203, 206, 300, 301, 410,
Willy Tarreau198a7442008-01-17 12:05:32 +01001615 provided that the server has not set a "Cache-control: public" header ;
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001616 - all those that come from a POST request, provided that the server has not
1617 set a 'Cache-Control: public' header ;
1618 - those with a 'Pragma: no-cache' header
1619 - those with a 'Cache-control: private' header
1620 - those with a 'Cache-control: no-store' header
1621 - those with a 'Cache-control: max-age=0' header
1622 - those with a 'Cache-control: s-maxage=0' header
1623 - those with a 'Cache-control: no-cache' header
1624 - those with a 'Cache-control: no-cache="set-cookie"' header
1625 - those with a 'Cache-control: no-cache="set-cookie,' header
1626 (allowing other fields after set-cookie)
1627
1628 If a response doesn't respect these requirements, then it will be blocked
Willy Tarreau198a7442008-01-17 12:05:32 +01001629 just as if it was from an "rspdeny" filter, with an "HTTP 502 bad gateway".
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001630 The session state shows "PH--" meaning that the proxy blocked the response
1631 during headers processing. Additionnaly, an alert will be sent in the logs so
1632 that admins are informed that there's something to be fixed.
1633
1634 Due to the high impact on the application, the application should be tested
1635 in depth with the option enabled before going to production. It is also a
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001636 good practice to always activate it during tests, even if it is not used in
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001637 production, as it will report potentially dangerous application behaviours.
1638
1639 If this option has been enabled in a "defaults" section, it can be disabled
1640 in a specific instance by prepending the "no" keyword before it.
1641
1642
1643option clitcpka
1644no option clitcpka
1645 Enable or disable the sending of TCP keepalive packets on the client side
1646 May be used in sections : defaults | frontend | listen | backend
1647 yes | yes | yes | no
1648 Arguments : none
1649
1650 When there is a firewall or any session-aware component between a client and
1651 a server, and when the protocol involves very long sessions with long idle
1652 periods (eg: remote desktops), there is a risk that one of the intermediate
1653 components decides to expire a session which has remained idle for too long.
1654
1655 Enabling socket-level TCP keep-alives makes the system regularly send packets
1656 to the other end of the connection, leaving it active. The delay between
1657 keep-alive probes is controlled by the system only and depends both on the
1658 operating system and its tuning parameters.
1659
1660 It is important to understand that keep-alive packets are neither emitted nor
1661 received at the application level. It is only the network stacks which sees
1662 them. For this reason, even if one side of the proxy already uses keep-alives
1663 to maintain its connection alive, those keep-alive packets will not be
1664 forwarded to the other side of the proxy.
1665
1666 Please note that this has nothing to do with HTTP keep-alive.
1667
1668 Using option "clitcpka" enables the emission of TCP keep-alive probes on the
1669 client side of a connection, which should help when session expirations are
1670 noticed between HAProxy and a client.
1671
1672 If this option has been enabled in a "defaults" section, it can be disabled
1673 in a specific instance by prepending the "no" keyword before it.
1674
1675 See also : "option srvtcpka", "option tcpka"
1676
1677
Willy Tarreau0ba27502007-12-24 16:55:16 +01001678option contstats
1679 Enable continuous traffic statistics updates
1680 May be used in sections : defaults | frontend | listen | backend
1681 yes | yes | yes | no
1682 Arguments : none
1683
1684 By default, counters used for statistics calculation are incremented
1685 only when a session finishes. It works quite well when serving small
1686 objects, but with big ones (for example large images or archives) or
1687 with A/V streaming, a graph generated from haproxy counters looks like
1688 a hedgehog. With this option enabled counters get incremented continuously,
1689 during a whole session. Recounting touches a hotpath directly so
1690 it is not enabled by default, as it has small performance impact (~0.5%).
1691
1692
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001693option dontlognull
1694no option dontlognull
1695 Enable or disable logging of null connections
1696 May be used in sections : defaults | frontend | listen | backend
1697 yes | yes | yes | no
1698 Arguments : none
1699
1700 In certain environments, there are components which will regularly connect to
1701 various systems to ensure that they are still alive. It can be the case from
1702 another load balancer as well as from monitoring systems. By default, even a
1703 simple port probe or scan will produce a log. If those connections pollute
1704 the logs too much, it is possible to enable option "dontlognull" to indicate
1705 that a connection on which no data has been transferred will not be logged,
1706 which typically corresponds to those probes.
1707
1708 It is generally recommended not to use this option in uncontrolled
1709 environments (eg: internet), otherwise scans and other malicious activities
1710 would not be logged.
1711
1712 If this option has been enabled in a "defaults" section, it can be disabled
1713 in a specific instance by prepending the "no" keyword before it.
1714
Willy Tarreauced27012008-01-17 20:35:34 +01001715 See also : "log", "monitor-net", "monitor-uri" and section 2.6 about logging.
Willy Tarreaubf1f8162007-12-28 17:42:56 +01001716
1717
1718option forceclose
1719no option forceclose
1720 Enable or disable active connection closing after response is transferred.
1721 May be used in sections : defaults | frontend | listen | backend
1722 yes | no | yes | yes
1723 Arguments : none
1724
1725 Some HTTP servers do not necessarily close the connections when they receive
1726 the "Connection: close" set by "option httpclose", and if the client does not
1727 close either, then the connection remains open till the timeout expires. This
1728 causes high number of simultaneous connections on the servers and shows high
1729 global session times in the logs.
1730
1731 When this happens, it is possible to use "option forceclose". It will
1732 actively close the outgoing server channel as soon as the server begins to
1733 reply and only if the request buffer is empty. Note that this should NOT be
1734 used if CONNECT requests are expected between the client and the server. This
1735 option implicitly enables the "httpclose" option.
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 See also : "option httpclose"
1741
1742
Willy Tarreauc27debf2008-01-06 08:57:02 +01001743option forwardfor [ except <network> ]
1744 Enable insertion of the X-Forwarded-For header to requests sent to servers
1745 May be used in sections : defaults | frontend | listen | backend
1746 yes | yes | yes | yes
1747 Arguments :
1748 <network> is an optional argument used to disable this option for sources
1749 matching <network>
1750
1751 Since HAProxy works in reverse-proxy mode, the servers see its IP address as
1752 their client address. This is sometimes annoying when the client's IP address
1753 is expected in server logs. To solve this problem, the well-known HTTP header
1754 "X-Forwarded-For" may be added by HAProxy to all requests sent to the server.
1755 This header contains a value representing the client's IP address. Since this
1756 header is always appended at the end of the existing header list, the server
1757 must be configured to always use the last occurrence of this header only. See
1758 the server's manual to find how to enable use of this standard header.
1759
1760 Sometimes, a same HAProxy instance may be shared between a direct client
1761 access and a reverse-proxy access (for instance when an SSL reverse-proxy is
1762 used to decrypt HTTPS traffic). It is possible to disable the addition of the
1763 header for a known source address or network by adding the "except" keyword
1764 followed by the network address. In this case, any source IP matching the
1765 network will not cause an addition of this header. Most common uses are with
1766 private networks or 127.0.0.1.
1767
1768 This option may be specified either in the frontend or in the backend. If at
1769 least one of them uses it, the header will be added.
1770
1771 It is important to note that as long as HAProxy does not support keep-alive
1772 connections, only the first request of a connection will receive the header.
1773 For this reason, it is important to ensure that "option httpclose" is set
1774 when using this option.
1775
1776 Example :
1777 # Public HTTP address also used by stunnel on the same machine
1778 frontend www
1779 mode http
1780 option forwardfor except 127.0.0.1 # stunnel already adds the header
1781
1782 See also : "option httpclose"
1783
1784
1785option http_proxy
1786no option http_proxy
1787 Enable or disable plain HTTP proxy mode
1788 May be used in sections : defaults | frontend | listen | backend
1789 yes | yes | yes | yes
1790 Arguments : none
1791
1792 It sometimes happens that people need a pure HTTP proxy which understands
1793 basic proxy requests without caching nor any fancy feature. In this case,
1794 it may be worth setting up an HAProxy instance with the "option http_proxy"
1795 set. In this mode, no server is declared, and the connection is forwarded to
1796 the IP address and port found in the URL after the "http://" scheme.
1797
1798 No host address resolution is performed, so this only works when pure IP
1799 addresses are passed. Since this option's usage perimeter is rather limited,
1800 it will probably be used only by experts who know they need exactly it. Last,
1801 if the clients are susceptible of sending keep-alive requests, it will be
1802 needed to add "option http_close" to ensure that all requests will correctly
1803 be analyzed.
1804
1805 If this option has been enabled in a "defaults" section, it can be disabled
1806 in a specific instance by prepending the "no" keyword before it.
1807
1808 Example :
1809 # this backend understands HTTP proxy requests and forwards them directly.
1810 backend direct_forward
1811 option httpclose
1812 option http_proxy
1813
1814 See also : "option httpclose"
1815
1816
1817option httpchk
1818option httpchk <uri>
1819option httpchk <method> <uri>
1820option httpchk <method> <uri> <version>
1821 Enable HTTP protocol to check on the servers health
1822 May be used in sections : defaults | frontend | listen | backend
1823 yes | no | yes | yes
1824 Arguments :
1825 <method> is the optional HTTP method used with the requests. When not set,
1826 the "OPTIONS" method is used, as it generally requires low server
1827 processing and is easy to filter out from the logs. Any method
1828 may be used, though it is not recommended to invent non-standard
1829 ones.
1830
1831 <uri> is the URI referenced in the HTTP requests. It defaults to " / "
1832 which is accessible by default on almost any server, but may be
1833 changed to any other URI. Query strings are permitted.
1834
1835 <version> is the optional HTTP version string. It defaults to "HTTP/1.0"
1836 but some servers might behave incorrectly in HTTP 1.0, so turning
1837 it to HTTP/1.1 may sometimes help. Note that the Host field is
1838 mandatory in HTTP/1.1, and as a trick, it is possible to pass it
1839 after "\r\n" following the version string.
1840
1841 By default, server health checks only consist in trying to establish a TCP
1842 connection. When "option httpchk" is specified, a complete HTTP request is
1843 sent once the TCP connection is established, and responses 2xx and 3xx are
1844 considered valid, while all other ones indicate a server failure, including
1845 the lack of any response.
1846
1847 The port and interval are specified in the server configuration.
1848
1849 This option does not necessarily require an HTTP backend, it also works with
1850 plain TCP backends. This is particularly useful to check simple scripts bound
1851 to some dedicated ports using the inetd daemon.
1852
1853 Examples :
1854 # Relay HTTPS traffic to Apache instance and check service availability
1855 # using HTTP request "OPTIONS * HTTP/1.1" on port 80.
1856 backend https_relay
1857 mode tcp
1858 option httpchk OPTIONS * HTTP/1.1\r\nHost: www
1859 server apache1 192.168.1.1:443 check port 80
1860
1861 See also : "option ssl-hello-chk", "option smtpchk", "http-check" and the
1862 "check", "port" and "interval" server options.
1863
1864
1865option httpclose
1866no option httpclose
1867 Enable or disable passive HTTP connection closing
1868 May be used in sections : defaults | frontend | listen | backend
1869 yes | yes | yes | yes
1870 Arguments : none
1871
1872 As stated in section 2.1, HAProxy does not yes support the HTTP keep-alive
1873 mode. So by default, if a client communicates with a server in this mode, it
1874 will only analyze, log, and process the first request of each connection. To
1875 workaround this limitation, it is possible to specify "option httpclose". It
1876 will check if a "Connection: close" header is already set in each direction,
1877 and will add one if missing. Each end should react to this by actively
1878 closing the TCP connection after each transfer, thus resulting in a switch to
1879 the HTTP close mode. Any "Connection" header different from "close" will also
1880 be removed.
1881
1882 It seldom happens that some servers incorrectly ignore this header and do not
1883 close the connection eventough they reply "Connection: close". For this
1884 reason, they are not compatible with older HTTP 1.0 browsers. If this
1885 happens it is possible to use the "option forceclose" which actively closes
1886 the request connection once the server responds.
1887
1888 This option may be set both in a frontend and in a backend. It is enabled if
1889 at least one of the frontend or backend holding a connection has it enabled.
1890 If "option forceclose" is specified too, it has precedence over "httpclose".
1891
1892 If this option has been enabled in a "defaults" section, it can be disabled
1893 in a specific instance by prepending the "no" keyword before it.
1894
1895 See also : "option forceclose"
1896
1897
1898option httplog
1899 Enable logging of HTTP request, session state and timers
1900 May be used in sections : defaults | frontend | listen | backend
1901 yes | yes | yes | yes
1902 Arguments : none
1903
1904 By default, the log output format is very poor, as it only contains the
1905 source and destination addresses, and the instance name. By specifying
1906 "option httplog", each log line turns into a much richer format including,
1907 but not limited to, the HTTP request, the connection timers, the session
1908 status, the connections numbers, the captured headers and cookies, the
1909 frontend, backend and server name, and of course the source address and
1910 ports.
1911
1912 This option may be set either in the frontend or the backend.
1913
Willy Tarreauced27012008-01-17 20:35:34 +01001914 See also : section 2.6 about logging.
Willy Tarreauc27debf2008-01-06 08:57:02 +01001915
Willy Tarreauc27debf2008-01-06 08:57:02 +01001916
1917option logasap
1918no option logasap
1919 Enable or disable early logging of HTTP requests
1920 May be used in sections : defaults | frontend | listen | backend
1921 yes | yes | yes | no
1922 Arguments : none
1923
1924 By default, HTTP requests are logged upon termination so that the total
1925 transfer time and the number of bytes appear in the logs. When large objects
1926 are being transferred, it may take a while before the request appears in the
1927 logs. Using "option logasap", the request gets logged as soon as the server
1928 sends the complete headers. The only missing information in the logs will be
1929 the total number of bytes which will indicate everything except the amount
1930 of data transferred, and the total time which will not take the transfer
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01001931 time into account. In such a situation, it's a good practice to capture the
Willy Tarreauc27debf2008-01-06 08:57:02 +01001932 "Content-Length" response header so that the logs at least indicate how many
1933 bytes are expected to be transferred.
1934
Willy Tarreauced27012008-01-17 20:35:34 +01001935 See also : "option httplog", "capture response header", and section 2.6 about
Willy Tarreauc27debf2008-01-06 08:57:02 +01001936 logging.
1937
1938
Willy Tarreaua453bdd2008-01-08 19:50:52 +01001939option nolinger
1940no option nolinger
1941 Enable or disable immediate session ressource cleaning after close
1942 May be used in sections: defaults | frontend | listen | backend
1943 yes | yes | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01001944 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01001945
1946 When clients or servers abort connections in a dirty way (eg: they are
1947 physically disconnected), the session timeouts triggers and the session is
1948 closed. But it will remain in FIN_WAIT1 state for some time in the system,
1949 using some resources and possibly limiting the ability to establish newer
1950 connections.
1951
1952 When this happens, it is possible to activate "option nolinger" which forces
1953 the system to immediately remove any socket's pending data on close. Thus,
1954 the session is instantly purged from the system's tables. This usually has
1955 side effects such as increased number of TCP resets due to old retransmits
1956 getting immediately rejected. Some firewalls may sometimes complain about
1957 this too.
1958
1959 For this reason, it is not recommended to use this option when not absolutely
1960 needed. You know that you need it when you have thousands of FIN_WAIT1
1961 sessions on your system (TIME_WAIT ones do not count).
1962
1963 This option may be used both on frontends and backends, depending on the side
1964 where it is required. Use it on the frontend for clients, and on the backend
1965 for servers.
1966
1967 If this option has been enabled in a "defaults" section, it can be disabled
1968 in a specific instance by prepending the "no" keyword before it.
1969
1970
1971option persist
1972no option persist
1973 Enable or disable forced persistence on down servers
1974 May be used in sections: defaults | frontend | listen | backend
1975 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01001976 Arguments : none
Willy Tarreaua453bdd2008-01-08 19:50:52 +01001977
1978 When an HTTP request reaches a backend with a cookie which references a dead
1979 server, by default it is redispatched to another server. It is possible to
1980 force the request to be sent to the dead server first using "option persist"
1981 if absolutely needed. A common use case is when servers are under extreme
1982 load and spend their time flapping. In this case, the users would still be
1983 directed to the server they opened the session on, in the hope they would be
1984 correctly served. It is recommended to use "option redispatch" in conjunction
1985 with this option so that in the event it would not be possible to connect to
1986 the server at all (server definitely dead), the client would finally be
1987 redirected to another valid server.
1988
1989 If this option has been enabled in a "defaults" section, it can be disabled
1990 in a specific instance by prepending the "no" keyword before it.
1991
1992 See also : "option redispatch", "retries"
1993
1994
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01001995option redispatch
1996no option redispatch
1997 Enable or disable session redistribution in case of connection failure
1998 May be used in sections: defaults | frontend | listen | backend
1999 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002000 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002001
2002 In HTTP mode, if a server designated by a cookie is down, clients may
2003 definitely stick to it because they cannot flush the cookie, so they will not
2004 be able to access the service anymore.
2005
2006 Specifying "option redispatch" will allow the proxy to break their
2007 persistence and redistribute them to a working server.
2008
2009 It also allows to retry last connection to another server in case of multiple
2010 connection failures. Of course, it requires having "retries" set to a nonzero
2011 value.
2012
2013 This form is the preferred form, which replaces both the "redispatch" and
2014 "redisp" keywords.
2015
2016 If this option has been enabled in a "defaults" section, it can be disabled
2017 in a specific instance by prepending the "no" keyword before it.
2018
2019 See also : "redispatch", "retries"
2020
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002021
2022option smtpchk
2023option smtpchk <hello> <domain>
2024 Use SMTP health checks for server testing
2025 May be used in sections : defaults | frontend | listen | backend
2026 yes | no | yes | yes
2027 Arguments :
2028 <hello> is an optional argument. It is the "hello" command to use. It can
2029 be either "HELO" (for SMTP) or "EHLO" (for ESTMP). All other
2030 values will be turned into the default command ("HELO").
2031
2032 <domain> is the domain name to present to the server. It may only be
2033 specified (and is mandatory) if the hello command has been
2034 specified. By default, "localhost" is used.
2035
2036 When "option smtpchk" is set, the health checks will consist in TCP
2037 connections followed by an SMTP command. By default, this command is
2038 "HELO localhost". The server's return code is analyzed and only return codes
2039 starting with a "2" will be considered as valid. All other responses,
2040 including a lack of response will constitute an error and will indicate a
2041 dead server.
2042
2043 This test is meant to be used with SMTP servers or relays. Depending on the
2044 request, it is possible that some servers do not log each connection attempt,
2045 so you may want to experiment to improve the behaviour. Using telnet on port
2046 25 is often easier than adjusting the configuration.
2047
2048 Most often, an incoming SMTP server needs to see the client's IP address for
2049 various purposes, including spam filtering, anti-spoofing and logging. When
2050 possible, it is often wise to masquerade the client's IP address when
2051 connecting to the server using the "usesrc" argument of the "source" keyword,
2052 which requires the cttproxy feature to be compiled in.
2053
2054 Example :
2055 option smtpchk HELO mydomain.org
2056
2057 See also : "option httpchk", "source"
2058
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002059
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002060option srvtcpka
2061no option srvtcpka
2062 Enable or disable the sending of TCP keepalive packets on the server side
2063 May be used in sections : defaults | frontend | listen | backend
2064 yes | no | yes | yes
2065 Arguments : none
2066
2067 When there is a firewall or any session-aware component between a client and
2068 a server, and when the protocol involves very long sessions with long idle
2069 periods (eg: remote desktops), there is a risk that one of the intermediate
2070 components decides to expire a session which has remained idle for too long.
2071
2072 Enabling socket-level TCP keep-alives makes the system regularly send packets
2073 to the other end of the connection, leaving it active. The delay between
2074 keep-alive probes is controlled by the system only and depends both on the
2075 operating system and its tuning parameters.
2076
2077 It is important to understand that keep-alive packets are neither emitted nor
2078 received at the application level. It is only the network stacks which sees
2079 them. For this reason, even if one side of the proxy already uses keep-alives
2080 to maintain its connection alive, those keep-alive packets will not be
2081 forwarded to the other side of the proxy.
2082
2083 Please note that this has nothing to do with HTTP keep-alive.
2084
2085 Using option "srvtcpka" enables the emission of TCP keep-alive probes on the
2086 server side of a connection, which should help when session expirations are
2087 noticed between HAProxy and a server.
2088
2089 If this option has been enabled in a "defaults" section, it can be disabled
2090 in a specific instance by prepending the "no" keyword before it.
2091
2092 See also : "option clitcpka", "option tcpka"
2093
2094
Willy Tarreaua453bdd2008-01-08 19:50:52 +01002095option ssl-hello-chk
2096 Use SSLv3 client hello health checks for server testing
2097 May be used in sections : defaults | frontend | listen | backend
2098 yes | no | yes | yes
2099 Arguments : none
2100
2101 When some SSL-based protocols are relayed in TCP mode through HAProxy, it is
2102 possible to test that the server correctly talks SSL instead of just testing
2103 that it accepts the TCP connection. When "option ssl-hello-chk" is set, pure
2104 SSLv3 client hello messages are sent once the connection is established to
2105 the server, and the response is analyzed to find an SSL server hello message.
2106 The server is considered valid only when the response contains this server
2107 hello message.
2108
2109 All servers tested till there correctly reply to SSLv3 client hello messages,
2110 and most servers tested do not even log the requests containing only hello
2111 messages, which is appreciable.
2112
2113 See also: "option httpchk"
2114
2115
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002116option tcpka
2117 Enable or disable the sending of TCP keepalive packets on both sides
2118 May be used in sections : defaults | frontend | listen | backend
2119 yes | yes | yes | yes
2120 Arguments : none
2121
2122 When there is a firewall or any session-aware component between a client and
2123 a server, and when the protocol involves very long sessions with long idle
2124 periods (eg: remote desktops), there is a risk that one of the intermediate
2125 components decides to expire a session which has remained idle for too long.
2126
2127 Enabling socket-level TCP keep-alives makes the system regularly send packets
2128 to the other end of the connection, leaving it active. The delay between
2129 keep-alive probes is controlled by the system only and depends both on the
2130 operating system and its tuning parameters.
2131
2132 It is important to understand that keep-alive packets are neither emitted nor
2133 received at the application level. It is only the network stacks which sees
2134 them. For this reason, even if one side of the proxy already uses keep-alives
2135 to maintain its connection alive, those keep-alive packets will not be
2136 forwarded to the other side of the proxy.
2137
2138 Please note that this has nothing to do with HTTP keep-alive.
2139
2140 Using option "tcpka" enables the emission of TCP keep-alive probes on both
2141 the client and server sides of a connection. Note that this is meaningful
2142 only in "defaults" or "listen" sections. If this option is used in a
2143 frontend, only the client side will get keep-alives, and if this option is
2144 used in a backend, only the server side will get keep-alives. For this
2145 reason, it is strongly recommended to explicitly use "option clitcpka" and
2146 "option srvtcpka" when the configuration is split between frontends and
2147 backends.
2148
2149 See also : "option clitcpka", "option srvtcpka"
2150
Willy Tarreau844e3c52008-01-11 16:28:18 +01002151
2152option tcplog
2153 Enable advanced logging of TCP connections with session state and timers
2154 May be used in sections : defaults | frontend | listen | backend
2155 yes | yes | yes | yes
2156 Arguments : none
2157
2158 By default, the log output format is very poor, as it only contains the
2159 source and destination addresses, and the instance name. By specifying
2160 "option tcplog", each log line turns into a much richer format including, but
2161 not limited to, the connection timers, the session status, the connections
2162 numbers, the frontend, backend and server name, and of course the source
2163 address and ports. This option is useful for pure TCP proxies in order to
2164 find which of the client or server disconnects or times out. For normal HTTP
2165 proxies, it's better to use "option httplog" which is even more complete.
2166
2167 This option may be set either in the frontend or the backend.
2168
Willy Tarreauced27012008-01-17 20:35:34 +01002169 See also : "option httplog", and section 2.6 about logging.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002170
2171
2172option tcpsplice [ experimental ]
2173 Enable linux kernel-based acceleration of data relaying
2174 May be used in sections : defaults | frontend | listen | backend
2175 yes | yes | yes | yes
2176 Arguments : none
2177
2178 This option is only available when HAProxy has been built for use on Linux
2179 with USE_TCPSPLICE=1. This option requires a kernel patch which is available
2180 on http://www.linux-l7sw.org/.
2181
2182 When "option tcpsplice" is set, as soon as the server's response headers have
2183 been transferred, the session handling is transferred to the kernel which
2184 will forward all subsequent data from the server to the client untill the
2185 session closes. This leads to much faster data transfers between client and
2186 server since the data is not copied twice between kernel and user space, but
2187 there are some limitations such as the lack of information about the number
2188 of bytes transferred and the total transfer time.
2189
2190 This is an experimental feature. It happens to reliably work but issues
2191 caused by corner cases are to be expected.
2192
2193 Note that this option requires that the process permanently runs with
2194 CAP_NETADMIN privileges, which most often translates into running as root.
2195
2196
2197option transparent
2198no option transparent
2199 Enable client-side transparent proxying
2200 May be used in sections : defaults | frontend | listen | backend
2201 yes | yes | yes | no
2202 Arguments : none
2203
2204 This option was introduced in order to provide layer 7 persistence to layer 3
2205 load balancers. The idea is to use the OS's ability to redirect an incoming
2206 connection for a remote address to a local process (here HAProxy), and let
2207 this process know what address was initially requested. When this option is
2208 used, sessions without cookies will be forwarded to the original destination
2209 IP address of the incoming request (which should match that of another
2210 equipment), while requests with cookies will still be forwarded to the
2211 appropriate server.
2212
2213 Note that contrary to a common belief, this option does NOT make HAProxy
2214 present the client's IP to the server when establishing the connection.
2215
2216 Use of this option is really discouraged, and since no really valid use of it
2217 has been reported for years, it will probably be removed in future versions.
2218
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002219 See also: the "usersrc" argument of the "source" keyword, and the
2220 "transparent" option of the "bind" keyword.
Willy Tarreau844e3c52008-01-11 16:28:18 +01002221
Willy Tarreaubf1f8162007-12-28 17:42:56 +01002222
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002223redisp (deprecated)
2224redispatch (deprecated)
2225 Enable or disable session redistribution in case of connection failure
2226 May be used in sections: defaults | frontend | listen | backend
2227 yes | no | yes | yes
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002228 Arguments : none
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002229
2230 In HTTP mode, if a server designated by a cookie is down, clients may
2231 definitely stick to it because they cannot flush the cookie, so they will not
2232 be able to access the service anymore.
2233
2234 Specifying "redispatch" will allow the proxy to break their persistence and
2235 redistribute them to a working server.
2236
2237 It also allows to retry last connection to another server in case of multiple
2238 connection failures. Of course, it requires having "retries" set to a nonzero
2239 value.
2240
2241 This form is deprecated, do not use it in any new configuration, use the new
2242 "option redispatch" instead.
2243
2244 See also : "option redispatch"
2245
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002246
Willy Tarreau303c0352008-01-17 19:01:39 +01002247reqadd <string>
2248 Add a header at the end of the HTTP request
2249 May be used in sections : defaults | frontend | listen | backend
2250 no | yes | yes | yes
2251 Arguments :
2252 <string> is the complete line to be added. Any space or known delimiter
2253 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002254 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002255
2256 A new line consisting in <string> followed by a line feed will be added after
2257 the last header of an HTTP request.
2258
2259 Header transformations only apply to traffic which passes through HAProxy,
2260 and not to traffic generated by HAProxy, such as health-checks or error
2261 responses.
2262
Willy Tarreauced27012008-01-17 20:35:34 +01002263 See also: "rspadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002264
2265
2266reqallow <search>
2267reqiallow <search> (ignore case)
2268 Definitely allow an HTTP request if a line matches a regular expression
2269 May be used in sections : defaults | frontend | listen | backend
2270 no | yes | yes | yes
2271 Arguments :
2272 <search> is the regular expression applied to HTTP headers and to the
2273 request line. This is an extended regular expression. Parenthesis
2274 grouping is supported and no preliminary backslash is required.
2275 Any space or known delimiter must be escaped using a backslash
2276 ('\'). The pattern applies to a full line at a time. The
2277 "reqallow" keyword strictly matches case while "reqiallow"
2278 ignores case.
2279
2280 A request containing any line which matches extended regular expression
2281 <search> will mark the request as allowed, even if any later test would
2282 result in a deny. The test applies both to the request line and to request
2283 headers. Keep in mind that URLs in request line are case-sensitive while
2284 header names are not.
2285
2286 It is easier, faster and more powerful to use ACLs to write access policies.
2287 Reqdeny, reqallow and reqpass should be avoided in new designs.
2288
2289 Example :
2290 # allow www.* but refuse *.local
2291 reqiallow ^Host:\ www\.
2292 reqideny ^Host:\ .*\.local
2293
Willy Tarreauced27012008-01-17 20:35:34 +01002294 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002295 manipulation
2296
2297
2298reqdel <search>
2299reqidel <search> (ignore case)
2300 Delete all headers matching a regular expression in an HTTP request
2301 May be used in sections : defaults | frontend | listen | backend
2302 no | yes | yes | yes
2303 Arguments :
2304 <search> is the regular expression applied to HTTP headers and to the
2305 request line. This is an extended regular expression. Parenthesis
2306 grouping is supported and no preliminary backslash is required.
2307 Any space or known delimiter must be escaped using a backslash
2308 ('\'). The pattern applies to a full line at a time. The "reqdel"
2309 keyword strictly matches case while "reqidel" ignores case.
2310
2311 Any header line matching extended regular expression <search> in the request
2312 will be completely deleted. Most common use of this is to remove unwanted
2313 and/or dangerous headers or cookies from a request before passing it to the
2314 next servers.
2315
2316 Header transformations only apply to traffic which passes through HAProxy,
2317 and not to traffic generated by HAProxy, such as health-checks or error
2318 responses. Keep in mind that header names are not case-sensitive.
2319
2320 Example :
2321 # remove X-Forwarded-For header and SERVER cookie
2322 reqidel ^X-Forwarded-For:.*
2323 reqidel ^Cookie:.*SERVER=
2324
Willy Tarreauced27012008-01-17 20:35:34 +01002325 See also: "reqadd", "reqrep", "rspdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002326 manipulation
2327
2328
2329reqdeny <search>
2330reqideny <search> (ignore case)
2331 Deny an HTTP request if a line matches a regular expression
2332 May be used in sections : defaults | frontend | listen | backend
2333 no | yes | yes | yes
2334 Arguments :
2335 <search> is the regular expression applied to HTTP headers and to the
2336 request line. This is an extended regular expression. Parenthesis
2337 grouping is supported and no preliminary backslash is required.
2338 Any space or known delimiter must be escaped using a backslash
2339 ('\'). The pattern applies to a full line at a time. The
2340 "reqdeny" keyword strictly matches case while "reqideny" ignores
2341 case.
2342
2343 A request containing any line which matches extended regular expression
2344 <search> will mark the request as denied, even if any later test would
2345 result in an allow. The test applies both to the request line and to request
2346 headers. Keep in mind that URLs in request line are case-sensitive while
2347 header names are not.
2348
Willy Tarreauced27012008-01-17 20:35:34 +01002349 A denied request will generate an "HTTP 403 forbidden" response once the
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002350 complete request has been parsed. This is consistent with what is practiced
Willy Tarreauced27012008-01-17 20:35:34 +01002351 using ACLs.
2352
Willy Tarreau303c0352008-01-17 19:01:39 +01002353 It is easier, faster and more powerful to use ACLs to write access policies.
2354 Reqdeny, reqallow and reqpass should be avoided in new designs.
2355
2356 Example :
2357 # refuse *.local, then allow www.*
2358 reqideny ^Host:\ .*\.local
2359 reqiallow ^Host:\ www\.
2360
Willy Tarreauced27012008-01-17 20:35:34 +01002361 See also: "reqallow", "rspdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002362 header manipulation
2363
2364
2365reqpass <search>
2366reqipass <search> (ignore case)
2367 Ignore any HTTP request line matching a regular expression in next rules
2368 May be used in sections : defaults | frontend | listen | backend
2369 no | yes | yes | yes
2370 Arguments :
2371 <search> is the regular expression applied to HTTP headers and to the
2372 request line. This is an extended regular expression. Parenthesis
2373 grouping is supported and no preliminary backslash is required.
2374 Any space or known delimiter must be escaped using a backslash
2375 ('\'). The pattern applies to a full line at a time. The
2376 "reqpass" keyword strictly matches case while "reqipass" ignores
2377 case.
2378
2379 A request containing any line which matches extended regular expression
2380 <search> will skip next rules, without assigning any deny or allow verdict.
2381 The test applies both to the request line and to request headers. Keep in
2382 mind that URLs in request line are case-sensitive while header names are not.
2383
2384 It is easier, faster and more powerful to use ACLs to write access policies.
2385 Reqdeny, reqallow and reqpass should be avoided in new designs.
2386
2387 Example :
2388 # refuse *.local, then allow www.*, but ignore "www.private.local"
2389 reqipass ^Host:\ www.private\.local
2390 reqideny ^Host:\ .*\.local
2391 reqiallow ^Host:\ www\.
2392
Willy Tarreauced27012008-01-17 20:35:34 +01002393 See also: "reqallow", "reqdeny", "acl", "block" and section 2.5 about HTTP
Willy Tarreau303c0352008-01-17 19:01:39 +01002394 header manipulation
2395
2396
2397reqrep <search> <string>
2398reqirep <search> <string> (ignore case)
2399 Replace a regular expression with a string in an HTTP request line
2400 May be used in sections : defaults | frontend | listen | backend
2401 no | yes | yes | yes
2402 Arguments :
2403 <search> is the regular expression applied to HTTP headers and to the
2404 request line. This is an extended regular expression. Parenthesis
2405 grouping is supported and no preliminary backslash is required.
2406 Any space or known delimiter must be escaped using a backslash
2407 ('\'). The pattern applies to a full line at a time. The "reqrep"
2408 keyword strictly matches case while "reqirep" ignores case.
2409
2410 <string> is the complete line to be added. Any space or known delimiter
2411 must be escaped using a backslash ('\'). References to matched
2412 pattern groups are possible using the common \N form, with N
2413 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002414 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002415
2416 Any line matching extended regular expression <search> in the request (both
2417 the request line and header lines) will be completely replaced with <string>.
2418 Most common use of this is to rewrite URLs or domain names in "Host" headers.
2419
2420 Header transformations only apply to traffic which passes through HAProxy,
2421 and not to traffic generated by HAProxy, such as health-checks or error
2422 responses. Note that for increased readability, it is suggested to add enough
2423 spaces between the request and the response. Keep in mind that URLs in
2424 request line are case-sensitive while header names are not.
2425
2426 Example :
2427 # replace "/static/" with "/" at the beginning of any request path.
2428 reqrep ^([^\ ]*)\ /static/(.*) \1\ /\2
2429 # replace "www.mydomain.com" with "www" in the host name.
2430 reqirep ^Host:\ www.mydomain.com Host:\ www
2431
Willy Tarreauced27012008-01-17 20:35:34 +01002432 See also: "reqadd", "reqdel", "rsprep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002433 manipulation
2434
2435
2436reqtarpit <search>
2437reqitarpit <search> (ignore case)
2438 Tarpit an HTTP request containing a line matching a regular expression
2439 May be used in sections : defaults | frontend | listen | backend
2440 no | yes | yes | yes
2441 Arguments :
2442 <search> is the regular expression applied to HTTP headers and to the
2443 request line. This is an extended regular expression. Parenthesis
2444 grouping is supported and no preliminary backslash is required.
2445 Any space or known delimiter must be escaped using a backslash
2446 ('\'). The pattern applies to a full line at a time. The
2447 "reqtarpit" keyword strictly matches case while "reqitarpit"
2448 ignores case.
2449
2450 A request containing any line which matches extended regular expression
2451 <search> will be tarpitted, which means that it will connect to nowhere, will
Willy Tarreauced27012008-01-17 20:35:34 +01002452 be kept open for a pre-defined time, then will return an HTTP error 500 so
2453 that the attacker does not suspect it has been tarpitted. The status 500 will
2454 be reported in the logs, but the completion flags will indicate "PT". The
Willy Tarreau303c0352008-01-17 19:01:39 +01002455 delay is defined by "timeout tarpit", or "timeout connect" if the former is
2456 not set.
2457
2458 The goal of the tarpit is to slow down robots attacking servers with
2459 identifiable requests. Many robots limit their outgoing number of connections
2460 and stay connected waiting for a reply which can take several minutes to
2461 come. Depending on the environment and attack, it may be particularly
2462 efficient at reducing the load on the network and firewalls.
2463
2464 Example :
2465 # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but
2466 # block all others.
2467 reqipass ^User-Agent:\.*(Mozilla|MSIE)
2468 reqitarpit ^User-Agent:
2469
Willy Tarreauced27012008-01-17 20:35:34 +01002470 See also: "reqallow", "reqdeny", "reqpass", and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002471 manipulation
2472
2473
2474rspadd <string>
2475 Add a header at the end of the HTTP response
2476 May be used in sections : defaults | frontend | listen | backend
2477 no | yes | yes | yes
2478 Arguments :
2479 <string> is the complete line to be added. Any space or known delimiter
2480 must be escaped using a backslash ('\'). Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002481 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002482
2483 A new line consisting in <string> followed by a line feed will be added after
2484 the last header of an HTTP response.
2485
2486 Header transformations only apply to traffic which passes through HAProxy,
2487 and not to traffic generated by HAProxy, such as health-checks or error
2488 responses.
2489
Willy Tarreauced27012008-01-17 20:35:34 +01002490 See also: "reqadd" and section 2.5 about HTTP header manipulation
Willy Tarreau303c0352008-01-17 19:01:39 +01002491
2492
2493rspdel <search>
2494rspidel <search> (ignore case)
2495 Delete all headers matching a regular expression in an HTTP response
2496 May be used in sections : defaults | frontend | listen | backend
2497 no | yes | yes | yes
2498 Arguments :
2499 <search> is the regular expression applied to HTTP headers and to the
2500 response line. This is an extended regular expression, so
2501 parenthesis grouping is supported and no preliminary backslash
2502 is required. Any space or known delimiter must be escaped using
2503 a backslash ('\'). The pattern applies to a full line at a time.
2504 The "rspdel" keyword strictly matches case while "rspidel"
2505 ignores case.
2506
2507 Any header line matching extended regular expression <search> in the response
2508 will be completely deleted. Most common use of this is to remove unwanted
2509 and/or sensible headers or cookies from a response before passing it to the
2510 client.
2511
2512 Header transformations only apply to traffic which passes through HAProxy,
2513 and not to traffic generated by HAProxy, such as health-checks or error
2514 responses. Keep in mind that header names are not case-sensitive.
2515
2516 Example :
2517 # remove the Server header from responses
2518 reqidel ^Server:.*
2519
Willy Tarreauced27012008-01-17 20:35:34 +01002520 See also: "rspadd", "rsprep", "reqdel" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002521 manipulation
2522
2523
2524rspdeny <search>
2525rspideny <search> (ignore case)
2526 Block an HTTP response if a line matches a regular expression
2527 May be used in sections : defaults | frontend | listen | backend
2528 no | yes | yes | yes
2529 Arguments :
2530 <search> is the regular expression applied to HTTP headers and to the
2531 response line. This is an extended regular expression, so
2532 parenthesis grouping is supported and no preliminary backslash
2533 is required. Any space or known delimiter must be escaped using
2534 a backslash ('\'). The pattern applies to a full line at a time.
2535 The "rspdeny" keyword strictly matches case while "rspideny"
2536 ignores case.
2537
2538 A response containing any line which matches extended regular expression
2539 <search> will mark the request as denied. The test applies both to the
2540 response line and to response headers. Keep in mind that header names are not
2541 case-sensitive.
2542
2543 Main use of this keyword is to prevent sensitive information leak and to
Willy Tarreauced27012008-01-17 20:35:34 +01002544 block the response before it reaches the client. If a response is denied, it
2545 will be replaced with an HTTP 502 error so that the client never retrieves
2546 any sensitive data.
Willy Tarreau303c0352008-01-17 19:01:39 +01002547
2548 It is easier, faster and more powerful to use ACLs to write access policies.
2549 Rspdeny should be avoided in new designs.
2550
2551 Example :
2552 # Ensure that no content type matching ms-word will leak
2553 rspideny ^Content-type:\.*/ms-word
2554
Willy Tarreauced27012008-01-17 20:35:34 +01002555 See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002556 manipulation
2557
2558
2559rsprep <search> <string>
2560rspirep <search> <string> (ignore case)
2561 Replace a regular expression with a string in an HTTP response line
2562 May be used in sections : defaults | frontend | listen | backend
2563 no | yes | yes | yes
2564 Arguments :
2565 <search> is the regular expression applied to HTTP headers and to the
2566 response line. This is an extended regular expression, so
2567 parenthesis grouping is supported and no preliminary backslash
2568 is required. Any space or known delimiter must be escaped using
2569 a backslash ('\'). The pattern applies to a full line at a time.
2570 The "rsprep" keyword strictly matches case while "rspirep"
2571 ignores case.
2572
2573 <string> is the complete line to be added. Any space or known delimiter
2574 must be escaped using a backslash ('\'). References to matched
2575 pattern groups are possible using the common \N form, with N
2576 being a single digit between 0 and 9. Please refer to section
Willy Tarreauced27012008-01-17 20:35:34 +01002577 2.5 about HTTP header manipulation for more information.
Willy Tarreau303c0352008-01-17 19:01:39 +01002578
2579 Any line matching extended regular expression <search> in the response (both
2580 the response line and header lines) will be completely replaced with
2581 <string>. Most common use of this is to rewrite Location headers.
2582
2583 Header transformations only apply to traffic which passes through HAProxy,
2584 and not to traffic generated by HAProxy, such as health-checks or error
2585 responses. Note that for increased readability, it is suggested to add enough
2586 spaces between the request and the response. Keep in mind that header names
2587 are not case-sensitive.
2588
2589 Example :
2590 # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com"
2591 rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com
2592
Willy Tarreauced27012008-01-17 20:35:34 +01002593 See also: "rspadd", "rspdel", "reqrep" and section 2.5 about HTTP header
Willy Tarreau303c0352008-01-17 19:01:39 +01002594 manipulation
2595
2596
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002597server <name> <address>[:port] [param*]
2598 Declare a server in a backend
2599 May be used in sections : defaults | frontend | listen | backend
2600 no | no | yes | yes
2601 Arguments :
2602 <name> is the internal name assigned to this server. This name will
2603 appear in logs and alerts.
2604
2605 <address> is the IPv4 address of the server. Alternatively, a resolvable
2606 hostname is supported, but this name will be resolved during
2607 start-up.
2608
2609 <ports> is an optional port specification. If set, all connections will
2610 be sent to this port. If unset, the same port the client
2611 connected to will be used. The port may also be prefixed by a "+"
2612 or a "-". In this case, the server's port will be determined by
2613 adding this value to the client's port.
2614
2615 <param*> is a list of parameters for this server. The "server" keywords
2616 accepts an important number of options and has a complete section
2617 dedicated to it. Please refer to section 2.4 for more details.
2618
2619 Examples :
2620 server first 10.1.1.1:1080 cookie first check inter 1000
2621 server second 10.1.1.2:1080 cookie second check inter 1000
2622
2623 See also : section 2.4 about server options
2624
2625
2626source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
2627 Set the source address for outgoing connections
2628 May be used in sections : defaults | frontend | listen | backend
2629 yes | no | yes | yes
2630 Arguments :
2631 <addr> is the IPv4 address HAProxy will bind to before connecting to a
2632 server. This address is also used as a source for health checks.
2633 The default value of 0.0.0.0 means that the system will select
2634 the most appropriate address to reach its destination.
2635
2636 <port> is an optional port. It is normally not needed but may be useful
2637 in some very specific contexts. The default value of zero means
2638 the system will select a free port.
2639
2640 <addr2> is the IP address to present to the server when connections are
2641 forwarded in full transparent proxy mode. This is currently only
2642 supported on some patched Linux kernels. When this address is
2643 specified, clients connecting to the server will be presented
2644 with this address, while health checks will still use the address
2645 <addr>.
2646
2647 <port2> is the optional port to present to the server when connections
2648 are forwarded in full transparent proxy mode (see <addr2> above).
2649 The default value of zero means the system will select a free
2650 port.
2651
2652 The "source" keyword is useful in complex environments where a specific
2653 address only is allowed to connect to the servers. It may be needed when a
2654 private address must be used through a public gateway for instance, and it is
2655 known that the system cannot determine the adequate source address by itself.
2656
2657 An extension which is available on certain patched Linux kernels may be used
2658 through the "usesrc" optional keyword. It makes it possible to connect to the
2659 servers with an IP address which does not belong to the system itself. This
2660 is called "full transparent proxy mode". For this to work, the destination
2661 servers have to route their traffic back to this address through the machine
2662 running HAProxy, and IP forwarding must generally be enabled on this machine.
2663
2664 In this "full transparent proxy" mode, it is possible to force a specific IP
2665 address to be presented to the servers. This is not much used in fact. A more
2666 common use is to tell HAProxy to present the client's IP address. For this,
2667 there are two methods :
2668
2669 - present the client's IP and port addresses. This is the most transparent
2670 mode, but it can cause problems when IP connection tracking is enabled on
2671 the machine, because a same connection may be seen twice with different
2672 states. However, this solution presents the huge advantage of not
2673 limiting the system to the 64k outgoing address+port couples, because all
2674 of the client ranges may be used.
2675
2676 - present only the client's IP address and select a spare port. This
2677 solution is still quite elegant but slightly less transparent (downstream
2678 firewalls logs will not match upstream's). It also presents the downside
2679 of limiting the number of concurrent connections to the usual 64k ports.
2680 However, since the upstream and downstream ports are different, local IP
2681 connection tracking on the machine will not be upset by the reuse of the
2682 same session.
2683
2684 Note that depending on the transparent proxy technology used, it may be
2685 required to force the source address. In fact, cttproxy version 2 requires an
2686 IP address in <addr> above, and does not support setting of "0.0.0.0" as the
2687 IP address because it creates NAT entries which much match the exact outgoing
2688 address. Tproxy version 4 and some other kernel patches which work in pure
2689 forwarding mode generally will not have this limitation.
2690
2691 This option sets the default source for all servers in the backend. It may
2692 also be specified in a "defaults" section. Finer source address specification
2693 is possible at the server level using the "source" server option. Refer to
2694 section 2.4 for more information.
2695
2696 Examples :
2697 backend private
2698 # Connect to the servers using our 192.168.1.200 source address
2699 source 192.168.1.200
2700
2701 backend transparent_ssl1
2702 # Connect to the SSL farm from the client's source address
2703 source 192.168.1.200 usesrc clientip
2704
2705 backend transparent_ssl2
2706 # Connect to the SSL farm from the client's source address and port
2707 # not recommended if IP conntrack is present on the local machine.
2708 source 192.168.1.200 usesrc client
2709
2710 backend transparent_ssl3
2711 # Connect to the SSL farm from the client's source address. It
2712 # is more conntrack-friendly.
2713 source 192.168.1.200 usesrc clientip
2714
2715 backend transparent_smtp
2716 # Connect to the SMTP farm from the client's source address/port
2717 # with Tproxy version 4.
2718 source 0.0.0.0 usesrc clientip
2719
2720 See also : the "source" server option in section 2.4, the Tproxy patches for
2721 the Linux kernel on www.balabit.com, the "bind" keyword.
2722
Krzysztof Piotr Oledzki25b501a2008-01-06 16:36:16 +01002723
Willy Tarreau844e3c52008-01-11 16:28:18 +01002724srvtimeout <timeout> (deprecated)
2725 Set the maximum inactivity time on the server side.
2726 May be used in sections : defaults | frontend | listen | backend
2727 yes | no | yes | yes
2728 Arguments :
2729 <timeout> is the timeout value specified in milliseconds by default, but
2730 can be in any other unit if the number is suffixed by the unit,
2731 as explained at the top of this document.
2732
2733 The inactivity timeout applies when the server is expected to acknowledge or
2734 send data. In HTTP mode, this timeout is particularly important to consider
2735 during the first phase of the server's response, when it has to send the
2736 headers, as it directly represents the server's processing time for the
2737 request. To find out what value to put there, it's often good to start with
2738 what would be considered as unacceptable response times, then check the logs
2739 to observe the response time distribution, and adjust the value accordingly.
2740
2741 The value is specified in milliseconds by default, but can be in any other
2742 unit if the number is suffixed by the unit, as specified at the top of this
2743 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
2744 recommended that the client timeout remains equal to the server timeout in
2745 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01002746 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01002747 packet losses by specifying timeouts that are slightly above multiples of 3
2748 seconds (eg: 4 or 5 seconds minimum).
2749
2750 This parameter is specific to backends, but can be specified once for all in
2751 "defaults" sections. This is in fact one of the easiest solutions not to
2752 forget about it. An unspecified timeout results in an infinite timeout, which
2753 is not recommended. Such a usage is accepted and works but reports a warning
2754 during startup because it may results in accumulation of expired sessions in
2755 the system if the system's timeouts are not configured either.
2756
2757 This parameter is provided for compatibility but is currently deprecated.
2758 Please use "timeout server" instead.
2759
2760 See also : "timeout server", "timeout client" and "clitimeout".
2761
2762
Willy Tarreaueabeafa2008-01-16 16:17:06 +01002763stats auth <user>:<passwd>
2764 Enable statistics with authentication and grant access to an account
2765 May be used in sections : defaults | frontend | listen | backend
2766 yes | no | yes | yes
2767 Arguments :
2768 <user> is a user name to grant access to
2769
2770 <passwd> is the cleartext password associated to this user
2771
2772 This statement enables statistics with default settings, and restricts access
2773 to declared users only. It may be repeated as many times as necessary to
2774 allow as many users as desired. When a user tries to access the statistics
2775 without a valid account, a "401 Forbidden" response will be returned so that
2776 the browser asks the user to provide a valid user and password. The real
2777 which will be returned to the browser is configurable using "stats realm".
2778
2779 Since the authentication method is HTTP Basic Authentication, the passwords
2780 circulate in cleartext on the network. Thus, it was decided that the
2781 configuration file would also use cleartext passwords to remind the users
2782 that those ones should not be sensible and not shared with any other account.
2783
2784 It is also possible to reduce the scope of the proxies which appear in the
2785 report using "stats scope".
2786
2787 Though this statement alone is enough to enable statistics reporting, it is
2788 recommended to set all other settings in order to avoid relying on default
2789 unobvious parameters.
2790
2791 Example :
2792 # public access (limited to this backend only)
2793 backend public_www
2794 server srv1 192.168.0.1:80
2795 stats enable
2796 stats hide-version
2797 stats scope .
2798 stats uri /admin?stats
2799 stats realm Haproxy\ Statistics
2800 stats auth admin1:AdMiN123
2801 stats auth admin2:AdMiN321
2802
2803 # internal monitoring access (unlimited)
2804 backend private_monitoring
2805 stats enable
2806 stats uri /admin?stats
2807 stats refresh 5s
2808
2809 See also : "stats enable", "stats realm", "stats scope", "stats uri"
2810
2811
2812stats enable
2813 Enable statistics reporting with default settings
2814 May be used in sections : defaults | frontend | listen | backend
2815 yes | no | yes | yes
2816 Arguments : none
2817
2818 This statement enables statistics reporting with default settings defined
2819 at build time. Unless stated otherwise, these settings are used :
2820 - stats uri : /haproxy?stats
2821 - stats realm : "HAProxy Statistics"
2822 - stats auth : no authentication
2823 - stats scope : no restriction
2824
2825 Though this statement alone is enough to enable statistics reporting, it is
2826 recommended to set all other settings in order to avoid relying on default
2827 unobvious parameters.
2828
2829 Example :
2830 # public access (limited to this backend only)
2831 backend public_www
2832 server srv1 192.168.0.1:80
2833 stats enable
2834 stats hide-version
2835 stats scope .
2836 stats uri /admin?stats
2837 stats realm Haproxy\ Statistics
2838 stats auth admin1:AdMiN123
2839 stats auth admin2:AdMiN321
2840
2841 # internal monitoring access (unlimited)
2842 backend private_monitoring
2843 stats enable
2844 stats uri /admin?stats
2845 stats refresh 5s
2846
2847 See also : "stats auth", "stats realm", "stats uri"
2848
2849
2850stats realm <realm>
2851 Enable statistics and set authentication realm
2852 May be used in sections : defaults | frontend | listen | backend
2853 yes | no | yes | yes
2854 Arguments :
2855 <realm> is the name of the HTTP Basic Authentication realm reported to
2856 the browser. The browser uses it to display it in the pop-up
2857 inviting the user to enter a valid username and password.
2858
2859 The realm is read as a single word, so any spaces in it should be escaped
2860 using a backslash ('\').
2861
2862 This statement is useful only in conjunction with "stats auth" since it is
2863 only related to authentication.
2864
2865 Though this statement alone is enough to enable statistics reporting, it is
2866 recommended to set all other settings in order to avoid relying on default
2867 unobvious parameters.
2868
2869 Example :
2870 # public access (limited to this backend only)
2871 backend public_www
2872 server srv1 192.168.0.1:80
2873 stats enable
2874 stats hide-version
2875 stats scope .
2876 stats uri /admin?stats
2877 stats realm Haproxy\ Statistics
2878 stats auth admin1:AdMiN123
2879 stats auth admin2:AdMiN321
2880
2881 # internal monitoring access (unlimited)
2882 backend private_monitoring
2883 stats enable
2884 stats uri /admin?stats
2885 stats refresh 5s
2886
2887 See also : "stats auth", "stats enable", "stats uri"
2888
2889
2890stats refresh <delay>
2891 Enable statistics with automatic refresh
2892 May be used in sections : defaults | frontend | listen | backend
2893 yes | no | yes | yes
2894 Arguments :
2895 <delay> is the suggested refresh delay, specified in seconds, which will
2896 be returned to the browser consulting the report page. While the
2897 browser is free to apply any delay, it will generally respect it
2898 and refresh the page this every seconds. The refresh interval may
2899 be specified in any other non-default time unit, by suffixing the
2900 unit after the value, as explained at the top of this document.
2901
2902 This statement is useful on monitoring displays with a permanent page
2903 reporting the load balancer's activity. When set, the HTML report page will
2904 include a link "refresh"/"stop refresh" so that the user can select whether
2905 he wants automatic refresh of the page or not.
2906
2907 Though this statement alone is enough to enable statistics reporting, it is
2908 recommended to set all other settings in order to avoid relying on default
2909 unobvious parameters.
2910
2911 Example :
2912 # public access (limited to this backend only)
2913 backend public_www
2914 server srv1 192.168.0.1:80
2915 stats enable
2916 stats hide-version
2917 stats scope .
2918 stats uri /admin?stats
2919 stats realm Haproxy\ Statistics
2920 stats auth admin1:AdMiN123
2921 stats auth admin2:AdMiN321
2922
2923 # internal monitoring access (unlimited)
2924 backend private_monitoring
2925 stats enable
2926 stats uri /admin?stats
2927 stats refresh 5s
2928
2929 See also : "stats auth", "stats enable", "stats realm", "stats uri"
2930
2931
2932stats scope { <name> | "." }
2933 Enable statistics and limit access scope
2934 May be used in sections : defaults | frontend | listen | backend
2935 yes | no | yes | yes
2936 Arguments :
2937 <name> is the name of a listen, frontend or backend section to be
2938 reported. The special name "." (a single dot) designates the
2939 section in which the statement appears.
2940
2941 When this statement is specified, only the sections enumerated with this
2942 statement will appear in the report. All other ones will be hidden. This
2943 statement may appear as many times as needed if multiple sections need to be
2944 reported. Please note that the name checking is performed as simple string
2945 comparisons, and that it is never checked that a give section name really
2946 exists.
2947
2948 Though this statement alone is enough to enable statistics reporting, it is
2949 recommended to set all other settings in order to avoid relying on default
2950 unobvious parameters.
2951
2952 Example :
2953 # public access (limited to this backend only)
2954 backend public_www
2955 server srv1 192.168.0.1:80
2956 stats enable
2957 stats hide-version
2958 stats scope .
2959 stats uri /admin?stats
2960 stats realm Haproxy\ Statistics
2961 stats auth admin1:AdMiN123
2962 stats auth admin2:AdMiN321
2963
2964 # internal monitoring access (unlimited)
2965 backend private_monitoring
2966 stats enable
2967 stats uri /admin?stats
2968 stats refresh 5s
2969
2970 See also : "stats auth", "stats enable", "stats realm", "stats uri"
2971
2972
2973stats uri <prefix>
2974 Enable statistics and define the URI prefix to access them
2975 May be used in sections : defaults | frontend | listen | backend
2976 yes | no | yes | yes
2977 Arguments :
2978 <prefix> is the prefix of any URI which will be redirected to stats. This
2979 prefix may contain a question mark ('?') to indicate part of a
2980 query string.
2981
2982 The statistics URI is intercepted on the relayed traffic, so it appears as a
2983 page within the normal application. It is strongly advised to ensure that the
2984 selected URI will never appear in the application, otherwise it will never be
2985 possible to reach it in the application.
2986
2987 The default URI compiled in haproxy is "/haproxy?stats", but this may be
2988 changed at build time, so it's better to always explictly specify it here.
2989 It is generally a good idea to include a question mark in the URI so that
2990 intermediate proxies refrain from caching the results. Also, since any string
2991 beginning with the prefix will be accepted as a stats request, the question
2992 mark helps ensuring that no valid URI will begin with the same words.
2993
2994 It is sometimes very convenient to use "/" as the URI prefix, and put that
2995 statement in a "listen" instance of its own. That makes it easy to dedicate
2996 an address or a port to statistics only.
2997
2998 Though this statement alone is enough to enable statistics reporting, it is
2999 recommended to set all other settings in order to avoid relying on default
3000 unobvious parameters.
3001
3002 Example :
3003 # public access (limited to this backend only)
3004 backend public_www
3005 server srv1 192.168.0.1:80
3006 stats enable
3007 stats hide-version
3008 stats scope .
3009 stats uri /admin?stats
3010 stats realm Haproxy\ Statistics
3011 stats auth admin1:AdMiN123
3012 stats auth admin2:AdMiN321
3013
3014 # internal monitoring access (unlimited)
3015 backend private_monitoring
3016 stats enable
3017 stats uri /admin?stats
3018 stats refresh 5s
3019
3020 See also : "stats auth", "stats enable", "stats realm"
3021
3022
3023stats hide-version
3024 Enable statistics and hide HAProxy version reporting
3025 May be used in sections : defaults | frontend | listen | backend
3026 yes | no | yes | yes
3027 Arguments : none
3028
3029 By default, the stats page reports some useful status information along with
3030 the statistics. Among them is HAProxy's version. However, it is generally
3031 considered dangerous to report precise version to anyone, as it can help them
3032 target known weaknesses with specific attacks. The "stats hide-version"
3033 statement removes the version from the statistics report. This is recommended
3034 for public sites or any site with a weak login/password.
3035
3036 Though this statement alone is enough to enable statistics reporting, it is
3037 recommended to set all other settings in order to avoid relying on default
3038 unobvious parameters.
3039
3040 Example :
3041 # public access (limited to this backend only)
3042 backend public_www
3043 server srv1 192.168.0.1:80
3044 stats enable
3045 stats hide-version
3046 stats scope .
3047 stats uri /admin?stats
3048 stats realm Haproxy\ Statistics
3049 stats auth admin1:AdMiN123
3050 stats auth admin2:AdMiN321
3051
3052 # internal monitoring access (unlimited)
3053 backend private_monitoring
3054 stats enable
3055 stats uri /admin?stats
3056 stats refresh 5s
3057
3058 See also : "stats auth", "stats enable", "stats realm", "stats uri"
3059
3060
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003061timeout check <timeout>
3062 Set additional check timeout, but only after a connection has been already
3063 established.
3064
3065 May be used in sections: defaults | frontend | listen | backend
3066 yes | no | yes | yes
3067 Arguments:
3068 <timeout> is the timeout value specified in milliseconds by default, but
3069 can be in any other unit if the number is suffixed by the unit,
3070 as explained at the top of this document.
3071
3072 If set, haproxy uses min("timeout connect", "inter") as a connect timeout
3073 for check and "timeout check" as an additional read timeout. The "min" is
3074 used so that people running with *very* long "timeout connect" (eg. those
3075 who needed this due to the queue or tarpit) do not slow down their checks.
3076 Of course it is better to use "check queue" and "check tarpit" instead of
3077 long "timeout connect".
3078
3079 If "timeout check" is not set haproxy uses "inter" for complete check
3080 timeout (connect + read) exactly like all <1.3.15 version.
3081
3082 In most cases check request is much simpler and faster to handle than normal
3083 requests and people may want to kick out laggy servers so this timeout should
Willy Tarreau41a340d2008-01-22 12:25:31 +01003084 be smaller than "timeout server".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003085
3086 This parameter is specific to backends, but can be specified once for all in
3087 "defaults" sections. This is in fact one of the easiest solutions not to
3088 forget about it.
3089
Willy Tarreau41a340d2008-01-22 12:25:31 +01003090 See also: "timeout connect", "timeout queue", "timeout server",
3091 "timeout tarpit".
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003092
3093
Willy Tarreau0ba27502007-12-24 16:55:16 +01003094timeout client <timeout>
3095timeout clitimeout <timeout> (deprecated)
3096 Set the maximum inactivity time on the client side.
3097 May be used in sections : defaults | frontend | listen | backend
3098 yes | yes | yes | no
3099 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003100 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003101 can be in any other unit if the number is suffixed by the unit,
3102 as explained at the top of this document.
3103
3104 The inactivity timeout applies when the client is expected to acknowledge or
3105 send data. In HTTP mode, this timeout is particularly important to consider
3106 during the first phase, when the client sends the request, and during the
3107 response while it is reading data sent by the server. The value is specified
3108 in milliseconds by default, but can be in any other unit if the number is
3109 suffixed by the unit, as specified at the top of this document. In TCP mode
3110 (and to a lesser extent, in HTTP mode), it is highly recommended that the
3111 client timeout remains equal to the server timeout in order to avoid complex
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003112 situations to debug. It is a good practice to cover one or several TCP packet
Willy Tarreau0ba27502007-12-24 16:55:16 +01003113 losses by specifying timeouts that are slightly above multiples of 3 seconds
3114 (eg: 4 or 5 seconds).
3115
3116 This parameter is specific to frontends, but can be specified once for all in
3117 "defaults" sections. This is in fact one of the easiest solutions not to
3118 forget about it. An unspecified timeout results in an infinite timeout, which
3119 is not recommended. Such a usage is accepted and works but reports a warning
3120 during startup because it may results in accumulation of expired sessions in
3121 the system if the system's timeouts are not configured either.
3122
3123 This parameter replaces the old, deprecated "clitimeout". It is recommended
3124 to use it to write new configurations. The form "timeout clitimeout" is
3125 provided only by backwards compatibility but its use is strongly discouraged.
3126
3127 See also : "clitimeout", "timeout server".
3128
3129
3130timeout connect <timeout>
3131timeout contimeout <timeout> (deprecated)
3132 Set the maximum time to wait for a connection attempt to a server to succeed.
3133 May be used in sections : defaults | frontend | listen | backend
3134 yes | no | yes | yes
3135 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003136 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau0ba27502007-12-24 16:55:16 +01003137 can be in any other unit if the number is suffixed by the unit,
3138 as explained at the top of this document.
3139
3140 If the server is located on the same LAN as haproxy, the connection should be
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003141 immediate (less than a few milliseconds). Anyway, it is a good practice to
Willy Tarreau0ba27502007-12-24 16:55:16 +01003142 cover one or several TCP packet losses by specifying timeouts that are
3143 slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003144 connect timeout also presets both queue and tarpit timeouts to the same value
3145 if these have not been specified.
Willy Tarreau0ba27502007-12-24 16:55:16 +01003146
3147 This parameter is specific to backends, but can be specified once for all in
3148 "defaults" sections. This is in fact one of the easiest solutions not to
3149 forget about it. An unspecified timeout results in an infinite timeout, which
3150 is not recommended. Such a usage is accepted and works but reports a warning
3151 during startup because it may results in accumulation of failed sessions in
3152 the system if the system's timeouts are not configured either.
3153
3154 This parameter replaces the old, deprecated "contimeout". It is recommended
3155 to use it to write new configurations. The form "timeout contimeout" is
3156 provided only by backwards compatibility but its use is strongly discouraged.
3157
Willy Tarreau41a340d2008-01-22 12:25:31 +01003158 See also: "timeout check", "timeout queue", "timeout server", "contimeout",
3159 "timeout tarpit".
Willy Tarreau0ba27502007-12-24 16:55:16 +01003160
3161
Willy Tarreau036fae02008-01-06 13:24:40 +01003162timeout http-request <timeout>
3163 Set the maximum allowed time to wait for a complete HTTP request
3164 May be used in sections : defaults | frontend | listen | backend
3165 yes | yes | yes | no
3166 Arguments :
Willy Tarreau844e3c52008-01-11 16:28:18 +01003167 <timeout> is the timeout value specified in milliseconds by default, but
Willy Tarreau036fae02008-01-06 13:24:40 +01003168 can be in any other unit if the number is suffixed by the unit,
3169 as explained at the top of this document.
3170
3171 In order to offer DoS protection, it may be required to lower the maximum
3172 accepted time to receive a complete HTTP request without affecting the client
3173 timeout. This helps protecting against established connections on which
3174 nothing is sent. The client timeout cannot offer a good protection against
3175 this abuse because it is an inactivity timeout, which means that if the
3176 attacker sends one character every now and then, the timeout will not
3177 trigger. With the HTTP request timeout, no matter what speed the client
3178 types, the request will be aborted if it does not complete in time.
3179
3180 Note that this timeout only applies to the header part of the request, and
3181 not to any data. As soon as the empty line is received, this timeout is not
3182 used anymore.
3183
3184 Generally it is enough to set it to a few seconds, as most clients send the
3185 full request immediately upon connection. Add 3 or more seconds to cover TCP
3186 retransmits but that's all. Setting it to very low values (eg: 50 ms) will
3187 generally work on local networks as long as there are no packet losses. This
3188 will prevent people from sending bare HTTP requests using telnet.
3189
3190 If this parameter is not set, the client timeout still applies between each
3191 chunk of the incoming request.
3192
3193 See also : "timeout client".
3194
Willy Tarreau844e3c52008-01-11 16:28:18 +01003195
3196timeout queue <timeout>
3197 Set the maximum time to wait in the queue for a connection slot to be free
3198 May be used in sections : defaults | frontend | listen | backend
3199 yes | no | yes | yes
3200 Arguments :
3201 <timeout> is the timeout value specified in milliseconds by default, but
3202 can be in any other unit if the number is suffixed by the unit,
3203 as explained at the top of this document.
3204
3205 When a server's maxconn is reached, connections are left pending in a queue
3206 which may be server-specific or global to the backend. In order not to wait
3207 indefinitely, a timeout is applied to requests pending in the queue. If the
3208 timeout is reached, it is considered that the request will almost never be
3209 served, so it is dropped and a 503 error is returned to the client.
3210
3211 The "timeout queue" statement allows to fix the maximum time for a request to
3212 be left pending in a queue. If unspecified, the same value as the backend's
3213 connection timeout ("timeout connect") is used, for backwards compatibility
3214 with older versions with no "timeout queue" parameter.
3215
3216 See also : "timeout connect", "contimeout".
3217
3218
3219timeout server <timeout>
3220timeout srvtimeout <timeout> (deprecated)
3221 Set the maximum inactivity time on the server side.
3222 May be used in sections : defaults | frontend | listen | backend
3223 yes | no | yes | yes
3224 Arguments :
3225 <timeout> is the timeout value specified in milliseconds by default, but
3226 can be in any other unit if the number is suffixed by the unit,
3227 as explained at the top of this document.
3228
3229 The inactivity timeout applies when the server is expected to acknowledge or
3230 send data. In HTTP mode, this timeout is particularly important to consider
3231 during the first phase of the server's response, when it has to send the
3232 headers, as it directly represents the server's processing time for the
3233 request. To find out what value to put there, it's often good to start with
3234 what would be considered as unacceptable response times, then check the logs
3235 to observe the response time distribution, and adjust the value accordingly.
3236
3237 The value is specified in milliseconds by default, but can be in any other
3238 unit if the number is suffixed by the unit, as specified at the top of this
3239 document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly
3240 recommended that the client timeout remains equal to the server timeout in
3241 order to avoid complex situations to debug. Whatever the expected server
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003242 response times, it is a good practice to cover at least one or several TCP
Willy Tarreau844e3c52008-01-11 16:28:18 +01003243 packet losses by specifying timeouts that are slightly above multiples of 3
3244 seconds (eg: 4 or 5 seconds minimum).
3245
3246 This parameter is specific to backends, but can be specified once for all in
3247 "defaults" sections. This is in fact one of the easiest solutions not to
3248 forget about it. An unspecified timeout results in an infinite timeout, which
3249 is not recommended. Such a usage is accepted and works but reports a warning
3250 during startup because it may results in accumulation of expired sessions in
3251 the system if the system's timeouts are not configured either.
3252
3253 This parameter replaces the old, deprecated "srvtimeout". It is recommended
3254 to use it to write new configurations. The form "timeout srvtimeout" is
3255 provided only by backwards compatibility but its use is strongly discouraged.
3256
3257 See also : "srvtimeout", "timeout client".
3258
3259
3260timeout tarpit <timeout>
3261 Set the duration for which tapitted connections will be maintained
3262 May be used in sections : defaults | frontend | listen | backend
3263 yes | yes | yes | yes
3264 Arguments :
3265 <timeout> is the tarpit duration specified in milliseconds by default, but
3266 can be in any other unit if the number is suffixed by the unit,
3267 as explained at the top of this document.
3268
3269 When a connection is tarpitted using "reqtarpit", it is maintained open with
3270 no activity for a certain amount of time, then closed. "timeout tarpit"
3271 defines how long it will be maintained open.
3272
3273 The value is specified in milliseconds by default, but can be in any other
3274 unit if the number is suffixed by the unit, as specified at the top of this
3275 document. If unspecified, the same value as the backend's connection timeout
3276 ("timeout connect") is used, for backwards compatibility with older versions
3277 with no "timeout tapit" parameter.
3278
3279 See also : "timeout connect", "contimeout".
3280
3281
3282transparent (deprecated)
3283 Enable client-side transparent proxying
3284 May be used in sections : defaults | frontend | listen | backend
3285 yes | yes | yes | no
3286 Arguments : none
3287
3288 This keyword was introduced in order to provide layer 7 persistence to layer
3289 3 load balancers. The idea is to use the OS's ability to redirect an incoming
3290 connection for a remote address to a local process (here HAProxy), and let
3291 this process know what address was initially requested. When this option is
3292 used, sessions without cookies will be forwarded to the original destination
3293 IP address of the incoming request (which should match that of another
3294 equipment), while requests with cookies will still be forwarded to the
3295 appropriate server.
3296
3297 The "transparent" keyword is deprecated, use "option transparent" instead.
3298
3299 Note that contrary to a common belief, this option does NOT make HAProxy
3300 present the client's IP to the server when establishing the connection.
3301
3302 Use of this option is really discouraged, and since no really valid use of it
3303 has been reported for years, it will probably be removed in future versions.
3304
3305 See also: "option transparent"
3306
3307
3308use_backend <backend> if <condition>
3309use_backend <backend> unless <condition>
3310 Switch to a specific backend if/unless a Layer 7 condition is matched.
3311 May be used in sections : defaults | frontend | listen | backend
3312 no | yes | yes | no
3313 Arguments :
3314 <backend> is the name of a valid backend or "listen" section.
3315
3316 <condition> is a condition composed of ACLs, as described in section 2.3.
3317
3318 When doing content-switching, connections arrive on a frontend and are then
3319 dispatched to various backends depending on a number of conditions. The
3320 relation between the conditions and the backends is described with the
3321 "use_backend" keyword. This is supported only in HTTP mode.
3322
3323 There may be as many "use_backend" rules as desired. All of these rules are
3324 evaluated in their declaration order, and the first one which matches will
3325 assign the backend.
3326
3327 In the first form, the backend will be used if the condition is met. In the
3328 second form, the backend will be used if the condition is not met. If no
3329 condition is valid, the backend defined with "default_backend" will be used.
3330 If no default backend is defined, either the servers in the same section are
3331 used (in case of a "listen" section) or, in case of a frontend, no server is
3332 used and a 503 service unavailable response is returned.
3333
3334 See also: "default_backend" and section 2.3 about ACLs.
3335
Willy Tarreau036fae02008-01-06 13:24:40 +01003336
Willy Tarreau0ba27502007-12-24 16:55:16 +010033372.3) Using ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003338---------------
3339
3340The use of Access Control Lists (ACL) provides a flexible solution to perform
Willy Tarreau0ba27502007-12-24 16:55:16 +01003341content switching and generally to take decisions based on content extracted
3342from the request, the response or any environmental status. The principle is
3343simple :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003344
3345 - define test criteria with sets of values
3346 - perform actions only if a set of tests is valid
3347
3348The actions generally consist in blocking the request, or selecting a backend.
3349
3350In order to define a test, the "acl" keyword is used. The syntax is :
3351
3352 acl <aclname> <criterion> [flags] [operator] <value> ...
3353
Willy Tarreau0ba27502007-12-24 16:55:16 +01003354This creates a new ACL <aclname> or completes an existing one with new tests.
3355Those tests apply to the portion of request/response specified in <criterion>
Willy Tarreau6a06a402007-07-15 20:15:28 +02003356and may be adjusted with optional flags [flags]. Some criteria also support
3357an operator which may be specified before the set of values. The values are
3358of the type supported by the criterion, and are separated by spaces.
3359
Willy Tarreau0ba27502007-12-24 16:55:16 +01003360ACL names must be formed from upper and lower case letters, digits, '-' (dash),
3361'_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive,
3362which means that "my_acl" and "My_Acl" are two different ACLs.
3363
3364There is no enforced limit to the number of ACLs. The unused ones do not affect
Willy Tarreau6a06a402007-07-15 20:15:28 +02003365performance, they just consume a small amount of memory.
3366
Willy Tarreau0ba27502007-12-24 16:55:16 +01003367The following ACL flags are currently supported :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003368
3369 -i : ignore case during matching.
3370 -- : force end of flags. Useful when a string looks like one of the flags.
3371
3372Supported types of values are :
Willy Tarreau0ba27502007-12-24 16:55:16 +01003373
Willy Tarreau6a06a402007-07-15 20:15:28 +02003374 - integers or integer ranges
3375 - strings
3376 - regular expressions
3377 - IP addresses and networks
3378
3379
Willy Tarreau0ba27502007-12-24 16:55:16 +010033802.3.1) Matching integers
Willy Tarreau6a06a402007-07-15 20:15:28 +02003381------------------------
3382
3383Matching integers is special in that ranges and operators are permitted. Note
3384that integer matching only applies to positive values. A range is a value
3385expressed with a lower and an upper bound separated with a colon, both of which
3386may be omitted.
3387
3388For instance, "1024:65535" is a valid range to represent a range of
3389unprivileged ports, and "1024:" would also work. "0:1023" is a valid
3390representation of privileged ports, and ":1023" would also work.
3391
3392For an easier usage, comparison operators are also supported. Note that using
Willy Tarreau0ba27502007-12-24 16:55:16 +01003393operators with ranges does not make much sense and is strongly discouraged.
3394Similarly, it does not make much sense to perform order comparisons with a set
3395of values.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003396
Willy Tarreau0ba27502007-12-24 16:55:16 +01003397Available operators for integer matching are :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003398
3399 eq : true if the tested value equals at least one value
3400 ge : true if the tested value is greater than or equal to at least one value
3401 gt : true if the tested value is greater than at least one value
3402 le : true if the tested value is less than or equal to at least one value
3403 lt : true if the tested value is less than at least one value
3404
Willy Tarreau0ba27502007-12-24 16:55:16 +01003405For instance, the following ACL matches any negative Content-Length header :
Willy Tarreau6a06a402007-07-15 20:15:28 +02003406
3407 acl negative-length hdr_val(content-length) lt 0
3408
3409
Willy Tarreau0ba27502007-12-24 16:55:16 +010034102.3.2) Matching strings
Willy Tarreau6a06a402007-07-15 20:15:28 +02003411-----------------------
3412
3413String matching applies to verbatim strings as they are passed, with the
3414exception of the backslash ("\") which makes it possible to escape some
3415characters such as the space. If the "-i" flag is passed before the first
3416string, then the matching will be performed ignoring the case. In order
3417to match the string "-i", either set it second, or pass the "--" flag
Willy Tarreau0ba27502007-12-24 16:55:16 +01003418before the first string. Same applies of course to match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003419
3420
Willy Tarreau0ba27502007-12-24 16:55:16 +010034212.3.3) Matching regular expressions (regexes)
Willy Tarreau6a06a402007-07-15 20:15:28 +02003422---------------------------------------------
3423
3424Just like with string matching, regex matching applies to verbatim strings as
3425they are passed, with the exception of the backslash ("\") which makes it
3426possible to escape some characters such as the space. If the "-i" flag is
3427passed before the first regex, then the matching will be performed ignoring
3428the case. In order to match the string "-i", either set it second, or pass
Willy Tarreau0ba27502007-12-24 16:55:16 +01003429the "--" flag before the first string. Same principle applies of course to
3430match the string "--".
Willy Tarreau6a06a402007-07-15 20:15:28 +02003431
3432
Willy Tarreau0ba27502007-12-24 16:55:16 +010034332.3.4) Matching IPv4 addresses
3434------------------------------
Willy Tarreau6a06a402007-07-15 20:15:28 +02003435
3436IPv4 addresses values can be specified either as plain addresses or with a
3437netmask appended, in which case the IPv4 address matches whenever it is
3438within the network. Plain addresses may also be replaced with a resolvable
Willy Tarreaud2a4aa22008-01-31 15:28:22 +01003439host name, but this practice is generally discouraged as it makes it more
Willy Tarreau0ba27502007-12-24 16:55:16 +01003440difficult to read and debug configurations. If hostnames are used, you should
3441at least ensure that they are present in /etc/hosts so that the configuration
3442does not depend on any random DNS match at the moment the configuration is
3443parsed.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003444
3445
Willy Tarreau0ba27502007-12-24 16:55:16 +010034462.3.5) Available matching criteria
Willy Tarreau6a06a402007-07-15 20:15:28 +02003447----------------------------------
3448
Willy Tarreau0ba27502007-12-24 16:55:16 +010034492.3.5.1) Matching at Layer 4 and below
3450--------------------------------------
3451
3452A first set of criteria applies to information which does not require any
3453analysis of the request or response contents. Those generally include TCP/IP
3454addresses and ports, as well as internal values independant on the stream.
3455
Willy Tarreau6a06a402007-07-15 20:15:28 +02003456always_false
3457 This one never matches. All values and flags are ignored. It may be used as
3458 a temporary replacement for another one when adjusting configurations.
3459
3460always_true
3461 This one always matches. All values and flags are ignored. It may be used as
3462 a temporary replacement for another one when adjusting configurations.
3463
3464src <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003465 Applies to the client's IPv4 address. It is usually used to limit access to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003466 certain resources such as statistics. Note that it is the TCP-level source
3467 address which is used, and not the address of a client behind a proxy.
3468
3469src_port <integer>
3470 Applies to the client's TCP source port. This has a very limited usage.
3471
3472dst <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003473 Applies to the local IPv4 address the client connected to. It can be used to
Willy Tarreau6a06a402007-07-15 20:15:28 +02003474 switch to a different backend for some alternative addresses.
3475
3476dst_port <integer>
3477 Applies to the local port the client connected to. It can be used to switch
3478 to a different backend for some alternative ports.
3479
3480dst_conn <integer>
3481 Applies to the number of currently established connections on the frontend,
3482 including the one being evaluated. It can be used to either return a sorry
Willy Tarreau0ba27502007-12-24 16:55:16 +01003483 page before hard-blocking, or to use a specific backend to drain new requests
Willy Tarreau6a06a402007-07-15 20:15:28 +02003484 when the farm is considered saturated.
3485
Willy Tarreau0ba27502007-12-24 16:55:16 +01003486nbsrv <integer>
3487nbsrv(backend) <integer>
3488 Returns true when the number of usable servers of either the current backend
3489 or the named backend matches the values or ranges specified. This is used to
3490 switch to an alternate backend when the number of servers is too low to
3491 to handle some load. It is useful to report a failure when combined with
3492 "monitor fail".
3493
3494
34952.3.5.2) Matching at Layer 7
3496----------------------------
3497
3498A second set of criteria applies to information which can be found at the
3499application layer (layer 7). Those require that a full HTTP request has been
3500read, and are only evaluated then. They may require slightly more CPU resources
3501than the layer 4 ones, but not much since the request and response are indexed.
3502
Willy Tarreau6a06a402007-07-15 20:15:28 +02003503method <string>
3504 Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
3505 already check for most common methods.
3506
3507req_ver <string>
3508 Applies to the version string in the HTTP request, eg: "1.0". Some predefined
3509 ACL already check for versions 1.0 and 1.1.
3510
3511path <string>
3512 Returns true when the path part of the request, which starts at the first
3513 slash and ends before the question mark, equals one of the strings. It may be
3514 used to match known files, such as /favicon.ico.
3515
3516path_beg <string>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003517 Returns true when the path begins with one of the strings. This can be used
3518 to send certain directory names to alternative backends.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003519
3520path_end <string>
3521 Returns true when the path ends with one of the strings. This may be used to
3522 control file name extension.
3523
3524path_sub <string>
3525 Returns true when the path contains one of the strings. It can be used to
3526 detect particular patterns in paths, such as "../" for example. See also
3527 "path_dir".
3528
3529path_dir <string>
3530 Returns true when one of the strings is found isolated or delimited with
3531 slashes in the path. This is used to perform filename or directory name
3532 matching without the risk of wrong match due to colliding prefixes. See also
3533 "url_dir" and "path_sub".
3534
3535path_dom <string>
3536 Returns true when one of the strings is found isolated or delimited with dots
3537 in the path. This may be used to perform domain name matching in proxy
3538 requests. See also "path_sub" and "url_dom".
3539
3540path_reg <regex>
3541 Returns true when the path matches one of the regular expressions. It can be
3542 used any time, but it is important to remember that regex matching is slower
3543 than other methods. See also "url_reg" and all "path_" criteria.
3544
3545url <string>
3546 Applies to the whole URL passed in the request. The only real use is to match
3547 "*", for which there already is a predefined ACL.
3548
3549url_beg <string>
3550 Returns true when the URL begins with one of the strings. This can be used to
3551 check whether a URL begins with a slash or with a protocol scheme.
3552
3553url_end <string>
3554 Returns true when the URL ends with one of the strings. It has very limited
3555 use. "path_end" should be used instead for filename matching.
3556
3557url_sub <string>
3558 Returns true when the URL contains one of the strings. It can be used to
3559 detect particular patterns in query strings for example. See also "path_sub".
3560
3561url_dir <string>
3562 Returns true when one of the strings is found isolated or delimited with
3563 slashes in the URL. This is used to perform filename or directory name
3564 matching without the risk of wrong match due to colliding prefixes. See also
3565 "path_dir" and "url_sub".
3566
3567url_dom <string>
3568 Returns true when one of the strings is found isolated or delimited with dots
3569 in the URL. This is used to perform domain name matching without the risk of
3570 wrong match due to colliding prefixes. See also "url_sub".
3571
3572url_reg <regex>
3573 Returns true when the URL matches one of the regular expressions. It can be
3574 used any time, but it is important to remember that regex matching is slower
3575 than other methods. See also "path_reg" and all "url_" criteria.
3576
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003577url_ip <ip_address>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003578 Applies to the IP address specified in the absolute URI in an HTTP request.
3579 It can be used to prevent access to certain resources such as local network.
Willy Tarreau198a7442008-01-17 12:05:32 +01003580 It is useful with option "http_proxy".
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003581
3582url_port <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003583 Applies to the port specified in the absolute URI in an HTTP request. It can
3584 be used to prevent access to certain resources. It is useful with option
Willy Tarreau198a7442008-01-17 12:05:32 +01003585 "http_proxy". Note that if the port is not specified in the request, port 80
Willy Tarreau0ba27502007-12-24 16:55:16 +01003586 is assumed.
Alexandre Cassen5eb1a902007-11-29 15:43:32 +01003587
Willy Tarreau6a06a402007-07-15 20:15:28 +02003588hdr <string>
3589hdr(header) <string>
3590 Note: all the "hdr*" matching criteria either apply to all headers, or to a
3591 particular header whose name is passed between parenthesis and without any
Willy Tarreau0ba27502007-12-24 16:55:16 +01003592 space. The header name is not case-sensitive. The header matching complies
3593 with RFC2616, and treats as separate headers all values delimited by commas.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003594
3595 The "hdr" criteria returns true if any of the headers matching the criteria
Willy Tarreau0ba27502007-12-24 16:55:16 +01003596 match any of the strings. This can be used to check exact for values. For
Willy Tarreau6a06a402007-07-15 20:15:28 +02003597 instance, checking that "connection: close" is set :
3598
3599 hdr(Connection) -i close
3600
3601hdr_beg <string>
3602hdr_beg(header) <string>
3603 Returns true when one of the headers begins with one of the strings. See
3604 "hdr" for more information on header matching.
3605
3606hdr_end <string>
3607hdr_end(header) <string>
3608 Returns true when one of the headers ends with one of the strings. See "hdr"
3609 for more information on header matching.
3610
3611hdr_sub <string>
3612hdr_sub(header) <string>
3613 Returns true when one of the headers contains one of the strings. See "hdr"
3614 for more information on header matching.
3615
3616hdr_dir <string>
3617hdr_dir(header) <string>
3618 Returns true when one of the headers contains one of the strings either
3619 isolated or delimited by slashes. This is used to perform filename or
3620 directory name matching, and may be used with Referer. See "hdr" for more
3621 information on header matching.
3622
3623hdr_dom <string>
3624hdr_dom(header) <string>
3625 Returns true when one of the headers contains one of the strings either
3626 isolated or delimited by dots. This is used to perform domain name matching,
3627 and may be used with the Host header. See "hdr" for more information on
3628 header matching.
3629
3630hdr_reg <regex>
3631hdr_reg(header) <regex>
3632 Returns true when one of the headers matches of the regular expressions. It
3633 can be used at any time, but it is important to remember that regex matching
3634 is slower than other methods. See also other "hdr_" criteria, as well as
3635 "hdr" for more information on header matching.
3636
3637hdr_val <integer>
3638hdr_val(header) <integer>
3639 Returns true when one of the headers starts with a number which matches the
3640 values or ranges specified. This may be used to limit content-length to
3641 acceptable values for example. See "hdr" for more information on header
3642 matching.
3643
3644hdr_cnt <integer>
3645hdr_cnt(header) <integer>
Willy Tarreau0ba27502007-12-24 16:55:16 +01003646 Returns true when the number of occurrence of the specified header matches
3647 the values or ranges specified. It is important to remember that one header
3648 line may count as several headers if it has several values. This is used to
3649 detect presence, absence or abuse of a specific header, as well as to block
3650 request smugling attacks by rejecting requests which contain more than one
3651 of certain headers. See "hdr" for more information on header matching.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003652
3653
Willy Tarreau0ba27502007-12-24 16:55:16 +010036542.3.6) Pre-defined ACLs
Willy Tarreau6a06a402007-07-15 20:15:28 +02003655-----------------------
3656
3657Some predefined ACLs are hard-coded so that they do not have to be declared in
3658every frontend which needs them. They all have their names in upper case in
Willy Tarreau0ba27502007-12-24 16:55:16 +01003659order to avoid confusion. Their equivalence is provided below. Please note that
3660only the first three ones are not layer 7 based.
Willy Tarreau6a06a402007-07-15 20:15:28 +02003661
3662ACL name Equivalent to Usage
3663---------------+-----------------------------+---------------------------------
3664TRUE always_true 1 always match
3665FALSE always_false 0 never match
3666LOCALHOST src 127.0.0.1/8 match connection from local host
3667HTTP_1.0 req_ver 1.0 match HTTP version 1.0
3668HTTP_1.1 req_ver 1.1 match HTTP version 1.1
3669METH_CONNECT method CONNECT match HTTP CONNECT method
3670METH_GET method GET HEAD match HTTP GET or HEAD method
3671METH_HEAD method HEAD match HTTP HEAD method
3672METH_OPTIONS method OPTIONS match HTTP OPTIONS method
3673METH_POST method POST match HTTP POST method
3674METH_TRACE method TRACE match HTTP TRACE method
3675HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
3676HTTP_URL_SLASH url_beg / match URL begining with "/"
3677HTTP_URL_STAR url * match URL equal to "*"
3678HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
3679---------------+-----------------------------+---------------------------------
3680
3681
Willy Tarreau0ba27502007-12-24 16:55:16 +010036822.3.7) Using ACLs to form conditions
Willy Tarreau6a06a402007-07-15 20:15:28 +02003683------------------------------------
3684
3685Some actions are only performed upon a valid condition. A condition is a
3686combination of ACLs with operators. 3 operators are supported :
3687
3688 - AND (implicit)
3689 - OR (explicit with the "or" keyword or the "||" operator)
3690 - Negation with the exclamation mark ("!")
3691
3692A condition is formed as a disjonctive form :
3693
3694 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
3695
3696Such conditions are generally used after an "if" or "unless" statement,
3697indicating when the condition will trigger the action.
3698
3699For instance, to block HTTP requests to the "*" URL with methods other than
Willy Tarreau0ba27502007-12-24 16:55:16 +01003700"OPTIONS", as well as POST requests without content-length, and GET or HEAD
3701requests with a content-length greater than 0, and finally every request which
3702is not either GET/HEAD/POST/OPTIONS !
Willy Tarreau6a06a402007-07-15 20:15:28 +02003703
3704 acl missing_cl hdr_cnt(Content-length) eq 0
3705 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
3706 block if METH_GET HTTP_CONTENT
3707 block unless METH_GET or METH_POST or METH_OPTIONS
3708
3709To select a different backend for requests to static contents on the "www" site
3710and to every request on the "img", "video", "download" and "ftp" hosts :
3711
3712 acl url_static path_beg /static /images /img /css
3713 acl url_static path_end .gif .png .jpg .css .js
3714 acl host_www hdr_beg(host) -i www
3715 acl host_static hdr_beg(host) -i img. video. download. ftp.
3716
3717 # now use backend "static" for all static-only hosts, and for static urls
3718 # of host "www". Use backend "www" for the rest.
3719 use_backend static if host_static or host_www url_static
3720 use_backend www if host_www
3721
Willy Tarreau844e3c52008-01-11 16:28:18 +01003722See section 2.2 for detailed help on the "block" and "use_backend" keywords.
Willy Tarreaudbc36f62007-11-30 12:29:11 +01003723
3724
Willy Tarreauc7246fc2007-12-02 17:31:20 +010037252.4) Server options
Willy Tarreau5764b382007-11-30 17:46:49 +01003726-------------------
3727
Willy Tarreau198a7442008-01-17 12:05:32 +01003728The "server" keyword supports a certain number of settings which are all passed
3729as arguments on the server line. The order in which those arguments appear does
3730not count, and they are all optional. Some of those settings are single words
3731(booleans) while others expect one or several values after them. In this case,
3732the values must immediately follow the setting name. All those settings must be
3733specified after the server's address if they are used :
3734
3735 server <name> <address>[:port] [settings ...]
3736
3737The currently supported settings are the following ones.
3738
3739addr <ipv4>
3740 Using the "addr" parameter, it becomes possible to use a different IP address
3741 to send health-checks. On some servers, it may be desirable to dedicate an IP
3742 address to specific component able to perform complex tests which are more
3743 suitable to health-checks than the application. This parameter is ignored if
3744 the "check" parameter is not set. See also the "port" parameter.
3745
3746backup
3747 When "backup" is present on a server line, the server is only used in load
3748 balancing when all other non-backup servers are unavailable. Requests coming
3749 with a persistence cookie referencing the server will always be served
3750 though. By default, only the first operational backup server is used, unless
Willy Tarreauaf85d942008-01-30 10:47:10 +01003751 the "allbackups" option is set in the backend. See also the "allbackups"
Willy Tarreau198a7442008-01-17 12:05:32 +01003752 option.
3753
3754check
3755 This option enables health checks on the server. By default, a server is
3756 always considered available. If "check" is set, the server will receive
3757 periodic health checks to ensure that it is really able to serve requests.
3758 The default address and port to send the tests to are those of the server,
3759 and the default source is the same as the one defined in the backend. It is
3760 possible to change the address using the "addr" parameter, the port using the
3761 "port" parameter, the source address using the "source" address, and the
3762 interval and timers using the "inter", "rise" and "fall" parameters. The
3763 request method is define in the backend using the "httpchk", "smtpchk",
3764 and "ssl-hello-chk" options. Please refer to those options and parameters for
3765 more information.
3766
3767cookie <value>
3768 The "cookie" parameter sets the cookie value assigned to the server to
3769 <value>. This value will be checked in incoming requests, and the first
3770 operational server possessing the same value will be selected. In return, in
3771 cookie insertion or rewrite modes, this value will be assigned to the cookie
3772 sent to the client. There is nothing wrong in having several servers sharing
3773 the same cookie value, and it is in fact somewhat common between normal and
3774 backup servers. See also the "cookie" keyword in backend section.
3775
3776fall <count>
3777 The "fall" parameter states that a server will be considered as dead after
3778 <count> consecutive unsuccessful health checks. This value defaults to 3 if
3779 unspecified. See also the "check", "inter" and "rise" parameters.
3780
3781inter <delay>
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003782fastinter <delay>
3783downinter <delay>
Willy Tarreau198a7442008-01-17 12:05:32 +01003784 The "inter" parameter sets the interval between two consecutive health checks
3785 to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms.
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01003786 It is also possible to use "fastinter" and "downinter" to optimize delays
Willy Tarreau41a340d2008-01-22 12:25:31 +01003787 between checks depending on the server state :
3788
3789 Server state | Interval used
3790 ---------------------------------+-----------------------------------------
3791 UP 100% (non-transitional) | "inter"
3792 ---------------------------------+-----------------------------------------
3793 Transitionally UP (going down), |
3794 Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise.
3795 or yet unchecked. |
3796 ---------------------------------+-----------------------------------------
3797 DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise.
3798 ---------------------------------+-----------------------------------------
3799
3800 Just as with every other time-based parameter, they can be entered in any
3801 other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also
3802 serves as a timeout for health checks sent to servers if "timeout check" is
3803 not set. In order to reduce "resonance" effects when multiple servers are
3804 hosted on the same hardware, the health-checks of all servers are started
3805 with a small time offset between them. It is also possible to add some random
3806 noise in the health checks interval using the global "spread-checks"
3807 keyword. This makes sense for instance when a lot of backends use the same
3808 servers.
Willy Tarreau198a7442008-01-17 12:05:32 +01003809
3810maxconn <maxconn>
3811 The "maxconn" parameter specifies the maximal number of concurrent
3812 connections that will be sent to this server. If the number of incoming
3813 concurrent requests goes higher than this value, they will be queued, waiting
3814 for a connection to be released. This parameter is very important as it can
3815 save fragile servers from going down under extreme loads. If a "minconn"
3816 parameter is specified, the limit becomes dynamic. The default value is "0"
3817 which means unlimited. See also the "minconn" and "maxqueue" parameters, and
3818 the backend's "fullconn" keyword.
3819
3820maxqueue <maxqueue>
3821 The "maxqueue" parameter specifies the maximal number of connections which
3822 will wait in the queue for this server. If this limit is reached, next
3823 requests will be redispatched to other servers instead of indefinitely
3824 waiting to be served. This will break persistence but may allow people to
3825 quickly re-log in when the server they try to connect to is dying. The
3826 default value is "0" which means the queue is unlimited. See also the
3827 "maxconn" and "minconn" parameters.
3828
3829minconn <minconn>
3830 When the "minconn" parameter is set, the maxconn limit becomes a dynamic
3831 limit following the backend's load. The server will always accept at least
3832 <minconn> connections, never more than <maxconn>, and the limit will be on
3833 the ramp between both values when the backend has less than <fullconn>
3834 concurrent connections. This makes it possible to limit the load on the
3835 server during normal loads, but push it further for important loads without
3836 overloading the server during exceptionnal loads. See also the "maxconn"
3837 and "maxqueue" parameters, as well as the "fullconn" backend keyword.
3838
3839port <port>
3840 Using the "port" parameter, it becomes possible to use a different port to
3841 send health-checks. On some servers, it may be desirable to dedicate a port
3842 to a specific component able to perform complex tests which are more suitable
3843 to health-checks than the application. It is common to run a simple script in
3844 inetd for instance. This parameter is ignored if the "check" parameter is not
3845 set. See also the "addr" parameter.
3846
Willy Tarreau21d2af32008-02-14 20:25:24 +01003847redir <prefix>
3848 The "redir" parameter enables the redirection mode for all GET and HEAD
3849 requests addressing this server. This means that instead of having HAProxy
3850 forward the request to the server, it will send an "HTTP 302" response with
3851 the "Location" header composed of this prefix immediately followed by the
3852 requested URI beginning at the leading '/' of the path component. That means
3853 that no trailing slash should be used after <prefix>. All invalid requests
3854 will be rejected, and all non-GET or HEAD requests will be normally served by
3855 the server. Note that since the response is completely forged, no header
3856 mangling nor cookie insertion is possible in the respose. However, cookies in
3857 requests are still analysed, making this solution completely usable to direct
3858 users to a remote location in case of local disaster. Main use consists in
3859 increasing bandwidth for static servers by having the clients directly
3860 connect to them. Note: never use a relative location here, it would cause a
3861 loop between the client and HAProxy!
3862
3863 Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check
3864
Willy Tarreau198a7442008-01-17 12:05:32 +01003865rise <count>
3866 The "rise" parameter states that a server will be considered as operational
3867 after <count> consecutive successful health checks. This value defaults to 2
3868 if unspecified. See also the "check", "inter" and "fall" parameters.
3869
Willy Tarreau5764b382007-11-30 17:46:49 +01003870slowstart <start_time_in_ms>
Willy Tarreau198a7442008-01-17 12:05:32 +01003871 The "slowstart" parameter for a server accepts a value in milliseconds which
Willy Tarreau5764b382007-11-30 17:46:49 +01003872 indicates after how long a server which has just come back up will run at
Willy Tarreaubefdff12007-12-02 22:27:38 +01003873 full speed. Just as with every other time-based parameter, it can be entered
3874 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
3875 linearly from 0 to 100% during this time. The limitation applies to two
3876 parameters :
Willy Tarreau5764b382007-11-30 17:46:49 +01003877
3878 - maxconn: the number of connections accepted by the server will grow from 1
3879 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
3880
3881 - weight: when the backend uses a dynamic weighted algorithm, the weight
3882 grows linearly from 1 to 100%. In this case, the weight is updated at every
Willy Tarreau198a7442008-01-17 12:05:32 +01003883 health-check. For this reason, it is important that the "inter" parameter
3884 is smaller than the "slowstart", in order to maximize the number of steps.
Willy Tarreau5764b382007-11-30 17:46:49 +01003885
3886 The slowstart never applies when haproxy starts, otherwise it would cause
3887 trouble to running servers. It only applies when a server has been previously
3888 seen as failed.
3889
Willy Tarreau198a7442008-01-17 12:05:32 +01003890source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
3891 The "source" parameter sets the source address which will be used when
3892 connecting to the server. It follows the exact same parameters and principle
3893 as the backend "source" keyword, except that it only applies to the server
3894 referencing it. Please consult the "source" keyword for details.
3895
3896weight <weight>
3897 The "weight" parameter is used to adjust the server's weight relative to
3898 other servers. All servers will receive a load proportional to their weight
3899 relative to the sum of all weights, so the higher the weight, the higher the
3900 load. The default weight is 1, and the maximal value is 255. If this
3901 parameter is used to distribute the load according to server's capacity, it
3902 is recommended to start with values which can both grow and shrink, for
3903 instance between 10 and 100 to leave enough room above and below for later
3904 adjustments.
3905
Willy Tarreauced27012008-01-17 20:35:34 +01003906
39072.5) HTTP header manipulation
3908-----------------------------
3909
3910In HTTP mode, it is possible to rewrite, add or delete some of the request and
3911response headers based on regular expressions. It is also possible to block a
3912request or a response if a particular header matches a regular expression,
3913which is enough to stop most elementary protocol attacks, and to protect
3914against information leak from the internal network. But there is a limitation
3915to this : since HAProxy's HTTP engine does not support keep-alive, only headers
3916passed during the first request of a TCP session will be seen. All subsequent
3917headers will be considered data only and not analyzed. Furthermore, HAProxy
3918never touches data contents, it stops analysis at the end of headers.
3919
3920This section covers common usage of the following keywords, described in detail
3921in section 2.2.1 :
3922
3923 - reqadd <string>
3924 - reqallow <search>
3925 - reqiallow <search>
3926 - reqdel <search>
3927 - reqidel <search>
3928 - reqdeny <search>
3929 - reqideny <search>
3930 - reqpass <search>
3931 - reqipass <search>
3932 - reqrep <search> <replace>
3933 - reqirep <search> <replace>
3934 - reqtarpit <search>
3935 - reqitarpit <search>
3936 - rspadd <string>
3937 - rspdel <search>
3938 - rspidel <search>
3939 - rspdeny <search>
3940 - rspideny <search>
3941 - rsprep <search> <replace>
3942 - rspirep <search> <replace>
3943
3944With all these keywords, the same conventions are used. The <search> parameter
3945is a POSIX extended regular expression (regex) which supports grouping through
3946parenthesis (without the backslash). Spaces and other delimiters must be
3947prefixed with a backslash ('\') to avoid confusion with a field delimiter.
3948Other characters may be prefixed with a backslash to change their meaning :
3949
3950 \t for a tab
3951 \r for a carriage return (CR)
3952 \n for a new line (LF)
3953 \ to mark a space and differentiate it from a delimiter
3954 \# to mark a sharp and differentiate it from a comment
3955 \\ to use a backslash in a regex
3956 \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy)
3957 \xXX to write the ASCII hex code XX as in the C language
3958
3959The <replace> parameter contains the string to be used to replace the largest
3960portion of text matching the regex. It can make use of the special characters
3961above, and can reference a substring which is delimited by parenthesis in the
3962regex, by writing a backslash ('\') immediately followed by one digit from 0 to
Willy Tarreaud2a4aa22008-01-31 15:28:22 +010039639 indicating the group position (0 designating the entire line). This practice
Willy Tarreauced27012008-01-17 20:35:34 +01003964is very common to users of the "sed" program.
3965
3966The <string> parameter represents the string which will systematically be added
3967after the last header line. It can also use special character sequences above.
3968
3969Notes related to these keywords :
3970---------------------------------
3971 - these keywords are not always convenient to allow/deny based on header
3972 contents. It is strongly recommended to use ACLs with the "block" keyword
3973 instead, resulting in far more flexible and manageable rules.
3974
3975 - lines are always considered as a whole. It is not possible to reference
3976 a header name only or a value only. This is important because of the way
3977 headers are written (notably the number of spaces after the colon).
3978
3979 - the first line is always considered as a header, which makes it possible to
3980 rewrite or filter HTTP requests URIs or response codes, but in turn makes
3981 it harder to distinguish between headers and request line. The regex prefix
3982 ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix
3983 ^[^ \t:]*: matches any header name followed by a colon.
3984
3985 - for performances reasons, the number of characters added to a request or to
3986 a response is limited at build time to values between 1 and 4 kB. This
3987 should normally be far more than enough for most usages. If it is too short
3988 on occasional usages, it is possible to gain some space by removing some
3989 useless headers before adding new ones.
3990
3991 - keywords beginning with "reqi" and "rspi" are the same as their couterpart
3992 without the 'i' letter except that they ignore case when matching patterns.
3993
3994 - when a request passes through a frontend then a backend, all req* rules
3995 from the frontend will be evaluated, then all req* rules from the backend
3996 will be evaluated. The reverse path is applied to responses.
3997
3998 - req* statements are applied after "block" statements, so that "block" is
3999 always the first one, but before "use_backend" in order to permit rewriting
4000 before switching.
4001
Willy Tarreau5764b382007-11-30 17:46:49 +01004002
Willy Tarreauced27012008-01-17 20:35:34 +010040032.6) Logging
Willy Tarreau844e3c52008-01-11 16:28:18 +01004004------------
4005
4006[to do]
4007
4008
Willy Tarreau0ba27502007-12-24 16:55:16 +01004009/*
4010 * Local variables:
4011 * fill-column: 79
4012 * End:
4013 */