blob: 43d287d76e092d9198c8b8e0d5377044b40cf225 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreaudeb9ed82010-01-03 21:03:22 +01002 * 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 Tarreaubaaee002006-06-26 02:48:02 +020021
Willy Tarreau2dd0d472006-06-29 17:53:05 +020022#ifndef _COMMON_DEFAULTS_H
23#define _COMMON_DEFAULTS_H
Willy Tarreaubaaee002006-06-26 02:48:02 +020024
Willy Tarreauff9c9142019-02-07 10:39:36 +010025/* MAX_PROCS defines the highest limit for the global "nbproc" value. It
26 * defaults to the number of bits in a long integer but may be lowered to save
27 * resources on embedded systems.
28 */
29#ifndef MAX_PROCS
30#define MAX_PROCS LONGBITS
31#endif
32
Willy Tarreaubaaee002006-06-26 02:48:02 +020033/*
34 * BUFSIZE defines the size of a read and write buffer. It is the maximum
Willy Tarreau87b09662015-04-03 00:22:06 +020035 * amount of bytes which can be stored by the proxy for each stream. However,
Willy Tarreaubaaee002006-06-26 02:48:02 +020036 * when reading HTTP headers, the proxy needs some spare space to add or rewrite
37 * headers if needed. The size of this spare is defined with MAXREWRITE. So it
38 * is not possible to process headers longer than BUFSIZE-MAXREWRITE bytes. By
Willy Tarreau27097842015-09-28 13:53:23 +020039 * default, BUFSIZE=16384 bytes and MAXREWRITE=min(1024,BUFSIZE/2), so the
40 * maximum length of headers accepted is 15360 bytes.
Willy Tarreaubaaee002006-06-26 02:48:02 +020041 */
42#ifndef BUFSIZE
43#define BUFSIZE 16384
44#endif
45
Willy Tarreaua24adf02014-11-27 01:11:56 +010046/* certain buffers may only be allocated for responses in order to avoid
47 * deadlocks caused by request queuing. 2 buffers is the absolute minimum
48 * acceptable to ensure that a request gaining access to a server can get
49 * a response buffer even if it doesn't completely flush the request buffer.
50 * The worst case is an applet making use of a request buffer that cannot
51 * completely be sent while the server starts to respond, and all unreserved
52 * buffers are allocated by request buffers from pending connections in the
53 * queue waiting for this one to flush. Both buffers reserved buffers may
54 * thus be used at the same time.
55 */
56#ifndef RESERVED_BUFS
57#define RESERVED_BUFS 2
58#endif
59
Willy Tarreaubaaee002006-06-26 02:48:02 +020060// reserved buffer space for header rewriting
61#ifndef MAXREWRITE
Willy Tarreau27097842015-09-28 13:53:23 +020062#define MAXREWRITE 1024
Willy Tarreaubaaee002006-06-26 02:48:02 +020063#endif
64
Willy Tarreaubf43f6e2013-06-03 15:52:52 +020065#ifndef REQURI_LEN
Willy Tarreaubaaee002006-06-26 02:48:02 +020066#define REQURI_LEN 1024
Willy Tarreaubf43f6e2013-06-03 15:52:52 +020067#endif
68
69#ifndef CAPTURE_LEN
Willy Tarreaubaaee002006-06-26 02:48:02 +020070#define CAPTURE_LEN 64
Willy Tarreaubf43f6e2013-06-03 15:52:52 +020071#endif
Willy Tarreaubaaee002006-06-26 02:48:02 +020072
Willy Tarreau4e957902014-06-27 18:08:49 +020073#ifndef MAX_SYSLOG_LEN
74#define MAX_SYSLOG_LEN 1024
75#endif
76
Krzysztof Piotr Oledzkie6bbd742007-11-01 00:33:12 +010077// maximum line size when parsing config
78#ifndef LINESIZE
79#define LINESIZE 2048
80#endif
81
Willy Tarreaubaaee002006-06-26 02:48:02 +020082// max # args on a configuration line
Krzysztof Piotr Oledzkie6bbd742007-11-01 00:33:12 +010083#define MAX_LINE_ARGS 64
Willy Tarreaubaaee002006-06-26 02:48:02 +020084
Emmanuel Hocdet98263292016-12-29 18:26:15 +010085// maximum line size when parsing crt-bind-list config
86#define CRT_LINESIZE 65536
87
88// max # args on crt-bind-list configuration line
89#define MAX_CRT_ARGS 2048
Emmanuel Hocdet5e0e6e42016-05-13 11:18:50 +020090
Willy Tarreau5ca791d2009-08-16 19:06:42 +020091// max # args on a stats socket
Willy Tarreau47060b62013-08-01 21:11:42 +020092// This should cover at least 5 + twice the # of data_types
93#define MAX_STATS_ARGS 64
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010094
Willy Tarreaubaaee002006-06-26 02:48:02 +020095// max # of matches per regexp
96#define MAX_MATCH 10
97
Willy Tarreaue5f20dc2006-12-03 15:21:35 +010098// max # of headers in one HTTP request or response
Willy Tarreauac1932d2011-10-24 19:14:41 +020099// By default, about 100 headers (+1 for the first line)
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100100#ifndef MAX_HTTP_HDR
Willy Tarreauac1932d2011-10-24 19:14:41 +0200101#define MAX_HTTP_HDR 101
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100102#endif
103
Willy Tarreaubce70882009-09-07 11:51:47 +0200104// max # of headers in history when looking for header #-X
105#ifndef MAX_HDR_HISTORY
106#define MAX_HDR_HISTORY 10
107#endif
108
Willy Tarreaub4c84932013-07-23 19:15:30 +0200109// max # of stick counters per session (at least 3 for sc0..sc2)
Willy Tarreaub4c84932013-07-23 19:15:30 +0200110#ifndef MAX_SESS_STKCTR
111#define MAX_SESS_STKCTR 3
112#endif
113
Ilya Shipitsin77e3b4a2020-03-10 12:06:11 +0500114// max # of extra stick-table data types that can be registered at runtime
Willy Tarreauedee1d62014-07-15 16:44:27 +0200115#ifndef STKTABLE_EXTRA_DATA_TYPES
116#define STKTABLE_EXTRA_DATA_TYPES 0
117#endif
118
Adis Nezirovic1a693fc2020-01-16 15:19:29 +0100119// max # of stick-table filter entries that can be used during dump
120#ifndef STKTABLE_FILTER_LEN
121#define STKTABLE_FILTER_LEN 4
122#endif
123
Willy Tarreaub8949f12007-03-23 22:39:59 +0100124// max # of loops we can perform around a read() which succeeds.
125// It's very frequent that the system returns a few TCP segments at a time.
126#ifndef MAX_READ_POLL_LOOPS
127#define MAX_READ_POLL_LOOPS 4
128#endif
129
Willy Tarreau6f4a82c2009-03-21 20:43:57 +0100130// minimum number of bytes read at once above which we don't try to read
131// more, in order not to risk facing an EAGAIN. Most often, if we read
132// at least 10 kB, we can consider that the system has tried to read a
133// full buffer and got multiple segments (>1 MSS for jumbo frames, >7 MSS
134// for normal frames) did not bother truncating the last segment.
135#ifndef MIN_RECV_AT_ONCE_ENOUGH
136#define MIN_RECV_AT_ONCE_ENOUGH (7*1448)
137#endif
138
Willy Tarreau14acc702011-05-11 20:47:24 +0200139// The minimum number of bytes to be forwarded that is worth trying to splice.
140// Below 4kB, it's not worth allocating pipes nor pretending to zero-copy.
141#ifndef MIN_SPLICE_FORWARD
142#define MIN_SPLICE_FORWARD 4096
143#endif
144
Willy Tarreau1db37712007-06-03 17:16:49 +0200145// the max number of events returned in one call to poll/epoll. Too small a
146// value will cause lots of calls, and too high a value may cause high latency.
147#ifndef MAX_POLL_EVENTS
148#define MAX_POLL_EVENTS 200
149#endif
150
Olivier Houchard1599b802018-05-24 18:59:04 +0200151// the max number of tasks to run at once
152#ifndef RUNQUEUE_DEPTH
153#define RUNQUEUE_DEPTH 200
154#endif
155
Ilya Shipitsin77e3b4a2020-03-10 12:06:11 +0500156// cookie delimiter in "prefix" mode. This character is inserted between the
Lukas Tribus23953682017-04-28 13:24:30 +0000157// persistence cookie and the original value. The '~' is allowed by RFC6265,
Willy Tarreaubaaee002006-06-26 02:48:02 +0200158// and should not be too common in server names.
159#ifndef COOKIE_DELIM
160#define COOKIE_DELIM '~'
161#endif
162
Ilya Shipitsin77e3b4a2020-03-10 12:06:11 +0500163// this delimiter is used between a server's name and a last visit date in
Willy Tarreaubca99692010-10-06 19:25:55 +0200164// cookies exchanged with the client.
165#ifndef COOKIE_DELIM_DATE
166#define COOKIE_DELIM_DATE '|'
167#endif
168
Willy Tarreaubaaee002006-06-26 02:48:02 +0200169#define CONN_RETRIES 3
170
171#define CHK_CONNTIME 2000
172#define DEF_CHKINTR 2000
Pieter Baauw46af1702016-02-12 14:35:20 +0100173#define DEF_MAILALERTTIME 10000
Willy Tarreaubaaee002006-06-26 02:48:02 +0200174#define DEF_FALLTIME 3
175#define DEF_RISETIME 2
Simon Horman58c32972013-11-25 10:46:38 +0900176#define DEF_AGENT_FALLTIME 1
177#define DEF_AGENT_RISETIME 1
Willy Tarreaue9d87882010-01-27 11:28:42 +0100178#define DEF_CHECK_REQ "OPTIONS / HTTP/1.0\r\n"
Simon Horman98637e52014-06-20 12:30:16 +0900179#define DEF_CHECK_PATH ""
Willy Tarreau23677902007-05-08 23:50:35 +0200180#define DEF_SMTP_CHECK_REQ "HELO localhost\r\n"
Gabor Lekenyb4c81e42010-09-29 18:17:05 +0200181#define DEF_LDAP_CHECK_REQ "\x30\x0c\x02\x01\x01\x60\x07\x02\x01\x03\x04\x00\x80\x00"
Hervé COMMOWICKec032d62011-08-05 16:23:48 +0200182#define DEF_REDIS_CHECK_REQ "*1\r\n$4\r\nPING\r\n"
Willy Tarreaubaaee002006-06-26 02:48:02 +0200183
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +0100184#define DEF_HANA_ONERR HANA_ONERR_FAILCHK
185#define DEF_HANA_ERRLIMIT 10
186
Ross Westaf72a1d2008-08-03 10:51:45 +0200187// X-Forwarded-For header default
188#define DEF_XFORWARDFOR_HDR "X-Forwarded-For"
189
Maik Broemme2850cb42009-04-17 18:53:21 +0200190// X-Original-To header default
191#define DEF_XORIGINALTO_HDR "X-Original-To"
192
Willy Tarreaubaaee002006-06-26 02:48:02 +0200193/* Default connections limit.
194 *
195 * A system limit can be enforced at build time in order to avoid using haproxy
196 * beyond reasonable system limits. For this, just define SYSTEM_MAXCONN to the
197 * absolute limit accepted by the system. If the configuration specifies a
198 * higher value, it will be capped to SYSTEM_MAXCONN and a warning will be
199 * emitted. The only way to override this limit will be to set it via the
Willy Tarreaudf23c0c2019-03-13 10:10:49 +0100200 * command-line '-n' argument. If SYSTEM_MAXCONN is not set, a minimum value
201 * of 100 will be used for DEFAULT_MAXCONN which almost guarantees that a
202 * process will correctly start in any situation.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200203 */
Willy Tarreauca783d42019-03-13 10:03:07 +0100204#ifdef SYSTEM_MAXCONN
Willy Tarreauc9fe4562009-06-15 16:33:36 +0200205#undef DEFAULT_MAXCONN
Willy Tarreaubaaee002006-06-26 02:48:02 +0200206#define DEFAULT_MAXCONN SYSTEM_MAXCONN
Willy Tarreaudf23c0c2019-03-13 10:10:49 +0100207#elif !defined(DEFAULT_MAXCONN)
208#define DEFAULT_MAXCONN 100
Willy Tarreaubaaee002006-06-26 02:48:02 +0200209#endif
210
Willy Tarreau2c43a1e2007-10-14 23:05:39 +0200211/* Minimum check interval for spread health checks. Servers with intervals
212 * greater than or equal to this value will have their checks spread apart
213 * and will be considered when searching the minimal interval.
214 * Others will be ignored for the minimal interval and will have their checks
215 * scheduled on a different basis.
216 */
217#ifndef SRV_CHK_INTER_THRES
218#define SRV_CHK_INTER_THRES 1000
219#endif
220
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +0200221/* Specifies the string used to report the version and release date on the
222 * statistics page. May be defined to the empty string ("") to permanently
223 * disable the feature.
224 */
225#ifndef STATS_VERSION_STRING
226#define STATS_VERSION_STRING " version " HAPROXY_VERSION ", released " HAPROXY_DATE
227#endif
228
Willy Tarreau8f38bd02009-05-10 08:53:33 +0200229/* Maximum signal queue size, and also number of different signals we can
230 * handle.
231 */
232#ifndef MAX_SIGNAL
233#define MAX_SIGNAL 256
234#endif
235
Willy Tarreau3ad6a762009-08-16 10:08:02 +0200236/* Maximum host name length */
237#ifndef MAX_HOSTNAME_LEN
Willy Tarreau75abcb32015-01-14 11:48:58 +0100238#if MAXHOSTNAMELEN
239#define MAX_HOSTNAME_LEN MAXHOSTNAMELEN
240#else
241#define MAX_HOSTNAME_LEN 64
242#endif // MAXHOSTNAMELEN
243#endif // MAX_HOSTNAME_LEN
Willy Tarreau3ad6a762009-08-16 10:08:02 +0200244
Krzysztof Piotr Oledzkif7089f52009-10-10 21:06:49 +0200245/* Maximum health check description length */
246#ifndef HCHK_DESC_LEN
247#define HCHK_DESC_LEN 128
248#endif
249
Emeric Brun76d88952012-10-05 15:47:31 +0200250/* ciphers used as defaults on connect */
251#ifndef CONNECT_DEFAULT_CIPHERS
252#define CONNECT_DEFAULT_CIPHERS NULL
253#endif
254
Dirkjan Bussink415150f2018-09-14 11:14:21 +0200255/* ciphers used as defaults on TLS 1.3 connect */
256#ifndef CONNECT_DEFAULT_CIPHERSUITES
257#define CONNECT_DEFAULT_CIPHERSUITES NULL
258#endif
259
Emeric Brun76d88952012-10-05 15:47:31 +0200260/* ciphers used as defaults on listeners */
261#ifndef LISTEN_DEFAULT_CIPHERS
262#define LISTEN_DEFAULT_CIPHERS NULL
263#endif
264
Dirkjan Bussink415150f2018-09-14 11:14:21 +0200265/* cipher suites used as defaults on TLS 1.3 listeners */
266#ifndef LISTEN_DEFAULT_CIPHERSUITES
267#define LISTEN_DEFAULT_CIPHERSUITES NULL
268#endif
269
Emeric Brun6924ef82013-03-06 14:08:53 +0100270/* named curve used as defaults for ECDHE ciphers */
271#ifndef ECDHE_DEFAULT_CURVE
272#define ECDHE_DEFAULT_CURVE "prime256v1"
273#endif
274
Emeric Brun46635772012-11-14 11:32:56 +0100275/* ssl cache size */
276#ifndef SSLCACHESIZE
277#define SSLCACHESIZE 20000
278#endif
279
Remi Gacognef46cd6e2014-06-12 14:58:40 +0200280/* ssl max dh param size */
281#ifndef SSL_DEFAULT_DH_PARAM
282#define SSL_DEFAULT_DH_PARAM 0
283#endif
284
Willy Tarreaud92aa5c2015-01-15 21:34:39 +0100285/* max memory cost per SSL session */
286#ifndef SSL_SESSION_MAX_COST
287#define SSL_SESSION_MAX_COST (16*1024) // measured
288#endif
289
290/* max memory cost per SSL handshake (on top of session) */
291#ifndef SSL_HANDSHAKE_MAX_COST
292#define SSL_HANDSHAKE_MAX_COST (76*1024) // measured
293#endif
Willy Tarreaud0256482015-01-15 21:45:22 +0100294
Christopher Faulet31af49d2015-06-09 17:29:50 +0200295#ifndef DEFAULT_SSL_CTX_CACHE
296#define DEFAULT_SSL_CTX_CACHE 1000
297#endif
298
Willy Tarreau87b09662015-04-03 00:22:06 +0200299/* approximate stream size (for maxconn estimate) */
300#ifndef STREAM_MAX_COST
301#define STREAM_MAX_COST (sizeof(struct stream) + \
Willy Tarreaud0256482015-01-15 21:45:22 +0100302 2 * sizeof(struct channel) + \
303 2 * sizeof(struct connection) + \
Stéphane Cottin23e9e932017-05-18 08:58:41 +0200304 global.tune.requri_len + \
Willy Tarreaud0256482015-01-15 21:45:22 +0100305 2 * global.tune.cookie_len)
306#endif
307
308/* available memory estimate : count about 3% of overhead in various structures */
309#ifndef MEM_USABLE_RATIO
310#define MEM_USABLE_RATIO 0.97
Willy Tarreaud92aa5c2015-01-15 21:34:39 +0100311#endif
312
Willy Tarreau4bfc5802014-06-17 12:19:18 +0200313/* Number of samples used to compute the times reported in stats. A power of
314 * two is highly recommended, and this value multiplied by the largest response
315 * time must not overflow and unsigned int. See freq_ctr.h for more information.
316 * We consider that values are accurate to 95% with two batches of samples below,
317 * so in order to advertise accurate times across 1k samples, we effectively
318 * measure over 512.
319 */
320#ifndef TIME_STATS_SAMPLES
321#define TIME_STATS_SAMPLES 512
322#endif
323
Emeric Brun4147b2e2014-06-16 18:36:30 +0200324/* max ocsp cert id asn1 encoded length */
325#ifndef OCSP_MAX_CERTID_ASN1_LENGTH
326#define OCSP_MAX_CERTID_ASN1_LENGTH 128
327#endif
328
Emeric Brunc8b27b62014-06-19 14:16:17 +0200329#ifndef OCSP_MAX_RESPONSE_TIME_SKEW
330#define OCSP_MAX_RESPONSE_TIME_SKEW 300
331#endif
Nenad Merdanovic05552d42015-02-27 19:56:49 +0100332
333/* Number of TLS tickets to check, used for rotation */
334#ifndef TLS_TICKETS_NO
335#define TLS_TICKETS_NO 3
336#endif
Willy Tarreauf3045d22015-04-29 16:24:50 +0200337
338/* pattern lookup default cache size, in number of entries :
339 * 10k entries at 10k req/s mean 1% risk of a collision after 60 years, that's
340 * already much less than the memory's reliability in most machines and more
341 * durable than most admin's life expectancy. A collision will result in a
342 * valid result to be returned for a different entry from the same list.
343 */
344#ifndef DEFAULT_PAT_LRU_SIZE
345#define DEFAULT_PAT_LRU_SIZE 10000
346#endif
347
Willy Tarreau2dd0d472006-06-29 17:53:05 +0200348#endif /* _COMMON_DEFAULTS_H */