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 | |
Willy Tarreau | a24adf0 | 2014-11-27 01:11:56 +0100 | [diff] [blame] | 38 | /* certain buffers may only be allocated for responses in order to avoid |
| 39 | * deadlocks caused by request queuing. 2 buffers is the absolute minimum |
| 40 | * acceptable to ensure that a request gaining access to a server can get |
| 41 | * a response buffer even if it doesn't completely flush the request buffer. |
| 42 | * The worst case is an applet making use of a request buffer that cannot |
| 43 | * completely be sent while the server starts to respond, and all unreserved |
| 44 | * buffers are allocated by request buffers from pending connections in the |
| 45 | * queue waiting for this one to flush. Both buffers reserved buffers may |
| 46 | * thus be used at the same time. |
| 47 | */ |
| 48 | #ifndef RESERVED_BUFS |
| 49 | #define RESERVED_BUFS 2 |
| 50 | #endif |
| 51 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 52 | // reserved buffer space for header rewriting |
| 53 | #ifndef MAXREWRITE |
| 54 | #define MAXREWRITE (BUFSIZE / 2) |
| 55 | #endif |
| 56 | |
Willy Tarreau | bf43f6e | 2013-06-03 15:52:52 +0200 | [diff] [blame] | 57 | #ifndef REQURI_LEN |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 58 | #define REQURI_LEN 1024 |
Willy Tarreau | bf43f6e | 2013-06-03 15:52:52 +0200 | [diff] [blame] | 59 | #endif |
| 60 | |
| 61 | #ifndef CAPTURE_LEN |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 62 | #define CAPTURE_LEN 64 |
Willy Tarreau | bf43f6e | 2013-06-03 15:52:52 +0200 | [diff] [blame] | 63 | #endif |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 64 | |
Willy Tarreau | 4e95790 | 2014-06-27 18:08:49 +0200 | [diff] [blame] | 65 | #ifndef MAX_SYSLOG_LEN |
| 66 | #define MAX_SYSLOG_LEN 1024 |
| 67 | #endif |
| 68 | |
Krzysztof Piotr Oledzki | e6bbd74 | 2007-11-01 00:33:12 +0100 | [diff] [blame] | 69 | // maximum line size when parsing config |
| 70 | #ifndef LINESIZE |
| 71 | #define LINESIZE 2048 |
| 72 | #endif |
| 73 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 74 | // max # args on a configuration line |
Krzysztof Piotr Oledzki | e6bbd74 | 2007-11-01 00:33:12 +0100 | [diff] [blame] | 75 | #define MAX_LINE_ARGS 64 |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 76 | |
Willy Tarreau | 5ca791d | 2009-08-16 19:06:42 +0200 | [diff] [blame] | 77 | // max # args on a stats socket |
Willy Tarreau | 47060b6 | 2013-08-01 21:11:42 +0200 | [diff] [blame] | 78 | // This should cover at least 5 + twice the # of data_types |
| 79 | #define MAX_STATS_ARGS 64 |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 80 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 81 | // max # of matches per regexp |
| 82 | #define MAX_MATCH 10 |
| 83 | |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 84 | // max # of headers in one HTTP request or response |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 85 | // By default, about 100 headers (+1 for the first line) |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 86 | #ifndef MAX_HTTP_HDR |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 87 | #define MAX_HTTP_HDR 101 |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 88 | #endif |
| 89 | |
Willy Tarreau | bce7088 | 2009-09-07 11:51:47 +0200 | [diff] [blame] | 90 | // max # of headers in history when looking for header #-X |
| 91 | #ifndef MAX_HDR_HISTORY |
| 92 | #define MAX_HDR_HISTORY 10 |
| 93 | #endif |
| 94 | |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 95 | // max # of stick counters per session (at least 3 for sc0..sc2) |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 96 | #ifndef MAX_SESS_STKCTR |
| 97 | #define MAX_SESS_STKCTR 3 |
| 98 | #endif |
| 99 | |
Willy Tarreau | edee1d6 | 2014-07-15 16:44:27 +0200 | [diff] [blame] | 100 | // max # of extra stick-table data types that can be registred at runtime |
| 101 | #ifndef STKTABLE_EXTRA_DATA_TYPES |
| 102 | #define STKTABLE_EXTRA_DATA_TYPES 0 |
| 103 | #endif |
| 104 | |
Willy Tarreau | b8949f1 | 2007-03-23 22:39:59 +0100 | [diff] [blame] | 105 | // max # of loops we can perform around a read() which succeeds. |
| 106 | // It's very frequent that the system returns a few TCP segments at a time. |
| 107 | #ifndef MAX_READ_POLL_LOOPS |
| 108 | #define MAX_READ_POLL_LOOPS 4 |
| 109 | #endif |
| 110 | |
Willy Tarreau | 6f4a82c | 2009-03-21 20:43:57 +0100 | [diff] [blame] | 111 | // minimum number of bytes read at once above which we don't try to read |
| 112 | // more, in order not to risk facing an EAGAIN. Most often, if we read |
| 113 | // at least 10 kB, we can consider that the system has tried to read a |
| 114 | // full buffer and got multiple segments (>1 MSS for jumbo frames, >7 MSS |
| 115 | // for normal frames) did not bother truncating the last segment. |
| 116 | #ifndef MIN_RECV_AT_ONCE_ENOUGH |
| 117 | #define MIN_RECV_AT_ONCE_ENOUGH (7*1448) |
| 118 | #endif |
| 119 | |
Willy Tarreau | 14acc70 | 2011-05-11 20:47:24 +0200 | [diff] [blame] | 120 | // The minimum number of bytes to be forwarded that is worth trying to splice. |
| 121 | // Below 4kB, it's not worth allocating pipes nor pretending to zero-copy. |
| 122 | #ifndef MIN_SPLICE_FORWARD |
| 123 | #define MIN_SPLICE_FORWARD 4096 |
| 124 | #endif |
| 125 | |
Willy Tarreau | 1db3771 | 2007-06-03 17:16:49 +0200 | [diff] [blame] | 126 | // the max number of events returned in one call to poll/epoll. Too small a |
| 127 | // value will cause lots of calls, and too high a value may cause high latency. |
| 128 | #ifndef MAX_POLL_EVENTS |
| 129 | #define MAX_POLL_EVENTS 200 |
| 130 | #endif |
| 131 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 132 | // cookie delimitor in "prefix" mode. This character is inserted between the |
| 133 | // persistence cookie and the original value. The '~' is allowed by RFC2965, |
| 134 | // and should not be too common in server names. |
| 135 | #ifndef COOKIE_DELIM |
| 136 | #define COOKIE_DELIM '~' |
| 137 | #endif |
| 138 | |
Willy Tarreau | bca9969 | 2010-10-06 19:25:55 +0200 | [diff] [blame] | 139 | // this delimitor is used between a server's name and a last visit date in |
| 140 | // cookies exchanged with the client. |
| 141 | #ifndef COOKIE_DELIM_DATE |
| 142 | #define COOKIE_DELIM_DATE '|' |
| 143 | #endif |
| 144 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 145 | #define CONN_RETRIES 3 |
| 146 | |
| 147 | #define CHK_CONNTIME 2000 |
| 148 | #define DEF_CHKINTR 2000 |
| 149 | #define DEF_FALLTIME 3 |
| 150 | #define DEF_RISETIME 2 |
Simon Horman | 58c3297 | 2013-11-25 10:46:38 +0900 | [diff] [blame] | 151 | #define DEF_AGENT_FALLTIME 1 |
| 152 | #define DEF_AGENT_RISETIME 1 |
Willy Tarreau | e9d8788 | 2010-01-27 11:28:42 +0100 | [diff] [blame] | 153 | #define DEF_CHECK_REQ "OPTIONS / HTTP/1.0\r\n" |
Simon Horman | 98637e5 | 2014-06-20 12:30:16 +0900 | [diff] [blame] | 154 | #define DEF_CHECK_PATH "" |
Willy Tarreau | 2367790 | 2007-05-08 23:50:35 +0200 | [diff] [blame] | 155 | #define DEF_SMTP_CHECK_REQ "HELO localhost\r\n" |
Gabor Lekeny | b4c81e4 | 2010-09-29 18:17:05 +0200 | [diff] [blame] | 156 | #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] | 157 | #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] | 158 | |
Krzysztof Piotr Oledzki | 97f07b8 | 2009-12-15 22:31:24 +0100 | [diff] [blame] | 159 | #define DEF_HANA_ONERR HANA_ONERR_FAILCHK |
| 160 | #define DEF_HANA_ERRLIMIT 10 |
| 161 | |
Ross West | af72a1d | 2008-08-03 10:51:45 +0200 | [diff] [blame] | 162 | // X-Forwarded-For header default |
| 163 | #define DEF_XFORWARDFOR_HDR "X-Forwarded-For" |
| 164 | |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 165 | // X-Original-To header default |
| 166 | #define DEF_XORIGINALTO_HDR "X-Original-To" |
| 167 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 168 | /* Default connections limit. |
| 169 | * |
| 170 | * A system limit can be enforced at build time in order to avoid using haproxy |
| 171 | * beyond reasonable system limits. For this, just define SYSTEM_MAXCONN to the |
| 172 | * absolute limit accepted by the system. If the configuration specifies a |
| 173 | * higher value, it will be capped to SYSTEM_MAXCONN and a warning will be |
| 174 | * emitted. The only way to override this limit will be to set it via the |
| 175 | * command-line '-n' argument. |
| 176 | */ |
| 177 | #ifndef SYSTEM_MAXCONN |
Willy Tarreau | c9fe456 | 2009-06-15 16:33:36 +0200 | [diff] [blame] | 178 | #ifndef DEFAULT_MAXCONN |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 179 | #define DEFAULT_MAXCONN 2000 |
Willy Tarreau | c9fe456 | 2009-06-15 16:33:36 +0200 | [diff] [blame] | 180 | #endif |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 181 | #else |
Willy Tarreau | c9fe456 | 2009-06-15 16:33:36 +0200 | [diff] [blame] | 182 | #undef DEFAULT_MAXCONN |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 183 | #define DEFAULT_MAXCONN SYSTEM_MAXCONN |
| 184 | #endif |
| 185 | |
Willy Tarreau | 2c43a1e | 2007-10-14 23:05:39 +0200 | [diff] [blame] | 186 | /* Minimum check interval for spread health checks. Servers with intervals |
| 187 | * greater than or equal to this value will have their checks spread apart |
| 188 | * and will be considered when searching the minimal interval. |
| 189 | * Others will be ignored for the minimal interval and will have their checks |
| 190 | * scheduled on a different basis. |
| 191 | */ |
| 192 | #ifndef SRV_CHK_INTER_THRES |
| 193 | #define SRV_CHK_INTER_THRES 1000 |
| 194 | #endif |
| 195 | |
Krzysztof Oledzki | d9db927 | 2007-10-15 10:05:11 +0200 | [diff] [blame] | 196 | /* Specifies the string used to report the version and release date on the |
| 197 | * statistics page. May be defined to the empty string ("") to permanently |
| 198 | * disable the feature. |
| 199 | */ |
| 200 | #ifndef STATS_VERSION_STRING |
| 201 | #define STATS_VERSION_STRING " version " HAPROXY_VERSION ", released " HAPROXY_DATE |
| 202 | #endif |
| 203 | |
Willy Tarreau | 8f38bd0 | 2009-05-10 08:53:33 +0200 | [diff] [blame] | 204 | /* Maximum signal queue size, and also number of different signals we can |
| 205 | * handle. |
| 206 | */ |
| 207 | #ifndef MAX_SIGNAL |
| 208 | #define MAX_SIGNAL 256 |
| 209 | #endif |
| 210 | |
Willy Tarreau | 3ad6a76 | 2009-08-16 10:08:02 +0200 | [diff] [blame] | 211 | /* Maximum host name length */ |
| 212 | #ifndef MAX_HOSTNAME_LEN |
Willy Tarreau | 75abcb3 | 2015-01-14 11:48:58 +0100 | [diff] [blame] | 213 | #if MAXHOSTNAMELEN |
| 214 | #define MAX_HOSTNAME_LEN MAXHOSTNAMELEN |
| 215 | #else |
| 216 | #define MAX_HOSTNAME_LEN 64 |
| 217 | #endif // MAXHOSTNAMELEN |
| 218 | #endif // MAX_HOSTNAME_LEN |
Willy Tarreau | 3ad6a76 | 2009-08-16 10:08:02 +0200 | [diff] [blame] | 219 | |
Krzysztof Piotr Oledzki | f7089f5 | 2009-10-10 21:06:49 +0200 | [diff] [blame] | 220 | /* Maximum health check description length */ |
| 221 | #ifndef HCHK_DESC_LEN |
| 222 | #define HCHK_DESC_LEN 128 |
| 223 | #endif |
| 224 | |
Emeric Brun | 76d8895 | 2012-10-05 15:47:31 +0200 | [diff] [blame] | 225 | /* ciphers used as defaults on connect */ |
| 226 | #ifndef CONNECT_DEFAULT_CIPHERS |
| 227 | #define CONNECT_DEFAULT_CIPHERS NULL |
| 228 | #endif |
| 229 | |
| 230 | /* ciphers used as defaults on listeners */ |
| 231 | #ifndef LISTEN_DEFAULT_CIPHERS |
| 232 | #define LISTEN_DEFAULT_CIPHERS NULL |
| 233 | #endif |
| 234 | |
Emeric Brun | 6924ef8 | 2013-03-06 14:08:53 +0100 | [diff] [blame] | 235 | /* named curve used as defaults for ECDHE ciphers */ |
| 236 | #ifndef ECDHE_DEFAULT_CURVE |
| 237 | #define ECDHE_DEFAULT_CURVE "prime256v1" |
| 238 | #endif |
| 239 | |
Emeric Brun | 4663577 | 2012-11-14 11:32:56 +0100 | [diff] [blame] | 240 | /* ssl cache size */ |
| 241 | #ifndef SSLCACHESIZE |
| 242 | #define SSLCACHESIZE 20000 |
| 243 | #endif |
| 244 | |
Remi Gacogne | f46cd6e | 2014-06-12 14:58:40 +0200 | [diff] [blame] | 245 | /* ssl max dh param size */ |
| 246 | #ifndef SSL_DEFAULT_DH_PARAM |
| 247 | #define SSL_DEFAULT_DH_PARAM 0 |
| 248 | #endif |
| 249 | |
Willy Tarreau | d92aa5c | 2015-01-15 21:34:39 +0100 | [diff] [blame] | 250 | /* max memory cost per SSL session */ |
| 251 | #ifndef SSL_SESSION_MAX_COST |
| 252 | #define SSL_SESSION_MAX_COST (16*1024) // measured |
| 253 | #endif |
| 254 | |
| 255 | /* max memory cost per SSL handshake (on top of session) */ |
| 256 | #ifndef SSL_HANDSHAKE_MAX_COST |
| 257 | #define SSL_HANDSHAKE_MAX_COST (76*1024) // measured |
| 258 | #endif |
Willy Tarreau | d025648 | 2015-01-15 21:45:22 +0100 | [diff] [blame] | 259 | |
| 260 | /* approximate session size (for maxconn estimate) */ |
| 261 | #ifndef SESSION_MAX_COST |
| 262 | #define SESSION_MAX_COST (sizeof(struct session) + \ |
| 263 | 2 * sizeof(struct channel) + \ |
| 264 | 2 * sizeof(struct connection) + \ |
| 265 | REQURI_LEN + \ |
| 266 | 2 * global.tune.cookie_len) |
| 267 | #endif |
| 268 | |
| 269 | /* available memory estimate : count about 3% of overhead in various structures */ |
| 270 | #ifndef MEM_USABLE_RATIO |
| 271 | #define MEM_USABLE_RATIO 0.97 |
Willy Tarreau | d92aa5c | 2015-01-15 21:34:39 +0100 | [diff] [blame] | 272 | #endif |
| 273 | |
Willy Tarreau | 4bfc580 | 2014-06-17 12:19:18 +0200 | [diff] [blame] | 274 | /* Number of samples used to compute the times reported in stats. A power of |
| 275 | * two is highly recommended, and this value multiplied by the largest response |
| 276 | * time must not overflow and unsigned int. See freq_ctr.h for more information. |
| 277 | * We consider that values are accurate to 95% with two batches of samples below, |
| 278 | * so in order to advertise accurate times across 1k samples, we effectively |
| 279 | * measure over 512. |
| 280 | */ |
| 281 | #ifndef TIME_STATS_SAMPLES |
| 282 | #define TIME_STATS_SAMPLES 512 |
| 283 | #endif |
| 284 | |
Emeric Brun | 4147b2e | 2014-06-16 18:36:30 +0200 | [diff] [blame] | 285 | /* max ocsp cert id asn1 encoded length */ |
| 286 | #ifndef OCSP_MAX_CERTID_ASN1_LENGTH |
| 287 | #define OCSP_MAX_CERTID_ASN1_LENGTH 128 |
| 288 | #endif |
| 289 | |
Emeric Brun | c8b27b6 | 2014-06-19 14:16:17 +0200 | [diff] [blame] | 290 | #ifndef OCSP_MAX_RESPONSE_TIME_SKEW |
| 291 | #define OCSP_MAX_RESPONSE_TIME_SKEW 300 |
| 292 | #endif |
Nenad Merdanovic | 05552d4 | 2015-02-27 19:56:49 +0100 | [diff] [blame] | 293 | |
| 294 | /* Number of TLS tickets to check, used for rotation */ |
| 295 | #ifndef TLS_TICKETS_NO |
| 296 | #define TLS_TICKETS_NO 3 |
| 297 | #endif |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 298 | #endif /* _COMMON_DEFAULTS_H */ |