blob: 966ef4fbd9aece606f0bbf8ed239ce5166dc14b4 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau2dd0d472006-06-29 17:53:05 +02002 include/common/defaults.h
Willy Tarreaubaaee002006-06-26 02:48:02 +02003 Miscellaneous default values.
4
Willy Tarreau6b66f3e2008-12-14 17:31:54 +01005 Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
6
Willy Tarreaubaaee002006-06-26 02:48:02 +02007 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*/
21
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 Tarreaubaaee002006-06-26 02:48:02 +020025/*
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
Willy Tarreau6b66f3e2008-12-14 17:31:54 +010043/* FORWARD_DEFAULT_SIZE
44 * Indicates how many bytes may be forwarded at once in low-level stream-socks
45 * without waking the owner task up. This should be much larger than the buffer
46 * size. A few megabytes seem appropriate.
47 */
48#ifndef FORWARD_DEFAULT_SIZE
49#define FORWARD_DEFAULT_SIZE (16*1024*1024)
50#endif
51
52
Willy Tarreaubaaee002006-06-26 02:48:02 +020053#define REQURI_LEN 1024
54#define CAPTURE_LEN 64
55
Krzysztof Piotr Oledzkie6bbd742007-11-01 00:33:12 +010056// maximum line size when parsing config
57#ifndef LINESIZE
58#define LINESIZE 2048
59#endif
60
Willy Tarreau5d01a632009-06-22 16:02:30 +020061// max # of configuration files
62#define MAX_CFG_FILES 10
63
Willy Tarreaubaaee002006-06-26 02:48:02 +020064// max # args on a configuration line
Krzysztof Piotr Oledzkie6bbd742007-11-01 00:33:12 +010065#define MAX_LINE_ARGS 64
Willy Tarreaubaaee002006-06-26 02:48:02 +020066
Willy Tarreau5ca791d2009-08-16 19:06:42 +020067// max # args on a stats socket
68#define MAX_STATS_ARGS 16
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010069
Willy Tarreaubaaee002006-06-26 02:48:02 +020070// max # of added headers per request
71#define MAX_NEWHDR 10
72
73// max # of matches per regexp
74#define MAX_MATCH 10
75
Willy Tarreaue5f20dc2006-12-03 15:21:35 +010076// max # of headers in one HTTP request or response
77// By default, about 100 headers per 8 kB.
78#ifndef MAX_HTTP_HDR
79#define MAX_HTTP_HDR ((BUFSIZE+79)/80)
80#endif
81
Willy Tarreaub8949f12007-03-23 22:39:59 +010082// max # of loops we can perform around a read() which succeeds.
83// It's very frequent that the system returns a few TCP segments at a time.
84#ifndef MAX_READ_POLL_LOOPS
85#define MAX_READ_POLL_LOOPS 4
86#endif
87
Willy Tarreau6f4a82c2009-03-21 20:43:57 +010088// minimum number of bytes read at once above which we don't try to read
89// more, in order not to risk facing an EAGAIN. Most often, if we read
90// at least 10 kB, we can consider that the system has tried to read a
91// full buffer and got multiple segments (>1 MSS for jumbo frames, >7 MSS
92// for normal frames) did not bother truncating the last segment.
93#ifndef MIN_RECV_AT_ONCE_ENOUGH
94#define MIN_RECV_AT_ONCE_ENOUGH (7*1448)
95#endif
96
Willy Tarreau83749182007-04-15 20:56:27 +020097// same, but for writes. Generally, it's enough to write twice: one time for
98// first half of the buffer, and a second time for the last half after a
99// wrap-around.
100#ifndef MAX_WRITE_POLL_LOOPS
101#define MAX_WRITE_POLL_LOOPS 2
102#endif
103
Willy Tarreau9641e8f2007-03-23 23:02:09 +0100104// the number of bytes returned by a read below which we will not try to
105// poll the socket again. Generally, return values below the MSS are worthless
106// to try again.
107#ifndef MIN_RET_FOR_READ_LOOP
108#define MIN_RET_FOR_READ_LOOP 1460
109#endif
110
Willy Tarreau1db37712007-06-03 17:16:49 +0200111// the max number of events returned in one call to poll/epoll. Too small a
112// value will cause lots of calls, and too high a value may cause high latency.
113#ifndef MAX_POLL_EVENTS
114#define MAX_POLL_EVENTS 200
115#endif
116
Willy Tarreaubaaee002006-06-26 02:48:02 +0200117// cookie delimitor in "prefix" mode. This character is inserted between the
118// persistence cookie and the original value. The '~' is allowed by RFC2965,
119// and should not be too common in server names.
120#ifndef COOKIE_DELIM
121#define COOKIE_DELIM '~'
122#endif
123
124#define CONN_RETRIES 3
125
126#define CHK_CONNTIME 2000
127#define DEF_CHKINTR 2000
128#define DEF_FALLTIME 3
129#define DEF_RISETIME 2
130#define DEF_CHECK_REQ "OPTIONS / HTTP/1.0\r\n\r\n"
Willy Tarreau23677902007-05-08 23:50:35 +0200131#define DEF_SMTP_CHECK_REQ "HELO localhost\r\n"
Willy Tarreaubaaee002006-06-26 02:48:02 +0200132
Ross Westaf72a1d2008-08-03 10:51:45 +0200133// X-Forwarded-For header default
134#define DEF_XFORWARDFOR_HDR "X-Forwarded-For"
135
Maik Broemme2850cb42009-04-17 18:53:21 +0200136// X-Original-To header default
137#define DEF_XORIGINALTO_HDR "X-Original-To"
138
Willy Tarreaubaaee002006-06-26 02:48:02 +0200139/* Default connections limit.
140 *
141 * A system limit can be enforced at build time in order to avoid using haproxy
142 * beyond reasonable system limits. For this, just define SYSTEM_MAXCONN to the
143 * absolute limit accepted by the system. If the configuration specifies a
144 * higher value, it will be capped to SYSTEM_MAXCONN and a warning will be
145 * emitted. The only way to override this limit will be to set it via the
146 * command-line '-n' argument.
147 */
148#ifndef SYSTEM_MAXCONN
Willy Tarreauc9fe4562009-06-15 16:33:36 +0200149#ifndef DEFAULT_MAXCONN
Willy Tarreaubaaee002006-06-26 02:48:02 +0200150#define DEFAULT_MAXCONN 2000
Willy Tarreauc9fe4562009-06-15 16:33:36 +0200151#endif
Willy Tarreaubaaee002006-06-26 02:48:02 +0200152#else
Willy Tarreauc9fe4562009-06-15 16:33:36 +0200153#undef DEFAULT_MAXCONN
Willy Tarreaubaaee002006-06-26 02:48:02 +0200154#define DEFAULT_MAXCONN SYSTEM_MAXCONN
155#endif
156
Willy Tarreau2c43a1e2007-10-14 23:05:39 +0200157/* Minimum check interval for spread health checks. Servers with intervals
158 * greater than or equal to this value will have their checks spread apart
159 * and will be considered when searching the minimal interval.
160 * Others will be ignored for the minimal interval and will have their checks
161 * scheduled on a different basis.
162 */
163#ifndef SRV_CHK_INTER_THRES
164#define SRV_CHK_INTER_THRES 1000
165#endif
166
Krzysztof Oledzkid9db9272007-10-15 10:05:11 +0200167/* Specifies the string used to report the version and release date on the
168 * statistics page. May be defined to the empty string ("") to permanently
169 * disable the feature.
170 */
171#ifndef STATS_VERSION_STRING
172#define STATS_VERSION_STRING " version " HAPROXY_VERSION ", released " HAPROXY_DATE
173#endif
174
Willy Tarreau8f38bd02009-05-10 08:53:33 +0200175/* Maximum signal queue size, and also number of different signals we can
176 * handle.
177 */
178#ifndef MAX_SIGNAL
179#define MAX_SIGNAL 256
180#endif
181
Willy Tarreau3ad6a762009-08-16 10:08:02 +0200182/* Maximum host name length */
183#ifndef MAX_HOSTNAME_LEN
184#define MAX_HOSTNAME_LEN 32
185#endif
186
Willy Tarreau2dd0d472006-06-29 17:53:05 +0200187#endif /* _COMMON_DEFAULTS_H */