Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 1 | ---------------------- |
| 2 | HAProxy |
| 3 | Configuration Manual |
| 4 | ---------------------- |
Willy Tarreau | b1e52e8 | 2008-01-13 14:49:51 +0100 | [diff] [blame] | 5 | version 1.3.15 |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 6 | willy tarreau |
Willy Tarreau | 41a340d | 2008-01-22 12:25:31 +0100 | [diff] [blame] | 7 | 2008/01/22 |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 8 | |
| 9 | |
| 10 | This document covers the configuration language as implemented in the version |
| 11 | specified above. It does not provide any hint, example or advice. For such |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 12 | documentation, please refer to the Reference Manual or the Architecture Manual. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 13 | |
Willy Tarreau | 41a340d | 2008-01-22 12:25:31 +0100 | [diff] [blame] | 14 | Note to documentation contributors : this document is formated with 80 columns |
| 15 | per line, with even number of spaces for indentation and without tabs. Please |
| 16 | follow these rules strictly so that it remains easily printable everywhere. If |
| 17 | a line needs to be printed verbatim and does not fit, please end each line with |
| 18 | a backslash ('\') and continue on next line. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 19 | |
| 20 | HAProxy'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 Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 27 | The configuration file syntax consists in lines beginning with a keyword |
| 28 | referenced in this manual, optionally followed by one or several parameters |
| 29 | delimited by spaces. If spaces have to be entered in strings, then they must be |
| 30 | preceeded by a backslash ('\') to be escaped. Backslashes also have to be |
| 31 | escaped by doubling them. |
| 32 | |
| 33 | Some parameters involve values representating time, such as timeouts. These |
| 34 | values are generally expressed in milliseconds (unless explicitly stated |
| 35 | otherwise) but may be expressed in any other unit by suffixing the unit to the |
| 36 | numeric value. It is important to consider this because it will not be repeated |
| 37 | for 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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 47 | 1. Global parameters |
| 48 | -------------------- |
| 49 | |
| 50 | Parameters in the "global" section are process-wide and often OS-specific. They |
| 51 | are generally set once for all and do not need being changed once correct. Some |
| 52 | of them have command-line equivalents. |
| 53 | |
| 54 | The 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 Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 67 | - stats |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 68 | |
| 69 | * Performance tuning |
| 70 | - maxconn |
| 71 | - noepoll |
| 72 | - nokqueue |
| 73 | - nopoll |
| 74 | - nosepoll |
Willy Tarreau | fe255b7 | 2007-10-14 23:09:26 +0200 | [diff] [blame] | 75 | - spread-checks |
Willy Tarreau | a0250ba | 2008-01-06 11:22:57 +0100 | [diff] [blame] | 76 | - tune.maxaccept |
| 77 | - tune.maxpollevents |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 78 | |
| 79 | * Debugging |
| 80 | - debug |
| 81 | - quiet |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 82 | |
| 83 | |
| 84 | 1.1) Process management and security |
| 85 | ------------------------------------ |
| 86 | |
| 87 | chroot <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 | |
| 95 | daemon |
| 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 | |
| 100 | gid <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 | |
| 106 | group <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 | |
| 110 | log <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 Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 113 | configured with "log global". |
| 114 | |
| 115 | <address> can be one of: |
| 116 | |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 117 | - An IPv4 address optionally followed by a colon and a UDP port. If |
Robert Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 118 | 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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 127 | |
| 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 | |
| 138 | nbproc <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 | |
| 145 | pidfile <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 Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 150 | stats 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 Tarreau | a8efd36 | 2008-01-03 10:19:15 +0100 | [diff] [blame] | 154 | "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 Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 164 | |
| 165 | stats 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 Tarreau | befdff1 | 2007-12-02 22:27:38 +0100 | [diff] [blame] | 168 | milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }. |
Willy Tarreau | fbee713 | 2007-10-18 13:53:22 +0200 | [diff] [blame] | 169 | |
| 170 | stats 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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 174 | uid <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 | |
| 180 | ulimit-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 | |
| 185 | user <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 | |
| 190 | 1.2) Performance tuning |
| 191 | ----------------------- |
| 192 | |
| 193 | maxconn <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 | |
| 199 | noepoll |
| 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 | |
| 204 | nokqueue |
| 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 | |
| 209 | nopoll |
| 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 Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 212 | It should never be needed to disable "poll" since it's available on all |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 213 | platforms supported by HAProxy. See also "nosepoll", and "nopoll" and |
| 214 | "nokqueue". |
| 215 | |
| 216 | nosepoll |
| 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 Tarreau | fe255b7 | 2007-10-14 23:09:26 +0200 | [diff] [blame] | 221 | spread-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 Tarreau | a0250ba | 2008-01-06 11:22:57 +0100 | [diff] [blame] | 228 | tune.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 | |
| 238 | tune.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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 245 | |
| 246 | 1.3) Debugging |
| 247 | --------------- |
| 248 | |
| 249 | debug |
| 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 | |
| 255 | quiet |
| 256 | Do not display any message during startup. It is equivalent to the command- |
| 257 | line argument "-q". |
| 258 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 259 | |
| 260 | 2) Proxies |
| 261 | ---------- |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 262 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 263 | Proxy configuration can be located in a set of sections : |
| 264 | - defaults <name> |
| 265 | - frontend <name> |
| 266 | - backend <name> |
| 267 | - listen <name> |
| 268 | |
| 269 | A "defaults" section sets default parameters for all other sections following |
| 270 | its declaration. Those default parameters are reset by the next "defaults" |
| 271 | section. See below for the list of parameters which can be set in a "defaults" |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 272 | section. The name is optional but its use is encouraged for better readability. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 273 | |
| 274 | A "frontend" section describes a set of listening sockets accepting client |
| 275 | connections. |
| 276 | |
| 277 | A "backend" section describes a set of servers to which the proxy will connect |
| 278 | to forward incoming connections. |
| 279 | |
| 280 | A "listen" section defines a complete proxy with its frontend and backend |
| 281 | parts combined in one section. It is generally useful for TCP-only traffic. |
| 282 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 283 | All proxy names must be formed from upper and lower case letters, digits, |
| 284 | '-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are |
| 285 | case-sensitive, which means that "www" and "WWW" are two different proxies. |
| 286 | |
| 287 | Historically, all proxy names could overlap, it just caused troubles in the |
| 288 | logs. Since the introduction of content switching, it is mandatory that two |
| 289 | proxies with overlapping capabilities (frontend/backend) have different names. |
| 290 | However, it is still permitted that a frontend and a backend share the same |
| 291 | name, as this configuration seems to be commonly encountered. |
| 292 | |
| 293 | Right now, two major proxy modes are supported : "tcp", also known as layer 4, |
| 294 | and "http", also known as layer 7. In layer 4 mode, HAProxy simply forwards |
| 295 | bidirectionnal traffic between two sides. In layer 7 mode, HAProxy analyzes the |
| 296 | protocol, and can interact with it by allowing, blocking, switching, adding, |
| 297 | modifying, or removing arbitrary contents in requests or responses, based on |
| 298 | arbitrary criteria. |
| 299 | |
| 300 | |
| 301 | 2.1) Quick reminder about HTTP |
| 302 | ------------------------------ |
| 303 | |
| 304 | When a proxy is running in HTTP mode, both the request and the response are |
| 305 | fully analyzed and indexed, thus it becomes possible to build matching criteria |
| 306 | on almost anything found in the contents. |
| 307 | |
| 308 | However, it is important to understand how HTTP requests and responses are |
| 309 | formed, and how HAProxy decomposes them. It will then become easier to write |
| 310 | correct rules and to debug existing configurations. |
| 311 | |
| 312 | |
| 313 | 2.1.1) The HTTP transaction model |
| 314 | --------------------------------- |
| 315 | |
| 316 | The HTTP protocol is transaction-driven. This means that each request will lead |
| 317 | to one and only one response. Traditionnally, a TCP connection is established |
| 318 | from the client to the server, a request is sent by the client on the |
| 319 | connection, the server responds and the connection is closed. A new request |
| 320 | will involve a new connection : |
| 321 | |
| 322 | [CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ... |
| 323 | |
| 324 | In this mode, called the "HTTP close" mode, there are as many connection |
| 325 | establishments as there are HTTP transactions. Since the connection is closed |
| 326 | by the server after the response, the client does not need to know the content |
| 327 | length. |
| 328 | |
| 329 | Due to the transactional nature of the protocol, it was possible to improve it |
| 330 | to avoid closing a connection between two subsequent transactions. In this mode |
| 331 | however, it is mandatory that the server indicates the content length for each |
| 332 | response so that the client does not wait indefinitely. For this, a special |
| 333 | header is used: "Content-length". This mode is called the "keep-alive" mode : |
| 334 | |
| 335 | [CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ... |
| 336 | |
| 337 | Its advantages are a reduced latency between transactions, and less processing |
| 338 | power required on the server side. It is generally better than the close mode, |
| 339 | but not always because the clients often limit their concurrent connections to |
| 340 | a smaller value. HAProxy currently does not support the HTTP keep-alive mode, |
| 341 | but knows how to transform it to the close mode. |
| 342 | |
| 343 | A last improvement in the communications is the pipelining mode. It still uses |
| 344 | keep-alive, but the client does not wait for the first response to send the |
| 345 | second request. This is useful for fetching large number of images composing a |
| 346 | page : |
| 347 | |
| 348 | [CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ... |
| 349 | |
| 350 | This can obviously have a tremendous benefit on performance because the network |
| 351 | latency is eliminated between subsequent requests. Many HTTP agents do not |
| 352 | correctly support pipelining since there is no way to associate a response with |
| 353 | the corresponding request in HTTP. For this reason, it is mandatory for the |
| 354 | server to reply in the exact same order as the requests were received. |
| 355 | |
| 356 | Right now, HAProxy only supports the first mode (HTTP close) if it needs to |
| 357 | process the request. This means that for each request, there will be one TCP |
| 358 | connection. If keep-alive or pipelining are required, HAProxy will still |
| 359 | support them, but will only see the first request and the first response of |
| 360 | each transaction. While this is generally problematic with regards to logs, |
| 361 | content switching or filtering, it most often causes no problem for persistence |
| 362 | with cookie insertion. |
| 363 | |
| 364 | |
| 365 | 2.1.2) HTTP request |
| 366 | ------------------- |
| 367 | |
| 368 | First, 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 | |
| 379 | 2.1.2.1) The Request line |
| 380 | ------------------------- |
| 381 | |
| 382 | Line 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 | |
| 388 | All of them are delimited by what the standard calls LWS (linear white spaces), |
| 389 | which are commonly spaces, but can also be tabs or line feeds/carriage returns |
| 390 | followed by spaces/tabs. The method itself cannot contain any colon (':') and |
| 391 | is limited to alphabetic letters. All those various combinations make it |
| 392 | desirable that HAProxy performs the splitting itself rather than leaving it to |
| 393 | the user to write a complex or inaccurate regular expression. |
| 394 | |
| 395 | The 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 | |
| 423 | In a relative URI, two sub-parts are identified. The part before the question |
| 424 | mark is called the "path". It is typically the relative path to static objects |
| 425 | on the server. The part after the question mark is called the "query string". |
| 426 | It is mostly used with GET requests sent to dynamic scripts and is very |
| 427 | specific to the language, framework or application in use. |
| 428 | |
| 429 | |
| 430 | 2.1.2.2) The request headers |
| 431 | ---------------------------- |
| 432 | |
| 433 | The headers start at the second line. They are composed of a name at the |
| 434 | beginning of the line, immediately followed by a colon (':'). Traditionally, |
| 435 | an LWS is added after the colon but that's not required. Then come the values. |
| 436 | Multiple identical headers may be folded into one single line, delimiting the |
| 437 | values with commas, provided that their order is respected. This is commonly |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 438 | encountered in the "Cookie:" field. A header may span over multiple lines if |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 439 | the subsequent lines begin with an LWS. In the example in 2.1.2, lines 4 and 5 |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 440 | define a total of 3 values for the "Accept:" header. |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 441 | |
| 442 | Contrary to a common mis-conception, header names are not case-sensitive, and |
| 443 | their values are not either if they refer to other header names (such as the |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 444 | "Connection:" header). |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 445 | |
| 446 | The end of the headers is indicated by the first empty line. People often say |
| 447 | that it's a double line feed, which is not exact, even if a double line feed |
| 448 | is one valid form of empty line. |
| 449 | |
| 450 | Fortunately, HAProxy takes care of all these complex combinations when indexing |
| 451 | headers, checking values and counting them, so there is no reason to worry |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 452 | about the way they could be written, but it is important not to accuse an |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 453 | application of being buggy if it does unusual, valid things. |
| 454 | |
| 455 | Important 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 | |
| 462 | 2.1.3) HTTP response |
| 463 | -------------------- |
| 464 | |
| 465 | An HTTP response looks very much like an HTTP request. Both are called HTTP |
| 466 | messages. 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 | |
| 475 | 2.1.3.1) The Response line |
| 476 | -------------------------- |
| 477 | |
| 478 | Line 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 | |
| 484 | The 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 | |
| 490 | Please 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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 492 | found there, but it's a common practice to respect the well-established |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 493 | messages. It can be composed of one or multiple words, such as "OK", "Found", |
| 494 | or "Authentication Required". |
| 495 | |
| 496 | |
| 497 | 2.1.3.2) The response headers |
| 498 | ----------------------------- |
| 499 | |
| 500 | Response headers work exactly like request headers, and as such, HAProxy uses |
| 501 | the same parsing function for both. Please refer to paragraph 2.1.2.2 for more |
| 502 | details. |
| 503 | |
| 504 | |
| 505 | 2.2) Proxy keywords matrix |
| 506 | ---------------------------- |
| 507 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 508 | The following list of keywords is supported. Most of them may only be used in a |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 509 | limited set of section types. Some of them are marked as "deprecated" because |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 510 | they are inherited from an old syntax which may be confusing or functionally |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 511 | limited, and there are new recommended keywords to replace them. Keywords |
| 512 | listed with [no] can be optionally inverted using the "no" prefix, ex. "no |
| 513 | option contstats". This makes sense when the option has been enabled by default |
| 514 | and must be disabled for a specific instance. |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 515 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 516 | |
| 517 | keyword defaults frontend listen backend |
| 518 | ----------------------+----------+----------+---------+--------- |
| 519 | acl - X X X |
| 520 | appsession - - X X |
Willy Tarreau | c73ce2b | 2008-01-06 10:55:10 +0100 | [diff] [blame] | 521 | backlog X X X - |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 522 | balance X - X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 523 | bind - X X - |
| 524 | block - X X X |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 525 | capture cookie - X X - |
| 526 | capture request header - X X - |
| 527 | capture response header - X X - |
Willy Tarreau | e219db7 | 2007-12-03 01:30:13 +0100 | [diff] [blame] | 528 | clitimeout X X X - (deprecated) |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 529 | contimeout X - X X (deprecated) |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 530 | cookie X - X X |
| 531 | default_backend - X X - |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 532 | disabled X X X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 533 | dispatch - - X X |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 534 | enabled X X X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 535 | errorfile X X X X |
| 536 | errorloc X X X X |
| 537 | errorloc302 X X X X |
| 538 | errorloc303 X X X X |
| 539 | fullconn X - X X |
| 540 | grace - X X X |
Willy Tarreau | dbc36f6 | 2007-11-30 12:29:11 +0100 | [diff] [blame] | 541 | http-check disable-on-404 X - X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 542 | log X X X X |
| 543 | maxconn X X X - |
| 544 | mode X X X X |
Willy Tarreau | c7246fc | 2007-12-02 17:31:20 +0100 | [diff] [blame] | 545 | monitor fail - X X - |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 546 | monitor-net X X X - |
| 547 | monitor-uri X X X - |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 548 | [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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 555 | option forwardfor X X X X |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 556 | [no] option http_proxy X X X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 557 | option httpchk X - X X |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 558 | [no] option httpclose X X X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 559 | option httplog X X X X |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 560 | [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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 564 | option smtpchk X - X X |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 565 | [no] option srvtcpka X - X X |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 566 | option ssl-hello-chk X - X X |
| 567 | option tcpka X X X X |
| 568 | option tcplog X X X X |
Krzysztof Oledzki | 336d475 | 2007-12-25 02:40:22 +0100 | [diff] [blame] | 569 | [no] option tcpsplice X X X X |
| 570 | [no] option transparent X X X - |
| 571 | redisp X - X X (deprecated) |
| 572 | redispatch X - X X (deprecated) |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 573 | reqadd - X X X |
| 574 | reqallow - X X X |
| 575 | reqdel - X X X |
| 576 | reqdeny - X X X |
| 577 | reqiallow - X X X |
| 578 | reqidel - X X X |
| 579 | reqideny - X X X |
| 580 | reqipass - X X X |
| 581 | reqirep - X X X |
| 582 | reqisetbe - X X X |
| 583 | reqitarpit - X X X |
| 584 | reqpass - X X X |
| 585 | reqrep - X X X |
| 586 | reqsetbe - X X X |
| 587 | reqtarpit - X X X |
| 588 | retries X - X X |
| 589 | rspadd - X X X |
| 590 | rspdel - X X X |
| 591 | rspdeny - X X X |
| 592 | rspidel - X X X |
| 593 | rspideny - X X X |
| 594 | rspirep - X X X |
| 595 | rsprep - X X X |
| 596 | server - - X X |
| 597 | source X - X X |
Willy Tarreau | e219db7 | 2007-12-03 01:30:13 +0100 | [diff] [blame] | 598 | srvtimeout X - X X (deprecated) |
Willy Tarreau | 24e779b | 2007-07-24 23:43:37 +0200 | [diff] [blame] | 599 | stats auth X - X X |
| 600 | stats enable X - X X |
| 601 | stats realm X - X X |
Willy Tarreau | bbd4212 | 2007-07-25 07:26:38 +0200 | [diff] [blame] | 602 | stats refresh X - X X |
Willy Tarreau | 24e779b | 2007-07-24 23:43:37 +0200 | [diff] [blame] | 603 | stats scope X - X X |
| 604 | stats uri X - X X |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 605 | stats hide-version X - X X |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 606 | timeout check X - X X |
Willy Tarreau | e219db7 | 2007-12-03 01:30:13 +0100 | [diff] [blame] | 607 | timeout client X X X - |
| 608 | timeout clitimeout X X X - (deprecated) |
| 609 | timeout connect X - X X |
| 610 | timeout contimeout X - X X (deprecated) |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 611 | timeout http-request X X X - |
Willy Tarreau | e219db7 | 2007-12-03 01:30:13 +0100 | [diff] [blame] | 612 | timeout queue X - X X |
| 613 | timeout server X - X X |
| 614 | timeout srvtimeout X - X X (deprecated) |
Willy Tarreau | 51c9bde | 2008-01-06 13:40:03 +0100 | [diff] [blame] | 615 | timeout tarpit X X X X |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 616 | transparent X X X - (deprecated) |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 617 | use_backend - X X - |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 618 | ----------------------+----------+----------+---------+--------- |
| 619 | keyword defaults frontend listen backend |
| 620 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 621 | |
| 622 | 2.2.1) Alphabetically sorted keywords reference |
| 623 | ----------------------------------------------- |
| 624 | |
| 625 | This section provides a description of each keyword and its usage. |
| 626 | |
| 627 | |
| 628 | acl <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 | |
| 640 | appsession <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 Tarreau | c73ce2b | 2008-01-06 10:55:10 +0100 | [diff] [blame] | 673 | backlog <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 Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 698 | balance <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 | |
| 766 | bind [<address>]:<port> [, ...] |
Willy Tarreau | b1e52e8 | 2008-01-13 14:49:51 +0100 | [diff] [blame] | 767 | bind [<address>]:<port> [, ...] transparent |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 768 | 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 Tarreau | b1e52e8 | 2008-01-13 14:49:51 +0100 | [diff] [blame] | 772 | <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 Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 781 | |
Willy Tarreau | b1e52e8 | 2008-01-13 14:49:51 +0100 | [diff] [blame] | 782 | 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 Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 791 | |
| 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 | |
| 806 | block { 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 | |
| 827 | capture 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 Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 863 | section 2.6 about logging. |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 864 | |
| 865 | |
| 866 | capture 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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 872 | case-sensitive, but it is a common practice to write them as they |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 873 | 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 Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 900 | See also : "capture cookie", "capture response header" as well as section 2.6 |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 901 | about logging. |
| 902 | |
| 903 | |
| 904 | capture 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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 910 | case-sensitive, but it is a common practice to write them as they |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 911 | 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 Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 936 | See also : "capture cookie", "capture request header" as well as section 2.6 |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 937 | about logging. |
| 938 | |
| 939 | |
| 940 | clitimeout <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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 957 | situations to debug. It is a good practice to cover one or several TCP packet |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 958 | 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 Tarreau | 036fae0 | 2008-01-06 13:24:40 +0100 | [diff] [blame] | 971 | See also : "timeout client", "timeout http-request", "timeout server", and |
| 972 | "srvtimeout". |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 973 | |
| 974 | |
| 975 | contimeout <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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 985 | immediate (less than a few milliseconds). Anyway, it is a good practice to |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 986 | 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 | |
| 1007 | cookie <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 Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 1091 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1092 | 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 | |
| 1100 | default_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 Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1123 | See also : "use_backend", "reqsetbe", "reqisetbe" |
| 1124 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1125 | |
| 1126 | disabled |
| 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 | |
| 1143 | enabled |
| 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 | |
| 1155 | errorfile <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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 1164 | recommended to follow the common practice of appending ".http" to |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1165 | 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 Tarreau | c27debf | 2008-01-06 08:57:02 +0100 | [diff] [blame] | 1180 | simple method for developing those files consists in associating them to the |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1181 | 403 status code and interrogating a blocked URL. |
| 1182 | |
| 1183 | See also : "errorloc", "errorloc302", "errorloc303" |
| 1184 | |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1185 | |
| 1186 | errorloc <code> <url> |
| 1187 | errorloc302 <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 | |
| 1216 | errorloc303 <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 Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 1238 | it, but no such problem has been reported till now. |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1239 | |
| 1240 | See also : "errorfile", "errorloc", "errorloc302" |
| 1241 | |
| 1242 | |
| 1243 | fullconn <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 Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1251 | When a server has a "maxconn" parameter specified, it means that its number |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1252 | of concurrent connections will never go higher. Additionally, if it has a |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1253 | "minconn" parameter, it indicates a dynamic limit following the backend's |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1254 | 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 | |
| 1273 | grace <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 Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1291 | |
| 1292 | http-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 Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1295 | yes | no | yes | yes |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1296 | 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 Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1308 | See also : "option httpchk" |
| 1309 | |
| 1310 | |
Krzysztof Piotr Oledzki | f58a962 | 2008-02-23 01:19:10 +0100 | [diff] [blame] | 1311 | id <value> |
| 1312 | Set a persistent value for proxy ID. Must be unique and larger than 1000, as |
| 1313 | smaller values are reserved for auto-assigned ids. |
| 1314 | |
| 1315 | |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1316 | log global |
| 1317 | log <address> <facility> [<level>] |
| 1318 | Enable per-instance logging of events and traffic. |
| 1319 | May be used in sections : defaults | frontend | listen | backend |
| 1320 | yes | yes | yes | yes |
| 1321 | Arguments : |
| 1322 | global should be used when the instance's logging parameters are the |
| 1323 | same as the global ones. This is the most common usage. "global" |
| 1324 | replaces <address>, <facility> and <level> with those of the log |
| 1325 | entries found in the "global" section. Only one "log global" |
| 1326 | statement may be used per instance, and this form takes no other |
| 1327 | parameter. |
| 1328 | |
| 1329 | <address> indicates where to send the logs. It takes the same format as |
| 1330 | for the "global" section's logs, and can be one of : |
| 1331 | |
| 1332 | - An IPv4 address optionally followed by a colon (':') and a UDP |
| 1333 | port. If no port is specified, 514 is used by default (the |
| 1334 | standard syslog port). |
| 1335 | |
| 1336 | - A filesystem path to a UNIX domain socket, keeping in mind |
| 1337 | considerations for chroot (be sure the path is accessible |
| 1338 | inside the chroot) and uid/gid (be sure the path is |
| 1339 | appropriately writeable). |
| 1340 | |
| 1341 | <facility> must be one of the 24 standard syslog facilities : |
| 1342 | |
| 1343 | kern user mail daemon auth syslog lpr news |
| 1344 | uucp cron auth2 ftp ntp audit alert cron2 |
| 1345 | local0 local1 local2 local3 local4 local5 local6 local7 |
| 1346 | |
| 1347 | <level> is optional and can be specified to filter outgoing messages. By |
| 1348 | default, all messages are sent. If a level is specified, only |
| 1349 | messages with a severity at least as important as this level |
| 1350 | will be sent. 8 levels are known : |
| 1351 | |
| 1352 | emerg alert crit err warning notice info debug |
| 1353 | |
| 1354 | Note that up to two "log" entries may be specified per instance. However, if |
| 1355 | "log global" is used and if the "global" section already contains 2 log |
| 1356 | entries, then additional log entries will be ignored. |
| 1357 | |
| 1358 | Also, it is important to keep in mind that it is the frontend which decides |
| 1359 | what to log, and that in case of content switching, the log entries from the |
| 1360 | backend will be ignored. |
| 1361 | |
| 1362 | Example : |
| 1363 | log global |
| 1364 | log 127.0.0.1:514 local0 notice |
| 1365 | |
| 1366 | |
| 1367 | maxconn <conns> |
| 1368 | Fix the maximum number of concurrent connections on a frontend |
| 1369 | May be used in sections : defaults | frontend | listen | backend |
| 1370 | yes | yes | yes | no |
| 1371 | Arguments : |
| 1372 | <conns> is the maximum number of concurrent connections the frontend will |
| 1373 | accept to serve. Excess connections will be queued by the system |
| 1374 | in the socket's listen queue and will be served once a connection |
| 1375 | closes. |
| 1376 | |
| 1377 | If the system supports it, it can be useful on big sites to raise this limit |
| 1378 | very high so that haproxy manages connection queues, instead of leaving the |
| 1379 | clients with unanswered connection attempts. This value should not exceed the |
| 1380 | global maxconn. Also, keep in mind that a connection contains two buffers |
| 1381 | of 8kB each, as well as some other data resulting in about 17 kB of RAM being |
| 1382 | consumed per established connection. That means that a medium system equipped |
| 1383 | with 1GB of RAM can withstand around 40000-50000 concurrent connections if |
| 1384 | properly tuned. |
| 1385 | |
| 1386 | Also, when <conns> is set to large values, it is possible that the servers |
| 1387 | are not sized to accept such loads, and for this reason it is generally wise |
| 1388 | to assign them some reasonable connection limits. |
| 1389 | |
| 1390 | See also : "server", global section's "maxconn", "fullconn" |
| 1391 | |
| 1392 | |
| 1393 | mode { tcp|http|health } |
| 1394 | Set the running mode or protocol of the instance |
| 1395 | May be used in sections : defaults | frontend | listen | backend |
| 1396 | yes | yes | yes | yes |
| 1397 | Arguments : |
| 1398 | tcp The instance will work in pure TCP mode. A full-duplex connection |
| 1399 | will be established between clients and servers, and no layer 7 |
| 1400 | examination will be performed. This is the default mode. It |
| 1401 | should be used for SSL, SSH, SMTP, ... |
| 1402 | |
| 1403 | http The instance will work in HTTP mode. The client request will be |
| 1404 | analyzed in depth before connecting to any server. Any request |
| 1405 | which is not RFC-compliant will be rejected. Layer 7 filtering, |
| 1406 | processing and switching will be possible. This is the mode which |
| 1407 | brings HAProxy most of its value. |
| 1408 | |
| 1409 | health The instance will work in "health" mode. It will just reply "OK" |
| 1410 | to incoming connections and close the connection. Nothing will be |
| 1411 | logged. This mode is used to reply to external components health |
| 1412 | checks. This mode is deprecated and should not be used anymore as |
| 1413 | it is possible to do the same and even better by combining TCP or |
| 1414 | HTTP modes with the "monitor" keyword. |
| 1415 | |
| 1416 | When doing content switching, it is mandatory that the frontend and the |
| 1417 | backend are in the same mode (generally HTTP), otherwise the configuration |
| 1418 | will be refused. |
| 1419 | |
| 1420 | Example : |
| 1421 | defaults http_instances |
| 1422 | mode http |
| 1423 | |
| 1424 | See also : "monitor", "monitor-net" |
| 1425 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1426 | |
| 1427 | monitor fail [if | unless] <condition> |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1428 | Add a condition to report a failure to a monitor HTTP request. |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1429 | May be used in sections : defaults | frontend | listen | backend |
| 1430 | no | yes | yes | no |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1431 | Arguments : |
| 1432 | if <cond> the monitor request will fail if the condition is satisfied, |
| 1433 | and will succeed otherwise. The condition should describe a |
| 1434 | combinated test which must induce a failure if all conditions |
| 1435 | are met, for instance a low number of servers both in a |
| 1436 | backend and its backup. |
| 1437 | |
| 1438 | unless <cond> the monitor request will succeed only if the condition is |
| 1439 | satisfied, and will fail otherwise. Such a condition may be |
| 1440 | based on a test on the presence of a minimum number of active |
| 1441 | servers in a list of backends. |
| 1442 | |
| 1443 | This statement adds a condition which can force the response to a monitor |
| 1444 | request to report a failure. By default, when an external component queries |
| 1445 | the URI dedicated to monitoring, a 200 response is returned. When one of the |
| 1446 | conditions above is met, haproxy will return 503 instead of 200. This is |
| 1447 | very useful to report a site failure to an external component which may base |
| 1448 | routing advertisements between multiple sites on the availability reported by |
| 1449 | haproxy. In this case, one would rely on an ACL involving the "nbsrv" |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1450 | criterion. Note that "monitor fail" only works in HTTP mode. |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1451 | |
| 1452 | Example: |
| 1453 | frontend www |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1454 | mode http |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1455 | acl site_dead nbsrv(dynamic) lt 2 |
| 1456 | acl site_dead nbsrv(static) lt 2 |
| 1457 | monitor-uri /site_alive |
| 1458 | monitor fail if site_dead |
| 1459 | |
Willy Tarreau | 2769aa0 | 2007-12-27 18:26:09 +0100 | [diff] [blame] | 1460 | See also : "monitor-net", "monitor-uri" |
| 1461 | |
| 1462 | |
| 1463 | monitor-net <source> |
| 1464 | Declare a source network which is limited to monitor requests |
| 1465 | May be used in sections : defaults | frontend | listen | backend |
| 1466 | yes | yes | yes | no |
| 1467 | Arguments : |
| 1468 | <source> is the source IPv4 address or network which will only be able to |
| 1469 | get monitor responses to any request. It can be either an IPv4 |
| 1470 | address, a host name, or an address followed by a slash ('/') |
| 1471 | followed by a mask. |
| 1472 | |
| 1473 | In TCP mode, any connection coming from a source matching <source> will cause |
| 1474 | the connection to be immediately closed without any log. This allows another |
| 1475 | equipement to probe the port and verify that it is still listening, without |
| 1476 | forwarding the connection to a remote server. |
| 1477 | |
| 1478 | In HTTP mode, a connection coming from a source matching <source> will be |
| 1479 | accepted, the following response will be sent without waiting for a request, |
| 1480 | then the connection will be closed : "HTTP/1.0 200 OK". This is normally |
| 1481 | enough for any front-end HTTP probe to detect that the service is UP and |
| 1482 | running without forwarding the request to a backend server. |
| 1483 | |
| 1484 | Monitor requests are processed very early. It is not possible to block nor |
| 1485 | divert them using ACLs. They cannot be logged either, and it is the intended |
| 1486 | purpose. They are only used to report HAProxy's health to an upper component, |
| 1487 | nothing more. Right now, it is not possible to set failure conditions on |
| 1488 | requests caught by "monitor-net". |
| 1489 | |
| 1490 | Example : |
| 1491 | # addresses .252 and .253 are just probing us. |
| 1492 | frontend www |
| 1493 | monitor-net 192.168.0.252/31 |
| 1494 | |
| 1495 | See also : "monitor fail", "monitor-uri" |
| 1496 | |
| 1497 | |
| 1498 | monitor-uri <uri> |
| 1499 | Intercept a URI used by external components' monitor requests |
| 1500 | May be used in sections : defaults | frontend | listen | backend |
| 1501 | yes | yes | yes | no |
| 1502 | Arguments : |
| 1503 | <uri> is the exact URI which we want to intercept to return HAProxy's |
| 1504 | health status instead of forwarding the request. |
| 1505 | |
| 1506 | When an HTTP request referencing <uri> will be received on a frontend, |
| 1507 | HAProxy will not forward it nor log it, but instead will return either |
| 1508 | "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure |
| 1509 | conditions defined with "monitor fail". This is normally enough for any |
| 1510 | front-end HTTP probe to detect that the service is UP and running without |
| 1511 | forwarding the request to a backend server. Note that the HTTP method, the |
| 1512 | version and all headers are ignored, but the request must at least be valid |
| 1513 | at the HTTP level. This keyword may only be used with an HTTP-mode frontend. |
| 1514 | |
| 1515 | Monitor requests are processed very early. It is not possible to block nor |
| 1516 | divert them using ACLs. They cannot be logged either, and it is the intended |
| 1517 | purpose. They are only used to report HAProxy's health to an upper component, |
| 1518 | nothing more. However, it is possible to add any number of conditions using |
| 1519 | "monitor fail" and ACLs so that the result can be adjusted to whatever check |
| 1520 | can be imagined (most often the number of available servers in a backend). |
| 1521 | |
| 1522 | Example : |
| 1523 | # Use /haproxy_test to report haproxy's status |
| 1524 | frontend www |
| 1525 | mode http |
| 1526 | monitor-uri /haproxy_test |
| 1527 | |
| 1528 | See also : "monitor fail", "monitor-net" |
| 1529 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1530 | |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1531 | option abortonclose |
| 1532 | no option abortonclose |
| 1533 | Enable or disable early dropping of aborted requests pending in queues. |
| 1534 | May be used in sections : defaults | frontend | listen | backend |
| 1535 | yes | no | yes | yes |
| 1536 | Arguments : none |
| 1537 | |
| 1538 | In presence of very high loads, the servers will take some time to respond. |
| 1539 | The per-instance connection queue will inflate, and the response time will |
| 1540 | increase respective to the size of the queue times the average per-session |
| 1541 | response time. When clients will wait for more than a few seconds, they will |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1542 | often hit the "STOP" button on their browser, leaving a useless request in |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1543 | the queue, and slowing down other users, and the servers as well, because the |
| 1544 | request will eventually be served, then aborted at the first error |
| 1545 | encountered while delivering the response. |
| 1546 | |
| 1547 | As there is no way to distinguish between a full STOP and a simple output |
| 1548 | close on the client side, HTTP agents should be conservative and consider |
| 1549 | that the client might only have closed its output channel while waiting for |
| 1550 | the response. However, this introduces risks of congestion when lots of users |
| 1551 | do the same, and is completely useless nowadays because probably no client at |
| 1552 | all will close the session while waiting for the response. Some HTTP agents |
| 1553 | support this behaviour (Squid, Apache, HAProxy), and others do not (TUX, most |
| 1554 | hardware-based load balancers). So the probability for a closed input channel |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1555 | to represent a user hitting the "STOP" button is close to 100%, and the risk |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1556 | of being the single component to break rare but valid traffic is extremely |
| 1557 | low, which adds to the temptation to be able to abort a session early while |
| 1558 | still not served and not pollute the servers. |
| 1559 | |
| 1560 | In HAProxy, the user can choose the desired behaviour using the option |
| 1561 | "abortonclose". By default (without the option) the behaviour is HTTP |
| 1562 | compliant and aborted requests will be served. But when the option is |
| 1563 | specified, a session with an incoming channel closed will be aborted while |
| 1564 | it is still possible, either pending in the queue for a connection slot, or |
| 1565 | during the connection establishment if the server has not yet acknowledged |
| 1566 | the connection request. This considerably reduces the queue size and the load |
| 1567 | on saturated servers when users are tempted to click on STOP, which in turn |
| 1568 | reduces the response time for other users. |
| 1569 | |
| 1570 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1571 | in a specific instance by prepending the "no" keyword before it. |
| 1572 | |
| 1573 | See also : "timeout queue" and server's "maxconn" and "maxqueue" parameters |
| 1574 | |
| 1575 | |
| 1576 | option allbackups |
| 1577 | no option allbackups |
| 1578 | Use either all backup servers at a time or only the first one |
| 1579 | May be used in sections : defaults | frontend | listen | backend |
| 1580 | yes | no | yes | yes |
| 1581 | Arguments : none |
| 1582 | |
| 1583 | By default, the first operational backup server gets all traffic when normal |
| 1584 | servers are all down. Sometimes, it may be preferred to use multiple backups |
| 1585 | at once, because one will not be enough. When "option allbackups" is enabled, |
| 1586 | the load balancing will be performed among all backup servers when all normal |
| 1587 | ones are unavailable. The same load balancing algorithm will be used and the |
| 1588 | servers' weights will be respected. Thus, there will not be any priority |
| 1589 | order between the backup servers anymore. |
| 1590 | |
| 1591 | This option is mostly used with static server farms dedicated to return a |
| 1592 | "sorry" page when an application is completely offline. |
| 1593 | |
| 1594 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1595 | in a specific instance by prepending the "no" keyword before it. |
| 1596 | |
| 1597 | |
| 1598 | option checkcache |
| 1599 | no option checkcache |
| 1600 | Analyze all server responses and block requests with cachable cookies |
| 1601 | May be used in sections : defaults | frontend | listen | backend |
| 1602 | yes | no | yes | yes |
| 1603 | Arguments : none |
| 1604 | |
| 1605 | Some high-level frameworks set application cookies everywhere and do not |
| 1606 | always let enough control to the developer to manage how the responses should |
| 1607 | be cached. When a session cookie is returned on a cachable object, there is a |
| 1608 | high risk of session crossing or stealing between users traversing the same |
| 1609 | caches. In some situations, it is better to block the response than to let |
| 1610 | some sensible session information go in the wild. |
| 1611 | |
| 1612 | The option "checkcache" enables deep inspection of all server responses for |
| 1613 | strict compliance with HTTP specification in terms of cachability. It |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1614 | carefully checks "Cache-control", "Pragma" and "Set-cookie" headers in server |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1615 | response to check if there's a risk of caching a cookie on a client-side |
| 1616 | proxy. When this option is enabled, the only responses which can be delivered |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1617 | to the client are : |
| 1618 | - all those without "Set-Cookie" header ; |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1619 | - all those with a return code other than 200, 203, 206, 300, 301, 410, |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1620 | provided that the server has not set a "Cache-control: public" header ; |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1621 | - all those that come from a POST request, provided that the server has not |
| 1622 | set a 'Cache-Control: public' header ; |
| 1623 | - those with a 'Pragma: no-cache' header |
| 1624 | - those with a 'Cache-control: private' header |
| 1625 | - those with a 'Cache-control: no-store' header |
| 1626 | - those with a 'Cache-control: max-age=0' header |
| 1627 | - those with a 'Cache-control: s-maxage=0' header |
| 1628 | - those with a 'Cache-control: no-cache' header |
| 1629 | - those with a 'Cache-control: no-cache="set-cookie"' header |
| 1630 | - those with a 'Cache-control: no-cache="set-cookie,' header |
| 1631 | (allowing other fields after set-cookie) |
| 1632 | |
| 1633 | If a response doesn't respect these requirements, then it will be blocked |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 1634 | just as if it was from an "rspdeny" filter, with an "HTTP 502 bad gateway". |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1635 | The session state shows "PH--" meaning that the proxy blocked the response |
| 1636 | during headers processing. Additionnaly, an alert will be sent in the logs so |
| 1637 | that admins are informed that there's something to be fixed. |
| 1638 | |
| 1639 | Due to the high impact on the application, the application should be tested |
| 1640 | in depth with the option enabled before going to production. It is also a |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 1641 | good practice to always activate it during tests, even if it is not used in |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1642 | production, as it will report potentially dangerous application behaviours. |
| 1643 | |
| 1644 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1645 | in a specific instance by prepending the "no" keyword before it. |
| 1646 | |
| 1647 | |
| 1648 | option clitcpka |
| 1649 | no option clitcpka |
| 1650 | Enable or disable the sending of TCP keepalive packets on the client side |
| 1651 | May be used in sections : defaults | frontend | listen | backend |
| 1652 | yes | yes | yes | no |
| 1653 | Arguments : none |
| 1654 | |
| 1655 | When there is a firewall or any session-aware component between a client and |
| 1656 | a server, and when the protocol involves very long sessions with long idle |
| 1657 | periods (eg: remote desktops), there is a risk that one of the intermediate |
| 1658 | components decides to expire a session which has remained idle for too long. |
| 1659 | |
| 1660 | Enabling socket-level TCP keep-alives makes the system regularly send packets |
| 1661 | to the other end of the connection, leaving it active. The delay between |
| 1662 | keep-alive probes is controlled by the system only and depends both on the |
| 1663 | operating system and its tuning parameters. |
| 1664 | |
| 1665 | It is important to understand that keep-alive packets are neither emitted nor |
| 1666 | received at the application level. It is only the network stacks which sees |
| 1667 | them. For this reason, even if one side of the proxy already uses keep-alives |
| 1668 | to maintain its connection alive, those keep-alive packets will not be |
| 1669 | forwarded to the other side of the proxy. |
| 1670 | |
| 1671 | Please note that this has nothing to do with HTTP keep-alive. |
| 1672 | |
| 1673 | Using option "clitcpka" enables the emission of TCP keep-alive probes on the |
| 1674 | client side of a connection, which should help when session expirations are |
| 1675 | noticed between HAProxy and a client. |
| 1676 | |
| 1677 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1678 | in a specific instance by prepending the "no" keyword before it. |
| 1679 | |
| 1680 | See also : "option srvtcpka", "option tcpka" |
| 1681 | |
| 1682 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 1683 | option contstats |
| 1684 | Enable continuous traffic statistics updates |
| 1685 | May be used in sections : defaults | frontend | listen | backend |
| 1686 | yes | yes | yes | no |
| 1687 | Arguments : none |
| 1688 | |
| 1689 | By default, counters used for statistics calculation are incremented |
| 1690 | only when a session finishes. It works quite well when serving small |
| 1691 | objects, but with big ones (for example large images or archives) or |
| 1692 | with A/V streaming, a graph generated from haproxy counters looks like |
| 1693 | a hedgehog. With this option enabled counters get incremented continuously, |
| 1694 | during a whole session. Recounting touches a hotpath directly so |
| 1695 | it is not enabled by default, as it has small performance impact (~0.5%). |
| 1696 | |
| 1697 | |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1698 | option dontlognull |
| 1699 | no option dontlognull |
| 1700 | Enable or disable logging of null connections |
| 1701 | May be used in sections : defaults | frontend | listen | backend |
| 1702 | yes | yes | yes | no |
| 1703 | Arguments : none |
| 1704 | |
| 1705 | In certain environments, there are components which will regularly connect to |
| 1706 | various systems to ensure that they are still alive. It can be the case from |
| 1707 | another load balancer as well as from monitoring systems. By default, even a |
| 1708 | simple port probe or scan will produce a log. If those connections pollute |
| 1709 | the logs too much, it is possible to enable option "dontlognull" to indicate |
| 1710 | that a connection on which no data has been transferred will not be logged, |
| 1711 | which typically corresponds to those probes. |
| 1712 | |
| 1713 | It is generally recommended not to use this option in uncontrolled |
| 1714 | environments (eg: internet), otherwise scans and other malicious activities |
| 1715 | would not be logged. |
| 1716 | |
| 1717 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1718 | in a specific instance by prepending the "no" keyword before it. |
| 1719 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 1720 | See also : "log", "monitor-net", "monitor-uri" and section 2.6 about logging. |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 1721 | |
| 1722 | |
| 1723 | option forceclose |
| 1724 | no option forceclose |
| 1725 | Enable or disable active connection closing after response is transferred. |
| 1726 | May be used in sections : defaults | frontend | listen | backend |
| 1727 | yes | no | yes | yes |
| 1728 | Arguments : none |
| 1729 | |
| 1730 | Some HTTP servers do not necessarily close the connections when they receive |
| 1731 | the "Connection: close" set by "option httpclose", and if the client does not |
| 1732 | close either, then the connection remains open till the timeout expires. This |
| 1733 | causes high number of simultaneous connections on the servers and shows high |
| 1734 | global session times in the logs. |
| 1735 | |
| 1736 | When this happens, it is possible to use "option forceclose". It will |
| 1737 | actively close the outgoing server channel as soon as the server begins to |
| 1738 | reply and only if the request buffer is empty. Note that this should NOT be |
| 1739 | used if CONNECT requests are expected between the client and the server. This |
| 1740 | option implicitly enables the "httpclose" option. |
| 1741 | |
| 1742 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1743 | in a specific instance by prepending the "no" keyword before it. |
| 1744 | |
| 1745 | See also : "option httpclose" |
| 1746 | |
| 1747 | |
Willy Tarreau | c27debf | 2008-01-06 08:57:02 +0100 | [diff] [blame] | 1748 | option forwardfor [ except <network> ] |
| 1749 | Enable insertion of the X-Forwarded-For header to requests sent to servers |
| 1750 | May be used in sections : defaults | frontend | listen | backend |
| 1751 | yes | yes | yes | yes |
| 1752 | Arguments : |
| 1753 | <network> is an optional argument used to disable this option for sources |
| 1754 | matching <network> |
| 1755 | |
| 1756 | Since HAProxy works in reverse-proxy mode, the servers see its IP address as |
| 1757 | their client address. This is sometimes annoying when the client's IP address |
| 1758 | is expected in server logs. To solve this problem, the well-known HTTP header |
| 1759 | "X-Forwarded-For" may be added by HAProxy to all requests sent to the server. |
| 1760 | This header contains a value representing the client's IP address. Since this |
| 1761 | header is always appended at the end of the existing header list, the server |
| 1762 | must be configured to always use the last occurrence of this header only. See |
| 1763 | the server's manual to find how to enable use of this standard header. |
| 1764 | |
| 1765 | Sometimes, a same HAProxy instance may be shared between a direct client |
| 1766 | access and a reverse-proxy access (for instance when an SSL reverse-proxy is |
| 1767 | used to decrypt HTTPS traffic). It is possible to disable the addition of the |
| 1768 | header for a known source address or network by adding the "except" keyword |
| 1769 | followed by the network address. In this case, any source IP matching the |
| 1770 | network will not cause an addition of this header. Most common uses are with |
| 1771 | private networks or 127.0.0.1. |
| 1772 | |
| 1773 | This option may be specified either in the frontend or in the backend. If at |
| 1774 | least one of them uses it, the header will be added. |
| 1775 | |
| 1776 | It is important to note that as long as HAProxy does not support keep-alive |
| 1777 | connections, only the first request of a connection will receive the header. |
| 1778 | For this reason, it is important to ensure that "option httpclose" is set |
| 1779 | when using this option. |
| 1780 | |
| 1781 | Example : |
| 1782 | # Public HTTP address also used by stunnel on the same machine |
| 1783 | frontend www |
| 1784 | mode http |
| 1785 | option forwardfor except 127.0.0.1 # stunnel already adds the header |
| 1786 | |
| 1787 | See also : "option httpclose" |
| 1788 | |
| 1789 | |
| 1790 | option http_proxy |
| 1791 | no option http_proxy |
| 1792 | Enable or disable plain HTTP proxy mode |
| 1793 | May be used in sections : defaults | frontend | listen | backend |
| 1794 | yes | yes | yes | yes |
| 1795 | Arguments : none |
| 1796 | |
| 1797 | It sometimes happens that people need a pure HTTP proxy which understands |
| 1798 | basic proxy requests without caching nor any fancy feature. In this case, |
| 1799 | it may be worth setting up an HAProxy instance with the "option http_proxy" |
| 1800 | set. In this mode, no server is declared, and the connection is forwarded to |
| 1801 | the IP address and port found in the URL after the "http://" scheme. |
| 1802 | |
| 1803 | No host address resolution is performed, so this only works when pure IP |
| 1804 | addresses are passed. Since this option's usage perimeter is rather limited, |
| 1805 | it will probably be used only by experts who know they need exactly it. Last, |
| 1806 | if the clients are susceptible of sending keep-alive requests, it will be |
| 1807 | needed to add "option http_close" to ensure that all requests will correctly |
| 1808 | be analyzed. |
| 1809 | |
| 1810 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1811 | in a specific instance by prepending the "no" keyword before it. |
| 1812 | |
| 1813 | Example : |
| 1814 | # this backend understands HTTP proxy requests and forwards them directly. |
| 1815 | backend direct_forward |
| 1816 | option httpclose |
| 1817 | option http_proxy |
| 1818 | |
| 1819 | See also : "option httpclose" |
| 1820 | |
| 1821 | |
| 1822 | option httpchk |
| 1823 | option httpchk <uri> |
| 1824 | option httpchk <method> <uri> |
| 1825 | option httpchk <method> <uri> <version> |
| 1826 | Enable HTTP protocol to check on the servers health |
| 1827 | May be used in sections : defaults | frontend | listen | backend |
| 1828 | yes | no | yes | yes |
| 1829 | Arguments : |
| 1830 | <method> is the optional HTTP method used with the requests. When not set, |
| 1831 | the "OPTIONS" method is used, as it generally requires low server |
| 1832 | processing and is easy to filter out from the logs. Any method |
| 1833 | may be used, though it is not recommended to invent non-standard |
| 1834 | ones. |
| 1835 | |
| 1836 | <uri> is the URI referenced in the HTTP requests. It defaults to " / " |
| 1837 | which is accessible by default on almost any server, but may be |
| 1838 | changed to any other URI. Query strings are permitted. |
| 1839 | |
| 1840 | <version> is the optional HTTP version string. It defaults to "HTTP/1.0" |
| 1841 | but some servers might behave incorrectly in HTTP 1.0, so turning |
| 1842 | it to HTTP/1.1 may sometimes help. Note that the Host field is |
| 1843 | mandatory in HTTP/1.1, and as a trick, it is possible to pass it |
| 1844 | after "\r\n" following the version string. |
| 1845 | |
| 1846 | By default, server health checks only consist in trying to establish a TCP |
| 1847 | connection. When "option httpchk" is specified, a complete HTTP request is |
| 1848 | sent once the TCP connection is established, and responses 2xx and 3xx are |
| 1849 | considered valid, while all other ones indicate a server failure, including |
| 1850 | the lack of any response. |
| 1851 | |
| 1852 | The port and interval are specified in the server configuration. |
| 1853 | |
| 1854 | This option does not necessarily require an HTTP backend, it also works with |
| 1855 | plain TCP backends. This is particularly useful to check simple scripts bound |
| 1856 | to some dedicated ports using the inetd daemon. |
| 1857 | |
| 1858 | Examples : |
| 1859 | # Relay HTTPS traffic to Apache instance and check service availability |
| 1860 | # using HTTP request "OPTIONS * HTTP/1.1" on port 80. |
| 1861 | backend https_relay |
| 1862 | mode tcp |
| 1863 | option httpchk OPTIONS * HTTP/1.1\r\nHost: www |
| 1864 | server apache1 192.168.1.1:443 check port 80 |
| 1865 | |
| 1866 | See also : "option ssl-hello-chk", "option smtpchk", "http-check" and the |
| 1867 | "check", "port" and "interval" server options. |
| 1868 | |
| 1869 | |
| 1870 | option httpclose |
| 1871 | no option httpclose |
| 1872 | Enable or disable passive HTTP connection closing |
| 1873 | May be used in sections : defaults | frontend | listen | backend |
| 1874 | yes | yes | yes | yes |
| 1875 | Arguments : none |
| 1876 | |
| 1877 | As stated in section 2.1, HAProxy does not yes support the HTTP keep-alive |
| 1878 | mode. So by default, if a client communicates with a server in this mode, it |
| 1879 | will only analyze, log, and process the first request of each connection. To |
| 1880 | workaround this limitation, it is possible to specify "option httpclose". It |
| 1881 | will check if a "Connection: close" header is already set in each direction, |
| 1882 | and will add one if missing. Each end should react to this by actively |
| 1883 | closing the TCP connection after each transfer, thus resulting in a switch to |
| 1884 | the HTTP close mode. Any "Connection" header different from "close" will also |
| 1885 | be removed. |
| 1886 | |
| 1887 | It seldom happens that some servers incorrectly ignore this header and do not |
| 1888 | close the connection eventough they reply "Connection: close". For this |
| 1889 | reason, they are not compatible with older HTTP 1.0 browsers. If this |
| 1890 | happens it is possible to use the "option forceclose" which actively closes |
| 1891 | the request connection once the server responds. |
| 1892 | |
| 1893 | This option may be set both in a frontend and in a backend. It is enabled if |
| 1894 | at least one of the frontend or backend holding a connection has it enabled. |
| 1895 | If "option forceclose" is specified too, it has precedence over "httpclose". |
| 1896 | |
| 1897 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1898 | in a specific instance by prepending the "no" keyword before it. |
| 1899 | |
| 1900 | See also : "option forceclose" |
| 1901 | |
| 1902 | |
| 1903 | option httplog |
| 1904 | Enable logging of HTTP request, session state and timers |
| 1905 | May be used in sections : defaults | frontend | listen | backend |
| 1906 | yes | yes | yes | yes |
| 1907 | Arguments : none |
| 1908 | |
| 1909 | By default, the log output format is very poor, as it only contains the |
| 1910 | source and destination addresses, and the instance name. By specifying |
| 1911 | "option httplog", each log line turns into a much richer format including, |
| 1912 | but not limited to, the HTTP request, the connection timers, the session |
| 1913 | status, the connections numbers, the captured headers and cookies, the |
| 1914 | frontend, backend and server name, and of course the source address and |
| 1915 | ports. |
| 1916 | |
| 1917 | This option may be set either in the frontend or the backend. |
| 1918 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 1919 | See also : section 2.6 about logging. |
Willy Tarreau | c27debf | 2008-01-06 08:57:02 +0100 | [diff] [blame] | 1920 | |
Willy Tarreau | c27debf | 2008-01-06 08:57:02 +0100 | [diff] [blame] | 1921 | |
| 1922 | option logasap |
| 1923 | no option logasap |
| 1924 | Enable or disable early logging of HTTP requests |
| 1925 | May be used in sections : defaults | frontend | listen | backend |
| 1926 | yes | yes | yes | no |
| 1927 | Arguments : none |
| 1928 | |
| 1929 | By default, HTTP requests are logged upon termination so that the total |
| 1930 | transfer time and the number of bytes appear in the logs. When large objects |
| 1931 | are being transferred, it may take a while before the request appears in the |
| 1932 | logs. Using "option logasap", the request gets logged as soon as the server |
| 1933 | sends the complete headers. The only missing information in the logs will be |
| 1934 | the total number of bytes which will indicate everything except the amount |
| 1935 | of data transferred, and the total time which will not take the transfer |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 1936 | time into account. In such a situation, it's a good practice to capture the |
Willy Tarreau | c27debf | 2008-01-06 08:57:02 +0100 | [diff] [blame] | 1937 | "Content-Length" response header so that the logs at least indicate how many |
| 1938 | bytes are expected to be transferred. |
| 1939 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 1940 | See also : "option httplog", "capture response header", and section 2.6 about |
Willy Tarreau | c27debf | 2008-01-06 08:57:02 +0100 | [diff] [blame] | 1941 | logging. |
| 1942 | |
| 1943 | |
Willy Tarreau | a453bdd | 2008-01-08 19:50:52 +0100 | [diff] [blame] | 1944 | option nolinger |
| 1945 | no option nolinger |
| 1946 | Enable or disable immediate session ressource cleaning after close |
| 1947 | May be used in sections: defaults | frontend | listen | backend |
| 1948 | yes | yes | yes | yes |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 1949 | Arguments : none |
Willy Tarreau | a453bdd | 2008-01-08 19:50:52 +0100 | [diff] [blame] | 1950 | |
| 1951 | When clients or servers abort connections in a dirty way (eg: they are |
| 1952 | physically disconnected), the session timeouts triggers and the session is |
| 1953 | closed. But it will remain in FIN_WAIT1 state for some time in the system, |
| 1954 | using some resources and possibly limiting the ability to establish newer |
| 1955 | connections. |
| 1956 | |
| 1957 | When this happens, it is possible to activate "option nolinger" which forces |
| 1958 | the system to immediately remove any socket's pending data on close. Thus, |
| 1959 | the session is instantly purged from the system's tables. This usually has |
| 1960 | side effects such as increased number of TCP resets due to old retransmits |
| 1961 | getting immediately rejected. Some firewalls may sometimes complain about |
| 1962 | this too. |
| 1963 | |
| 1964 | For this reason, it is not recommended to use this option when not absolutely |
| 1965 | needed. You know that you need it when you have thousands of FIN_WAIT1 |
| 1966 | sessions on your system (TIME_WAIT ones do not count). |
| 1967 | |
| 1968 | This option may be used both on frontends and backends, depending on the side |
| 1969 | where it is required. Use it on the frontend for clients, and on the backend |
| 1970 | for servers. |
| 1971 | |
| 1972 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1973 | in a specific instance by prepending the "no" keyword before it. |
| 1974 | |
| 1975 | |
| 1976 | option persist |
| 1977 | no option persist |
| 1978 | Enable or disable forced persistence on down servers |
| 1979 | May be used in sections: defaults | frontend | listen | backend |
| 1980 | yes | no | yes | yes |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 1981 | Arguments : none |
Willy Tarreau | a453bdd | 2008-01-08 19:50:52 +0100 | [diff] [blame] | 1982 | |
| 1983 | When an HTTP request reaches a backend with a cookie which references a dead |
| 1984 | server, by default it is redispatched to another server. It is possible to |
| 1985 | force the request to be sent to the dead server first using "option persist" |
| 1986 | if absolutely needed. A common use case is when servers are under extreme |
| 1987 | load and spend their time flapping. In this case, the users would still be |
| 1988 | directed to the server they opened the session on, in the hope they would be |
| 1989 | correctly served. It is recommended to use "option redispatch" in conjunction |
| 1990 | with this option so that in the event it would not be possible to connect to |
| 1991 | the server at all (server definitely dead), the client would finally be |
| 1992 | redirected to another valid server. |
| 1993 | |
| 1994 | If this option has been enabled in a "defaults" section, it can be disabled |
| 1995 | in a specific instance by prepending the "no" keyword before it. |
| 1996 | |
| 1997 | See also : "option redispatch", "retries" |
| 1998 | |
| 1999 | |
Krzysztof Piotr Oledzki | 25b501a | 2008-01-06 16:36:16 +0100 | [diff] [blame] | 2000 | option redispatch |
| 2001 | no option redispatch |
| 2002 | Enable or disable session redistribution in case of connection failure |
| 2003 | May be used in sections: defaults | frontend | listen | backend |
| 2004 | yes | no | yes | yes |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 2005 | Arguments : none |
Krzysztof Piotr Oledzki | 25b501a | 2008-01-06 16:36:16 +0100 | [diff] [blame] | 2006 | |
| 2007 | In HTTP mode, if a server designated by a cookie is down, clients may |
| 2008 | definitely stick to it because they cannot flush the cookie, so they will not |
| 2009 | be able to access the service anymore. |
| 2010 | |
| 2011 | Specifying "option redispatch" will allow the proxy to break their |
| 2012 | persistence and redistribute them to a working server. |
| 2013 | |
| 2014 | It also allows to retry last connection to another server in case of multiple |
| 2015 | connection failures. Of course, it requires having "retries" set to a nonzero |
| 2016 | value. |
| 2017 | |
| 2018 | This form is the preferred form, which replaces both the "redispatch" and |
| 2019 | "redisp" keywords. |
| 2020 | |
| 2021 | If this option has been enabled in a "defaults" section, it can be disabled |
| 2022 | in a specific instance by prepending the "no" keyword before it. |
| 2023 | |
| 2024 | See also : "redispatch", "retries" |
| 2025 | |
Willy Tarreau | a453bdd | 2008-01-08 19:50:52 +0100 | [diff] [blame] | 2026 | |
| 2027 | option smtpchk |
| 2028 | option smtpchk <hello> <domain> |
| 2029 | Use SMTP health checks for server testing |
| 2030 | May be used in sections : defaults | frontend | listen | backend |
| 2031 | yes | no | yes | yes |
| 2032 | Arguments : |
| 2033 | <hello> is an optional argument. It is the "hello" command to use. It can |
| 2034 | be either "HELO" (for SMTP) or "EHLO" (for ESTMP). All other |
| 2035 | values will be turned into the default command ("HELO"). |
| 2036 | |
| 2037 | <domain> is the domain name to present to the server. It may only be |
| 2038 | specified (and is mandatory) if the hello command has been |
| 2039 | specified. By default, "localhost" is used. |
| 2040 | |
| 2041 | When "option smtpchk" is set, the health checks will consist in TCP |
| 2042 | connections followed by an SMTP command. By default, this command is |
| 2043 | "HELO localhost". The server's return code is analyzed and only return codes |
| 2044 | starting with a "2" will be considered as valid. All other responses, |
| 2045 | including a lack of response will constitute an error and will indicate a |
| 2046 | dead server. |
| 2047 | |
| 2048 | This test is meant to be used with SMTP servers or relays. Depending on the |
| 2049 | request, it is possible that some servers do not log each connection attempt, |
| 2050 | so you may want to experiment to improve the behaviour. Using telnet on port |
| 2051 | 25 is often easier than adjusting the configuration. |
| 2052 | |
| 2053 | Most often, an incoming SMTP server needs to see the client's IP address for |
| 2054 | various purposes, including spam filtering, anti-spoofing and logging. When |
| 2055 | possible, it is often wise to masquerade the client's IP address when |
| 2056 | connecting to the server using the "usesrc" argument of the "source" keyword, |
| 2057 | which requires the cttproxy feature to be compiled in. |
| 2058 | |
| 2059 | Example : |
| 2060 | option smtpchk HELO mydomain.org |
| 2061 | |
| 2062 | See also : "option httpchk", "source" |
| 2063 | |
Krzysztof Piotr Oledzki | 25b501a | 2008-01-06 16:36:16 +0100 | [diff] [blame] | 2064 | |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 2065 | option srvtcpka |
| 2066 | no option srvtcpka |
| 2067 | Enable or disable the sending of TCP keepalive packets on the server side |
| 2068 | May be used in sections : defaults | frontend | listen | backend |
| 2069 | yes | no | yes | yes |
| 2070 | Arguments : none |
| 2071 | |
| 2072 | When there is a firewall or any session-aware component between a client and |
| 2073 | a server, and when the protocol involves very long sessions with long idle |
| 2074 | periods (eg: remote desktops), there is a risk that one of the intermediate |
| 2075 | components decides to expire a session which has remained idle for too long. |
| 2076 | |
| 2077 | Enabling socket-level TCP keep-alives makes the system regularly send packets |
| 2078 | to the other end of the connection, leaving it active. The delay between |
| 2079 | keep-alive probes is controlled by the system only and depends both on the |
| 2080 | operating system and its tuning parameters. |
| 2081 | |
| 2082 | It is important to understand that keep-alive packets are neither emitted nor |
| 2083 | received at the application level. It is only the network stacks which sees |
| 2084 | them. For this reason, even if one side of the proxy already uses keep-alives |
| 2085 | to maintain its connection alive, those keep-alive packets will not be |
| 2086 | forwarded to the other side of the proxy. |
| 2087 | |
| 2088 | Please note that this has nothing to do with HTTP keep-alive. |
| 2089 | |
| 2090 | Using option "srvtcpka" enables the emission of TCP keep-alive probes on the |
| 2091 | server side of a connection, which should help when session expirations are |
| 2092 | noticed between HAProxy and a server. |
| 2093 | |
| 2094 | If this option has been enabled in a "defaults" section, it can be disabled |
| 2095 | in a specific instance by prepending the "no" keyword before it. |
| 2096 | |
| 2097 | See also : "option clitcpka", "option tcpka" |
| 2098 | |
| 2099 | |
Willy Tarreau | a453bdd | 2008-01-08 19:50:52 +0100 | [diff] [blame] | 2100 | option ssl-hello-chk |
| 2101 | Use SSLv3 client hello health checks for server testing |
| 2102 | May be used in sections : defaults | frontend | listen | backend |
| 2103 | yes | no | yes | yes |
| 2104 | Arguments : none |
| 2105 | |
| 2106 | When some SSL-based protocols are relayed in TCP mode through HAProxy, it is |
| 2107 | possible to test that the server correctly talks SSL instead of just testing |
| 2108 | that it accepts the TCP connection. When "option ssl-hello-chk" is set, pure |
| 2109 | SSLv3 client hello messages are sent once the connection is established to |
| 2110 | the server, and the response is analyzed to find an SSL server hello message. |
| 2111 | The server is considered valid only when the response contains this server |
| 2112 | hello message. |
| 2113 | |
| 2114 | All servers tested till there correctly reply to SSLv3 client hello messages, |
| 2115 | and most servers tested do not even log the requests containing only hello |
| 2116 | messages, which is appreciable. |
| 2117 | |
| 2118 | See also: "option httpchk" |
| 2119 | |
| 2120 | |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 2121 | option tcpka |
| 2122 | Enable or disable the sending of TCP keepalive packets on both sides |
| 2123 | May be used in sections : defaults | frontend | listen | backend |
| 2124 | yes | yes | yes | yes |
| 2125 | Arguments : none |
| 2126 | |
| 2127 | When there is a firewall or any session-aware component between a client and |
| 2128 | a server, and when the protocol involves very long sessions with long idle |
| 2129 | periods (eg: remote desktops), there is a risk that one of the intermediate |
| 2130 | components decides to expire a session which has remained idle for too long. |
| 2131 | |
| 2132 | Enabling socket-level TCP keep-alives makes the system regularly send packets |
| 2133 | to the other end of the connection, leaving it active. The delay between |
| 2134 | keep-alive probes is controlled by the system only and depends both on the |
| 2135 | operating system and its tuning parameters. |
| 2136 | |
| 2137 | It is important to understand that keep-alive packets are neither emitted nor |
| 2138 | received at the application level. It is only the network stacks which sees |
| 2139 | them. For this reason, even if one side of the proxy already uses keep-alives |
| 2140 | to maintain its connection alive, those keep-alive packets will not be |
| 2141 | forwarded to the other side of the proxy. |
| 2142 | |
| 2143 | Please note that this has nothing to do with HTTP keep-alive. |
| 2144 | |
| 2145 | Using option "tcpka" enables the emission of TCP keep-alive probes on both |
| 2146 | the client and server sides of a connection. Note that this is meaningful |
| 2147 | only in "defaults" or "listen" sections. If this option is used in a |
| 2148 | frontend, only the client side will get keep-alives, and if this option is |
| 2149 | used in a backend, only the server side will get keep-alives. For this |
| 2150 | reason, it is strongly recommended to explicitly use "option clitcpka" and |
| 2151 | "option srvtcpka" when the configuration is split between frontends and |
| 2152 | backends. |
| 2153 | |
| 2154 | See also : "option clitcpka", "option srvtcpka" |
| 2155 | |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 2156 | |
| 2157 | option tcplog |
| 2158 | Enable advanced logging of TCP connections with session state and timers |
| 2159 | May be used in sections : defaults | frontend | listen | backend |
| 2160 | yes | yes | yes | yes |
| 2161 | Arguments : none |
| 2162 | |
| 2163 | By default, the log output format is very poor, as it only contains the |
| 2164 | source and destination addresses, and the instance name. By specifying |
| 2165 | "option tcplog", each log line turns into a much richer format including, but |
| 2166 | not limited to, the connection timers, the session status, the connections |
| 2167 | numbers, the frontend, backend and server name, and of course the source |
| 2168 | address and ports. This option is useful for pure TCP proxies in order to |
| 2169 | find which of the client or server disconnects or times out. For normal HTTP |
| 2170 | proxies, it's better to use "option httplog" which is even more complete. |
| 2171 | |
| 2172 | This option may be set either in the frontend or the backend. |
| 2173 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2174 | See also : "option httplog", and section 2.6 about logging. |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 2175 | |
| 2176 | |
| 2177 | option tcpsplice [ experimental ] |
| 2178 | Enable linux kernel-based acceleration of data relaying |
| 2179 | May be used in sections : defaults | frontend | listen | backend |
| 2180 | yes | yes | yes | yes |
| 2181 | Arguments : none |
| 2182 | |
| 2183 | This option is only available when HAProxy has been built for use on Linux |
| 2184 | with USE_TCPSPLICE=1. This option requires a kernel patch which is available |
| 2185 | on http://www.linux-l7sw.org/. |
| 2186 | |
| 2187 | When "option tcpsplice" is set, as soon as the server's response headers have |
| 2188 | been transferred, the session handling is transferred to the kernel which |
| 2189 | will forward all subsequent data from the server to the client untill the |
| 2190 | session closes. This leads to much faster data transfers between client and |
| 2191 | server since the data is not copied twice between kernel and user space, but |
| 2192 | there are some limitations such as the lack of information about the number |
| 2193 | of bytes transferred and the total transfer time. |
| 2194 | |
| 2195 | This is an experimental feature. It happens to reliably work but issues |
| 2196 | caused by corner cases are to be expected. |
| 2197 | |
| 2198 | Note that this option requires that the process permanently runs with |
| 2199 | CAP_NETADMIN privileges, which most often translates into running as root. |
| 2200 | |
| 2201 | |
| 2202 | option transparent |
| 2203 | no option transparent |
| 2204 | Enable client-side transparent proxying |
| 2205 | May be used in sections : defaults | frontend | listen | backend |
| 2206 | yes | yes | yes | no |
| 2207 | Arguments : none |
| 2208 | |
| 2209 | This option was introduced in order to provide layer 7 persistence to layer 3 |
| 2210 | load balancers. The idea is to use the OS's ability to redirect an incoming |
| 2211 | connection for a remote address to a local process (here HAProxy), and let |
| 2212 | this process know what address was initially requested. When this option is |
| 2213 | used, sessions without cookies will be forwarded to the original destination |
| 2214 | IP address of the incoming request (which should match that of another |
| 2215 | equipment), while requests with cookies will still be forwarded to the |
| 2216 | appropriate server. |
| 2217 | |
| 2218 | Note that contrary to a common belief, this option does NOT make HAProxy |
| 2219 | present the client's IP to the server when establishing the connection. |
| 2220 | |
| 2221 | Use of this option is really discouraged, and since no really valid use of it |
| 2222 | has been reported for years, it will probably be removed in future versions. |
| 2223 | |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 2224 | See also: the "usersrc" argument of the "source" keyword, and the |
| 2225 | "transparent" option of the "bind" keyword. |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 2226 | |
Willy Tarreau | bf1f816 | 2007-12-28 17:42:56 +0100 | [diff] [blame] | 2227 | |
Krzysztof Piotr Oledzki | 25b501a | 2008-01-06 16:36:16 +0100 | [diff] [blame] | 2228 | redisp (deprecated) |
| 2229 | redispatch (deprecated) |
| 2230 | Enable or disable session redistribution in case of connection failure |
| 2231 | May be used in sections: defaults | frontend | listen | backend |
| 2232 | yes | no | yes | yes |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 2233 | Arguments : none |
Krzysztof Piotr Oledzki | 25b501a | 2008-01-06 16:36:16 +0100 | [diff] [blame] | 2234 | |
| 2235 | In HTTP mode, if a server designated by a cookie is down, clients may |
| 2236 | definitely stick to it because they cannot flush the cookie, so they will not |
| 2237 | be able to access the service anymore. |
| 2238 | |
| 2239 | Specifying "redispatch" will allow the proxy to break their persistence and |
| 2240 | redistribute them to a working server. |
| 2241 | |
| 2242 | It also allows to retry last connection to another server in case of multiple |
| 2243 | connection failures. Of course, it requires having "retries" set to a nonzero |
| 2244 | value. |
| 2245 | |
| 2246 | This form is deprecated, do not use it in any new configuration, use the new |
| 2247 | "option redispatch" instead. |
| 2248 | |
| 2249 | See also : "option redispatch" |
| 2250 | |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 2251 | |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2252 | reqadd <string> |
| 2253 | Add a header at the end of the HTTP request |
| 2254 | May be used in sections : defaults | frontend | listen | backend |
| 2255 | no | yes | yes | yes |
| 2256 | Arguments : |
| 2257 | <string> is the complete line to be added. Any space or known delimiter |
| 2258 | must be escaped using a backslash ('\'). Please refer to section |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2259 | 2.5 about HTTP header manipulation for more information. |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2260 | |
| 2261 | A new line consisting in <string> followed by a line feed will be added after |
| 2262 | the last header of an HTTP request. |
| 2263 | |
| 2264 | Header transformations only apply to traffic which passes through HAProxy, |
| 2265 | and not to traffic generated by HAProxy, such as health-checks or error |
| 2266 | responses. |
| 2267 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2268 | See also: "rspadd" and section 2.5 about HTTP header manipulation |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2269 | |
| 2270 | |
| 2271 | reqallow <search> |
| 2272 | reqiallow <search> (ignore case) |
| 2273 | Definitely allow an HTTP request if a line matches a regular expression |
| 2274 | May be used in sections : defaults | frontend | listen | backend |
| 2275 | no | yes | yes | yes |
| 2276 | Arguments : |
| 2277 | <search> is the regular expression applied to HTTP headers and to the |
| 2278 | request line. This is an extended regular expression. Parenthesis |
| 2279 | grouping is supported and no preliminary backslash is required. |
| 2280 | Any space or known delimiter must be escaped using a backslash |
| 2281 | ('\'). The pattern applies to a full line at a time. The |
| 2282 | "reqallow" keyword strictly matches case while "reqiallow" |
| 2283 | ignores case. |
| 2284 | |
| 2285 | A request containing any line which matches extended regular expression |
| 2286 | <search> will mark the request as allowed, even if any later test would |
| 2287 | result in a deny. The test applies both to the request line and to request |
| 2288 | headers. Keep in mind that URLs in request line are case-sensitive while |
| 2289 | header names are not. |
| 2290 | |
| 2291 | It is easier, faster and more powerful to use ACLs to write access policies. |
| 2292 | Reqdeny, reqallow and reqpass should be avoided in new designs. |
| 2293 | |
| 2294 | Example : |
| 2295 | # allow www.* but refuse *.local |
| 2296 | reqiallow ^Host:\ www\. |
| 2297 | reqideny ^Host:\ .*\.local |
| 2298 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2299 | See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2300 | manipulation |
| 2301 | |
| 2302 | |
| 2303 | reqdel <search> |
| 2304 | reqidel <search> (ignore case) |
| 2305 | Delete all headers matching a regular expression in an HTTP request |
| 2306 | May be used in sections : defaults | frontend | listen | backend |
| 2307 | no | yes | yes | yes |
| 2308 | Arguments : |
| 2309 | <search> is the regular expression applied to HTTP headers and to the |
| 2310 | request line. This is an extended regular expression. Parenthesis |
| 2311 | grouping is supported and no preliminary backslash is required. |
| 2312 | Any space or known delimiter must be escaped using a backslash |
| 2313 | ('\'). The pattern applies to a full line at a time. The "reqdel" |
| 2314 | keyword strictly matches case while "reqidel" ignores case. |
| 2315 | |
| 2316 | Any header line matching extended regular expression <search> in the request |
| 2317 | will be completely deleted. Most common use of this is to remove unwanted |
| 2318 | and/or dangerous headers or cookies from a request before passing it to the |
| 2319 | next servers. |
| 2320 | |
| 2321 | Header transformations only apply to traffic which passes through HAProxy, |
| 2322 | and not to traffic generated by HAProxy, such as health-checks or error |
| 2323 | responses. Keep in mind that header names are not case-sensitive. |
| 2324 | |
| 2325 | Example : |
| 2326 | # remove X-Forwarded-For header and SERVER cookie |
| 2327 | reqidel ^X-Forwarded-For:.* |
| 2328 | reqidel ^Cookie:.*SERVER= |
| 2329 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2330 | See also: "reqadd", "reqrep", "rspdel" and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2331 | manipulation |
| 2332 | |
| 2333 | |
| 2334 | reqdeny <search> |
| 2335 | reqideny <search> (ignore case) |
| 2336 | Deny an HTTP request if a line matches a regular expression |
| 2337 | May be used in sections : defaults | frontend | listen | backend |
| 2338 | no | yes | yes | yes |
| 2339 | Arguments : |
| 2340 | <search> is the regular expression applied to HTTP headers and to the |
| 2341 | request line. This is an extended regular expression. Parenthesis |
| 2342 | grouping is supported and no preliminary backslash is required. |
| 2343 | Any space or known delimiter must be escaped using a backslash |
| 2344 | ('\'). The pattern applies to a full line at a time. The |
| 2345 | "reqdeny" keyword strictly matches case while "reqideny" ignores |
| 2346 | case. |
| 2347 | |
| 2348 | A request containing any line which matches extended regular expression |
| 2349 | <search> will mark the request as denied, even if any later test would |
| 2350 | result in an allow. The test applies both to the request line and to request |
| 2351 | headers. Keep in mind that URLs in request line are case-sensitive while |
| 2352 | header names are not. |
| 2353 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2354 | A denied request will generate an "HTTP 403 forbidden" response once the |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 2355 | complete request has been parsed. This is consistent with what is practiced |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2356 | using ACLs. |
| 2357 | |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2358 | It is easier, faster and more powerful to use ACLs to write access policies. |
| 2359 | Reqdeny, reqallow and reqpass should be avoided in new designs. |
| 2360 | |
| 2361 | Example : |
| 2362 | # refuse *.local, then allow www.* |
| 2363 | reqideny ^Host:\ .*\.local |
| 2364 | reqiallow ^Host:\ www\. |
| 2365 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2366 | See also: "reqallow", "rspdeny", "acl", "block" and section 2.5 about HTTP |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2367 | header manipulation |
| 2368 | |
| 2369 | |
| 2370 | reqpass <search> |
| 2371 | reqipass <search> (ignore case) |
| 2372 | Ignore any HTTP request line matching a regular expression in next rules |
| 2373 | May be used in sections : defaults | frontend | listen | backend |
| 2374 | no | yes | yes | yes |
| 2375 | Arguments : |
| 2376 | <search> is the regular expression applied to HTTP headers and to the |
| 2377 | request line. This is an extended regular expression. Parenthesis |
| 2378 | grouping is supported and no preliminary backslash is required. |
| 2379 | Any space or known delimiter must be escaped using a backslash |
| 2380 | ('\'). The pattern applies to a full line at a time. The |
| 2381 | "reqpass" keyword strictly matches case while "reqipass" ignores |
| 2382 | case. |
| 2383 | |
| 2384 | A request containing any line which matches extended regular expression |
| 2385 | <search> will skip next rules, without assigning any deny or allow verdict. |
| 2386 | The test applies both to the request line and to request headers. Keep in |
| 2387 | mind that URLs in request line are case-sensitive while header names are not. |
| 2388 | |
| 2389 | It is easier, faster and more powerful to use ACLs to write access policies. |
| 2390 | Reqdeny, reqallow and reqpass should be avoided in new designs. |
| 2391 | |
| 2392 | Example : |
| 2393 | # refuse *.local, then allow www.*, but ignore "www.private.local" |
| 2394 | reqipass ^Host:\ www.private\.local |
| 2395 | reqideny ^Host:\ .*\.local |
| 2396 | reqiallow ^Host:\ www\. |
| 2397 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2398 | See also: "reqallow", "reqdeny", "acl", "block" and section 2.5 about HTTP |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2399 | header manipulation |
| 2400 | |
| 2401 | |
| 2402 | reqrep <search> <string> |
| 2403 | reqirep <search> <string> (ignore case) |
| 2404 | Replace a regular expression with a string in an HTTP request line |
| 2405 | May be used in sections : defaults | frontend | listen | backend |
| 2406 | no | yes | yes | yes |
| 2407 | Arguments : |
| 2408 | <search> is the regular expression applied to HTTP headers and to the |
| 2409 | request line. This is an extended regular expression. Parenthesis |
| 2410 | grouping is supported and no preliminary backslash is required. |
| 2411 | Any space or known delimiter must be escaped using a backslash |
| 2412 | ('\'). The pattern applies to a full line at a time. The "reqrep" |
| 2413 | keyword strictly matches case while "reqirep" ignores case. |
| 2414 | |
| 2415 | <string> is the complete line to be added. Any space or known delimiter |
| 2416 | must be escaped using a backslash ('\'). References to matched |
| 2417 | pattern groups are possible using the common \N form, with N |
| 2418 | being a single digit between 0 and 9. Please refer to section |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2419 | 2.5 about HTTP header manipulation for more information. |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2420 | |
| 2421 | Any line matching extended regular expression <search> in the request (both |
| 2422 | the request line and header lines) will be completely replaced with <string>. |
| 2423 | Most common use of this is to rewrite URLs or domain names in "Host" headers. |
| 2424 | |
| 2425 | Header transformations only apply to traffic which passes through HAProxy, |
| 2426 | and not to traffic generated by HAProxy, such as health-checks or error |
| 2427 | responses. Note that for increased readability, it is suggested to add enough |
| 2428 | spaces between the request and the response. Keep in mind that URLs in |
| 2429 | request line are case-sensitive while header names are not. |
| 2430 | |
| 2431 | Example : |
| 2432 | # replace "/static/" with "/" at the beginning of any request path. |
| 2433 | reqrep ^([^\ ]*)\ /static/(.*) \1\ /\2 |
| 2434 | # replace "www.mydomain.com" with "www" in the host name. |
| 2435 | reqirep ^Host:\ www.mydomain.com Host:\ www |
| 2436 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2437 | See also: "reqadd", "reqdel", "rsprep" and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2438 | manipulation |
| 2439 | |
| 2440 | |
| 2441 | reqtarpit <search> |
| 2442 | reqitarpit <search> (ignore case) |
| 2443 | Tarpit an HTTP request containing a line matching a regular expression |
| 2444 | May be used in sections : defaults | frontend | listen | backend |
| 2445 | no | yes | yes | yes |
| 2446 | Arguments : |
| 2447 | <search> is the regular expression applied to HTTP headers and to the |
| 2448 | request line. This is an extended regular expression. Parenthesis |
| 2449 | grouping is supported and no preliminary backslash is required. |
| 2450 | Any space or known delimiter must be escaped using a backslash |
| 2451 | ('\'). The pattern applies to a full line at a time. The |
| 2452 | "reqtarpit" keyword strictly matches case while "reqitarpit" |
| 2453 | ignores case. |
| 2454 | |
| 2455 | A request containing any line which matches extended regular expression |
| 2456 | <search> will be tarpitted, which means that it will connect to nowhere, will |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2457 | be kept open for a pre-defined time, then will return an HTTP error 500 so |
| 2458 | that the attacker does not suspect it has been tarpitted. The status 500 will |
| 2459 | be reported in the logs, but the completion flags will indicate "PT". The |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2460 | delay is defined by "timeout tarpit", or "timeout connect" if the former is |
| 2461 | not set. |
| 2462 | |
| 2463 | The goal of the tarpit is to slow down robots attacking servers with |
| 2464 | identifiable requests. Many robots limit their outgoing number of connections |
| 2465 | and stay connected waiting for a reply which can take several minutes to |
| 2466 | come. Depending on the environment and attack, it may be particularly |
| 2467 | efficient at reducing the load on the network and firewalls. |
| 2468 | |
| 2469 | Example : |
| 2470 | # ignore user-agents reporting any flavour of "Mozilla" or "MSIE", but |
| 2471 | # block all others. |
| 2472 | reqipass ^User-Agent:\.*(Mozilla|MSIE) |
| 2473 | reqitarpit ^User-Agent: |
| 2474 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2475 | See also: "reqallow", "reqdeny", "reqpass", and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2476 | manipulation |
| 2477 | |
| 2478 | |
| 2479 | rspadd <string> |
| 2480 | Add a header at the end of the HTTP response |
| 2481 | May be used in sections : defaults | frontend | listen | backend |
| 2482 | no | yes | yes | yes |
| 2483 | Arguments : |
| 2484 | <string> is the complete line to be added. Any space or known delimiter |
| 2485 | must be escaped using a backslash ('\'). Please refer to section |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2486 | 2.5 about HTTP header manipulation for more information. |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2487 | |
| 2488 | A new line consisting in <string> followed by a line feed will be added after |
| 2489 | the last header of an HTTP response. |
| 2490 | |
| 2491 | Header transformations only apply to traffic which passes through HAProxy, |
| 2492 | and not to traffic generated by HAProxy, such as health-checks or error |
| 2493 | responses. |
| 2494 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2495 | See also: "reqadd" and section 2.5 about HTTP header manipulation |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2496 | |
| 2497 | |
| 2498 | rspdel <search> |
| 2499 | rspidel <search> (ignore case) |
| 2500 | Delete all headers matching a regular expression in an HTTP response |
| 2501 | May be used in sections : defaults | frontend | listen | backend |
| 2502 | no | yes | yes | yes |
| 2503 | Arguments : |
| 2504 | <search> is the regular expression applied to HTTP headers and to the |
| 2505 | response line. This is an extended regular expression, so |
| 2506 | parenthesis grouping is supported and no preliminary backslash |
| 2507 | is required. Any space or known delimiter must be escaped using |
| 2508 | a backslash ('\'). The pattern applies to a full line at a time. |
| 2509 | The "rspdel" keyword strictly matches case while "rspidel" |
| 2510 | ignores case. |
| 2511 | |
| 2512 | Any header line matching extended regular expression <search> in the response |
| 2513 | will be completely deleted. Most common use of this is to remove unwanted |
| 2514 | and/or sensible headers or cookies from a response before passing it to the |
| 2515 | client. |
| 2516 | |
| 2517 | Header transformations only apply to traffic which passes through HAProxy, |
| 2518 | and not to traffic generated by HAProxy, such as health-checks or error |
| 2519 | responses. Keep in mind that header names are not case-sensitive. |
| 2520 | |
| 2521 | Example : |
| 2522 | # remove the Server header from responses |
| 2523 | reqidel ^Server:.* |
| 2524 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2525 | See also: "rspadd", "rsprep", "reqdel" and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2526 | manipulation |
| 2527 | |
| 2528 | |
| 2529 | rspdeny <search> |
| 2530 | rspideny <search> (ignore case) |
| 2531 | Block an HTTP response if a line matches a regular expression |
| 2532 | May be used in sections : defaults | frontend | listen | backend |
| 2533 | no | yes | yes | yes |
| 2534 | Arguments : |
| 2535 | <search> is the regular expression applied to HTTP headers and to the |
| 2536 | response line. This is an extended regular expression, so |
| 2537 | parenthesis grouping is supported and no preliminary backslash |
| 2538 | is required. Any space or known delimiter must be escaped using |
| 2539 | a backslash ('\'). The pattern applies to a full line at a time. |
| 2540 | The "rspdeny" keyword strictly matches case while "rspideny" |
| 2541 | ignores case. |
| 2542 | |
| 2543 | A response containing any line which matches extended regular expression |
| 2544 | <search> will mark the request as denied. The test applies both to the |
| 2545 | response line and to response headers. Keep in mind that header names are not |
| 2546 | case-sensitive. |
| 2547 | |
| 2548 | Main use of this keyword is to prevent sensitive information leak and to |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2549 | block the response before it reaches the client. If a response is denied, it |
| 2550 | will be replaced with an HTTP 502 error so that the client never retrieves |
| 2551 | any sensitive data. |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2552 | |
| 2553 | It is easier, faster and more powerful to use ACLs to write access policies. |
| 2554 | Rspdeny should be avoided in new designs. |
| 2555 | |
| 2556 | Example : |
| 2557 | # Ensure that no content type matching ms-word will leak |
| 2558 | rspideny ^Content-type:\.*/ms-word |
| 2559 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2560 | See also: "reqdeny", "acl", "block" and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2561 | manipulation |
| 2562 | |
| 2563 | |
| 2564 | rsprep <search> <string> |
| 2565 | rspirep <search> <string> (ignore case) |
| 2566 | Replace a regular expression with a string in an HTTP response line |
| 2567 | May be used in sections : defaults | frontend | listen | backend |
| 2568 | no | yes | yes | yes |
| 2569 | Arguments : |
| 2570 | <search> is the regular expression applied to HTTP headers and to the |
| 2571 | response line. This is an extended regular expression, so |
| 2572 | parenthesis grouping is supported and no preliminary backslash |
| 2573 | is required. Any space or known delimiter must be escaped using |
| 2574 | a backslash ('\'). The pattern applies to a full line at a time. |
| 2575 | The "rsprep" keyword strictly matches case while "rspirep" |
| 2576 | ignores case. |
| 2577 | |
| 2578 | <string> is the complete line to be added. Any space or known delimiter |
| 2579 | must be escaped using a backslash ('\'). References to matched |
| 2580 | pattern groups are possible using the common \N form, with N |
| 2581 | being a single digit between 0 and 9. Please refer to section |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2582 | 2.5 about HTTP header manipulation for more information. |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2583 | |
| 2584 | Any line matching extended regular expression <search> in the response (both |
| 2585 | the response line and header lines) will be completely replaced with |
| 2586 | <string>. Most common use of this is to rewrite Location headers. |
| 2587 | |
| 2588 | Header transformations only apply to traffic which passes through HAProxy, |
| 2589 | and not to traffic generated by HAProxy, such as health-checks or error |
| 2590 | responses. Note that for increased readability, it is suggested to add enough |
| 2591 | spaces between the request and the response. Keep in mind that header names |
| 2592 | are not case-sensitive. |
| 2593 | |
| 2594 | Example : |
| 2595 | # replace "Location: 127.0.0.1:8080" with "Location: www.mydomain.com" |
| 2596 | rspirep ^Location:\ 127.0.0.1:8080 Location:\ www.mydomain.com |
| 2597 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 2598 | See also: "rspadd", "rspdel", "reqrep" and section 2.5 about HTTP header |
Willy Tarreau | 303c035 | 2008-01-17 19:01:39 +0100 | [diff] [blame] | 2599 | manipulation |
| 2600 | |
| 2601 | |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 2602 | server <name> <address>[:port] [param*] |
| 2603 | Declare a server in a backend |
| 2604 | May be used in sections : defaults | frontend | listen | backend |
| 2605 | no | no | yes | yes |
| 2606 | Arguments : |
| 2607 | <name> is the internal name assigned to this server. This name will |
| 2608 | appear in logs and alerts. |
| 2609 | |
| 2610 | <address> is the IPv4 address of the server. Alternatively, a resolvable |
| 2611 | hostname is supported, but this name will be resolved during |
| 2612 | start-up. |
| 2613 | |
| 2614 | <ports> is an optional port specification. If set, all connections will |
| 2615 | be sent to this port. If unset, the same port the client |
| 2616 | connected to will be used. The port may also be prefixed by a "+" |
| 2617 | or a "-". In this case, the server's port will be determined by |
| 2618 | adding this value to the client's port. |
| 2619 | |
| 2620 | <param*> is a list of parameters for this server. The "server" keywords |
| 2621 | accepts an important number of options and has a complete section |
| 2622 | dedicated to it. Please refer to section 2.4 for more details. |
| 2623 | |
| 2624 | Examples : |
| 2625 | server first 10.1.1.1:1080 cookie first check inter 1000 |
| 2626 | server second 10.1.1.2:1080 cookie second check inter 1000 |
| 2627 | |
| 2628 | See also : section 2.4 about server options |
| 2629 | |
| 2630 | |
| 2631 | source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ] |
| 2632 | Set the source address for outgoing connections |
| 2633 | May be used in sections : defaults | frontend | listen | backend |
| 2634 | yes | no | yes | yes |
| 2635 | Arguments : |
| 2636 | <addr> is the IPv4 address HAProxy will bind to before connecting to a |
| 2637 | server. This address is also used as a source for health checks. |
| 2638 | The default value of 0.0.0.0 means that the system will select |
| 2639 | the most appropriate address to reach its destination. |
| 2640 | |
| 2641 | <port> is an optional port. It is normally not needed but may be useful |
| 2642 | in some very specific contexts. The default value of zero means |
| 2643 | the system will select a free port. |
| 2644 | |
| 2645 | <addr2> is the IP address to present to the server when connections are |
| 2646 | forwarded in full transparent proxy mode. This is currently only |
| 2647 | supported on some patched Linux kernels. When this address is |
| 2648 | specified, clients connecting to the server will be presented |
| 2649 | with this address, while health checks will still use the address |
| 2650 | <addr>. |
| 2651 | |
| 2652 | <port2> is the optional port to present to the server when connections |
| 2653 | are forwarded in full transparent proxy mode (see <addr2> above). |
| 2654 | The default value of zero means the system will select a free |
| 2655 | port. |
| 2656 | |
| 2657 | The "source" keyword is useful in complex environments where a specific |
| 2658 | address only is allowed to connect to the servers. It may be needed when a |
| 2659 | private address must be used through a public gateway for instance, and it is |
| 2660 | known that the system cannot determine the adequate source address by itself. |
| 2661 | |
| 2662 | An extension which is available on certain patched Linux kernels may be used |
| 2663 | through the "usesrc" optional keyword. It makes it possible to connect to the |
| 2664 | servers with an IP address which does not belong to the system itself. This |
| 2665 | is called "full transparent proxy mode". For this to work, the destination |
| 2666 | servers have to route their traffic back to this address through the machine |
| 2667 | running HAProxy, and IP forwarding must generally be enabled on this machine. |
| 2668 | |
| 2669 | In this "full transparent proxy" mode, it is possible to force a specific IP |
| 2670 | address to be presented to the servers. This is not much used in fact. A more |
| 2671 | common use is to tell HAProxy to present the client's IP address. For this, |
| 2672 | there are two methods : |
| 2673 | |
| 2674 | - present the client's IP and port addresses. This is the most transparent |
| 2675 | mode, but it can cause problems when IP connection tracking is enabled on |
| 2676 | the machine, because a same connection may be seen twice with different |
| 2677 | states. However, this solution presents the huge advantage of not |
| 2678 | limiting the system to the 64k outgoing address+port couples, because all |
| 2679 | of the client ranges may be used. |
| 2680 | |
| 2681 | - present only the client's IP address and select a spare port. This |
| 2682 | solution is still quite elegant but slightly less transparent (downstream |
| 2683 | firewalls logs will not match upstream's). It also presents the downside |
| 2684 | of limiting the number of concurrent connections to the usual 64k ports. |
| 2685 | However, since the upstream and downstream ports are different, local IP |
| 2686 | connection tracking on the machine will not be upset by the reuse of the |
| 2687 | same session. |
| 2688 | |
| 2689 | Note that depending on the transparent proxy technology used, it may be |
| 2690 | required to force the source address. In fact, cttproxy version 2 requires an |
| 2691 | IP address in <addr> above, and does not support setting of "0.0.0.0" as the |
| 2692 | IP address because it creates NAT entries which much match the exact outgoing |
| 2693 | address. Tproxy version 4 and some other kernel patches which work in pure |
| 2694 | forwarding mode generally will not have this limitation. |
| 2695 | |
| 2696 | This option sets the default source for all servers in the backend. It may |
| 2697 | also be specified in a "defaults" section. Finer source address specification |
| 2698 | is possible at the server level using the "source" server option. Refer to |
| 2699 | section 2.4 for more information. |
| 2700 | |
| 2701 | Examples : |
| 2702 | backend private |
| 2703 | # Connect to the servers using our 192.168.1.200 source address |
| 2704 | source 192.168.1.200 |
| 2705 | |
| 2706 | backend transparent_ssl1 |
| 2707 | # Connect to the SSL farm from the client's source address |
| 2708 | source 192.168.1.200 usesrc clientip |
| 2709 | |
| 2710 | backend transparent_ssl2 |
| 2711 | # Connect to the SSL farm from the client's source address and port |
| 2712 | # not recommended if IP conntrack is present on the local machine. |
| 2713 | source 192.168.1.200 usesrc client |
| 2714 | |
| 2715 | backend transparent_ssl3 |
| 2716 | # Connect to the SSL farm from the client's source address. It |
| 2717 | # is more conntrack-friendly. |
| 2718 | source 192.168.1.200 usesrc clientip |
| 2719 | |
| 2720 | backend transparent_smtp |
| 2721 | # Connect to the SMTP farm from the client's source address/port |
| 2722 | # with Tproxy version 4. |
| 2723 | source 0.0.0.0 usesrc clientip |
| 2724 | |
| 2725 | See also : the "source" server option in section 2.4, the Tproxy patches for |
| 2726 | the Linux kernel on www.balabit.com, the "bind" keyword. |
| 2727 | |
Krzysztof Piotr Oledzki | 25b501a | 2008-01-06 16:36:16 +0100 | [diff] [blame] | 2728 | |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 2729 | srvtimeout <timeout> (deprecated) |
| 2730 | Set the maximum inactivity time on the server side. |
| 2731 | May be used in sections : defaults | frontend | listen | backend |
| 2732 | yes | no | yes | yes |
| 2733 | Arguments : |
| 2734 | <timeout> is the timeout value specified in milliseconds by default, but |
| 2735 | can be in any other unit if the number is suffixed by the unit, |
| 2736 | as explained at the top of this document. |
| 2737 | |
| 2738 | The inactivity timeout applies when the server is expected to acknowledge or |
| 2739 | send data. In HTTP mode, this timeout is particularly important to consider |
| 2740 | during the first phase of the server's response, when it has to send the |
| 2741 | headers, as it directly represents the server's processing time for the |
| 2742 | request. To find out what value to put there, it's often good to start with |
| 2743 | what would be considered as unacceptable response times, then check the logs |
| 2744 | to observe the response time distribution, and adjust the value accordingly. |
| 2745 | |
| 2746 | The value is specified in milliseconds by default, but can be in any other |
| 2747 | unit if the number is suffixed by the unit, as specified at the top of this |
| 2748 | document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly |
| 2749 | recommended that the client timeout remains equal to the server timeout in |
| 2750 | order to avoid complex situations to debug. Whatever the expected server |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 2751 | response times, it is a good practice to cover at least one or several TCP |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 2752 | packet losses by specifying timeouts that are slightly above multiples of 3 |
| 2753 | seconds (eg: 4 or 5 seconds minimum). |
| 2754 | |
| 2755 | This parameter is specific to backends, but can be specified once for all in |
| 2756 | "defaults" sections. This is in fact one of the easiest solutions not to |
| 2757 | forget about it. An unspecified timeout results in an infinite timeout, which |
| 2758 | is not recommended. Such a usage is accepted and works but reports a warning |
| 2759 | during startup because it may results in accumulation of expired sessions in |
| 2760 | the system if the system's timeouts are not configured either. |
| 2761 | |
| 2762 | This parameter is provided for compatibility but is currently deprecated. |
| 2763 | Please use "timeout server" instead. |
| 2764 | |
| 2765 | See also : "timeout server", "timeout client" and "clitimeout". |
| 2766 | |
| 2767 | |
Willy Tarreau | eabeafa | 2008-01-16 16:17:06 +0100 | [diff] [blame] | 2768 | stats auth <user>:<passwd> |
| 2769 | Enable statistics with authentication and grant access to an account |
| 2770 | May be used in sections : defaults | frontend | listen | backend |
| 2771 | yes | no | yes | yes |
| 2772 | Arguments : |
| 2773 | <user> is a user name to grant access to |
| 2774 | |
| 2775 | <passwd> is the cleartext password associated to this user |
| 2776 | |
| 2777 | This statement enables statistics with default settings, and restricts access |
| 2778 | to declared users only. It may be repeated as many times as necessary to |
| 2779 | allow as many users as desired. When a user tries to access the statistics |
| 2780 | without a valid account, a "401 Forbidden" response will be returned so that |
| 2781 | the browser asks the user to provide a valid user and password. The real |
| 2782 | which will be returned to the browser is configurable using "stats realm". |
| 2783 | |
| 2784 | Since the authentication method is HTTP Basic Authentication, the passwords |
| 2785 | circulate in cleartext on the network. Thus, it was decided that the |
| 2786 | configuration file would also use cleartext passwords to remind the users |
| 2787 | that those ones should not be sensible and not shared with any other account. |
| 2788 | |
| 2789 | It is also possible to reduce the scope of the proxies which appear in the |
| 2790 | report using "stats scope". |
| 2791 | |
| 2792 | Though this statement alone is enough to enable statistics reporting, it is |
| 2793 | recommended to set all other settings in order to avoid relying on default |
| 2794 | unobvious parameters. |
| 2795 | |
| 2796 | Example : |
| 2797 | # public access (limited to this backend only) |
| 2798 | backend public_www |
| 2799 | server srv1 192.168.0.1:80 |
| 2800 | stats enable |
| 2801 | stats hide-version |
| 2802 | stats scope . |
| 2803 | stats uri /admin?stats |
| 2804 | stats realm Haproxy\ Statistics |
| 2805 | stats auth admin1:AdMiN123 |
| 2806 | stats auth admin2:AdMiN321 |
| 2807 | |
| 2808 | # internal monitoring access (unlimited) |
| 2809 | backend private_monitoring |
| 2810 | stats enable |
| 2811 | stats uri /admin?stats |
| 2812 | stats refresh 5s |
| 2813 | |
| 2814 | See also : "stats enable", "stats realm", "stats scope", "stats uri" |
| 2815 | |
| 2816 | |
| 2817 | stats enable |
| 2818 | Enable statistics reporting with default settings |
| 2819 | May be used in sections : defaults | frontend | listen | backend |
| 2820 | yes | no | yes | yes |
| 2821 | Arguments : none |
| 2822 | |
| 2823 | This statement enables statistics reporting with default settings defined |
| 2824 | at build time. Unless stated otherwise, these settings are used : |
| 2825 | - stats uri : /haproxy?stats |
| 2826 | - stats realm : "HAProxy Statistics" |
| 2827 | - stats auth : no authentication |
| 2828 | - stats scope : no restriction |
| 2829 | |
| 2830 | Though this statement alone is enough to enable statistics reporting, it is |
| 2831 | recommended to set all other settings in order to avoid relying on default |
| 2832 | unobvious parameters. |
| 2833 | |
| 2834 | Example : |
| 2835 | # public access (limited to this backend only) |
| 2836 | backend public_www |
| 2837 | server srv1 192.168.0.1:80 |
| 2838 | stats enable |
| 2839 | stats hide-version |
| 2840 | stats scope . |
| 2841 | stats uri /admin?stats |
| 2842 | stats realm Haproxy\ Statistics |
| 2843 | stats auth admin1:AdMiN123 |
| 2844 | stats auth admin2:AdMiN321 |
| 2845 | |
| 2846 | # internal monitoring access (unlimited) |
| 2847 | backend private_monitoring |
| 2848 | stats enable |
| 2849 | stats uri /admin?stats |
| 2850 | stats refresh 5s |
| 2851 | |
| 2852 | See also : "stats auth", "stats realm", "stats uri" |
| 2853 | |
| 2854 | |
| 2855 | stats realm <realm> |
| 2856 | Enable statistics and set authentication realm |
| 2857 | May be used in sections : defaults | frontend | listen | backend |
| 2858 | yes | no | yes | yes |
| 2859 | Arguments : |
| 2860 | <realm> is the name of the HTTP Basic Authentication realm reported to |
| 2861 | the browser. The browser uses it to display it in the pop-up |
| 2862 | inviting the user to enter a valid username and password. |
| 2863 | |
| 2864 | The realm is read as a single word, so any spaces in it should be escaped |
| 2865 | using a backslash ('\'). |
| 2866 | |
| 2867 | This statement is useful only in conjunction with "stats auth" since it is |
| 2868 | only related to authentication. |
| 2869 | |
| 2870 | Though this statement alone is enough to enable statistics reporting, it is |
| 2871 | recommended to set all other settings in order to avoid relying on default |
| 2872 | unobvious parameters. |
| 2873 | |
| 2874 | Example : |
| 2875 | # public access (limited to this backend only) |
| 2876 | backend public_www |
| 2877 | server srv1 192.168.0.1:80 |
| 2878 | stats enable |
| 2879 | stats hide-version |
| 2880 | stats scope . |
| 2881 | stats uri /admin?stats |
| 2882 | stats realm Haproxy\ Statistics |
| 2883 | stats auth admin1:AdMiN123 |
| 2884 | stats auth admin2:AdMiN321 |
| 2885 | |
| 2886 | # internal monitoring access (unlimited) |
| 2887 | backend private_monitoring |
| 2888 | stats enable |
| 2889 | stats uri /admin?stats |
| 2890 | stats refresh 5s |
| 2891 | |
| 2892 | See also : "stats auth", "stats enable", "stats uri" |
| 2893 | |
| 2894 | |
| 2895 | stats refresh <delay> |
| 2896 | Enable statistics with automatic refresh |
| 2897 | May be used in sections : defaults | frontend | listen | backend |
| 2898 | yes | no | yes | yes |
| 2899 | Arguments : |
| 2900 | <delay> is the suggested refresh delay, specified in seconds, which will |
| 2901 | be returned to the browser consulting the report page. While the |
| 2902 | browser is free to apply any delay, it will generally respect it |
| 2903 | and refresh the page this every seconds. The refresh interval may |
| 2904 | be specified in any other non-default time unit, by suffixing the |
| 2905 | unit after the value, as explained at the top of this document. |
| 2906 | |
| 2907 | This statement is useful on monitoring displays with a permanent page |
| 2908 | reporting the load balancer's activity. When set, the HTML report page will |
| 2909 | include a link "refresh"/"stop refresh" so that the user can select whether |
| 2910 | he wants automatic refresh of the page or not. |
| 2911 | |
| 2912 | Though this statement alone is enough to enable statistics reporting, it is |
| 2913 | recommended to set all other settings in order to avoid relying on default |
| 2914 | unobvious parameters. |
| 2915 | |
| 2916 | Example : |
| 2917 | # public access (limited to this backend only) |
| 2918 | backend public_www |
| 2919 | server srv1 192.168.0.1:80 |
| 2920 | stats enable |
| 2921 | stats hide-version |
| 2922 | stats scope . |
| 2923 | stats uri /admin?stats |
| 2924 | stats realm Haproxy\ Statistics |
| 2925 | stats auth admin1:AdMiN123 |
| 2926 | stats auth admin2:AdMiN321 |
| 2927 | |
| 2928 | # internal monitoring access (unlimited) |
| 2929 | backend private_monitoring |
| 2930 | stats enable |
| 2931 | stats uri /admin?stats |
| 2932 | stats refresh 5s |
| 2933 | |
| 2934 | See also : "stats auth", "stats enable", "stats realm", "stats uri" |
| 2935 | |
| 2936 | |
| 2937 | stats scope { <name> | "." } |
| 2938 | Enable statistics and limit access scope |
| 2939 | May be used in sections : defaults | frontend | listen | backend |
| 2940 | yes | no | yes | yes |
| 2941 | Arguments : |
| 2942 | <name> is the name of a listen, frontend or backend section to be |
| 2943 | reported. The special name "." (a single dot) designates the |
| 2944 | section in which the statement appears. |
| 2945 | |
| 2946 | When this statement is specified, only the sections enumerated with this |
| 2947 | statement will appear in the report. All other ones will be hidden. This |
| 2948 | statement may appear as many times as needed if multiple sections need to be |
| 2949 | reported. Please note that the name checking is performed as simple string |
| 2950 | comparisons, and that it is never checked that a give section name really |
| 2951 | exists. |
| 2952 | |
| 2953 | Though this statement alone is enough to enable statistics reporting, it is |
| 2954 | recommended to set all other settings in order to avoid relying on default |
| 2955 | unobvious parameters. |
| 2956 | |
| 2957 | Example : |
| 2958 | # public access (limited to this backend only) |
| 2959 | backend public_www |
| 2960 | server srv1 192.168.0.1:80 |
| 2961 | stats enable |
| 2962 | stats hide-version |
| 2963 | stats scope . |
| 2964 | stats uri /admin?stats |
| 2965 | stats realm Haproxy\ Statistics |
| 2966 | stats auth admin1:AdMiN123 |
| 2967 | stats auth admin2:AdMiN321 |
| 2968 | |
| 2969 | # internal monitoring access (unlimited) |
| 2970 | backend private_monitoring |
| 2971 | stats enable |
| 2972 | stats uri /admin?stats |
| 2973 | stats refresh 5s |
| 2974 | |
| 2975 | See also : "stats auth", "stats enable", "stats realm", "stats uri" |
| 2976 | |
| 2977 | |
| 2978 | stats uri <prefix> |
| 2979 | Enable statistics and define the URI prefix to access them |
| 2980 | May be used in sections : defaults | frontend | listen | backend |
| 2981 | yes | no | yes | yes |
| 2982 | Arguments : |
| 2983 | <prefix> is the prefix of any URI which will be redirected to stats. This |
| 2984 | prefix may contain a question mark ('?') to indicate part of a |
| 2985 | query string. |
| 2986 | |
| 2987 | The statistics URI is intercepted on the relayed traffic, so it appears as a |
| 2988 | page within the normal application. It is strongly advised to ensure that the |
| 2989 | selected URI will never appear in the application, otherwise it will never be |
| 2990 | possible to reach it in the application. |
| 2991 | |
| 2992 | The default URI compiled in haproxy is "/haproxy?stats", but this may be |
| 2993 | changed at build time, so it's better to always explictly specify it here. |
| 2994 | It is generally a good idea to include a question mark in the URI so that |
| 2995 | intermediate proxies refrain from caching the results. Also, since any string |
| 2996 | beginning with the prefix will be accepted as a stats request, the question |
| 2997 | mark helps ensuring that no valid URI will begin with the same words. |
| 2998 | |
| 2999 | It is sometimes very convenient to use "/" as the URI prefix, and put that |
| 3000 | statement in a "listen" instance of its own. That makes it easy to dedicate |
| 3001 | an address or a port to statistics only. |
| 3002 | |
| 3003 | Though this statement alone is enough to enable statistics reporting, it is |
| 3004 | recommended to set all other settings in order to avoid relying on default |
| 3005 | unobvious parameters. |
| 3006 | |
| 3007 | Example : |
| 3008 | # public access (limited to this backend only) |
| 3009 | backend public_www |
| 3010 | server srv1 192.168.0.1:80 |
| 3011 | stats enable |
| 3012 | stats hide-version |
| 3013 | stats scope . |
| 3014 | stats uri /admin?stats |
| 3015 | stats realm Haproxy\ Statistics |
| 3016 | stats auth admin1:AdMiN123 |
| 3017 | stats auth admin2:AdMiN321 |
| 3018 | |
| 3019 | # internal monitoring access (unlimited) |
| 3020 | backend private_monitoring |
| 3021 | stats enable |
| 3022 | stats uri /admin?stats |
| 3023 | stats refresh 5s |
| 3024 | |
| 3025 | See also : "stats auth", "stats enable", "stats realm" |
| 3026 | |
| 3027 | |
| 3028 | stats hide-version |
| 3029 | Enable statistics and hide HAProxy version reporting |
| 3030 | May be used in sections : defaults | frontend | listen | backend |
| 3031 | yes | no | yes | yes |
| 3032 | Arguments : none |
| 3033 | |
| 3034 | By default, the stats page reports some useful status information along with |
| 3035 | the statistics. Among them is HAProxy's version. However, it is generally |
| 3036 | considered dangerous to report precise version to anyone, as it can help them |
| 3037 | target known weaknesses with specific attacks. The "stats hide-version" |
| 3038 | statement removes the version from the statistics report. This is recommended |
| 3039 | for public sites or any site with a weak login/password. |
| 3040 | |
| 3041 | Though this statement alone is enough to enable statistics reporting, it is |
| 3042 | recommended to set all other settings in order to avoid relying on default |
| 3043 | unobvious parameters. |
| 3044 | |
| 3045 | Example : |
| 3046 | # public access (limited to this backend only) |
| 3047 | backend public_www |
| 3048 | server srv1 192.168.0.1:80 |
| 3049 | stats enable |
| 3050 | stats hide-version |
| 3051 | stats scope . |
| 3052 | stats uri /admin?stats |
| 3053 | stats realm Haproxy\ Statistics |
| 3054 | stats auth admin1:AdMiN123 |
| 3055 | stats auth admin2:AdMiN321 |
| 3056 | |
| 3057 | # internal monitoring access (unlimited) |
| 3058 | backend private_monitoring |
| 3059 | stats enable |
| 3060 | stats uri /admin?stats |
| 3061 | stats refresh 5s |
| 3062 | |
| 3063 | See also : "stats auth", "stats enable", "stats realm", "stats uri" |
| 3064 | |
| 3065 | |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 3066 | timeout check <timeout> |
| 3067 | Set additional check timeout, but only after a connection has been already |
| 3068 | established. |
| 3069 | |
| 3070 | May be used in sections: defaults | frontend | listen | backend |
| 3071 | yes | no | yes | yes |
| 3072 | Arguments: |
| 3073 | <timeout> is the timeout value specified in milliseconds by default, but |
| 3074 | can be in any other unit if the number is suffixed by the unit, |
| 3075 | as explained at the top of this document. |
| 3076 | |
| 3077 | If set, haproxy uses min("timeout connect", "inter") as a connect timeout |
| 3078 | for check and "timeout check" as an additional read timeout. The "min" is |
| 3079 | used so that people running with *very* long "timeout connect" (eg. those |
| 3080 | who needed this due to the queue or tarpit) do not slow down their checks. |
| 3081 | Of course it is better to use "check queue" and "check tarpit" instead of |
| 3082 | long "timeout connect". |
| 3083 | |
| 3084 | If "timeout check" is not set haproxy uses "inter" for complete check |
| 3085 | timeout (connect + read) exactly like all <1.3.15 version. |
| 3086 | |
| 3087 | In most cases check request is much simpler and faster to handle than normal |
| 3088 | requests and people may want to kick out laggy servers so this timeout should |
Willy Tarreau | 41a340d | 2008-01-22 12:25:31 +0100 | [diff] [blame] | 3089 | be smaller than "timeout server". |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 3090 | |
| 3091 | This parameter is specific to backends, but can be specified once for all in |
| 3092 | "defaults" sections. This is in fact one of the easiest solutions not to |
| 3093 | forget about it. |
| 3094 | |
Willy Tarreau | 41a340d | 2008-01-22 12:25:31 +0100 | [diff] [blame] | 3095 | See also: "timeout connect", "timeout queue", "timeout server", |
| 3096 | "timeout tarpit". |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 3097 | |
| 3098 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3099 | timeout client <timeout> |
| 3100 | timeout clitimeout <timeout> (deprecated) |
| 3101 | Set the maximum inactivity time on the client side. |
| 3102 | May be used in sections : defaults | frontend | listen | backend |
| 3103 | yes | yes | yes | no |
| 3104 | Arguments : |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 3105 | <timeout> is the timeout value specified in milliseconds by default, but |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3106 | can be in any other unit if the number is suffixed by the unit, |
| 3107 | as explained at the top of this document. |
| 3108 | |
| 3109 | The inactivity timeout applies when the client is expected to acknowledge or |
| 3110 | send data. In HTTP mode, this timeout is particularly important to consider |
| 3111 | during the first phase, when the client sends the request, and during the |
| 3112 | response while it is reading data sent by the server. The value is specified |
| 3113 | in milliseconds by default, but can be in any other unit if the number is |
| 3114 | suffixed by the unit, as specified at the top of this document. In TCP mode |
| 3115 | (and to a lesser extent, in HTTP mode), it is highly recommended that the |
| 3116 | client timeout remains equal to the server timeout in order to avoid complex |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 3117 | situations to debug. It is a good practice to cover one or several TCP packet |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3118 | losses by specifying timeouts that are slightly above multiples of 3 seconds |
| 3119 | (eg: 4 or 5 seconds). |
| 3120 | |
| 3121 | This parameter is specific to frontends, but can be specified once for all in |
| 3122 | "defaults" sections. This is in fact one of the easiest solutions not to |
| 3123 | forget about it. An unspecified timeout results in an infinite timeout, which |
| 3124 | is not recommended. Such a usage is accepted and works but reports a warning |
| 3125 | during startup because it may results in accumulation of expired sessions in |
| 3126 | the system if the system's timeouts are not configured either. |
| 3127 | |
| 3128 | This parameter replaces the old, deprecated "clitimeout". It is recommended |
| 3129 | to use it to write new configurations. The form "timeout clitimeout" is |
| 3130 | provided only by backwards compatibility but its use is strongly discouraged. |
| 3131 | |
| 3132 | See also : "clitimeout", "timeout server". |
| 3133 | |
| 3134 | |
| 3135 | timeout connect <timeout> |
| 3136 | timeout contimeout <timeout> (deprecated) |
| 3137 | Set the maximum time to wait for a connection attempt to a server to succeed. |
| 3138 | May be used in sections : defaults | frontend | listen | backend |
| 3139 | yes | no | yes | yes |
| 3140 | Arguments : |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 3141 | <timeout> is the timeout value specified in milliseconds by default, but |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3142 | can be in any other unit if the number is suffixed by the unit, |
| 3143 | as explained at the top of this document. |
| 3144 | |
| 3145 | If the server is located on the same LAN as haproxy, the connection should be |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 3146 | immediate (less than a few milliseconds). Anyway, it is a good practice to |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3147 | cover one or several TCP packet losses by specifying timeouts that are |
| 3148 | slightly above multiples of 3 seconds (eg: 4 or 5 seconds). By default, the |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 3149 | connect timeout also presets both queue and tarpit timeouts to the same value |
| 3150 | if these have not been specified. |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3151 | |
| 3152 | This parameter is specific to backends, but can be specified once for all in |
| 3153 | "defaults" sections. This is in fact one of the easiest solutions not to |
| 3154 | forget about it. An unspecified timeout results in an infinite timeout, which |
| 3155 | is not recommended. Such a usage is accepted and works but reports a warning |
| 3156 | during startup because it may results in accumulation of failed sessions in |
| 3157 | the system if the system's timeouts are not configured either. |
| 3158 | |
| 3159 | This parameter replaces the old, deprecated "contimeout". It is recommended |
| 3160 | to use it to write new configurations. The form "timeout contimeout" is |
| 3161 | provided only by backwards compatibility but its use is strongly discouraged. |
| 3162 | |
Willy Tarreau | 41a340d | 2008-01-22 12:25:31 +0100 | [diff] [blame] | 3163 | See also: "timeout check", "timeout queue", "timeout server", "contimeout", |
| 3164 | "timeout tarpit". |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3165 | |
| 3166 | |
Willy Tarreau | 036fae0 | 2008-01-06 13:24:40 +0100 | [diff] [blame] | 3167 | timeout http-request <timeout> |
| 3168 | Set the maximum allowed time to wait for a complete HTTP request |
| 3169 | May be used in sections : defaults | frontend | listen | backend |
| 3170 | yes | yes | yes | no |
| 3171 | Arguments : |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 3172 | <timeout> is the timeout value specified in milliseconds by default, but |
Willy Tarreau | 036fae0 | 2008-01-06 13:24:40 +0100 | [diff] [blame] | 3173 | can be in any other unit if the number is suffixed by the unit, |
| 3174 | as explained at the top of this document. |
| 3175 | |
| 3176 | In order to offer DoS protection, it may be required to lower the maximum |
| 3177 | accepted time to receive a complete HTTP request without affecting the client |
| 3178 | timeout. This helps protecting against established connections on which |
| 3179 | nothing is sent. The client timeout cannot offer a good protection against |
| 3180 | this abuse because it is an inactivity timeout, which means that if the |
| 3181 | attacker sends one character every now and then, the timeout will not |
| 3182 | trigger. With the HTTP request timeout, no matter what speed the client |
| 3183 | types, the request will be aborted if it does not complete in time. |
| 3184 | |
| 3185 | Note that this timeout only applies to the header part of the request, and |
| 3186 | not to any data. As soon as the empty line is received, this timeout is not |
| 3187 | used anymore. |
| 3188 | |
| 3189 | Generally it is enough to set it to a few seconds, as most clients send the |
| 3190 | full request immediately upon connection. Add 3 or more seconds to cover TCP |
| 3191 | retransmits but that's all. Setting it to very low values (eg: 50 ms) will |
| 3192 | generally work on local networks as long as there are no packet losses. This |
| 3193 | will prevent people from sending bare HTTP requests using telnet. |
| 3194 | |
| 3195 | If this parameter is not set, the client timeout still applies between each |
| 3196 | chunk of the incoming request. |
| 3197 | |
| 3198 | See also : "timeout client". |
| 3199 | |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 3200 | |
| 3201 | timeout queue <timeout> |
| 3202 | Set the maximum time to wait in the queue for a connection slot to be free |
| 3203 | May be used in sections : defaults | frontend | listen | backend |
| 3204 | yes | no | yes | yes |
| 3205 | Arguments : |
| 3206 | <timeout> is the timeout value specified in milliseconds by default, but |
| 3207 | can be in any other unit if the number is suffixed by the unit, |
| 3208 | as explained at the top of this document. |
| 3209 | |
| 3210 | When a server's maxconn is reached, connections are left pending in a queue |
| 3211 | which may be server-specific or global to the backend. In order not to wait |
| 3212 | indefinitely, a timeout is applied to requests pending in the queue. If the |
| 3213 | timeout is reached, it is considered that the request will almost never be |
| 3214 | served, so it is dropped and a 503 error is returned to the client. |
| 3215 | |
| 3216 | The "timeout queue" statement allows to fix the maximum time for a request to |
| 3217 | be left pending in a queue. If unspecified, the same value as the backend's |
| 3218 | connection timeout ("timeout connect") is used, for backwards compatibility |
| 3219 | with older versions with no "timeout queue" parameter. |
| 3220 | |
| 3221 | See also : "timeout connect", "contimeout". |
| 3222 | |
| 3223 | |
| 3224 | timeout server <timeout> |
| 3225 | timeout srvtimeout <timeout> (deprecated) |
| 3226 | Set the maximum inactivity time on the server side. |
| 3227 | May be used in sections : defaults | frontend | listen | backend |
| 3228 | yes | no | yes | yes |
| 3229 | Arguments : |
| 3230 | <timeout> is the timeout value specified in milliseconds by default, but |
| 3231 | can be in any other unit if the number is suffixed by the unit, |
| 3232 | as explained at the top of this document. |
| 3233 | |
| 3234 | The inactivity timeout applies when the server is expected to acknowledge or |
| 3235 | send data. In HTTP mode, this timeout is particularly important to consider |
| 3236 | during the first phase of the server's response, when it has to send the |
| 3237 | headers, as it directly represents the server's processing time for the |
| 3238 | request. To find out what value to put there, it's often good to start with |
| 3239 | what would be considered as unacceptable response times, then check the logs |
| 3240 | to observe the response time distribution, and adjust the value accordingly. |
| 3241 | |
| 3242 | The value is specified in milliseconds by default, but can be in any other |
| 3243 | unit if the number is suffixed by the unit, as specified at the top of this |
| 3244 | document. In TCP mode (and to a lesser extent, in HTTP mode), it is highly |
| 3245 | recommended that the client timeout remains equal to the server timeout in |
| 3246 | order to avoid complex situations to debug. Whatever the expected server |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 3247 | response times, it is a good practice to cover at least one or several TCP |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 3248 | packet losses by specifying timeouts that are slightly above multiples of 3 |
| 3249 | seconds (eg: 4 or 5 seconds minimum). |
| 3250 | |
| 3251 | This parameter is specific to backends, but can be specified once for all in |
| 3252 | "defaults" sections. This is in fact one of the easiest solutions not to |
| 3253 | forget about it. An unspecified timeout results in an infinite timeout, which |
| 3254 | is not recommended. Such a usage is accepted and works but reports a warning |
| 3255 | during startup because it may results in accumulation of expired sessions in |
| 3256 | the system if the system's timeouts are not configured either. |
| 3257 | |
| 3258 | This parameter replaces the old, deprecated "srvtimeout". It is recommended |
| 3259 | to use it to write new configurations. The form "timeout srvtimeout" is |
| 3260 | provided only by backwards compatibility but its use is strongly discouraged. |
| 3261 | |
| 3262 | See also : "srvtimeout", "timeout client". |
| 3263 | |
| 3264 | |
| 3265 | timeout tarpit <timeout> |
| 3266 | Set the duration for which tapitted connections will be maintained |
| 3267 | May be used in sections : defaults | frontend | listen | backend |
| 3268 | yes | yes | yes | yes |
| 3269 | Arguments : |
| 3270 | <timeout> is the tarpit duration specified in milliseconds by default, but |
| 3271 | can be in any other unit if the number is suffixed by the unit, |
| 3272 | as explained at the top of this document. |
| 3273 | |
| 3274 | When a connection is tarpitted using "reqtarpit", it is maintained open with |
| 3275 | no activity for a certain amount of time, then closed. "timeout tarpit" |
| 3276 | defines how long it will be maintained open. |
| 3277 | |
| 3278 | The value is specified in milliseconds by default, but can be in any other |
| 3279 | unit if the number is suffixed by the unit, as specified at the top of this |
| 3280 | document. If unspecified, the same value as the backend's connection timeout |
| 3281 | ("timeout connect") is used, for backwards compatibility with older versions |
| 3282 | with no "timeout tapit" parameter. |
| 3283 | |
| 3284 | See also : "timeout connect", "contimeout". |
| 3285 | |
| 3286 | |
| 3287 | transparent (deprecated) |
| 3288 | Enable client-side transparent proxying |
| 3289 | May be used in sections : defaults | frontend | listen | backend |
| 3290 | yes | yes | yes | no |
| 3291 | Arguments : none |
| 3292 | |
| 3293 | This keyword was introduced in order to provide layer 7 persistence to layer |
| 3294 | 3 load balancers. The idea is to use the OS's ability to redirect an incoming |
| 3295 | connection for a remote address to a local process (here HAProxy), and let |
| 3296 | this process know what address was initially requested. When this option is |
| 3297 | used, sessions without cookies will be forwarded to the original destination |
| 3298 | IP address of the incoming request (which should match that of another |
| 3299 | equipment), while requests with cookies will still be forwarded to the |
| 3300 | appropriate server. |
| 3301 | |
| 3302 | The "transparent" keyword is deprecated, use "option transparent" instead. |
| 3303 | |
| 3304 | Note that contrary to a common belief, this option does NOT make HAProxy |
| 3305 | present the client's IP to the server when establishing the connection. |
| 3306 | |
| 3307 | Use of this option is really discouraged, and since no really valid use of it |
| 3308 | has been reported for years, it will probably be removed in future versions. |
| 3309 | |
| 3310 | See also: "option transparent" |
| 3311 | |
| 3312 | |
| 3313 | use_backend <backend> if <condition> |
| 3314 | use_backend <backend> unless <condition> |
| 3315 | Switch to a specific backend if/unless a Layer 7 condition is matched. |
| 3316 | May be used in sections : defaults | frontend | listen | backend |
| 3317 | no | yes | yes | no |
| 3318 | Arguments : |
| 3319 | <backend> is the name of a valid backend or "listen" section. |
| 3320 | |
| 3321 | <condition> is a condition composed of ACLs, as described in section 2.3. |
| 3322 | |
| 3323 | When doing content-switching, connections arrive on a frontend and are then |
| 3324 | dispatched to various backends depending on a number of conditions. The |
| 3325 | relation between the conditions and the backends is described with the |
| 3326 | "use_backend" keyword. This is supported only in HTTP mode. |
| 3327 | |
| 3328 | There may be as many "use_backend" rules as desired. All of these rules are |
| 3329 | evaluated in their declaration order, and the first one which matches will |
| 3330 | assign the backend. |
| 3331 | |
| 3332 | In the first form, the backend will be used if the condition is met. In the |
| 3333 | second form, the backend will be used if the condition is not met. If no |
| 3334 | condition is valid, the backend defined with "default_backend" will be used. |
| 3335 | If no default backend is defined, either the servers in the same section are |
| 3336 | used (in case of a "listen" section) or, in case of a frontend, no server is |
| 3337 | used and a 503 service unavailable response is returned. |
| 3338 | |
| 3339 | See also: "default_backend" and section 2.3 about ACLs. |
| 3340 | |
Willy Tarreau | 036fae0 | 2008-01-06 13:24:40 +0100 | [diff] [blame] | 3341 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3342 | 2.3) Using ACLs |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3343 | --------------- |
| 3344 | |
| 3345 | The use of Access Control Lists (ACL) provides a flexible solution to perform |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3346 | content switching and generally to take decisions based on content extracted |
| 3347 | from the request, the response or any environmental status. The principle is |
| 3348 | simple : |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3349 | |
| 3350 | - define test criteria with sets of values |
| 3351 | - perform actions only if a set of tests is valid |
| 3352 | |
| 3353 | The actions generally consist in blocking the request, or selecting a backend. |
| 3354 | |
| 3355 | In order to define a test, the "acl" keyword is used. The syntax is : |
| 3356 | |
| 3357 | acl <aclname> <criterion> [flags] [operator] <value> ... |
| 3358 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3359 | This creates a new ACL <aclname> or completes an existing one with new tests. |
| 3360 | Those tests apply to the portion of request/response specified in <criterion> |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3361 | and may be adjusted with optional flags [flags]. Some criteria also support |
| 3362 | an operator which may be specified before the set of values. The values are |
| 3363 | of the type supported by the criterion, and are separated by spaces. |
| 3364 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3365 | ACL names must be formed from upper and lower case letters, digits, '-' (dash), |
| 3366 | '_' (underscore) , '.' (dot) and ':' (colon). ACL names are case-sensitive, |
| 3367 | which means that "my_acl" and "My_Acl" are two different ACLs. |
| 3368 | |
| 3369 | There is no enforced limit to the number of ACLs. The unused ones do not affect |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3370 | performance, they just consume a small amount of memory. |
| 3371 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3372 | The following ACL flags are currently supported : |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3373 | |
| 3374 | -i : ignore case during matching. |
| 3375 | -- : force end of flags. Useful when a string looks like one of the flags. |
| 3376 | |
| 3377 | Supported types of values are : |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3378 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3379 | - integers or integer ranges |
| 3380 | - strings |
| 3381 | - regular expressions |
| 3382 | - IP addresses and networks |
| 3383 | |
| 3384 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3385 | 2.3.1) Matching integers |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3386 | ------------------------ |
| 3387 | |
| 3388 | Matching integers is special in that ranges and operators are permitted. Note |
| 3389 | that integer matching only applies to positive values. A range is a value |
| 3390 | expressed with a lower and an upper bound separated with a colon, both of which |
| 3391 | may be omitted. |
| 3392 | |
| 3393 | For instance, "1024:65535" is a valid range to represent a range of |
| 3394 | unprivileged ports, and "1024:" would also work. "0:1023" is a valid |
| 3395 | representation of privileged ports, and ":1023" would also work. |
| 3396 | |
| 3397 | For an easier usage, comparison operators are also supported. Note that using |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3398 | operators with ranges does not make much sense and is strongly discouraged. |
| 3399 | Similarly, it does not make much sense to perform order comparisons with a set |
| 3400 | of values. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3401 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3402 | Available operators for integer matching are : |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3403 | |
| 3404 | eq : true if the tested value equals at least one value |
| 3405 | ge : true if the tested value is greater than or equal to at least one value |
| 3406 | gt : true if the tested value is greater than at least one value |
| 3407 | le : true if the tested value is less than or equal to at least one value |
| 3408 | lt : true if the tested value is less than at least one value |
| 3409 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3410 | For instance, the following ACL matches any negative Content-Length header : |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3411 | |
| 3412 | acl negative-length hdr_val(content-length) lt 0 |
| 3413 | |
| 3414 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3415 | 2.3.2) Matching strings |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3416 | ----------------------- |
| 3417 | |
| 3418 | String matching applies to verbatim strings as they are passed, with the |
| 3419 | exception of the backslash ("\") which makes it possible to escape some |
| 3420 | characters such as the space. If the "-i" flag is passed before the first |
| 3421 | string, then the matching will be performed ignoring the case. In order |
| 3422 | to match the string "-i", either set it second, or pass the "--" flag |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3423 | before the first string. Same applies of course to match the string "--". |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3424 | |
| 3425 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3426 | 2.3.3) Matching regular expressions (regexes) |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3427 | --------------------------------------------- |
| 3428 | |
| 3429 | Just like with string matching, regex matching applies to verbatim strings as |
| 3430 | they are passed, with the exception of the backslash ("\") which makes it |
| 3431 | possible to escape some characters such as the space. If the "-i" flag is |
| 3432 | passed before the first regex, then the matching will be performed ignoring |
| 3433 | the case. In order to match the string "-i", either set it second, or pass |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3434 | the "--" flag before the first string. Same principle applies of course to |
| 3435 | match the string "--". |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3436 | |
| 3437 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3438 | 2.3.4) Matching IPv4 addresses |
| 3439 | ------------------------------ |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3440 | |
| 3441 | IPv4 addresses values can be specified either as plain addresses or with a |
| 3442 | netmask appended, in which case the IPv4 address matches whenever it is |
| 3443 | within the network. Plain addresses may also be replaced with a resolvable |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 3444 | host name, but this practice is generally discouraged as it makes it more |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3445 | difficult to read and debug configurations. If hostnames are used, you should |
| 3446 | at least ensure that they are present in /etc/hosts so that the configuration |
| 3447 | does not depend on any random DNS match at the moment the configuration is |
| 3448 | parsed. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3449 | |
| 3450 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3451 | 2.3.5) Available matching criteria |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3452 | ---------------------------------- |
| 3453 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3454 | 2.3.5.1) Matching at Layer 4 and below |
| 3455 | -------------------------------------- |
| 3456 | |
| 3457 | A first set of criteria applies to information which does not require any |
| 3458 | analysis of the request or response contents. Those generally include TCP/IP |
| 3459 | addresses and ports, as well as internal values independant on the stream. |
| 3460 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3461 | always_false |
| 3462 | This one never matches. All values and flags are ignored. It may be used as |
| 3463 | a temporary replacement for another one when adjusting configurations. |
| 3464 | |
| 3465 | always_true |
| 3466 | This one always matches. All values and flags are ignored. It may be used as |
| 3467 | a temporary replacement for another one when adjusting configurations. |
| 3468 | |
| 3469 | src <ip_address> |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3470 | Applies to the client's IPv4 address. It is usually used to limit access to |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3471 | certain resources such as statistics. Note that it is the TCP-level source |
| 3472 | address which is used, and not the address of a client behind a proxy. |
| 3473 | |
| 3474 | src_port <integer> |
| 3475 | Applies to the client's TCP source port. This has a very limited usage. |
| 3476 | |
| 3477 | dst <ip_address> |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3478 | Applies to the local IPv4 address the client connected to. It can be used to |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3479 | switch to a different backend for some alternative addresses. |
| 3480 | |
| 3481 | dst_port <integer> |
| 3482 | Applies to the local port the client connected to. It can be used to switch |
| 3483 | to a different backend for some alternative ports. |
| 3484 | |
| 3485 | dst_conn <integer> |
| 3486 | Applies to the number of currently established connections on the frontend, |
| 3487 | including the one being evaluated. It can be used to either return a sorry |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3488 | page before hard-blocking, or to use a specific backend to drain new requests |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3489 | when the farm is considered saturated. |
| 3490 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3491 | nbsrv <integer> |
| 3492 | nbsrv(backend) <integer> |
| 3493 | Returns true when the number of usable servers of either the current backend |
| 3494 | or the named backend matches the values or ranges specified. This is used to |
| 3495 | switch to an alternate backend when the number of servers is too low to |
| 3496 | to handle some load. It is useful to report a failure when combined with |
| 3497 | "monitor fail". |
| 3498 | |
| 3499 | |
| 3500 | 2.3.5.2) Matching at Layer 7 |
| 3501 | ---------------------------- |
| 3502 | |
| 3503 | A second set of criteria applies to information which can be found at the |
| 3504 | application layer (layer 7). Those require that a full HTTP request has been |
| 3505 | read, and are only evaluated then. They may require slightly more CPU resources |
| 3506 | than the layer 4 ones, but not much since the request and response are indexed. |
| 3507 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3508 | method <string> |
| 3509 | Applies to the method in the HTTP request, eg: "GET". Some predefined ACL |
| 3510 | already check for most common methods. |
| 3511 | |
| 3512 | req_ver <string> |
| 3513 | Applies to the version string in the HTTP request, eg: "1.0". Some predefined |
| 3514 | ACL already check for versions 1.0 and 1.1. |
| 3515 | |
| 3516 | path <string> |
| 3517 | Returns true when the path part of the request, which starts at the first |
| 3518 | slash and ends before the question mark, equals one of the strings. It may be |
| 3519 | used to match known files, such as /favicon.ico. |
| 3520 | |
| 3521 | path_beg <string> |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3522 | Returns true when the path begins with one of the strings. This can be used |
| 3523 | to send certain directory names to alternative backends. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3524 | |
| 3525 | path_end <string> |
| 3526 | Returns true when the path ends with one of the strings. This may be used to |
| 3527 | control file name extension. |
| 3528 | |
| 3529 | path_sub <string> |
| 3530 | Returns true when the path contains one of the strings. It can be used to |
| 3531 | detect particular patterns in paths, such as "../" for example. See also |
| 3532 | "path_dir". |
| 3533 | |
| 3534 | path_dir <string> |
| 3535 | Returns true when one of the strings is found isolated or delimited with |
| 3536 | slashes in the path. This is used to perform filename or directory name |
| 3537 | matching without the risk of wrong match due to colliding prefixes. See also |
| 3538 | "url_dir" and "path_sub". |
| 3539 | |
| 3540 | path_dom <string> |
| 3541 | Returns true when one of the strings is found isolated or delimited with dots |
| 3542 | in the path. This may be used to perform domain name matching in proxy |
| 3543 | requests. See also "path_sub" and "url_dom". |
| 3544 | |
| 3545 | path_reg <regex> |
| 3546 | Returns true when the path matches one of the regular expressions. It can be |
| 3547 | used any time, but it is important to remember that regex matching is slower |
| 3548 | than other methods. See also "url_reg" and all "path_" criteria. |
| 3549 | |
| 3550 | url <string> |
| 3551 | Applies to the whole URL passed in the request. The only real use is to match |
| 3552 | "*", for which there already is a predefined ACL. |
| 3553 | |
| 3554 | url_beg <string> |
| 3555 | Returns true when the URL begins with one of the strings. This can be used to |
| 3556 | check whether a URL begins with a slash or with a protocol scheme. |
| 3557 | |
| 3558 | url_end <string> |
| 3559 | Returns true when the URL ends with one of the strings. It has very limited |
| 3560 | use. "path_end" should be used instead for filename matching. |
| 3561 | |
| 3562 | url_sub <string> |
| 3563 | Returns true when the URL contains one of the strings. It can be used to |
| 3564 | detect particular patterns in query strings for example. See also "path_sub". |
| 3565 | |
| 3566 | url_dir <string> |
| 3567 | Returns true when one of the strings is found isolated or delimited with |
| 3568 | slashes in the URL. This is used to perform filename or directory name |
| 3569 | matching without the risk of wrong match due to colliding prefixes. See also |
| 3570 | "path_dir" and "url_sub". |
| 3571 | |
| 3572 | url_dom <string> |
| 3573 | Returns true when one of the strings is found isolated or delimited with dots |
| 3574 | in the URL. This is used to perform domain name matching without the risk of |
| 3575 | wrong match due to colliding prefixes. See also "url_sub". |
| 3576 | |
| 3577 | url_reg <regex> |
| 3578 | Returns true when the URL matches one of the regular expressions. It can be |
| 3579 | used any time, but it is important to remember that regex matching is slower |
| 3580 | than other methods. See also "path_reg" and all "url_" criteria. |
| 3581 | |
Alexandre Cassen | 5eb1a90 | 2007-11-29 15:43:32 +0100 | [diff] [blame] | 3582 | url_ip <ip_address> |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3583 | Applies to the IP address specified in the absolute URI in an HTTP request. |
| 3584 | It can be used to prevent access to certain resources such as local network. |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3585 | It is useful with option "http_proxy". |
Alexandre Cassen | 5eb1a90 | 2007-11-29 15:43:32 +0100 | [diff] [blame] | 3586 | |
| 3587 | url_port <integer> |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3588 | Applies to the port specified in the absolute URI in an HTTP request. It can |
| 3589 | be used to prevent access to certain resources. It is useful with option |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3590 | "http_proxy". Note that if the port is not specified in the request, port 80 |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3591 | is assumed. |
Alexandre Cassen | 5eb1a90 | 2007-11-29 15:43:32 +0100 | [diff] [blame] | 3592 | |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3593 | hdr <string> |
| 3594 | hdr(header) <string> |
| 3595 | Note: all the "hdr*" matching criteria either apply to all headers, or to a |
| 3596 | particular header whose name is passed between parenthesis and without any |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3597 | space. The header name is not case-sensitive. The header matching complies |
| 3598 | with RFC2616, and treats as separate headers all values delimited by commas. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3599 | |
| 3600 | The "hdr" criteria returns true if any of the headers matching the criteria |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3601 | match any of the strings. This can be used to check exact for values. For |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3602 | instance, checking that "connection: close" is set : |
| 3603 | |
| 3604 | hdr(Connection) -i close |
| 3605 | |
| 3606 | hdr_beg <string> |
| 3607 | hdr_beg(header) <string> |
| 3608 | Returns true when one of the headers begins with one of the strings. See |
| 3609 | "hdr" for more information on header matching. |
| 3610 | |
| 3611 | hdr_end <string> |
| 3612 | hdr_end(header) <string> |
| 3613 | Returns true when one of the headers ends with one of the strings. See "hdr" |
| 3614 | for more information on header matching. |
| 3615 | |
| 3616 | hdr_sub <string> |
| 3617 | hdr_sub(header) <string> |
| 3618 | Returns true when one of the headers contains one of the strings. See "hdr" |
| 3619 | for more information on header matching. |
| 3620 | |
| 3621 | hdr_dir <string> |
| 3622 | hdr_dir(header) <string> |
| 3623 | Returns true when one of the headers contains one of the strings either |
| 3624 | isolated or delimited by slashes. This is used to perform filename or |
| 3625 | directory name matching, and may be used with Referer. See "hdr" for more |
| 3626 | information on header matching. |
| 3627 | |
| 3628 | hdr_dom <string> |
| 3629 | hdr_dom(header) <string> |
| 3630 | Returns true when one of the headers contains one of the strings either |
| 3631 | isolated or delimited by dots. This is used to perform domain name matching, |
| 3632 | and may be used with the Host header. See "hdr" for more information on |
| 3633 | header matching. |
| 3634 | |
| 3635 | hdr_reg <regex> |
| 3636 | hdr_reg(header) <regex> |
| 3637 | Returns true when one of the headers matches of the regular expressions. It |
| 3638 | can be used at any time, but it is important to remember that regex matching |
| 3639 | is slower than other methods. See also other "hdr_" criteria, as well as |
| 3640 | "hdr" for more information on header matching. |
| 3641 | |
| 3642 | hdr_val <integer> |
| 3643 | hdr_val(header) <integer> |
| 3644 | Returns true when one of the headers starts with a number which matches the |
| 3645 | values or ranges specified. This may be used to limit content-length to |
| 3646 | acceptable values for example. See "hdr" for more information on header |
| 3647 | matching. |
| 3648 | |
| 3649 | hdr_cnt <integer> |
| 3650 | hdr_cnt(header) <integer> |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3651 | Returns true when the number of occurrence of the specified header matches |
| 3652 | the values or ranges specified. It is important to remember that one header |
| 3653 | line may count as several headers if it has several values. This is used to |
| 3654 | detect presence, absence or abuse of a specific header, as well as to block |
| 3655 | request smugling attacks by rejecting requests which contain more than one |
| 3656 | of certain headers. See "hdr" for more information on header matching. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3657 | |
| 3658 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3659 | 2.3.6) Pre-defined ACLs |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3660 | ----------------------- |
| 3661 | |
| 3662 | Some predefined ACLs are hard-coded so that they do not have to be declared in |
| 3663 | every frontend which needs them. They all have their names in upper case in |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3664 | order to avoid confusion. Their equivalence is provided below. Please note that |
| 3665 | only the first three ones are not layer 7 based. |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3666 | |
| 3667 | ACL name Equivalent to Usage |
| 3668 | ---------------+-----------------------------+--------------------------------- |
| 3669 | TRUE always_true 1 always match |
| 3670 | FALSE always_false 0 never match |
| 3671 | LOCALHOST src 127.0.0.1/8 match connection from local host |
| 3672 | HTTP_1.0 req_ver 1.0 match HTTP version 1.0 |
| 3673 | HTTP_1.1 req_ver 1.1 match HTTP version 1.1 |
| 3674 | METH_CONNECT method CONNECT match HTTP CONNECT method |
| 3675 | METH_GET method GET HEAD match HTTP GET or HEAD method |
| 3676 | METH_HEAD method HEAD match HTTP HEAD method |
| 3677 | METH_OPTIONS method OPTIONS match HTTP OPTIONS method |
| 3678 | METH_POST method POST match HTTP POST method |
| 3679 | METH_TRACE method TRACE match HTTP TRACE method |
| 3680 | HTTP_URL_ABS url_reg ^[^/:]*:// match absolute URL with scheme |
| 3681 | HTTP_URL_SLASH url_beg / match URL begining with "/" |
| 3682 | HTTP_URL_STAR url * match URL equal to "*" |
| 3683 | HTTP_CONTENT hdr_val(content-length) gt 0 match an existing content-length |
| 3684 | ---------------+-----------------------------+--------------------------------- |
| 3685 | |
| 3686 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3687 | 2.3.7) Using ACLs to form conditions |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3688 | ------------------------------------ |
| 3689 | |
| 3690 | Some actions are only performed upon a valid condition. A condition is a |
| 3691 | combination of ACLs with operators. 3 operators are supported : |
| 3692 | |
| 3693 | - AND (implicit) |
| 3694 | - OR (explicit with the "or" keyword or the "||" operator) |
| 3695 | - Negation with the exclamation mark ("!") |
| 3696 | |
| 3697 | A condition is formed as a disjonctive form : |
| 3698 | |
| 3699 | [!]acl1 [!]acl2 ... [!]acln { or [!]acl1 [!]acl2 ... [!]acln } ... |
| 3700 | |
| 3701 | Such conditions are generally used after an "if" or "unless" statement, |
| 3702 | indicating when the condition will trigger the action. |
| 3703 | |
| 3704 | For instance, to block HTTP requests to the "*" URL with methods other than |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 3705 | "OPTIONS", as well as POST requests without content-length, and GET or HEAD |
| 3706 | requests with a content-length greater than 0, and finally every request which |
| 3707 | is not either GET/HEAD/POST/OPTIONS ! |
Willy Tarreau | 6a06a40 | 2007-07-15 20:15:28 +0200 | [diff] [blame] | 3708 | |
| 3709 | acl missing_cl hdr_cnt(Content-length) eq 0 |
| 3710 | block if HTTP_URL_STAR !METH_OPTIONS || METH_POST missing_cl |
| 3711 | block if METH_GET HTTP_CONTENT |
| 3712 | block unless METH_GET or METH_POST or METH_OPTIONS |
| 3713 | |
| 3714 | To select a different backend for requests to static contents on the "www" site |
| 3715 | and to every request on the "img", "video", "download" and "ftp" hosts : |
| 3716 | |
| 3717 | acl url_static path_beg /static /images /img /css |
| 3718 | acl url_static path_end .gif .png .jpg .css .js |
| 3719 | acl host_www hdr_beg(host) -i www |
| 3720 | acl host_static hdr_beg(host) -i img. video. download. ftp. |
| 3721 | |
| 3722 | # now use backend "static" for all static-only hosts, and for static urls |
| 3723 | # of host "www". Use backend "www" for the rest. |
| 3724 | use_backend static if host_static or host_www url_static |
| 3725 | use_backend www if host_www |
| 3726 | |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 3727 | See section 2.2 for detailed help on the "block" and "use_backend" keywords. |
Willy Tarreau | dbc36f6 | 2007-11-30 12:29:11 +0100 | [diff] [blame] | 3728 | |
| 3729 | |
Willy Tarreau | c7246fc | 2007-12-02 17:31:20 +0100 | [diff] [blame] | 3730 | 2.4) Server options |
Willy Tarreau | 5764b38 | 2007-11-30 17:46:49 +0100 | [diff] [blame] | 3731 | ------------------- |
| 3732 | |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3733 | The "server" keyword supports a certain number of settings which are all passed |
| 3734 | as arguments on the server line. The order in which those arguments appear does |
| 3735 | not count, and they are all optional. Some of those settings are single words |
| 3736 | (booleans) while others expect one or several values after them. In this case, |
| 3737 | the values must immediately follow the setting name. All those settings must be |
| 3738 | specified after the server's address if they are used : |
| 3739 | |
| 3740 | server <name> <address>[:port] [settings ...] |
| 3741 | |
| 3742 | The currently supported settings are the following ones. |
| 3743 | |
| 3744 | addr <ipv4> |
| 3745 | Using the "addr" parameter, it becomes possible to use a different IP address |
| 3746 | to send health-checks. On some servers, it may be desirable to dedicate an IP |
| 3747 | address to specific component able to perform complex tests which are more |
| 3748 | suitable to health-checks than the application. This parameter is ignored if |
| 3749 | the "check" parameter is not set. See also the "port" parameter. |
| 3750 | |
| 3751 | backup |
| 3752 | When "backup" is present on a server line, the server is only used in load |
| 3753 | balancing when all other non-backup servers are unavailable. Requests coming |
| 3754 | with a persistence cookie referencing the server will always be served |
| 3755 | though. By default, only the first operational backup server is used, unless |
Willy Tarreau | af85d94 | 2008-01-30 10:47:10 +0100 | [diff] [blame] | 3756 | the "allbackups" option is set in the backend. See also the "allbackups" |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3757 | option. |
| 3758 | |
| 3759 | check |
| 3760 | This option enables health checks on the server. By default, a server is |
| 3761 | always considered available. If "check" is set, the server will receive |
| 3762 | periodic health checks to ensure that it is really able to serve requests. |
| 3763 | The default address and port to send the tests to are those of the server, |
| 3764 | and the default source is the same as the one defined in the backend. It is |
| 3765 | possible to change the address using the "addr" parameter, the port using the |
| 3766 | "port" parameter, the source address using the "source" address, and the |
| 3767 | interval and timers using the "inter", "rise" and "fall" parameters. The |
| 3768 | request method is define in the backend using the "httpchk", "smtpchk", |
| 3769 | and "ssl-hello-chk" options. Please refer to those options and parameters for |
| 3770 | more information. |
| 3771 | |
| 3772 | cookie <value> |
| 3773 | The "cookie" parameter sets the cookie value assigned to the server to |
| 3774 | <value>. This value will be checked in incoming requests, and the first |
| 3775 | operational server possessing the same value will be selected. In return, in |
| 3776 | cookie insertion or rewrite modes, this value will be assigned to the cookie |
| 3777 | sent to the client. There is nothing wrong in having several servers sharing |
| 3778 | the same cookie value, and it is in fact somewhat common between normal and |
| 3779 | backup servers. See also the "cookie" keyword in backend section. |
| 3780 | |
| 3781 | fall <count> |
| 3782 | The "fall" parameter states that a server will be considered as dead after |
| 3783 | <count> consecutive unsuccessful health checks. This value defaults to 3 if |
| 3784 | unspecified. See also the "check", "inter" and "rise" parameters. |
| 3785 | |
Krzysztof Piotr Oledzki | f58a962 | 2008-02-23 01:19:10 +0100 | [diff] [blame] | 3786 | id <value> |
| 3787 | Set a persistent value for server ID. Must be unique and larger than 1000, as |
| 3788 | smaller values are reserved for auto-assigned ids. |
| 3789 | |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3790 | inter <delay> |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 3791 | fastinter <delay> |
| 3792 | downinter <delay> |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3793 | The "inter" parameter sets the interval between two consecutive health checks |
| 3794 | to <delay> milliseconds. If left unspecified, the delay defaults to 2000 ms. |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 3795 | It is also possible to use "fastinter" and "downinter" to optimize delays |
Willy Tarreau | 41a340d | 2008-01-22 12:25:31 +0100 | [diff] [blame] | 3796 | between checks depending on the server state : |
| 3797 | |
| 3798 | Server state | Interval used |
| 3799 | ---------------------------------+----------------------------------------- |
| 3800 | UP 100% (non-transitional) | "inter" |
| 3801 | ---------------------------------+----------------------------------------- |
| 3802 | Transitionally UP (going down), | |
| 3803 | Transitionally DOWN (going up), | "fastinter" if set, "inter" otherwise. |
| 3804 | or yet unchecked. | |
| 3805 | ---------------------------------+----------------------------------------- |
| 3806 | DOWN 100% (non-transitional) | "downinter" if set, "inter" otherwise. |
| 3807 | ---------------------------------+----------------------------------------- |
| 3808 | |
| 3809 | Just as with every other time-based parameter, they can be entered in any |
| 3810 | other explicit unit among { us, ms, s, m, h, d }. The "inter" parameter also |
| 3811 | serves as a timeout for health checks sent to servers if "timeout check" is |
| 3812 | not set. In order to reduce "resonance" effects when multiple servers are |
| 3813 | hosted on the same hardware, the health-checks of all servers are started |
| 3814 | with a small time offset between them. It is also possible to add some random |
| 3815 | noise in the health checks interval using the global "spread-checks" |
| 3816 | keyword. This makes sense for instance when a lot of backends use the same |
| 3817 | servers. |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3818 | |
| 3819 | maxconn <maxconn> |
| 3820 | The "maxconn" parameter specifies the maximal number of concurrent |
| 3821 | connections that will be sent to this server. If the number of incoming |
| 3822 | concurrent requests goes higher than this value, they will be queued, waiting |
| 3823 | for a connection to be released. This parameter is very important as it can |
| 3824 | save fragile servers from going down under extreme loads. If a "minconn" |
| 3825 | parameter is specified, the limit becomes dynamic. The default value is "0" |
| 3826 | which means unlimited. See also the "minconn" and "maxqueue" parameters, and |
| 3827 | the backend's "fullconn" keyword. |
| 3828 | |
| 3829 | maxqueue <maxqueue> |
| 3830 | The "maxqueue" parameter specifies the maximal number of connections which |
| 3831 | will wait in the queue for this server. If this limit is reached, next |
| 3832 | requests will be redispatched to other servers instead of indefinitely |
| 3833 | waiting to be served. This will break persistence but may allow people to |
| 3834 | quickly re-log in when the server they try to connect to is dying. The |
| 3835 | default value is "0" which means the queue is unlimited. See also the |
| 3836 | "maxconn" and "minconn" parameters. |
| 3837 | |
| 3838 | minconn <minconn> |
| 3839 | When the "minconn" parameter is set, the maxconn limit becomes a dynamic |
| 3840 | limit following the backend's load. The server will always accept at least |
| 3841 | <minconn> connections, never more than <maxconn>, and the limit will be on |
| 3842 | the ramp between both values when the backend has less than <fullconn> |
| 3843 | concurrent connections. This makes it possible to limit the load on the |
| 3844 | server during normal loads, but push it further for important loads without |
| 3845 | overloading the server during exceptionnal loads. See also the "maxconn" |
| 3846 | and "maxqueue" parameters, as well as the "fullconn" backend keyword. |
| 3847 | |
| 3848 | port <port> |
| 3849 | Using the "port" parameter, it becomes possible to use a different port to |
| 3850 | send health-checks. On some servers, it may be desirable to dedicate a port |
| 3851 | to a specific component able to perform complex tests which are more suitable |
| 3852 | to health-checks than the application. It is common to run a simple script in |
| 3853 | inetd for instance. This parameter is ignored if the "check" parameter is not |
| 3854 | set. See also the "addr" parameter. |
| 3855 | |
Willy Tarreau | 21d2af3 | 2008-02-14 20:25:24 +0100 | [diff] [blame] | 3856 | redir <prefix> |
| 3857 | The "redir" parameter enables the redirection mode for all GET and HEAD |
| 3858 | requests addressing this server. This means that instead of having HAProxy |
| 3859 | forward the request to the server, it will send an "HTTP 302" response with |
| 3860 | the "Location" header composed of this prefix immediately followed by the |
| 3861 | requested URI beginning at the leading '/' of the path component. That means |
| 3862 | that no trailing slash should be used after <prefix>. All invalid requests |
| 3863 | will be rejected, and all non-GET or HEAD requests will be normally served by |
| 3864 | the server. Note that since the response is completely forged, no header |
| 3865 | mangling nor cookie insertion is possible in the respose. However, cookies in |
| 3866 | requests are still analysed, making this solution completely usable to direct |
| 3867 | users to a remote location in case of local disaster. Main use consists in |
| 3868 | increasing bandwidth for static servers by having the clients directly |
| 3869 | connect to them. Note: never use a relative location here, it would cause a |
| 3870 | loop between the client and HAProxy! |
| 3871 | |
| 3872 | Example : server srv1 192.168.1.1:80 redir http://image1.mydomain.com check |
| 3873 | |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3874 | rise <count> |
| 3875 | The "rise" parameter states that a server will be considered as operational |
| 3876 | after <count> consecutive successful health checks. This value defaults to 2 |
| 3877 | if unspecified. See also the "check", "inter" and "fall" parameters. |
| 3878 | |
Willy Tarreau | 5764b38 | 2007-11-30 17:46:49 +0100 | [diff] [blame] | 3879 | slowstart <start_time_in_ms> |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3880 | The "slowstart" parameter for a server accepts a value in milliseconds which |
Willy Tarreau | 5764b38 | 2007-11-30 17:46:49 +0100 | [diff] [blame] | 3881 | indicates after how long a server which has just come back up will run at |
Willy Tarreau | befdff1 | 2007-12-02 22:27:38 +0100 | [diff] [blame] | 3882 | full speed. Just as with every other time-based parameter, it can be entered |
| 3883 | in any other explicit unit among { us, ms, s, m, h, d }. The speed grows |
| 3884 | linearly from 0 to 100% during this time. The limitation applies to two |
| 3885 | parameters : |
Willy Tarreau | 5764b38 | 2007-11-30 17:46:49 +0100 | [diff] [blame] | 3886 | |
| 3887 | - maxconn: the number of connections accepted by the server will grow from 1 |
| 3888 | to 100% of the usual dynamic limit defined by (minconn,maxconn,fullconn). |
| 3889 | |
| 3890 | - weight: when the backend uses a dynamic weighted algorithm, the weight |
| 3891 | grows linearly from 1 to 100%. In this case, the weight is updated at every |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3892 | health-check. For this reason, it is important that the "inter" parameter |
| 3893 | is smaller than the "slowstart", in order to maximize the number of steps. |
Willy Tarreau | 5764b38 | 2007-11-30 17:46:49 +0100 | [diff] [blame] | 3894 | |
| 3895 | The slowstart never applies when haproxy starts, otherwise it would cause |
| 3896 | trouble to running servers. It only applies when a server has been previously |
| 3897 | seen as failed. |
| 3898 | |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3899 | source <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ] |
| 3900 | The "source" parameter sets the source address which will be used when |
| 3901 | connecting to the server. It follows the exact same parameters and principle |
| 3902 | as the backend "source" keyword, except that it only applies to the server |
| 3903 | referencing it. Please consult the "source" keyword for details. |
| 3904 | |
Krzysztof Piotr Oledzki | c8b16fc | 2008-02-18 01:26:35 +0100 | [diff] [blame] | 3905 | track [<proxy>/]<server> |
| 3906 | This option enables ability to set the current state of the server by |
| 3907 | tracking another one. Only a server with checks enabled can be tracked |
| 3908 | so it is not possible for example to track a server that tracks another |
| 3909 | one. If <proxy> is omitted the current one is used. If disable-on-404 is |
| 3910 | used, it has to be enabled on both proxies. |
| 3911 | |
Willy Tarreau | 198a744 | 2008-01-17 12:05:32 +0100 | [diff] [blame] | 3912 | weight <weight> |
| 3913 | The "weight" parameter is used to adjust the server's weight relative to |
| 3914 | other servers. All servers will receive a load proportional to their weight |
| 3915 | relative to the sum of all weights, so the higher the weight, the higher the |
| 3916 | load. The default weight is 1, and the maximal value is 255. If this |
| 3917 | parameter is used to distribute the load according to server's capacity, it |
| 3918 | is recommended to start with values which can both grow and shrink, for |
| 3919 | instance between 10 and 100 to leave enough room above and below for later |
| 3920 | adjustments. |
| 3921 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 3922 | |
| 3923 | 2.5) HTTP header manipulation |
| 3924 | ----------------------------- |
| 3925 | |
| 3926 | In HTTP mode, it is possible to rewrite, add or delete some of the request and |
| 3927 | response headers based on regular expressions. It is also possible to block a |
| 3928 | request or a response if a particular header matches a regular expression, |
| 3929 | which is enough to stop most elementary protocol attacks, and to protect |
| 3930 | against information leak from the internal network. But there is a limitation |
| 3931 | to this : since HAProxy's HTTP engine does not support keep-alive, only headers |
| 3932 | passed during the first request of a TCP session will be seen. All subsequent |
| 3933 | headers will be considered data only and not analyzed. Furthermore, HAProxy |
| 3934 | never touches data contents, it stops analysis at the end of headers. |
| 3935 | |
| 3936 | This section covers common usage of the following keywords, described in detail |
| 3937 | in section 2.2.1 : |
| 3938 | |
| 3939 | - reqadd <string> |
| 3940 | - reqallow <search> |
| 3941 | - reqiallow <search> |
| 3942 | - reqdel <search> |
| 3943 | - reqidel <search> |
| 3944 | - reqdeny <search> |
| 3945 | - reqideny <search> |
| 3946 | - reqpass <search> |
| 3947 | - reqipass <search> |
| 3948 | - reqrep <search> <replace> |
| 3949 | - reqirep <search> <replace> |
| 3950 | - reqtarpit <search> |
| 3951 | - reqitarpit <search> |
| 3952 | - rspadd <string> |
| 3953 | - rspdel <search> |
| 3954 | - rspidel <search> |
| 3955 | - rspdeny <search> |
| 3956 | - rspideny <search> |
| 3957 | - rsprep <search> <replace> |
| 3958 | - rspirep <search> <replace> |
| 3959 | |
| 3960 | With all these keywords, the same conventions are used. The <search> parameter |
| 3961 | is a POSIX extended regular expression (regex) which supports grouping through |
| 3962 | parenthesis (without the backslash). Spaces and other delimiters must be |
| 3963 | prefixed with a backslash ('\') to avoid confusion with a field delimiter. |
| 3964 | Other characters may be prefixed with a backslash to change their meaning : |
| 3965 | |
| 3966 | \t for a tab |
| 3967 | \r for a carriage return (CR) |
| 3968 | \n for a new line (LF) |
| 3969 | \ to mark a space and differentiate it from a delimiter |
| 3970 | \# to mark a sharp and differentiate it from a comment |
| 3971 | \\ to use a backslash in a regex |
| 3972 | \\\\ to use a backslash in the text (*2 for regex, *2 for haproxy) |
| 3973 | \xXX to write the ASCII hex code XX as in the C language |
| 3974 | |
| 3975 | The <replace> parameter contains the string to be used to replace the largest |
| 3976 | portion of text matching the regex. It can make use of the special characters |
| 3977 | above, and can reference a substring which is delimited by parenthesis in the |
| 3978 | regex, by writing a backslash ('\') immediately followed by one digit from 0 to |
Willy Tarreau | d2a4aa2 | 2008-01-31 15:28:22 +0100 | [diff] [blame] | 3979 | 9 indicating the group position (0 designating the entire line). This practice |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 3980 | is very common to users of the "sed" program. |
| 3981 | |
| 3982 | The <string> parameter represents the string which will systematically be added |
| 3983 | after the last header line. It can also use special character sequences above. |
| 3984 | |
| 3985 | Notes related to these keywords : |
| 3986 | --------------------------------- |
| 3987 | - these keywords are not always convenient to allow/deny based on header |
| 3988 | contents. It is strongly recommended to use ACLs with the "block" keyword |
| 3989 | instead, resulting in far more flexible and manageable rules. |
| 3990 | |
| 3991 | - lines are always considered as a whole. It is not possible to reference |
| 3992 | a header name only or a value only. This is important because of the way |
| 3993 | headers are written (notably the number of spaces after the colon). |
| 3994 | |
| 3995 | - the first line is always considered as a header, which makes it possible to |
| 3996 | rewrite or filter HTTP requests URIs or response codes, but in turn makes |
| 3997 | it harder to distinguish between headers and request line. The regex prefix |
| 3998 | ^[^\ \t]*[\ \t] matches any HTTP method followed by a space, and the prefix |
| 3999 | ^[^ \t:]*: matches any header name followed by a colon. |
| 4000 | |
| 4001 | - for performances reasons, the number of characters added to a request or to |
| 4002 | a response is limited at build time to values between 1 and 4 kB. This |
| 4003 | should normally be far more than enough for most usages. If it is too short |
| 4004 | on occasional usages, it is possible to gain some space by removing some |
| 4005 | useless headers before adding new ones. |
| 4006 | |
| 4007 | - keywords beginning with "reqi" and "rspi" are the same as their couterpart |
| 4008 | without the 'i' letter except that they ignore case when matching patterns. |
| 4009 | |
| 4010 | - when a request passes through a frontend then a backend, all req* rules |
| 4011 | from the frontend will be evaluated, then all req* rules from the backend |
| 4012 | will be evaluated. The reverse path is applied to responses. |
| 4013 | |
| 4014 | - req* statements are applied after "block" statements, so that "block" is |
| 4015 | always the first one, but before "use_backend" in order to permit rewriting |
| 4016 | before switching. |
| 4017 | |
Willy Tarreau | 5764b38 | 2007-11-30 17:46:49 +0100 | [diff] [blame] | 4018 | |
Willy Tarreau | ced2701 | 2008-01-17 20:35:34 +0100 | [diff] [blame] | 4019 | 2.6) Logging |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 4020 | ------------ |
| 4021 | |
| 4022 | [to do] |
| 4023 | |
Krzysztof Piotr Oledzki | f58a962 | 2008-02-23 01:19:10 +0100 | [diff] [blame] | 4024 | 2.7) CSV format |
| 4025 | |
| 4026 | 0. pxname: proxy name |
| 4027 | 1. svname: service name (FRONTEND for frontend, BACKEND for backend, any name |
| 4028 | for server) |
| 4029 | 2. qcur: current queued requests |
| 4030 | 3. qmax: max queued requests |
| 4031 | 4. scur: current sessions |
| 4032 | 5. smax: max sessions |
| 4033 | 6. slim: sessions limit |
| 4034 | 7. stot: total sessions |
| 4035 | 8. bin: bytes in |
| 4036 | 9. bout: bytes out |
| 4037 | 10. dreq: denied requests |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 4038 | 11. dresp: denied responses |
Krzysztof Piotr Oledzki | f58a962 | 2008-02-23 01:19:10 +0100 | [diff] [blame] | 4039 | 12. ereq: request errors |
| 4040 | 13. econ: connection errors |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 4041 | 14. eresp: response errors |
Krzysztof Piotr Oledzki | f58a962 | 2008-02-23 01:19:10 +0100 | [diff] [blame] | 4042 | 15. wretr: retries (warning) |
| 4043 | 16. wredis: redispatches (warning) |
| 4044 | 17. status: status (UP/DOWN/...) |
| 4045 | 18. weight: server weight (server), total weight (backend) |
| 4046 | 19. act: server is active (server), number of active servers (backend) |
| 4047 | 20. bck: server is backup (server), number of backup servers (backend) |
| 4048 | 21. chkfail: number of failed checks |
| 4049 | 22. chkdown: number of UP->DOWN transitions |
| 4050 | 23. lastchg: last status change (in seconds) |
| 4051 | 24. downtime: total downtime (in seconds) |
| 4052 | 25. qlimit: queue limit |
| 4053 | 26. pid: process id (0 for first instance, 1 for second, ...) |
| 4054 | 27. iid: unique proxy id |
| 4055 | 28. sid: service id (unique inside a proxy) |
| 4056 | 29. throttle: warm up status |
| 4057 | 30. lbtot: total number of times a server was selected |
| 4058 | 31. tracked: id of proxy/server if tracking is enabled |
| 4059 | 32. type (0=frontend, 1=backend, 2=server) |
Willy Tarreau | 844e3c5 | 2008-01-11 16:28:18 +0100 | [diff] [blame] | 4060 | |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 4061 | 2.8) Unix Socket commands |
| 4062 | |
| 4063 | - "show stat [<iid> <type> <sid>]": dump statistics in the cvs format. By |
| 4064 | passing id, type and sid it is possible to dump only selected items: |
| 4065 | - iid is a proxy id, -1 to dump everything |
| 4066 | - type selects type of dumpable objects: 1 for frontend, 2 for backend, 4 for |
| 4067 | server, -1 for everything. Values can be ORed, for example: |
| 4068 | 1+2=3 -> frontend+backend. |
| 4069 | 1+2+4=7 -> frontend+backend+server. |
| 4070 | - sid is a service id, -1 to dump everything from the selected proxy. |
| 4071 | |
| 4072 | - "show info": dump info about current haproxy status. |
| 4073 | |
Willy Tarreau | 0ba2750 | 2007-12-24 16:55:16 +0100 | [diff] [blame] | 4074 | /* |
| 4075 | * Local variables: |
| 4076 | * fill-column: 79 |
| 4077 | * End: |
| 4078 | */ |