Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | deb9ed8 | 2010-01-03 21:03:22 +0100 | [diff] [blame] | 2 | * include/common/defaults.h |
| 3 | * Miscellaneous default values. |
| 4 | * |
| 5 | * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 21 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 22 | #ifndef _COMMON_DEFAULTS_H |
| 23 | #define _COMMON_DEFAULTS_H |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 24 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 25 | /* |
| 26 | * BUFSIZE defines the size of a read and write buffer. It is the maximum |
| 27 | * amount of bytes which can be stored by the proxy for each session. However, |
| 28 | * when reading HTTP headers, the proxy needs some spare space to add or rewrite |
| 29 | * headers if needed. The size of this spare is defined with MAXREWRITE. So it |
| 30 | * is not possible to process headers longer than BUFSIZE-MAXREWRITE bytes. By |
| 31 | * default, BUFSIZE=16384 bytes and MAXREWRITE=BUFSIZE/2, so the maximum length |
| 32 | * of headers accepted is 8192 bytes, which is in line with Apache's limits. |
| 33 | */ |
| 34 | #ifndef BUFSIZE |
| 35 | #define BUFSIZE 16384 |
| 36 | #endif |
| 37 | |
| 38 | // reserved buffer space for header rewriting |
| 39 | #ifndef MAXREWRITE |
| 40 | #define MAXREWRITE (BUFSIZE / 2) |
| 41 | #endif |
| 42 | |
| 43 | #define REQURI_LEN 1024 |
| 44 | #define CAPTURE_LEN 64 |
| 45 | |
Krzysztof Piotr Oledzki | e6bbd74 | 2007-11-01 00:33:12 +0100 | [diff] [blame] | 46 | // maximum line size when parsing config |
| 47 | #ifndef LINESIZE |
| 48 | #define LINESIZE 2048 |
| 49 | #endif |
| 50 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 51 | // max # args on a configuration line |
Krzysztof Piotr Oledzki | e6bbd74 | 2007-11-01 00:33:12 +0100 | [diff] [blame] | 52 | #define MAX_LINE_ARGS 64 |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 53 | |
Willy Tarreau | 5ca791d | 2009-08-16 19:06:42 +0200 | [diff] [blame] | 54 | // max # args on a stats socket |
| 55 | #define MAX_STATS_ARGS 16 |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 56 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 57 | // max # of matches per regexp |
| 58 | #define MAX_MATCH 10 |
| 59 | |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 60 | // max # of headers in one HTTP request or response |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 61 | // By default, about 100 headers (+1 for the first line) |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 62 | #ifndef MAX_HTTP_HDR |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 63 | #define MAX_HTTP_HDR 101 |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 64 | #endif |
| 65 | |
Willy Tarreau | bce7088 | 2009-09-07 11:51:47 +0200 | [diff] [blame] | 66 | // max # of headers in history when looking for header #-X |
| 67 | #ifndef MAX_HDR_HISTORY |
| 68 | #define MAX_HDR_HISTORY 10 |
| 69 | #endif |
| 70 | |
Willy Tarreau | b8949f1 | 2007-03-23 22:39:59 +0100 | [diff] [blame] | 71 | // max # of loops we can perform around a read() which succeeds. |
| 72 | // It's very frequent that the system returns a few TCP segments at a time. |
| 73 | #ifndef MAX_READ_POLL_LOOPS |
| 74 | #define MAX_READ_POLL_LOOPS 4 |
| 75 | #endif |
| 76 | |
Willy Tarreau | 6f4a82c | 2009-03-21 20:43:57 +0100 | [diff] [blame] | 77 | // minimum number of bytes read at once above which we don't try to read |
| 78 | // more, in order not to risk facing an EAGAIN. Most often, if we read |
| 79 | // at least 10 kB, we can consider that the system has tried to read a |
| 80 | // full buffer and got multiple segments (>1 MSS for jumbo frames, >7 MSS |
| 81 | // for normal frames) did not bother truncating the last segment. |
| 82 | #ifndef MIN_RECV_AT_ONCE_ENOUGH |
| 83 | #define MIN_RECV_AT_ONCE_ENOUGH (7*1448) |
| 84 | #endif |
| 85 | |
Willy Tarreau | 8374918 | 2007-04-15 20:56:27 +0200 | [diff] [blame] | 86 | // same, but for writes. Generally, it's enough to write twice: one time for |
| 87 | // first half of the buffer, and a second time for the last half after a |
| 88 | // wrap-around. |
| 89 | #ifndef MAX_WRITE_POLL_LOOPS |
| 90 | #define MAX_WRITE_POLL_LOOPS 2 |
| 91 | #endif |
| 92 | |
Willy Tarreau | 9641e8f | 2007-03-23 23:02:09 +0100 | [diff] [blame] | 93 | // the number of bytes returned by a read below which we will not try to |
| 94 | // poll the socket again. Generally, return values below the MSS are worthless |
| 95 | // to try again. |
| 96 | #ifndef MIN_RET_FOR_READ_LOOP |
| 97 | #define MIN_RET_FOR_READ_LOOP 1460 |
| 98 | #endif |
| 99 | |
Willy Tarreau | 14acc70 | 2011-05-11 20:47:24 +0200 | [diff] [blame] | 100 | // The minimum number of bytes to be forwarded that is worth trying to splice. |
| 101 | // Below 4kB, it's not worth allocating pipes nor pretending to zero-copy. |
| 102 | #ifndef MIN_SPLICE_FORWARD |
| 103 | #define MIN_SPLICE_FORWARD 4096 |
| 104 | #endif |
| 105 | |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 106 | // the max number of events returned in one call to poll/epoll. Too small a |
| 107 | // value will cause lots of calls, and too high a value may cause high latency. |
| 108 | #ifndef MAX_POLL_EVENTS |
| 109 | #define MAX_POLL_EVENTS 200 |
| 110 | #endif |
| 111 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 112 | // cookie delimitor in "prefix" mode. This character is inserted between the |
| 113 | // persistence cookie and the original value. The '~' is allowed by RFC2965, |
| 114 | // and should not be too common in server names. |
| 115 | #ifndef COOKIE_DELIM |
| 116 | #define COOKIE_DELIM '~' |
| 117 | #endif |
| 118 | |
Willy Tarreau | bca9969 | 2010-10-06 19:25:55 +0200 | [diff] [blame] | 119 | // this delimitor is used between a server's name and a last visit date in |
| 120 | // cookies exchanged with the client. |
| 121 | #ifndef COOKIE_DELIM_DATE |
| 122 | #define COOKIE_DELIM_DATE '|' |
| 123 | #endif |
| 124 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 125 | #define CONN_RETRIES 3 |
| 126 | |
| 127 | #define CHK_CONNTIME 2000 |
| 128 | #define DEF_CHKINTR 2000 |
| 129 | #define DEF_FALLTIME 3 |
| 130 | #define DEF_RISETIME 2 |
Willy Tarreau | e9d8788 | 2010-01-27 11:28:42 +0100 | [diff] [blame] | 131 | #define DEF_CHECK_REQ "OPTIONS / HTTP/1.0\r\n" |
Willy Tarreau | 2367790 | 2007-05-08 23:50:35 +0200 | [diff] [blame] | 132 | #define DEF_SMTP_CHECK_REQ "HELO localhost\r\n" |
Gabor Lekeny | b4c81e4 | 2010-09-29 18:17:05 +0200 | [diff] [blame] | 133 | #define DEF_LDAP_CHECK_REQ "\x30\x0c\x02\x01\x01\x60\x07\x02\x01\x03\x04\x00\x80\x00" |
Hervé COMMOWICK | ec032d6 | 2011-08-05 16:23:48 +0200 | [diff] [blame] | 134 | #define DEF_REDIS_CHECK_REQ "*1\r\n$4\r\nPING\r\n" |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 135 | |
Krzysztof Piotr Oledzki | 97f07b8 | 2009-12-15 22:31:24 +0100 | [diff] [blame] | 136 | #define DEF_HANA_ONERR HANA_ONERR_FAILCHK |
| 137 | #define DEF_HANA_ERRLIMIT 10 |
| 138 | |
Ross West | af72a1d | 2008-08-03 10:51:45 +0200 | [diff] [blame] | 139 | // X-Forwarded-For header default |
| 140 | #define DEF_XFORWARDFOR_HDR "X-Forwarded-For" |
| 141 | |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 142 | // X-Original-To header default |
| 143 | #define DEF_XORIGINALTO_HDR "X-Original-To" |
| 144 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 145 | /* Default connections limit. |
| 146 | * |
| 147 | * A system limit can be enforced at build time in order to avoid using haproxy |
| 148 | * beyond reasonable system limits. For this, just define SYSTEM_MAXCONN to the |
| 149 | * absolute limit accepted by the system. If the configuration specifies a |
| 150 | * higher value, it will be capped to SYSTEM_MAXCONN and a warning will be |
| 151 | * emitted. The only way to override this limit will be to set it via the |
| 152 | * command-line '-n' argument. |
| 153 | */ |
| 154 | #ifndef SYSTEM_MAXCONN |
Willy Tarreau | c9fe456 | 2009-06-15 16:33:36 +0200 | [diff] [blame] | 155 | #ifndef DEFAULT_MAXCONN |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 156 | #define DEFAULT_MAXCONN 2000 |
Willy Tarreau | c9fe456 | 2009-06-15 16:33:36 +0200 | [diff] [blame] | 157 | #endif |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 158 | #else |
Willy Tarreau | c9fe456 | 2009-06-15 16:33:36 +0200 | [diff] [blame] | 159 | #undef DEFAULT_MAXCONN |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 160 | #define DEFAULT_MAXCONN SYSTEM_MAXCONN |
| 161 | #endif |
| 162 | |
Willy Tarreau | 2c43a1e | 2007-10-14 23:05:39 +0200 | [diff] [blame] | 163 | /* Minimum check interval for spread health checks. Servers with intervals |
| 164 | * greater than or equal to this value will have their checks spread apart |
| 165 | * and will be considered when searching the minimal interval. |
| 166 | * Others will be ignored for the minimal interval and will have their checks |
| 167 | * scheduled on a different basis. |
| 168 | */ |
| 169 | #ifndef SRV_CHK_INTER_THRES |
| 170 | #define SRV_CHK_INTER_THRES 1000 |
| 171 | #endif |
| 172 | |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 173 | /* Specifies the string used to report the version and release date on the |
| 174 | * statistics page. May be defined to the empty string ("") to permanently |
| 175 | * disable the feature. |
| 176 | */ |
| 177 | #ifndef STATS_VERSION_STRING |
| 178 | #define STATS_VERSION_STRING " version " HAPROXY_VERSION ", released " HAPROXY_DATE |
| 179 | #endif |
| 180 | |
Willy Tarreau | 8f38bd0 | 2009-05-10 08:53:33 +0200 | [diff] [blame] | 181 | /* Maximum signal queue size, and also number of different signals we can |
| 182 | * handle. |
| 183 | */ |
| 184 | #ifndef MAX_SIGNAL |
| 185 | #define MAX_SIGNAL 256 |
| 186 | #endif |
| 187 | |
Willy Tarreau | 3ad6a76 | 2009-08-16 10:08:02 +0200 | [diff] [blame] | 188 | /* Maximum host name length */ |
| 189 | #ifndef MAX_HOSTNAME_LEN |
| 190 | #define MAX_HOSTNAME_LEN 32 |
| 191 | #endif |
| 192 | |
Krzysztof Piotr Oledzki | f7089f5 | 2009-10-10 21:06:49 +0200 | [diff] [blame] | 193 | /* Maximum health check description length */ |
| 194 | #ifndef HCHK_DESC_LEN |
| 195 | #define HCHK_DESC_LEN 128 |
| 196 | #endif |
| 197 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 198 | #endif /* _COMMON_DEFAULTS_H */ |