blob: 622e1686c0d221248d58cc5da1c9637de50fcf41 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau5b4c2b52009-10-03 11:21:53 +02002 * include/types/proxy.h
3 * This file defines everything related to proxies.
4 *
Willy Tarreauff011f22011-01-06 17:51:27 +01005 * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
Willy Tarreau5b4c2b52009-10-03 11:21:53 +02006 *
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
22#ifndef _TYPES_PROXY_H
23#define _TYPES_PROXY_H
24
Willy Tarreau7d677682006-10-15 23:18:47 +020025#include <sys/types.h>
26#include <sys/socket.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020027#include <netinet/in.h>
28#include <arpa/inet.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020029
Willy Tarreau2dd0d472006-06-29 17:53:05 +020030#include <common/appsession.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020031#include <common/config.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020032#include <common/mini-clist.h>
33#include <common/regex.h>
Willy Tarreau51041c72007-09-09 21:56:53 +020034#include <common/sessionhash.h>
Willy Tarreaua8cff1d2007-04-09 16:10:57 +020035#include <common/tools.h>
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010036#include <eb32tree.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020037
Willy Tarreaueb0c6142007-05-07 00:53:22 +020038#include <types/acl.h>
Willy Tarreau5b4c2b52009-10-03 11:21:53 +020039#include <types/backend.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020040#include <types/buffers.h>
Krzysztof Piotr Oledzki052d4fd2009-10-04 14:52:57 +020041#include <types/counters.h>
Willy Tarreau7f062c42009-03-05 18:43:00 +010042#include <types/freq_ctr.h>
Robert Tsai81ae1952007-12-05 10:47:29 +010043#include <types/log.h>
Willy Tarreaudd815982007-10-16 12:25:14 +020044#include <types/protocols.h>
Willy Tarreau436d9ed2011-05-11 16:10:11 +020045#include <types/proto_http.h>
Willy Tarreaucd3b0942012-04-27 21:52:18 +020046#include <types/sample.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020047#include <types/session.h>
48#include <types/server.h>
Emeric Brunb982a3d2010-01-04 15:45:53 +010049#include <types/stick_table.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020050
51/* values for proxy->state */
Willy Tarreau562515c2011-07-25 08:11:52 +020052enum {
53 PR_STNEW = 0, /* proxy has not been initialized yet */
54 PR_STREADY, /* proxy has been initialized and is ready */
55 PR_STFULL, /* frontend is full (maxconn reached) */
56 PR_STPAUSED, /* frontend is paused (during hot restart) */
57 PR_STSTOPPED, /* proxy is stopped (end of a restart) */
58 PR_STERROR, /* proxy experienced an unrecoverable error */
59};
Willy Tarreaubaaee002006-06-26 02:48:02 +020060
61/* values for proxy->mode */
62#define PR_MODE_TCP 0
63#define PR_MODE_HTTP 1
64#define PR_MODE_HEALTH 2
65
Willy Tarreau977b8e42006-12-29 14:19:17 +010066/* flag values for proxy->cap. This is a bitmask of capabilities supported by the proxy */
67#define PR_CAP_NONE 0x0000
68#define PR_CAP_FE 0x0001
69#define PR_CAP_BE 0x0002
70#define PR_CAP_RS 0x0004
71#define PR_CAP_LISTEN (PR_CAP_FE|PR_CAP_BE|PR_CAP_RS)
72
Willy Tarreau31682232007-11-29 15:38:04 +010073/* bits for proxy->options */
74#define PR_O_REDISP 0x00000001 /* allow reconnection to dispatch in case of errors */
75#define PR_O_TRANSP 0x00000002 /* transparent mode : use original DEST as dispatch */
76#define PR_O_COOK_RW 0x00000004 /* rewrite all direct cookies with the right serverid */
77#define PR_O_COOK_IND 0x00000008 /* keep only indirect cookies */
78#define PR_O_COOK_INS 0x00000010 /* insert cookies when not accessing a server directly */
79#define PR_O_COOK_PFX 0x00000020 /* rewrite all cookies by prefixing the right serverid */
80#define PR_O_COOK_ANY (PR_O_COOK_RW | PR_O_COOK_IND | PR_O_COOK_INS | PR_O_COOK_PFX)
Willy Tarreau1620ec32011-08-06 17:05:02 +020081#define PR_O_DISPATCH 0x00000040 /* use dispatch mode */
Willy Tarreau31682232007-11-29 15:38:04 +010082#define PR_O_KEEPALIVE 0x00000080 /* follow keep-alive sessions */
Willy Tarreau87cf5142011-08-19 22:57:24 +020083#define PR_O_FWDFOR 0x00000100 /* conditionally insert x-forwarded-for with client address */
Willy Tarreau31682232007-11-29 15:38:04 +010084#define PR_O_BIND_SRC 0x00000200 /* bind to a specific source address when connect()ing */
85#define PR_O_NULLNOLOG 0x00000400 /* a connect without request will not be logged */
86#define PR_O_COOK_NOC 0x00000800 /* add a 'Cache-control' header with the cookie */
87#define PR_O_COOK_POST 0x00001000 /* don't insert cookies for requests other than a POST */
Willy Tarreau87cf5142011-08-19 22:57:24 +020088#define PR_O_FF_ALWAYS 0x00002000 /* always set x-forwarded-for */
Willy Tarreau31682232007-11-29 15:38:04 +010089#define PR_O_PERSIST 0x00004000 /* server persistence stays effective even when server is down */
90#define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the session to complete */
91#define PR_O_HTTP_CLOSE 0x00010000 /* force 'connection: close' in both directions */
92#define PR_O_CHK_CACHE 0x00020000 /* require examination of cacheability of the 'set-cookie' field */
93#define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side sessions */
94#define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side sessions */
95#define PR_O_USE_ALL_BK 0x00100000 /* load-balance between backup servers */
96#define PR_O_FORCE_CLO 0x00200000 /* enforce the connection close immediately after server response */
97#define PR_O_TCP_NOLING 0x00400000 /* disable lingering on client and server connections */
98#define PR_O_ABRT_CLOSE 0x00800000 /* immediately abort request when client closes */
Willy Tarreau31682232007-11-29 15:38:04 +010099
100/* TPXY: exclusive values */
Willy Tarreau090466c2009-09-07 11:51:47 +0200101#define PR_O_TPXY_ADDR 0x01000000 /* bind to this non-local address when connect()ing */
102#define PR_O_TPXY_CIP 0x02000000 /* bind to the client's IP address when connect()ing */
103#define PR_O_TPXY_CLI 0x03000000 /* bind to the client's IP+port when connect()ing */
104#define PR_O_TPXY_DYN 0x04000000 /* bind to a dynamically computed non-local address */
105#define PR_O_TPXY_MASK 0x07000000 /* bind to a non-local address when connect()ing */
Willy Tarreau31682232007-11-29 15:38:04 +0100106
Willy Tarreaub608feb2010-01-02 22:47:18 +0100107#define PR_O_SERVER_CLO 0x08000000 /* option http-server-close */
Willy Tarreau31682232007-11-29 15:38:04 +0100108#define PR_O_CONTSTATS 0x10000000 /* continous counters */
Alexandre Cassen5eb1a902007-11-29 15:43:32 +0100109#define PR_O_HTTP_PROXY 0x20000000 /* Enable session to use HTTP proxy operations */
Willy Tarreau48494c02007-11-30 10:41:39 +0100110#define PR_O_DISABLE404 0x40000000 /* Disable a server on a 404 response to a health-check */
Maik Broemme2850cb42009-04-17 18:53:21 +0200111#define PR_O_ORGTO 0x80000000 /* insert x-original-to with destination address */
Willy Tarreau66aa61f2009-01-18 21:44:07 +0100112
113/* bits for proxy->options2 */
114#define PR_O2_SPLIC_REQ 0x00000001 /* transfer requests using linux kernel's splice() */
115#define PR_O2_SPLIC_RTR 0x00000002 /* transfer responses using linux kernel's splice() */
116#define PR_O2_SPLIC_AUT 0x00000004 /* automatically use linux kernel's splice() */
117#define PR_O2_SPLIC_ANY (PR_O2_SPLIC_REQ|PR_O2_SPLIC_RTR|PR_O2_SPLIC_AUT)
Willy Tarreau32a4ec02009-04-02 11:35:18 +0200118#define PR_O2_REQBUG_OK 0x00000008 /* let buggy requests pass through */
119#define PR_O2_RSPBUG_OK 0x00000010 /* let buggy responses pass through */
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +0200120#define PR_O2_NOLOGNORM 0x00000020 /* don't log normal traffic, only errors and retries */
121#define PR_O2_LOGERRORS 0x00000040 /* log errors and retries at level LOG_ERR */
Willy Tarreau9ea05a72009-06-14 12:07:01 +0200122#define PR_O2_SMARTACC 0x00000080 /* don't immediately ACK request after accept */
Willy Tarreaud88edf22009-06-14 15:48:17 +0200123#define PR_O2_SMARTCON 0x00000100 /* don't immediately send empty ACK after connect */
Emeric Brun647caf12009-06-30 17:57:00 +0200124#define PR_O2_RDPC_PRST 0x00000200 /* Actvate rdp cookie analyser */
Emeric Brun3a058f32009-06-30 18:26:00 +0200125#define PR_O2_CLFLOG 0x00000400 /* log into clf format */
Krzysztof Piotr Oledzki213014e2009-09-27 15:50:02 +0200126#define PR_O2_LOGHCHKS 0x00000800 /* log health checks */
Willy Tarreauf27b5ea2009-10-03 22:01:18 +0200127#define PR_O2_INDEPSTR 0x00001000 /* independant streams, don't update rex on write */
Krzysztof Piotr Oledzkiaeebf9b2009-10-04 15:43:17 +0200128#define PR_O2_SOCKSTAT 0x00002000 /* collect & provide separate statistics for sockets */
Cyril Bontéb21570a2009-11-29 20:04:48 +0100129
130/* appsession */
131#define PR_O2_AS_REQL 0x00004000 /* learn the session id from the request */
132#define PR_O2_AS_PFX 0x00008000 /* match on the cookie prefix */
133
134/* Encoding of appsession cookie matching modes : 2 possible values => 1 bit */
135#define PR_O2_AS_M_PP 0x00000000 /* path-parameters mode (the default mode) */
136#define PR_O2_AS_M_QS 0x00010000 /* query-string mode */
137#define PR_O2_AS_M_ANY 0x00010000 /* mask covering all PR_O2_AS_M_* values */
Willy Tarreau1620ec32011-08-06 17:05:02 +0200138#define PR_O2_NODELAY 0x00020000 /* fully interactive mode, never delay outgoing data */
Willy Tarreau88d349d2010-01-25 12:15:43 +0100139#define PR_O2_USE_PXHDR 0x00040000 /* use Proxy-Connection for proxy requests */
Willy Tarreauef781042010-01-27 11:53:01 +0100140#define PR_O2_CHK_SNDST 0x00080000 /* send the state of each server along with HTTP health checks */
William Lallemandb7ff6a32012-03-02 14:35:21 +0100141
142#define PR_O2_SRC_ADDR 0x00100000 /* get the source ip and port for logs */
143
Willy Tarreau8a8e1d92010-04-05 16:15:16 +0200144#define PR_O2_FAKE_KA 0x00200000 /* pretend we do keep-alive with server eventhough we close */
Willy Tarreau1620ec32011-08-06 17:05:02 +0200145/* unused: 0x00400000 */
Willy Tarreaubd741542010-03-16 18:46:54 +0100146#define PR_O2_EXP_NONE 0x00000000 /* http-check : no expect rule */
147#define PR_O2_EXP_STS 0x00800000 /* http-check expect status */
148#define PR_O2_EXP_RSTS 0x01000000 /* http-check expect rstatus */
149#define PR_O2_EXP_STR 0x01800000 /* http-check expect string */
150#define PR_O2_EXP_RSTR 0x02000000 /* http-check expect rstring */
151#define PR_O2_EXP_TYPE 0x03800000 /* mask for http-check expect type */
152#define PR_O2_EXP_INV 0x04000000 /* http-check expect !<rule> */
Willy Tarreauba4c5be2010-10-23 12:46:42 +0200153#define PR_O2_COOK_PSV 0x08000000 /* cookie ... preserve */
Rauf Kuliyev38b41562011-01-04 15:14:13 +0100154
Willy Tarreau1620ec32011-08-06 17:05:02 +0200155/* server health checks */
156#define PR_O2_CHK_NONE 0x00000000 /* no L7 health checks configured (TCP by default) */
Rauf Kuliyev38b41562011-01-04 15:14:13 +0100157#define PR_O2_PGSQL_CHK 0x10000000 /* use PGSQL check for server health */
Willy Tarreau1620ec32011-08-06 17:05:02 +0200158#define PR_O2_REDIS_CHK 0x20000000 /* use LDAP check for server health */
159#define PR_O2_SMTP_CHK 0x30000000 /* use SMTP EHLO check for server health - pvandijk@vision6.com.au */
160#define PR_O2_HTTP_CHK 0x40000000 /* use HTTP 'OPTIONS' method to check server health */
161#define PR_O2_MYSQL_CHK 0x50000000 /* use MYSQL check for server health */
162#define PR_O2_LDAP_CHK 0x60000000 /* use LDAP check for server health */
163#define PR_O2_SSL3_CHK 0x70000000 /* use SSLv3 CLIENT_HELLO packets for server health */
164/* unused: 0x80000000 to 0xF000000, reserved for health checks */
165#define PR_O2_CHK_ANY 0xF0000000 /* Mask to cover any check */
Emeric Brunb982a3d2010-01-04 15:45:53 +0100166/* end of proxy->options2 */
167
168/* bits for sticking rules */
169#define STK_IS_MATCH 0x00000001 /* match on request fetch */
170#define STK_IS_STORE 0x00000002 /* store on request fetch */
171#define STK_ON_RSP 0x00000004 /* store on response fetch */
Hervé COMMOWICK698ae002010-01-12 09:25:13 +0100172
Willy Tarreauf073a832009-03-01 23:21:47 +0100173struct error_snapshot {
174 struct timeval when; /* date of this event, (tv_sec == 0) means "never" */
175 unsigned int len; /* original length of the last invalid request/response */
176 unsigned int pos; /* position of the first invalid character */
177 unsigned int sid; /* ID of the faulty session */
Willy Tarreau10479e42010-12-12 14:00:34 +0100178 unsigned int ev_id; /* event number (counter incremented for each capture) */
Willy Tarreau078272e2010-12-12 12:46:33 +0100179 unsigned int state; /* message state before the error (when saved) */
Willy Tarreaud04b1bc2012-05-08 11:03:10 +0200180 unsigned int b_flags; /* buffer flags */
181 unsigned int s_flags; /* session flags */
182 unsigned int t_flags; /* transaction flags */
183 unsigned int m_flags; /* message flags */
184 unsigned int b_out; /* pending output bytes */
185 unsigned int b_wrap; /* position where the buffer is expected to wrap */
186 unsigned long long b_tot; /* total bytes transferred via this buffer */
187 unsigned long long m_clen; /* chunk len for this message */
188 unsigned long long m_blen; /* body len for this message */
Willy Tarreauf073a832009-03-01 23:21:47 +0100189 struct server *srv; /* server associated with the error (or NULL) */
190 struct proxy *oe; /* other end = frontend or backend involved */
191 struct sockaddr_storage src; /* client's address */
192 char buf[BUFSIZE]; /* copy of the beginning of the message */
193};
194
Willy Tarreaubaaee002006-06-26 02:48:02 +0200195struct proxy {
196 struct listener *listen; /* the listen addresses and sockets */
197 struct in_addr mon_net, mon_mask; /* don't forward connections from this net (network order) FIXME: should support IPv6 */
198 int state; /* proxy state */
Willy Tarreau35d66b02007-01-02 00:28:21 +0100199 int options; /* PR_O_REDISP, PR_O_TRANSP, ... */
Willy Tarreau66aa61f2009-01-18 21:44:07 +0100200 int options2; /* PR_O2_* */
Willy Tarreauc1a21672009-08-16 22:37:44 +0200201 unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
Willy Tarreau4e5b8282009-08-16 22:57:50 +0200202 unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */
Willy Tarreau35d66b02007-01-02 00:28:21 +0100203 int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
Willy Tarreau5fdfb912007-01-01 23:11:07 +0100204 union {
205 struct proxy *be; /* default backend, or NULL if none set */
206 char *name; /* default backend name during config parse */
207 } defbe;
Willy Tarreaueb0c6142007-05-07 00:53:22 +0200208 struct list acl; /* ACL declared on this proxy */
Willy Tarreauff011f22011-01-06 17:51:27 +0100209 struct list http_req_rules; /* HTTP request rules: allow/deny/http-auth */
Willy Tarreau5c8e3e02007-05-07 00:58:25 +0200210 struct list block_cond; /* early blocking conditions (chained) */
Willy Tarreaub463dfb2008-06-07 23:08:56 +0200211 struct list redirect_rules; /* content redirecting rules (chained) */
Willy Tarreau55ea7572007-06-17 19:56:27 +0200212 struct list switching_rules; /* content switching rules (chained) */
Cyril Bonté47fdd8e2010-04-25 00:00:51 +0200213 struct list persist_rules; /* 'force-persist' and 'ignore-persist' rules (chained) */
Emeric Brunb982a3d2010-01-04 15:45:53 +0100214 struct list sticking_rules; /* content sticking rules (chained) */
215 struct list storersp_rules; /* content store response rules (chained) */
Willy Tarreau4a5cade2012-04-05 21:09:48 +0200216 struct list server_rules; /* server switching rules (chained) */
Willy Tarreaub6866442008-07-14 23:54:42 +0200217 struct { /* TCP request processing */
Willy Tarreauc7e961e2008-08-17 17:13:47 +0200218 unsigned int inspect_delay; /* inspection delay */
Willy Tarreaub6866442008-07-14 23:54:42 +0200219 struct list inspect_rules; /* inspection rules */
Willy Tarreauab786192010-05-23 22:39:25 +0200220 struct list l4_rules; /* layer4 rules */
Willy Tarreaub6866442008-07-14 23:54:42 +0200221 } tcp_req;
Emeric Brun97679e72010-09-23 17:56:44 +0200222 struct { /* TCP request processing */
223 unsigned int inspect_delay; /* inspection delay */
224 struct list inspect_rules; /* inspection rules */
225 } tcp_rep;
Willy Tarreaua9fb0832009-07-10 20:53:53 +0200226 int acl_requires; /* Elements required to satisfy all ACLs (ACL_USE_*) */
Krzysztof Piotr Oledzkic6df0662010-01-05 16:38:49 +0100227 struct server *srv, defsrv; /* known servers; default server configuration */
Willy Tarreaub625a082007-11-26 01:15:43 +0100228 int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
Willy Tarreau5b4c2b52009-10-03 11:21:53 +0200229 struct lbprm lbprm; /* load-balancing parameters */
Krzysztof Piotr Oledzki1acf2172008-05-29 23:03:34 +0200230 char *cookie_domain; /* domain used to insert the cookie */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200231 char *cookie_name; /* name of the cookie to look for */
232 int cookie_len; /* strlen(cookie_name), computed only once */
Willy Tarreau31936852010-10-06 16:59:56 +0200233 unsigned int cookie_maxidle; /* max idle time for this cookie */
234 unsigned int cookie_maxlife; /* max life time for this cookie */
Emeric Brun647caf12009-06-30 17:57:00 +0200235 char *rdp_cookie_name; /* name of the RDP cookie to look for */
236 int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */
Willy Tarreau01732802007-11-01 22:48:15 +0100237 char *url_param_name; /* name of the URL parameter used for hashing */
238 int url_param_len; /* strlen(url_param_name), computed only once */
matt.farnsworth@nokia.com1c2ab962008-04-14 20:47:37 +0200239 unsigned url_param_post_limit; /* if checking POST body for URI parameter, max body to wait for */
Marek Majkowski9c30fc12008-04-27 23:25:55 +0200240 int uri_len_limit; /* character limit for uri balancing algorithm */
241 int uri_dirs_depth1; /* directories+1 (slashes) limit for uri balancing algorithm */
Oskar Stolc8dc41842012-05-19 10:19:54 +0100242 int uri_whole; /* if != 0, calculates the hash from the whole uri. Still honors the len_limit and dirs_depth1 */
Benoitaffb4812009-03-25 13:02:10 +0100243 char *hh_name; /* name of the header parameter used for hashing */
244 int hh_len; /* strlen(hh_name), computed only once */
245 int hh_match_domain; /* toggle use of special match function */
Willy Tarreau1c47f852006-07-09 08:22:27 +0200246 char *appsession_name; /* name of the cookie to look for */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200247 int appsession_name_len; /* strlen(appsession_name), computed only once */
Willy Tarreau1c47f852006-07-09 08:22:27 +0200248 int appsession_len; /* length of the appsession cookie value to be used */
Willy Tarreau51041c72007-09-09 21:56:53 +0200249 struct appsession_hash htbl_proxy; /* Per Proxy hashtable */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200250 char *capture_name; /* beginning of the name of the cookie to capture */
Willy Tarreau1c47f852006-07-09 08:22:27 +0200251 int capture_namelen; /* length of the cookie name to match */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200252 int capture_len; /* length of the string to be captured */
253 struct uri_auth *uri_auth; /* if non-NULL, the (list of) per-URI authentications */
Willy Tarreau1c47f852006-07-09 08:22:27 +0200254 char *monitor_uri; /* a special URI to which we respond with HTTP/200 OK */
255 int monitor_uri_len; /* length of the string above. 0 if unused */
Willy Tarreaub80c2302007-11-30 20:51:32 +0100256 struct list mon_fail_cond; /* list of conditions to fail monitoring requests (chained) */
Willy Tarreau3a70f942008-02-15 11:15:34 +0100257 struct { /* WARNING! check proxy_reset_timeouts() in proxy.h !!! */
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200258 int client; /* client I/O timeout (in ticks) */
259 int tarpit; /* tarpit timeout, defaults to connect if unspecified */
260 int queue; /* queue timeout, defaults to connect if unspecified */
261 int connect; /* connect timeout (in ticks) */
262 int server; /* server I/O timeout (in ticks) */
263 int appsession; /* appsession cookie expiration */
264 int httpreq; /* maximum time for complete HTTP request */
Willy Tarreaub16a5742010-01-10 14:46:16 +0100265 int httpka; /* maximum time for a new HTTP request when using keep-alive */
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200266 int check; /* maximum time for complete check */
Willy Tarreauce887fd2012-05-12 12:50:00 +0200267 int tunnel; /* I/O timeout to use in tunnel mode (in ticks) */
Willy Tarreau1fa31262007-12-03 00:36:16 +0100268 } timeout;
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +0200269 char *id, *desc; /* proxy id (name) and description */
Willy Tarreau1c47f852006-07-09 08:22:27 +0200270 struct list pendconns; /* pending connections with no server assigned yet */
Willy Tarreauac68c5d2009-10-04 23:12:44 +0200271 int nbpend; /* number of pending connections with no server assigned yet */
Willy Tarreau1c47f852006-07-09 08:22:27 +0200272 int totpend; /* total number of pending connections on this instance (for stats) */
Krzysztof Piotr Oledzki052d4fd2009-10-04 14:52:57 +0200273 unsigned int feconn, beconn; /* # of active frontend and backends sessions */
Willy Tarreaud9b587f2010-02-26 10:05:55 +0100274 struct freq_ctr fe_req_per_sec; /* HTTP requests per second on the frontend */
Willy Tarreaub36b4242010-06-04 20:59:39 +0200275 struct freq_ctr fe_conn_per_sec; /* received connections per second on the frontend */
276 struct freq_ctr fe_sess_per_sec; /* accepted sessions per second on the frontend (after tcp rules) */
Willy Tarreau7f062c42009-03-05 18:43:00 +0100277 struct freq_ctr be_sess_per_sec; /* sessions per second on the backend */
Willy Tarreau86034312006-12-29 00:10:33 +0100278 unsigned int maxconn; /* max # of active sessions on the frontend */
Willy Tarreau13a34bd2009-05-10 18:52:49 +0200279 unsigned int fe_sps_lim; /* limit on new sessions per second on the frontend */
Willy Tarreau86034312006-12-29 00:10:33 +0100280 unsigned int fullconn; /* #conns on backend above which servers are used at full load */
Willy Tarreau7ac51f62007-03-25 16:00:04 +0200281 struct in_addr except_net, except_mask; /* don't x-forward-for for this address. FIXME: should support IPv6 */
Maik Broemme2850cb42009-04-17 18:53:21 +0200282 struct in_addr except_to; /* don't x-original-to for this address. */
283 struct in_addr except_mask_to; /* the netmask for except_to. */
Ross Westaf72a1d2008-08-03 10:51:45 +0200284 char *fwdfor_hdr_name; /* header to use - default: "x-forwarded-for" */
285 int fwdfor_hdr_len; /* length of "x-forwarded-for" header */
Maik Broemme2850cb42009-04-17 18:53:21 +0200286 char *orgto_hdr_name; /* header to use - default: "x-original-to" */
287 int orgto_hdr_len; /* length of "x-original-to" header */
Mark Lamourinec2247f02012-01-04 13:02:01 -0500288 char *server_id_hdr_name; /* the header to use to send the server id (name) */
289 int server_id_hdr_len; /* the length of the id (name) header... name */
Krzysztof Oledzki85130942007-10-22 16:21:10 +0200290
291 unsigned down_trans; /* up-down transitions */
292 unsigned down_time; /* total time the proxy was down */
293 time_t last_change; /* last time, when the state was changed */
294
Willy Tarreaubaaee002006-06-26 02:48:02 +0200295 int conn_retries; /* maximum number of connect retries */
Willy Tarreau977b8e42006-12-29 14:19:17 +0100296 int cap; /* supported capabilities (PR_CAP_*) */
Willy Tarreaud53f96b2009-02-04 18:46:54 +0100297 int iface_len; /* bind interface name length */
298 char *iface_name; /* bind interface name or NULL */
Willy Tarreauf229eb82010-06-01 17:14:24 +0200299 int (*accept)(struct session *s); /* application layer's accept() */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200300 struct proxy *next;
William Lallemand0f99e342011-10-12 17:50:54 +0200301 struct list logsrvs;
William Lallemand723b73a2012-02-08 16:37:49 +0100302 struct list logformat; /* log_format linked list */
William Lallemanda73203e2012-03-12 12:48:57 +0100303 char *header_unique_id; /* unique-id header */
304 struct list format_unique_id; /* unique-id format */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200305 int to_log; /* things to be logged (LW_*) */
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200306 int stop_time; /* date to stop listening, when stopping != 0 (int ticks) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200307 struct hdr_exp *req_exp; /* regular expressions for request headers */
308 struct hdr_exp *rsp_exp; /* regular expressions for response headers */
309 int nb_req_cap, nb_rsp_cap; /* # of headers to be captured */
310 struct cap_hdr *req_cap; /* chained list of request headers to be captured */
311 struct cap_hdr *rsp_cap; /* chained list of response headers to be captured */
Willy Tarreaucf7f3202007-05-13 22:46:04 +0200312 struct pool_head *req_cap_pool, /* pools of pre-allocated char ** used to build the sessions */
313 *rsp_cap_pool;
Willy Tarreaudeb9ed82010-01-03 21:03:22 +0100314 struct list req_add, rsp_add; /* headers to be added */
Willy Tarreau7d0aaf32011-03-10 23:25:56 +0100315 struct pxcounters be_counters; /* backend statistics counters */
316 struct pxcounters fe_counters; /* frontend statistics counters */
Emeric Brunb982a3d2010-01-04 15:45:53 +0100317
Willy Tarreau07687c12011-07-24 23:55:06 +0200318 struct list listener_queue; /* list of the temporarily limited listeners because of lack of a proxy resource */
Emeric Brunb982a3d2010-01-04 15:45:53 +0100319 struct stktable table; /* table for storing sticking sessions */
320
Willy Tarreau918ff602011-07-25 16:33:49 +0200321 struct task *task; /* the associated task, mandatory to manage rate limiting, stopping and resource shortage */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200322 int grace; /* grace time after stop request */
Willy Tarreauf3c69202006-07-09 16:42:34 +0200323 char *check_req; /* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */
324 int check_len; /* Length of the HTTP or SSL3 request */
Willy Tarreau1ee51a62011-08-19 20:04:17 +0200325 char *expect_str; /* http-check expected content : string or text version of the regex */
Willy Tarreaubd741542010-03-16 18:46:54 +0100326 regex_t *expect_regex; /* http-check expected content */
Willy Tarreau0f772532006-12-23 20:51:41 +0100327 struct chunk errmsg[HTTP_ERR_SIZE]; /* default or customized error messages for known errors */
Willy Tarreaudcd47712007-11-04 23:35:08 +0100328 int uuid; /* universally unique proxy ID, used for SNMP */
Willy Tarreauc73ce2b2008-01-06 10:55:10 +0100329 unsigned int backlog; /* force the frontend's listen backlog */
Willy Tarreau0b9c02c2009-02-04 22:05:05 +0100330 unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */
Willy Tarreau7b815632011-10-21 18:51:57 +0200331
332 /* warning: these structs are huge, keep them at the bottom */
333 struct sockaddr_storage dispatch_addr; /* the default address to connect to */
334 struct sockaddr_storage source_addr; /* the address to which we want to bind for connect() */
335#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY)
336 struct sockaddr_storage tproxy_addr; /* non-local address we want to bind to for connect() */
337 char *bind_hdr_name; /* bind to this header name if defined */
338 int bind_hdr_len; /* length of the name of the header above */
339 int bind_hdr_occ; /* occurrence number of header above: >0 = from first, <0 = from end, 0=disabled */
340#endif
Willy Tarreauf073a832009-03-01 23:21:47 +0100341 struct error_snapshot invalid_req, invalid_rep; /* captures of last errors */
Willy Tarreau84b57da2009-06-14 11:10:45 +0200342
343 /* used only during configuration parsing */
344 int no_options; /* PR_O_REDISP, PR_O_TRANSP, ... */
345 int no_options2; /* PR_O2_* */
Krzysztof Piotr Oledzki052d4fd2009-10-04 14:52:57 +0200346
Willy Tarreau90a570f2009-10-04 20:54:54 +0200347 struct {
348 const char *file; /* file where the section appears */
349 int line; /* line where the section appears */
Willy Tarreau53fb4ae2009-10-04 23:04:08 +0200350 struct eb32_node id; /* place in the tree of used IDs */
351 struct eb_root used_listener_id;/* list of listener IDs in use */
352 struct eb_root used_server_id; /* list of server IDs in use */
Willy Tarreau90a570f2009-10-04 20:54:54 +0200353 } conf; /* config information */
Willy Tarreau258a14b2010-07-13 16:24:48 +0200354 void *parent; /* parent of the proxy when applicable */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200355};
356
Willy Tarreau55ea7572007-06-17 19:56:27 +0200357struct switching_rule {
358 struct list list; /* list linked to from the proxy */
359 struct acl_cond *cond; /* acl condition to meet */
360 union {
361 struct proxy *backend; /* target backend */
362 char *name; /* target backend name during config parsing */
363 } be;
364};
365
Willy Tarreau4a5cade2012-04-05 21:09:48 +0200366struct server_rule {
367 struct list list; /* list linked to from the proxy */
368 struct acl_cond *cond; /* acl condition to meet */
369 union {
370 struct server *ptr; /* target server */
371 char *name; /* target server name during config parsing */
372 } srv;
373};
374
Cyril Bonté47fdd8e2010-04-25 00:00:51 +0200375struct persist_rule {
Willy Tarreau4de91492010-01-22 19:10:05 +0100376 struct list list; /* list linked to from the proxy */
377 struct acl_cond *cond; /* acl condition to meet */
Cyril Bonté47fdd8e2010-04-25 00:00:51 +0200378 int type;
Willy Tarreau4de91492010-01-22 19:10:05 +0100379};
380
Emeric Brunb982a3d2010-01-04 15:45:53 +0100381struct sticking_rule {
382 struct list list; /* list linked to from the proxy */
383 struct acl_cond *cond; /* acl condition to meet */
Willy Tarreau12785782012-04-27 21:37:17 +0200384 struct sample_expr *expr; /* fetch expr to fetch key */
Emeric Brunb982a3d2010-01-04 15:45:53 +0100385 int flags; /* STK_* */
386 union {
387 struct stktable *t; /* target table */
388 char *name; /* target table name during config parsing */
389 } table;
390};
391
392
Willy Tarreaub463dfb2008-06-07 23:08:56 +0200393struct redirect_rule {
394 struct list list; /* list linked to from the proxy */
395 struct acl_cond *cond; /* acl condition to meet */
396 int type;
397 int rdr_len;
398 char *rdr_str;
399 int code;
Willy Tarreau79da4692008-11-19 20:03:04 +0100400 unsigned int flags;
Willy Tarreau0140f252008-11-19 21:07:09 +0100401 int cookie_len;
402 char *cookie_str;
Willy Tarreaub463dfb2008-06-07 23:08:56 +0200403};
404
Willy Tarreaubaaee002006-06-26 02:48:02 +0200405extern struct proxy *proxy;
Willy Tarreau53fb4ae2009-10-04 23:04:08 +0200406extern struct eb_root used_proxy_id; /* list of proxy IDs in use */
Willy Tarreau10479e42010-12-12 14:00:34 +0100407extern unsigned int error_snapshot_id; /* global ID assigned to each error then incremented */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200408
409#endif /* _TYPES_PROXY_H */
410
411/*
412 * Local variables:
413 * c-indent-level: 8
414 * c-basic-offset: 8
415 * End:
416 */