blob: c9ba70dcb2053c6e78e77641e1d619e3046f37fa [file] [log] [blame]
Willy Tarreau6a06a402007-07-15 20:15:28 +02001 ----------------------
2 HAProxy
3 Configuration Manual
4 ----------------------
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +02005 version 1.3.13
Willy Tarreau6a06a402007-07-15 20:15:28 +02006 willy tarreau
Willy Tarreaufbee7132007-10-18 13:53:22 +02007 2007/10/18
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
12docuemntation, please refer to the Reference Manual or the Architecture Manual.
13
14
15HAProxy's configuration process involves 3 major sources of parameters :
16
17 - the arguments from the command-line, which always take precedence
18 - the "global" section, which sets process-wide parameters
19 - the proxies sections which can take form of "defaults", "listen",
20 "frontend" and "backend".
21
221. Global parameters
23--------------------
24
25Parameters in the "global" section are process-wide and often OS-specific. They
26are generally set once for all and do not need being changed once correct. Some
27of them have command-line equivalents.
28
29The following keywords are supported in the "global" section :
30
31 * Process management and security
32 - chroot
33 - daemon
34 - gid
35 - group
36 - log
37 - nbproc
38 - pidfile
39 - uid
40 - ulimit-n
41 - user
Willy Tarreaufbee7132007-10-18 13:53:22 +020042 - stats
Willy Tarreau6a06a402007-07-15 20:15:28 +020043
44 * Performance tuning
45 - maxconn
46 - noepoll
47 - nokqueue
48 - nopoll
49 - nosepoll
50 - tune.maxpollevents
Willy Tarreaufe255b72007-10-14 23:09:26 +020051 - spread-checks
Willy Tarreau6a06a402007-07-15 20:15:28 +020052
53 * Debugging
54 - debug
55 - quiet
Willy Tarreau6a06a402007-07-15 20:15:28 +020056
57
581.1) Process management and security
59------------------------------------
60
61chroot <jail dir>
62 Changes current directory to <jail dir> and performs a chroot() there before
63 dropping privileges. This increases the security level in case an unknown
64 vulnerability would be exploited, since it would make it very hard for the
65 attacker to exploit the system. This only works when the process is started
66 with superuser privileges. It is important to ensure that <jail_dir> is both
67 empty and unwritable to anyone.
68
69daemon
70 Makes the process fork into background. This is the recommended mode of
71 operation. It is equivalent to the command line "-D" argument. It can be
72 disabled by the command line "-db" argument.
73
74gid <number>
75 Changes the process' group ID to <number>. It is recommended that the group
76 ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
77 be started with a user belonging to this group, or with superuser privileges.
78 See also "group" and "uid".
79
80group <group name>
81 Similar to "gid" but uses the GID of group name <group name> from /etc/group.
82 See also "gid" and "user".
83
84log <address> <facility> [max level]
85 Adds a global syslog server. Up to two global servers can be defined. They
86 will receive logs for startups and exits, as well as all logs from proxies
87 configured with "log global". <address> is an IPv4 address optionally
88 followed by a colon and an UDP port. If no port is specified, 514 is used
89 by default (the standard syslog port). <facility> must be one of the 24
90 standard syslog facilities :
91
92 kern user mail daemon auth syslog lpr news
93 uucp cron auth2 ftp ntp audit alert cron2
94 local0 local1 local2 local3 local4 local5 local6 local7
95
96 An optional level can be specified to filter outgoing messages. By default,
97 all messages are sent. If a level is specified, only messages with a severity
98 at least as important as this level will be sent. 8 levels are known :
99
100 emerg alert crit err warning notice info debug
101
102nbproc <number>
103 Creates <number> processes when going daemon. This requires the "daemon"
104 mode. By default, only one process is created, which is the recommended mode
105 of operation. For systems limited to small sets of file descriptors per
106 process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
107 IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
108
109pidfile <pidfile>
110 Writes pids of all daemons into file <pidfile>. This option is equivalent to
111 the "-p" command line argument. The file must be accessible to the user
112 starting the process. See also "daemon".
113
Willy Tarreaufbee7132007-10-18 13:53:22 +0200114stats socket <path> [{uid | user} <uid>] [{gid | group} <gid>] [mode <mode>]
115 Creates a UNIX socket in stream mode at location <path>. Any previously
116 existing socket will be backed up then replaced. Connections to this socket
117 will get a CSV-formated output of the process statistics in response to the
118 "show stat" command followed by a line feed. On platforms which support it,
119 it is possible to restrict access to this socket by specifying numerical IDs
120 after "uid" and "gid", or valid user and group names after the "user" and
121 "group" keywords. It is also possible to restrict permissions on the socket
122 by passing an octal value after the "mode" keyword (same syntax as chmod).
123 Depending on the platform, the permissions on the socket will be inherited
124 from the directory which hosts it, or from the user the process is started
125 with.
126
127stats timeout <timeout, in milliseconds>
128 The default timeout on the stats socket is set to 10 seconds. It is possible
129 to change this value with "stats timeout". The value must be passed in
Willy Tarreaubefdff12007-12-02 22:27:38 +0100130 milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
Willy Tarreaufbee7132007-10-18 13:53:22 +0200131
132stats maxconn <connections>
133 By default, the stats socket is limited to 10 concurrent connections. It is
134 possible to change this value with "stats maxconn".
135
Willy Tarreau6a06a402007-07-15 20:15:28 +0200136uid <number>
137 Changes the process' user ID to <number>. It is recommended that the user ID
138 is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
139 be started with superuser privileges in order to be able to switch to another
140 one. See also "gid" and "user".
141
142ulimit-n <number>
143 Sets the maximum number of per-process file-descriptors to <number>. By
144 default, it is automatically computed, so it is recommended not to use this
145 option.
146
147user <user name>
148 Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
149 See also "uid" and "group".
150
151
1521.2) Performance tuning
153-----------------------
154
155maxconn <number>
156 Sets the maximum per-process number of concurrent connections to <number>. It
157 is equivalent to the command-line argument "-n". Proxies will stop accepting
158 connections when this limit is reached. The "ulimit-n" parameter is
159 automatically adjusted according to this value. See also "ulimit-n".
160
161noepoll
162 Disables the use of the "epoll" event polling system on Linux. It is
163 equivalent to the command-line argument "-de". The next polling system
164 used will generally be "poll". See also "nosepoll", and "nopoll".
165
166nokqueue
167 Disables the use of the "kqueue" event polling system on BSD. It is
168 equivalent to the command-line argument "-dk". The next polling system
169 used will generally be "poll". See also "nopoll".
170
171nopoll
172 Disables the use of the "poll" event polling system. It is equivalent to the
173 command-line argument "-dp". The next polling system used will be "select".
174 It should never be needed to didsable "poll" since it's available on all
175 platforms supported by HAProxy. See also "nosepoll", and "nopoll" and
176 "nokqueue".
177
178nosepoll
179 Disables the use of the "speculative epoll" event polling system on Linux. It
180 is equivalent to the command-line argument "-ds". The next polling system
181 used will generally be "epoll". See also "nosepoll", and "nopoll".
182
183tune.maxpollevents <number>
184 Sets the maximum amount of events that can be processed at once in a call to
185 the polling system. The default value is adapted to the operating system. It
186 has been noticed that reducing it below 200 tends to slightly decrease
187 latency at the expense of network bandwidth, and increasing it above 200
188 tends to trade latency for slightly increased bandwidth.
189
Willy Tarreaufe255b72007-10-14 23:09:26 +0200190spread-checks <0..50, in percent>
191 Sometimes it is desirable to avoid sending health checks to servers at exact
192 intervals, for instance when many logical servers are located on the same
193 physical server. With the help of this parameter, it becomes possible to add
194 some randomness in the check interval between 0 and +/- 50%. A value between
195 2 and 5 seems to show good results. The default value remains at 0.
196
Willy Tarreau6a06a402007-07-15 20:15:28 +0200197
1981.3) Debugging
199---------------
200
201debug
202 Enables debug mode which dumps to stdout all exchanges, and disables forking
203 into background. It is the equivalent of the command-line argument "-d". It
204 should never be used in a production configuration since it may prevent full
205 system startup.
206
207quiet
208 Do not display any message during startup. It is equivalent to the command-
209 line argument "-q".
210
Willy Tarreau6a06a402007-07-15 20:15:28 +0200211
2122) Proxies
213----------
214Proxy configuration can be located in a set of sections :
215 - defaults <name>
216 - frontend <name>
217 - backend <name>
218 - listen <name>
219
220A "defaults" section sets default parameters for all other sections following
221its declaration. Those default parameters are reset by the next "defaults"
222section. See below for the list of parameters which can be set in a "defaults"
223section.
224
225A "frontend" section describes a set of listening sockets accepting client
226connections.
227
228A "backend" section describes a set of servers to which the proxy will connect
229to forward incoming connections.
230
231A "listen" section defines a complete proxy with its frontend and backend
232parts combined in one section. It is generally useful for TCP-only traffic.
233
234The following list of keywords is supported. Most of them may only be used in a
235limited set of section types.
236
237keyword defaults frontend listen backend
238----------------------+----------+----------+---------+---------
239acl - X X X
240appsession - - X X
241balance - - X X
242bind - X X -
243block - X X X
244capture cookie X X X X
245capture request header X X X X
246capture response header X X X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100247clitimeout X X X - (deprecated)
248contimeout X X X X (deprecated)
Willy Tarreau6a06a402007-07-15 20:15:28 +0200249cookie X - X X
250default_backend - X X -
251disabled - X X X
252dispatch - - X X
253enabled - X X X
254errorfile X X X X
255errorloc X X X X
256errorloc302 X X X X
257errorloc303 X X X X
258fullconn X - X X
259grace - X X X
Willy Tarreaudbc36f62007-11-30 12:29:11 +0100260http-check disable-on-404 X - X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200261log X X X X
262maxconn X X X -
263mode X X X X
Willy Tarreauc7246fc2007-12-02 17:31:20 +0100264monitor fail - X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200265monitor-net X X X -
266monitor-uri X X X -
267option abortonclose X - X X
268option allbackups X - X X
269option checkcache X - X X
270option clitcpka X X X -
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100271option contstats X X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200272option dontlognull X X X -
273option forceclose X - X X
274option forwardfor X X X X
275option httpchk X - X X
276option httpclose X X X X
277option httplog X X X X
278option logasap X X X -
Alexandre Cassen87ea5482007-10-11 20:48:58 +0200279option nolinger X X X X
Alexandre Cassen5eb1a902007-11-29 15:43:32 +0100280option http_proxy X X X X
Willy Tarreau6a06a402007-07-15 20:15:28 +0200281option persist X - X X
282option redispatch X - X X
283option smtpchk X - X X
284option srvtcpka X - X X
285option ssl-hello-chk X - X X
286option tcpka X X X X
287option tcplog X X X X
288option tcpsplice X X X X
289option transparent X X X -
290redisp X - X X
291redispatch X - X X
292reqadd - X X X
293reqallow - X X X
294reqdel - X X X
295reqdeny - X X X
296reqiallow - X X X
297reqidel - X X X
298reqideny - X X X
299reqipass - X X X
300reqirep - X X X
301reqisetbe - X X X
302reqitarpit - X X X
303reqpass - X X X
304reqrep - X X X
305reqsetbe - X X X
306reqtarpit - X X X
307retries X - X X
308rspadd - X X X
309rspdel - X X X
310rspdeny - X X X
311rspidel - X X X
312rspideny - X X X
313rspirep - X X X
314rsprep - X X X
315server - - X X
316source X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100317srvtimeout X - X X (deprecated)
Willy Tarreau24e779b2007-07-24 23:43:37 +0200318stats auth X - X X
319stats enable X - X X
320stats realm X - X X
Willy Tarreaubbd42122007-07-25 07:26:38 +0200321stats refresh X - X X
Willy Tarreau24e779b2007-07-24 23:43:37 +0200322stats scope X - X X
323stats uri X - X X
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +0200324stats hide-version X - X X
Willy Tarreaue219db72007-12-03 01:30:13 +0100325timeout appsession X - X X
326timeout client X X X -
327timeout clitimeout X X X - (deprecated)
328timeout connect X - X X
329timeout contimeout X - X X (deprecated)
330timeout queue X - X X
331timeout server X - X X
332timeout srvtimeout X - X X (deprecated)
333timeout tarpit X X X -
Willy Tarreau6a06a402007-07-15 20:15:28 +0200334transparent X X X -
335use_backend - X X -
336usesrc X - X X
337----------------------+----------+----------+---------+---------
338keyword defaults frontend listen backend
339
Willy Tarreau6a06a402007-07-15 20:15:28 +0200340
3412.1) using ACLs
342---------------
343
344The use of Access Control Lists (ACL) provides a flexible solution to perform
345content switching. The principle is simple :
346
347 - define test criteria with sets of values
348 - perform actions only if a set of tests is valid
349
350The actions generally consist in blocking the request, or selecting a backend.
351
352In order to define a test, the "acl" keyword is used. The syntax is :
353
354 acl <aclname> <criterion> [flags] [operator] <value> ...
355
356This creates an ACL <aclname> or completes an existing one with new
357tests. Those tests apply to the portion of request specified in <criterion>
358and may be adjusted with optional flags [flags]. Some criteria also support
359an operator which may be specified before the set of values. The values are
360of the type supported by the criterion, and are separated by spaces.
361
362There is no limit to the number of ACLs. The unused ones do not affect
363performance, they just consume a small amount of memory.
364
365The current flags are currently supported :
366
367 -i : ignore case during matching.
368 -- : force end of flags. Useful when a string looks like one of the flags.
369
370Supported types of values are :
371 - integers or integer ranges
372 - strings
373 - regular expressions
374 - IP addresses and networks
375
376
3772.1.1) Matching integers
378------------------------
379
380Matching integers is special in that ranges and operators are permitted. Note
381that integer matching only applies to positive values. A range is a value
382expressed with a lower and an upper bound separated with a colon, both of which
383may be omitted.
384
385For instance, "1024:65535" is a valid range to represent a range of
386unprivileged ports, and "1024:" would also work. "0:1023" is a valid
387representation of privileged ports, and ":1023" would also work.
388
389For an easier usage, comparison operators are also supported. Note that using
390operators with ranges does not make much sense and is discouraged. Also, it
391does not make much sense to perform order comparisons with a set of values.
392
393Available operators are :
394
395 eq : true if the tested value equals at least one value
396 ge : true if the tested value is greater than or equal to at least one value
397 gt : true if the tested value is greater than at least one value
398 le : true if the tested value is less than or equal to at least one value
399 lt : true if the tested value is less than at least one value
400
401For instance, the following ACL matches negative Content-Length headers :
402
403 acl negative-length hdr_val(content-length) lt 0
404
405
4062.1.2) Matching strings
407-----------------------
408
409String matching applies to verbatim strings as they are passed, with the
410exception of the backslash ("\") which makes it possible to escape some
411characters such as the space. If the "-i" flag is passed before the first
412string, then the matching will be performed ignoring the case. In order
413to match the string "-i", either set it second, or pass the "--" flag
414before the first string.
415
416
4172.1.3) Matching regular expressions (regexes)
418---------------------------------------------
419
420Just like with string matching, regex matching applies to verbatim strings as
421they are passed, with the exception of the backslash ("\") which makes it
422possible to escape some characters such as the space. If the "-i" flag is
423passed before the first regex, then the matching will be performed ignoring
424the case. In order to match the string "-i", either set it second, or pass
425the "--" flag before the first string.
426
427
4282.1.4) Matching IPv4 addresses
429----------------------------
430
431IPv4 addresses values can be specified either as plain addresses or with a
432netmask appended, in which case the IPv4 address matches whenever it is
433within the network. Plain addresses may also be replaced with a resolvable
434host name, but this practise is generally discouraged as it makes it more
435difficult to read configurations.
436
437
4382.1.5) Available matching criteria
439----------------------------------
440
441always_false
442 This one never matches. All values and flags are ignored. It may be used as
443 a temporary replacement for another one when adjusting configurations.
444
445always_true
446 This one always matches. All values and flags are ignored. It may be used as
447 a temporary replacement for another one when adjusting configurations.
448
449src <ip_address>
450 Applies to the client's IP address. It is usually used to limit access to
451 certain resources such as statistics. Note that it is the TCP-level source
452 address which is used, and not the address of a client behind a proxy.
453
454src_port <integer>
455 Applies to the client's TCP source port. This has a very limited usage.
456
457dst <ip_address>
458 Applies to the local IP address the client connected to. It can be used to
459 switch to a different backend for some alternative addresses.
460
461dst_port <integer>
462 Applies to the local port the client connected to. It can be used to switch
463 to a different backend for some alternative ports.
464
465dst_conn <integer>
466 Applies to the number of currently established connections on the frontend,
467 including the one being evaluated. It can be used to either return a sorry
468 page before hard-blocking, or to use a specific backend to drain the requests
469 when the farm is considered saturated.
470
471method <string>
472 Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
473 already check for most common methods.
474
475req_ver <string>
476 Applies to the version string in the HTTP request, eg: "1.0". Some predefined
477 ACL already check for versions 1.0 and 1.1.
478
479path <string>
480 Returns true when the path part of the request, which starts at the first
481 slash and ends before the question mark, equals one of the strings. It may be
482 used to match known files, such as /favicon.ico.
483
484path_beg <string>
485 Returns true when the path begins with one of the strings. This can be used to
486 send certain directory names to alternative backends.
487
488path_end <string>
489 Returns true when the path ends with one of the strings. This may be used to
490 control file name extension.
491
492path_sub <string>
493 Returns true when the path contains one of the strings. It can be used to
494 detect particular patterns in paths, such as "../" for example. See also
495 "path_dir".
496
497path_dir <string>
498 Returns true when one of the strings is found isolated or delimited with
499 slashes in the path. This is used to perform filename or directory name
500 matching without the risk of wrong match due to colliding prefixes. See also
501 "url_dir" and "path_sub".
502
503path_dom <string>
504 Returns true when one of the strings is found isolated or delimited with dots
505 in the path. This may be used to perform domain name matching in proxy
506 requests. See also "path_sub" and "url_dom".
507
508path_reg <regex>
509 Returns true when the path matches one of the regular expressions. It can be
510 used any time, but it is important to remember that regex matching is slower
511 than other methods. See also "url_reg" and all "path_" criteria.
512
513url <string>
514 Applies to the whole URL passed in the request. The only real use is to match
515 "*", for which there already is a predefined ACL.
516
517url_beg <string>
518 Returns true when the URL begins with one of the strings. This can be used to
519 check whether a URL begins with a slash or with a protocol scheme.
520
521url_end <string>
522 Returns true when the URL ends with one of the strings. It has very limited
523 use. "path_end" should be used instead for filename matching.
524
525url_sub <string>
526 Returns true when the URL contains one of the strings. It can be used to
527 detect particular patterns in query strings for example. See also "path_sub".
528
529url_dir <string>
530 Returns true when one of the strings is found isolated or delimited with
531 slashes in the URL. This is used to perform filename or directory name
532 matching without the risk of wrong match due to colliding prefixes. See also
533 "path_dir" and "url_sub".
534
535url_dom <string>
536 Returns true when one of the strings is found isolated or delimited with dots
537 in the URL. This is used to perform domain name matching without the risk of
538 wrong match due to colliding prefixes. See also "url_sub".
539
540url_reg <regex>
541 Returns true when the URL matches one of the regular expressions. It can be
542 used any time, but it is important to remember that regex matching is slower
543 than other methods. See also "path_reg" and all "url_" criteria.
544
Alexandre Cassen5eb1a902007-11-29 15:43:32 +0100545url_ip <ip_address>
546 Applies to the IP address parsed in HTTP request. It can be used to
547 prevent access to certain resources such as local network. It is useful
548 with option 'http_proxy'.
549
550url_port <integer>
551 Applies to the port parsed in HTTP request. It can be used to
552 prevent access to certain resources. It is useful with option 'http_proxy'.
553
Willy Tarreau6a06a402007-07-15 20:15:28 +0200554hdr <string>
555hdr(header) <string>
556 Note: all the "hdr*" matching criteria either apply to all headers, or to a
557 particular header whose name is passed between parenthesis and without any
558 space. The header matching complies with RFC2616, and treats as separate
559 headers all values delimited by comas.
560
561 The "hdr" criteria returns true if any of the headers matching the criteria
562 match any of the strings. This can be used to check exact values. For
563 instance, checking that "connection: close" is set :
564
565 hdr(Connection) -i close
566
567hdr_beg <string>
568hdr_beg(header) <string>
569 Returns true when one of the headers begins with one of the strings. See
570 "hdr" for more information on header matching.
571
572hdr_end <string>
573hdr_end(header) <string>
574 Returns true when one of the headers ends with one of the strings. See "hdr"
575 for more information on header matching.
576
577hdr_sub <string>
578hdr_sub(header) <string>
579 Returns true when one of the headers contains one of the strings. See "hdr"
580 for more information on header matching.
581
582hdr_dir <string>
583hdr_dir(header) <string>
584 Returns true when one of the headers contains one of the strings either
585 isolated or delimited by slashes. This is used to perform filename or
586 directory name matching, and may be used with Referer. See "hdr" for more
587 information on header matching.
588
589hdr_dom <string>
590hdr_dom(header) <string>
591 Returns true when one of the headers contains one of the strings either
592 isolated or delimited by dots. This is used to perform domain name matching,
593 and may be used with the Host header. See "hdr" for more information on
594 header matching.
595
596hdr_reg <regex>
597hdr_reg(header) <regex>
598 Returns true when one of the headers matches of the regular expressions. It
599 can be used at any time, but it is important to remember that regex matching
600 is slower than other methods. See also other "hdr_" criteria, as well as
601 "hdr" for more information on header matching.
602
603hdr_val <integer>
604hdr_val(header) <integer>
605 Returns true when one of the headers starts with a number which matches the
606 values or ranges specified. This may be used to limit content-length to
607 acceptable values for example. See "hdr" for more information on header
608 matching.
609
610hdr_cnt <integer>
611hdr_cnt(header) <integer>
612 Returns true when the count of the headers which matches the values or ranges
613 specified. This is used to detect presence or absence of a specific header,
614 as well as to block request smugling attacks by rejecting requests which
615 contain more than one of certain headers. See "hdr" for more information on
616 header matching.
617
Willy Tarreauc7246fc2007-12-02 17:31:20 +0100618nbsrv <integer>
619nbsrv(backend) <integer>
620 Returns true when the number of usable servers of either the current backend
621 or the named backend matches the values or ranges specified. This is used to
622 switch to an alternate backend when the number of servers is too low to
623 to handle some load. It is useful to report a failure when combined with
624 "monitor fail".
Willy Tarreau6a06a402007-07-15 20:15:28 +0200625
6262.1.6) Pre-defined ACLs
627-----------------------
628
629Some predefined ACLs are hard-coded so that they do not have to be declared in
630every frontend which needs them. They all have their names in upper case in
631order to avoid confusion. Their equivalence is provided below :
632
633ACL name Equivalent to Usage
634---------------+-----------------------------+---------------------------------
635TRUE always_true 1 always match
636FALSE always_false 0 never match
637LOCALHOST src 127.0.0.1/8 match connection from local host
638HTTP_1.0 req_ver 1.0 match HTTP version 1.0
639HTTP_1.1 req_ver 1.1 match HTTP version 1.1
640METH_CONNECT method CONNECT match HTTP CONNECT method
641METH_GET method GET HEAD match HTTP GET or HEAD method
642METH_HEAD method HEAD match HTTP HEAD method
643METH_OPTIONS method OPTIONS match HTTP OPTIONS method
644METH_POST method POST match HTTP POST method
645METH_TRACE method TRACE match HTTP TRACE method
646HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme
647HTTP_URL_SLASH url_beg / match URL begining with "/"
648HTTP_URL_STAR url * match URL equal to "*"
649HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length
650---------------+-----------------------------+---------------------------------
651
652
6532.1.7) Using ACLs to form conditions
654------------------------------------
655
656Some actions are only performed upon a valid condition. A condition is a
657combination of ACLs with operators. 3 operators are supported :
658
659 - AND (implicit)
660 - OR (explicit with the "or" keyword or the "||" operator)
661 - Negation with the exclamation mark ("!")
662
663A condition is formed as a disjonctive form :
664
665 [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ...
666
667Such conditions are generally used after an "if" or "unless" statement,
668indicating when the condition will trigger the action.
669
670For instance, to block HTTP requests to the "*" URL with methods other than
671"OPTIONS", as well as POST requests without content-length, and GET/HEAD
672requests with a content-length greater than 0, and finally every request
673which is not either GET/HEAD/POST/OPTIONS !
674
675 acl missing_cl hdr_cnt(Content-length) eq 0
676 block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl
677 block if METH_GET HTTP_CONTENT
678 block unless METH_GET or METH_POST or METH_OPTIONS
679
680To select a different backend for requests to static contents on the "www" site
681and to every request on the "img", "video", "download" and "ftp" hosts :
682
683 acl url_static path_beg /static /images /img /css
684 acl url_static path_end .gif .png .jpg .css .js
685 acl host_www hdr_beg(host) -i www
686 acl host_static hdr_beg(host) -i img. video. download. ftp.
687
688 # now use backend "static" for all static-only hosts, and for static urls
689 # of host "www". Use backend "www" for the rest.
690 use_backend static if host_static or host_www url_static
691 use_backend www if host_www
692
693See below for the detailed help on the "block" and "use_backend" keywords.
Willy Tarreaudbc36f62007-11-30 12:29:11 +0100694
695
Willy Tarreauc7246fc2007-12-02 17:31:20 +01006962.2) Instance-specific keywords and statements
697----------------------------------------------
698
699monitor fail [if | unless] <condition>
700 [ supported in: frontend, listen ]
701
702 This statement adds a condition which can force the response to a monitor
703 request to report a failure. By default, when an external component queries
704 the URI dedicated to monitoring, a 200 response is returned. When one of the
705 conditions above is met, haproxy will return 503 instead of 200. This is
706 very useful to report a site failure to an external component which may base
707 routing advertisements between multiple sites on the availability reported by
708 haproxy. In this case, one would rely on an ACL involving the "nbsrv"
709 criterion.
710
711 Example:
712
713 frontend www
714 acl site_dead nbsrv(dynamic) lt 2
715 acl site_dead nbsrv(static) lt 2
716 monitor-uri /site_alive
717 monitor fail if site_dead
718
719
7202.3) Options
Willy Tarreaudbc36f62007-11-30 12:29:11 +0100721------------
722
723A handful of options affect the way the load balancing is performed or reaction
724to state changes.
725
726http-check disable-on-404
727 When this option is set, a server which returns an HTTP code 404 will be
728 excluded from further load-balancing, but will still receive persistent
729 connections. This provides a very convenient method for Web administrators
730 to perform a graceful shutdown of their servers. It is also important to note
731 that a server which is detected as failed while it was in this mode will not
732 generate an alert, just a notice. If the server responds 2xx or 3xx again, it
733 will immediately be reinserted into the farm. The status on the stats page
734 reports "NOLB" for a server in this mode. It is important to note that this
735 option only works in conjunction with the "httpchk" option.
736
737option contstats
738 By default, counters used for statistics calculation are incremented
739 only when a session finishes. It works quite well when serving small
740 objects, but with big ones (for example large images or archives) or
741 with A/V streaming, a graph generated from haproxy counters looks like
742 a hedgehog. With this option enabled counters get incremented continuously,
743 during a whole session. Recounting touches a hotpath directly so
744 it is not enabled by default, as it has small performance impact (~0.5%).
745
746
Willy Tarreauc7246fc2007-12-02 17:31:20 +01007472.4) Server options
Willy Tarreau5764b382007-11-30 17:46:49 +0100748-------------------
749
750slowstart <start_time_in_ms>
751 The 'slowstart' parameter for a server accepts a value in milliseconds which
752 indicates after how long a server which has just come back up will run at
Willy Tarreaubefdff12007-12-02 22:27:38 +0100753 full speed. Just as with every other time-based parameter, it can be entered
754 in any other explicit unit among { us, ms, s, m, h, d }. The speed grows
755 linearly from 0 to 100% during this time. The limitation applies to two
756 parameters :
Willy Tarreau5764b382007-11-30 17:46:49 +0100757
758 - maxconn: the number of connections accepted by the server will grow from 1
759 to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn).
760
761 - weight: when the backend uses a dynamic weighted algorithm, the weight
762 grows linearly from 1 to 100%. In this case, the weight is updated at every
763 health-check. For this reason, it is important that the 'inter' parameter
764 is smaller than the 'slowstart', in order to maximize the number of steps.
765
766 The slowstart never applies when haproxy starts, otherwise it would cause
767 trouble to running servers. It only applies when a server has been previously
768 seen as failed.
769
770