Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | include/types/proxy.h |
| 3 | This file defines everything related to proxies. |
| 4 | |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 5 | Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 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 | */ |
| 21 | |
| 22 | #ifndef _TYPES_PROXY_H |
| 23 | #define _TYPES_PROXY_H |
| 24 | |
Willy Tarreau | 7d67768 | 2006-10-15 23:18:47 +0200 | [diff] [blame] | 25 | #include <sys/types.h> |
| 26 | #include <sys/socket.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 27 | #include <netinet/in.h> |
| 28 | #include <arpa/inet.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 29 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 30 | #include <common/appsession.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 31 | #include <common/config.h> |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 32 | #include <common/ebtree.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 33 | #include <common/mini-clist.h> |
| 34 | #include <common/regex.h> |
Willy Tarreau | 51041c7 | 2007-09-09 21:56:53 +0200 | [diff] [blame] | 35 | #include <common/sessionhash.h> |
Willy Tarreau | a8cff1d | 2007-04-09 16:10:57 +0200 | [diff] [blame] | 36 | #include <common/tools.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 37 | |
Willy Tarreau | eb0c614 | 2007-05-07 00:53:22 +0200 | [diff] [blame] | 38 | #include <types/acl.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 39 | #include <types/buffers.h> |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 40 | #include <types/freq_ctr.h> |
Willy Tarreau | 0f77253 | 2006-12-23 20:51:41 +0100 | [diff] [blame] | 41 | #include <types/httperr.h> |
Robert Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 42 | #include <types/log.h> |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 43 | #include <types/protocols.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 44 | #include <types/session.h> |
| 45 | #include <types/server.h> |
| 46 | |
| 47 | /* values for proxy->state */ |
| 48 | #define PR_STNEW 0 |
| 49 | #define PR_STIDLE 1 |
| 50 | #define PR_STRUN 2 |
| 51 | #define PR_STSTOPPED 3 |
| 52 | #define PR_STPAUSED 4 |
| 53 | #define PR_STERROR 5 |
| 54 | |
| 55 | /* values for proxy->mode */ |
| 56 | #define PR_MODE_TCP 0 |
| 57 | #define PR_MODE_HTTP 1 |
| 58 | #define PR_MODE_HEALTH 2 |
| 59 | |
Willy Tarreau | 2069704 | 2007-11-15 23:26:18 +0100 | [diff] [blame] | 60 | /* values for proxy->lbprm.map.state */ |
Willy Tarreau | 5af3a69 | 2007-07-24 23:32:33 +0200 | [diff] [blame] | 61 | #define PR_MAP_RECALC (1 << 0) |
| 62 | |
Willy Tarreau | 977b8e4 | 2006-12-29 14:19:17 +0100 | [diff] [blame] | 63 | /* flag values for proxy->cap. This is a bitmask of capabilities supported by the proxy */ |
| 64 | #define PR_CAP_NONE 0x0000 |
| 65 | #define PR_CAP_FE 0x0001 |
| 66 | #define PR_CAP_BE 0x0002 |
| 67 | #define PR_CAP_RS 0x0004 |
| 68 | #define PR_CAP_LISTEN (PR_CAP_FE|PR_CAP_BE|PR_CAP_RS) |
| 69 | |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 70 | /* bits for proxy->options */ |
| 71 | #define PR_O_REDISP 0x00000001 /* allow reconnection to dispatch in case of errors */ |
| 72 | #define PR_O_TRANSP 0x00000002 /* transparent mode : use original DEST as dispatch */ |
| 73 | #define PR_O_COOK_RW 0x00000004 /* rewrite all direct cookies with the right serverid */ |
| 74 | #define PR_O_COOK_IND 0x00000008 /* keep only indirect cookies */ |
| 75 | #define PR_O_COOK_INS 0x00000010 /* insert cookies when not accessing a server directly */ |
| 76 | #define PR_O_COOK_PFX 0x00000020 /* rewrite all cookies by prefixing the right serverid */ |
| 77 | #define PR_O_COOK_ANY (PR_O_COOK_RW | PR_O_COOK_IND | PR_O_COOK_INS | PR_O_COOK_PFX) |
| 78 | #define PR_O_SMTP_CHK 0x00000040 /* use SMTP EHLO check for server health - pvandijk@vision6.com.au */ |
| 79 | #define PR_O_KEEPALIVE 0x00000080 /* follow keep-alive sessions */ |
| 80 | #define PR_O_FWDFOR 0x00000100 /* insert x-forwarded-for with client address */ |
| 81 | #define PR_O_BIND_SRC 0x00000200 /* bind to a specific source address when connect()ing */ |
| 82 | #define PR_O_NULLNOLOG 0x00000400 /* a connect without request will not be logged */ |
| 83 | #define PR_O_COOK_NOC 0x00000800 /* add a 'Cache-control' header with the cookie */ |
| 84 | #define PR_O_COOK_POST 0x00001000 /* don't insert cookies for requests other than a POST */ |
| 85 | #define PR_O_HTTP_CHK 0x00002000 /* use HTTP 'OPTIONS' method to check server health */ |
| 86 | #define PR_O_PERSIST 0x00004000 /* server persistence stays effective even when server is down */ |
| 87 | #define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the session to complete */ |
| 88 | #define PR_O_HTTP_CLOSE 0x00010000 /* force 'connection: close' in both directions */ |
| 89 | #define PR_O_CHK_CACHE 0x00020000 /* require examination of cacheability of the 'set-cookie' field */ |
| 90 | #define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side sessions */ |
| 91 | #define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side sessions */ |
| 92 | #define PR_O_USE_ALL_BK 0x00100000 /* load-balance between backup servers */ |
| 93 | #define PR_O_FORCE_CLO 0x00200000 /* enforce the connection close immediately after server response */ |
| 94 | #define PR_O_TCP_NOLING 0x00400000 /* disable lingering on client and server connections */ |
| 95 | #define PR_O_ABRT_CLOSE 0x00800000 /* immediately abort request when client closes */ |
| 96 | #define PR_O_SSL3_CHK 0x01000000 /* use SSLv3 CLIENT_HELLO packets for server health */ |
| 97 | |
| 98 | /* TPXY: exclusive values */ |
| 99 | #define PR_O_TPXY_ADDR 0x02000000 /* bind to this non-local address when connect()ing */ |
| 100 | #define PR_O_TPXY_CIP 0x04000000 /* bind to the client's IP address when connect()ing */ |
| 101 | #define PR_O_TPXY_CLI 0x06000000 /* bind to the client's IP+port when connect()ing */ |
| 102 | #define PR_O_TPXY_MASK 0x06000000 /* bind to a non-local address when connect()ing */ |
| 103 | |
Willy Tarreau | b55932d | 2009-08-16 13:20:32 +0200 | [diff] [blame] | 104 | /* unused : tcpsplice 0x08000000 */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 105 | #define PR_O_CONTSTATS 0x10000000 /* continous counters */ |
Alexandre Cassen | 5eb1a90 | 2007-11-29 15:43:32 +0100 | [diff] [blame] | 106 | #define PR_O_HTTP_PROXY 0x20000000 /* Enable session to use HTTP proxy operations */ |
Willy Tarreau | 48494c0 | 2007-11-30 10:41:39 +0100 | [diff] [blame] | 107 | #define PR_O_DISABLE404 0x40000000 /* Disable a server on a 404 response to a health-check */ |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 108 | #define PR_O_ORGTO 0x80000000 /* insert x-original-to with destination address */ |
| 109 | /* unused: 0x80000000 - now used by PR_O_ORGTO */ |
Willy Tarreau | 66aa61f | 2009-01-18 21:44:07 +0100 | [diff] [blame] | 110 | |
| 111 | /* bits for proxy->options2 */ |
| 112 | #define PR_O2_SPLIC_REQ 0x00000001 /* transfer requests using linux kernel's splice() */ |
| 113 | #define PR_O2_SPLIC_RTR 0x00000002 /* transfer responses using linux kernel's splice() */ |
| 114 | #define PR_O2_SPLIC_AUT 0x00000004 /* automatically use linux kernel's splice() */ |
| 115 | #define PR_O2_SPLIC_ANY (PR_O2_SPLIC_REQ|PR_O2_SPLIC_RTR|PR_O2_SPLIC_AUT) |
Willy Tarreau | 32a4ec0 | 2009-04-02 11:35:18 +0200 | [diff] [blame] | 116 | #define PR_O2_REQBUG_OK 0x00000008 /* let buggy requests pass through */ |
| 117 | #define PR_O2_RSPBUG_OK 0x00000010 /* let buggy responses pass through */ |
Willy Tarreau | c9bd0cc | 2009-05-10 11:57:02 +0200 | [diff] [blame] | 118 | #define PR_O2_NOLOGNORM 0x00000020 /* don't log normal traffic, only errors and retries */ |
| 119 | #define PR_O2_LOGERRORS 0x00000040 /* log errors and retries at level LOG_ERR */ |
Willy Tarreau | 9ea05a7 | 2009-06-14 12:07:01 +0200 | [diff] [blame] | 120 | #define PR_O2_SMARTACC 0x00000080 /* don't immediately ACK request after accept */ |
Willy Tarreau | d88edf2 | 2009-06-14 15:48:17 +0200 | [diff] [blame] | 121 | #define PR_O2_SMARTCON 0x00000100 /* don't immediately send empty ACK after connect */ |
Emeric Brun | 647caf1 | 2009-06-30 17:57:00 +0200 | [diff] [blame] | 122 | #define PR_O2_RDPC_PRST 0x00000200 /* Actvate rdp cookie analyser */ |
Emeric Brun | 3a058f3 | 2009-06-30 18:26:00 +0200 | [diff] [blame] | 123 | #define PR_O2_CLFLOG 0x00000400 /* log into clf format */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 124 | |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 125 | /* This structure is used to apply fast weighted round robin on a server group */ |
| 126 | struct fwrr_group { |
| 127 | struct eb_root curr; /* tree for servers in "current" time range */ |
| 128 | struct eb_root t0, t1; /* "init" and "next" servers */ |
| 129 | struct eb_root *init; /* servers waiting to be placed */ |
| 130 | struct eb_root *next; /* servers to be placed at next run */ |
| 131 | int curr_pos; /* current position in the tree */ |
| 132 | int curr_weight; /* total weight of the current time range */ |
| 133 | int next_weight; /* total weight of the next time range */ |
| 134 | }; |
| 135 | |
Willy Tarreau | f073a83 | 2009-03-01 23:21:47 +0100 | [diff] [blame] | 136 | struct error_snapshot { |
| 137 | struct timeval when; /* date of this event, (tv_sec == 0) means "never" */ |
| 138 | unsigned int len; /* original length of the last invalid request/response */ |
| 139 | unsigned int pos; /* position of the first invalid character */ |
| 140 | unsigned int sid; /* ID of the faulty session */ |
| 141 | struct server *srv; /* server associated with the error (or NULL) */ |
| 142 | struct proxy *oe; /* other end = frontend or backend involved */ |
| 143 | struct sockaddr_storage src; /* client's address */ |
| 144 | char buf[BUFSIZE]; /* copy of the beginning of the message */ |
| 145 | }; |
| 146 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 147 | struct proxy { |
| 148 | struct listener *listen; /* the listen addresses and sockets */ |
| 149 | struct in_addr mon_net, mon_mask; /* don't forward connections from this net (network order) FIXME: should support IPv6 */ |
| 150 | int state; /* proxy state */ |
Willy Tarreau | 35d66b0 | 2007-01-02 00:28:21 +0100 | [diff] [blame] | 151 | int options; /* PR_O_REDISP, PR_O_TRANSP, ... */ |
Willy Tarreau | 66aa61f | 2009-01-18 21:44:07 +0100 | [diff] [blame] | 152 | int options2; /* PR_O2_* */ |
Willy Tarreau | 35d66b0 | 2007-01-02 00:28:21 +0100 | [diff] [blame] | 153 | int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 154 | struct sockaddr_in dispatch_addr; /* the default address to connect to */ |
Willy Tarreau | 5fdfb91 | 2007-01-01 23:11:07 +0100 | [diff] [blame] | 155 | union { |
| 156 | struct proxy *be; /* default backend, or NULL if none set */ |
| 157 | char *name; /* default backend name during config parse */ |
| 158 | } defbe; |
Willy Tarreau | eb0c614 | 2007-05-07 00:53:22 +0200 | [diff] [blame] | 159 | struct list acl; /* ACL declared on this proxy */ |
Willy Tarreau | 5c8e3e0 | 2007-05-07 00:58:25 +0200 | [diff] [blame] | 160 | struct list block_cond; /* early blocking conditions (chained) */ |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 161 | struct list redirect_rules; /* content redirecting rules (chained) */ |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 162 | struct list switching_rules; /* content switching rules (chained) */ |
Willy Tarreau | b686644 | 2008-07-14 23:54:42 +0200 | [diff] [blame] | 163 | struct { /* TCP request processing */ |
Willy Tarreau | c7e961e | 2008-08-17 17:13:47 +0200 | [diff] [blame] | 164 | unsigned int inspect_delay; /* inspection delay */ |
Willy Tarreau | b686644 | 2008-07-14 23:54:42 +0200 | [diff] [blame] | 165 | struct list inspect_rules; /* inspection rules */ |
| 166 | } tcp_req; |
Willy Tarreau | a9fb083 | 2009-07-10 20:53:53 +0200 | [diff] [blame] | 167 | int acl_requires; /* Elements required to satisfy all ACLs (ACL_USE_*) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 168 | struct server *srv; /* known servers */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 169 | int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */ |
Willy Tarreau | 2069704 | 2007-11-15 23:26:18 +0100 | [diff] [blame] | 170 | |
| 171 | struct { |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 172 | int algo; /* load balancing algorithm and variants: BE_LB_ALGO* */ |
Willy Tarreau | 2069704 | 2007-11-15 23:26:18 +0100 | [diff] [blame] | 173 | int tot_wact, tot_wbck; /* total effective weights of active and backup servers */ |
| 174 | int tot_weight; /* total effective weight of servers participating to LB */ |
| 175 | int tot_used; /* total number of servers used for LB */ |
| 176 | int wmult; /* ratio between user weight and effective weight */ |
Willy Tarreau | 5dc2fa6 | 2007-11-19 19:10:18 +0100 | [diff] [blame] | 177 | int wdiv; /* ratio between effective weight and user weight */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 178 | struct server *fbck; /* first backup server when !PR_O_USE_ALL_BK, or NULL */ |
Willy Tarreau | 2069704 | 2007-11-15 23:26:18 +0100 | [diff] [blame] | 179 | struct { |
| 180 | struct server **srv; /* the server map used to apply weights */ |
| 181 | int rr_idx; /* next server to be elected in round robin mode */ |
| 182 | int state; /* PR_MAP_RECALC */ |
| 183 | } map; /* LB parameters for map-based algorithms */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 184 | struct { |
| 185 | struct fwrr_group act; /* weighted round robin on the active servers */ |
| 186 | struct fwrr_group bck; /* weighted round robin on the backup servers */ |
| 187 | } fwrr; |
Willy Tarreau | 5140623 | 2008-03-10 22:04:20 +0100 | [diff] [blame] | 188 | struct { |
| 189 | struct eb_root act; /* weighted least conns on the active servers */ |
| 190 | struct eb_root bck; /* weighted least conns on the backup servers */ |
| 191 | } fwlc; |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 192 | void (*update_server_eweight)(struct server *);/* if non-NULL, to be called after eweight change */ |
| 193 | void (*set_server_status_up)(struct server *);/* to be called after status changes to UP */ |
| 194 | void (*set_server_status_down)(struct server *);/* to be called after status changes to DOWN */ |
Willy Tarreau | 5140623 | 2008-03-10 22:04:20 +0100 | [diff] [blame] | 195 | void (*server_take_conn)(struct server *);/* to be called when connection is assigned */ |
| 196 | void (*server_drop_conn)(struct server *);/* to be called when connection is dropped */ |
Willy Tarreau | 2069704 | 2007-11-15 23:26:18 +0100 | [diff] [blame] | 197 | } lbprm; /* LB parameters for all algorithms */ |
| 198 | |
Krzysztof Piotr Oledzki | 1acf217 | 2008-05-29 23:03:34 +0200 | [diff] [blame] | 199 | char *cookie_domain; /* domain used to insert the cookie */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 200 | char *cookie_name; /* name of the cookie to look for */ |
| 201 | int cookie_len; /* strlen(cookie_name), computed only once */ |
Emeric Brun | 647caf1 | 2009-06-30 17:57:00 +0200 | [diff] [blame] | 202 | char *rdp_cookie_name; /* name of the RDP cookie to look for */ |
| 203 | int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */ |
Willy Tarreau | 0173280 | 2007-11-01 22:48:15 +0100 | [diff] [blame] | 204 | char *url_param_name; /* name of the URL parameter used for hashing */ |
| 205 | int url_param_len; /* strlen(url_param_name), computed only once */ |
matt.farnsworth@nokia.com | 1c2ab96 | 2008-04-14 20:47:37 +0200 | [diff] [blame] | 206 | unsigned url_param_post_limit; /* if checking POST body for URI parameter, max body to wait for */ |
Marek Majkowski | 9c30fc1 | 2008-04-27 23:25:55 +0200 | [diff] [blame] | 207 | int uri_len_limit; /* character limit for uri balancing algorithm */ |
| 208 | int uri_dirs_depth1; /* directories+1 (slashes) limit for uri balancing algorithm */ |
Benoit | affb481 | 2009-03-25 13:02:10 +0100 | [diff] [blame] | 209 | char *hh_name; /* name of the header parameter used for hashing */ |
| 210 | int hh_len; /* strlen(hh_name), computed only once */ |
| 211 | int hh_match_domain; /* toggle use of special match function */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 212 | char *appsession_name; /* name of the cookie to look for */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 213 | int appsession_name_len; /* strlen(appsession_name), computed only once */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 214 | int appsession_len; /* length of the appsession cookie value to be used */ |
Willy Tarreau | 51041c7 | 2007-09-09 21:56:53 +0200 | [diff] [blame] | 215 | struct appsession_hash htbl_proxy; /* Per Proxy hashtable */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 216 | char *capture_name; /* beginning of the name of the cookie to capture */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 217 | int capture_namelen; /* length of the cookie name to match */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 218 | int capture_len; /* length of the string to be captured */ |
| 219 | struct uri_auth *uri_auth; /* if non-NULL, the (list of) per-URI authentications */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 220 | char *monitor_uri; /* a special URI to which we respond with HTTP/200 OK */ |
| 221 | int monitor_uri_len; /* length of the string above. 0 if unused */ |
Willy Tarreau | b80c230 | 2007-11-30 20:51:32 +0100 | [diff] [blame] | 222 | struct list mon_fail_cond; /* list of conditions to fail monitoring requests (chained) */ |
Willy Tarreau | 3a70f94 | 2008-02-15 11:15:34 +0100 | [diff] [blame] | 223 | struct { /* WARNING! check proxy_reset_timeouts() in proxy.h !!! */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 224 | int client; /* client I/O timeout (in ticks) */ |
| 225 | int tarpit; /* tarpit timeout, defaults to connect if unspecified */ |
| 226 | int queue; /* queue timeout, defaults to connect if unspecified */ |
| 227 | int connect; /* connect timeout (in ticks) */ |
| 228 | int server; /* server I/O timeout (in ticks) */ |
| 229 | int appsession; /* appsession cookie expiration */ |
| 230 | int httpreq; /* maximum time for complete HTTP request */ |
| 231 | int check; /* maximum time for complete check */ |
Willy Tarreau | 1fa3126 | 2007-12-03 00:36:16 +0100 | [diff] [blame] | 232 | } timeout; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 233 | char *id; /* proxy id */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 234 | struct list pendconns; /* pending connections with no server assigned yet */ |
| 235 | int nbpend, nbpend_max; /* number of pending connections with no server assigned yet */ |
| 236 | int totpend; /* total number of pending connections on this instance (for stats) */ |
Willy Tarreau | f1221aa | 2006-12-17 22:14:12 +0100 | [diff] [blame] | 237 | unsigned int feconn, feconn_max; /* # of active frontend sessions */ |
| 238 | unsigned int beconn, beconn_max; /* # of active backend sessions */ |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 239 | struct freq_ctr fe_sess_per_sec; /* sessions per second on the frontend */ |
Willy Tarreau | 13a34bd | 2009-05-10 18:52:49 +0200 | [diff] [blame] | 240 | unsigned int fe_sps_max; /* maximum of new sessions per second seen on the frontend */ |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 241 | struct freq_ctr be_sess_per_sec; /* sessions per second on the backend */ |
Willy Tarreau | 13a34bd | 2009-05-10 18:52:49 +0200 | [diff] [blame] | 242 | unsigned int be_sps_max; /* maximum of new sessions per second seen on the backend */ |
Willy Tarreau | 3b88d44 | 2009-04-11 20:44:08 +0200 | [diff] [blame] | 243 | long long cum_feconn, cum_beconn; /* cumulated number of processed sessions */ |
| 244 | long long cum_lbconn; /* cumulated number of sessions processed by load balancing */ |
Willy Tarreau | 8603431 | 2006-12-29 00:10:33 +0100 | [diff] [blame] | 245 | unsigned int maxconn; /* max # of active sessions on the frontend */ |
Willy Tarreau | 13a34bd | 2009-05-10 18:52:49 +0200 | [diff] [blame] | 246 | unsigned int fe_sps_lim; /* limit on new sessions per second on the frontend */ |
Willy Tarreau | 8603431 | 2006-12-29 00:10:33 +0100 | [diff] [blame] | 247 | unsigned int fullconn; /* #conns on backend above which servers are used at full load */ |
Willy Tarreau | 7ac51f6 | 2007-03-25 16:00:04 +0200 | [diff] [blame] | 248 | struct in_addr except_net, except_mask; /* don't x-forward-for for this address. FIXME: should support IPv6 */ |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 249 | struct in_addr except_to; /* don't x-original-to for this address. */ |
| 250 | struct in_addr except_mask_to; /* the netmask for except_to. */ |
Ross West | af72a1d | 2008-08-03 10:51:45 +0200 | [diff] [blame] | 251 | char *fwdfor_hdr_name; /* header to use - default: "x-forwarded-for" */ |
| 252 | int fwdfor_hdr_len; /* length of "x-forwarded-for" header */ |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 253 | char *orgto_hdr_name; /* header to use - default: "x-original-to" */ |
| 254 | int orgto_hdr_len; /* length of "x-original-to" header */ |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 255 | |
| 256 | unsigned down_trans; /* up-down transitions */ |
| 257 | unsigned down_time; /* total time the proxy was down */ |
| 258 | time_t last_change; /* last time, when the state was changed */ |
| 259 | |
Willy Tarreau | 3b88d44 | 2009-04-11 20:44:08 +0200 | [diff] [blame] | 260 | long long failed_conns, failed_resp; /* failed connect() and responses */ |
| 261 | long long retries, redispatches; /* retried and redispatched connections */ |
| 262 | long long denied_req, denied_resp; /* blocked requests/responses because of security concerns */ |
| 263 | long long failed_req; /* failed requests (eg: invalid or timeout) */ |
Willy Tarreau | 35d66b0 | 2007-01-02 00:28:21 +0100 | [diff] [blame] | 264 | long long bytes_in; /* number of bytes transferred from the client to the server */ |
| 265 | long long bytes_out; /* number of bytes transferred from the server to the client */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 266 | int conn_retries; /* maximum number of connect retries */ |
Willy Tarreau | 977b8e4 | 2006-12-29 14:19:17 +0100 | [diff] [blame] | 267 | int cap; /* supported capabilities (PR_CAP_*) */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 268 | struct sockaddr_in source_addr; /* the address to which we want to bind for connect() */ |
Willy Tarreau | 4864c35 | 2008-01-14 16:36:15 +0100 | [diff] [blame] | 269 | #if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 270 | struct sockaddr_in tproxy_addr; /* non-local address we want to bind to for connect() */ |
| 271 | #endif |
Willy Tarreau | d53f96b | 2009-02-04 18:46:54 +0100 | [diff] [blame] | 272 | int iface_len; /* bind interface name length */ |
| 273 | char *iface_name; /* bind interface name or NULL */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 274 | struct proxy *next; |
Robert Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 275 | struct logsrv logsrv1, logsrv2; /* 2 syslog servers */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 276 | signed char logfac1, logfac2; /* log facility for both servers. -1 = disabled */ |
| 277 | int loglev1, loglev2; /* log level for each server, 7 by default */ |
Willy Tarreau | f7edefa | 2009-05-10 17:20:05 +0200 | [diff] [blame] | 278 | int minlvl1, minlvl2; /* minimum log level for each server, 0 by default */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 279 | int to_log; /* things to be logged (LW_*) */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 280 | int stop_time; /* date to stop listening, when stopping != 0 (int ticks) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 281 | int nb_reqadd, nb_rspadd; |
| 282 | struct hdr_exp *req_exp; /* regular expressions for request headers */ |
| 283 | struct hdr_exp *rsp_exp; /* regular expressions for response headers */ |
| 284 | int nb_req_cap, nb_rsp_cap; /* # of headers to be captured */ |
| 285 | struct cap_hdr *req_cap; /* chained list of request headers to be captured */ |
| 286 | struct cap_hdr *rsp_cap; /* chained list of response headers to be captured */ |
Willy Tarreau | cf7f320 | 2007-05-13 22:46:04 +0200 | [diff] [blame] | 287 | struct pool_head *req_cap_pool, /* pools of pre-allocated char ** used to build the sessions */ |
| 288 | *rsp_cap_pool; |
Willy Tarreau | 1d4154a | 2007-05-13 22:57:02 +0200 | [diff] [blame] | 289 | struct pool_head *hdr_idx_pool; /* pools of pre-allocated int* used for headers indexing */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 290 | char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */ |
| 291 | int grace; /* grace time after stop request */ |
Willy Tarreau | f3c6920 | 2006-07-09 16:42:34 +0200 | [diff] [blame] | 292 | char *check_req; /* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */ |
| 293 | int check_len; /* Length of the HTTP or SSL3 request */ |
Willy Tarreau | 0f77253 | 2006-12-23 20:51:41 +0100 | [diff] [blame] | 294 | struct chunk errmsg[HTTP_ERR_SIZE]; /* default or customized error messages for known errors */ |
Willy Tarreau | dcd4771 | 2007-11-04 23:35:08 +0100 | [diff] [blame] | 295 | int uuid; /* universally unique proxy ID, used for SNMP */ |
| 296 | int next_svid; /* next server-id, used for SNMP */ |
Willy Tarreau | c73ce2b | 2008-01-06 10:55:10 +0100 | [diff] [blame] | 297 | unsigned int backlog; /* force the frontend's listen backlog */ |
Willy Tarreau | 0b9c02c | 2009-02-04 22:05:05 +0100 | [diff] [blame] | 298 | unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */ |
Willy Tarreau | f073a83 | 2009-03-01 23:21:47 +0100 | [diff] [blame] | 299 | struct error_snapshot invalid_req, invalid_rep; /* captures of last errors */ |
Willy Tarreau | 84b57da | 2009-06-14 11:10:45 +0200 | [diff] [blame] | 300 | |
| 301 | /* used only during configuration parsing */ |
| 302 | int no_options; /* PR_O_REDISP, PR_O_TRANSP, ... */ |
| 303 | int no_options2; /* PR_O2_* */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 304 | }; |
| 305 | |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 306 | struct switching_rule { |
| 307 | struct list list; /* list linked to from the proxy */ |
| 308 | struct acl_cond *cond; /* acl condition to meet */ |
| 309 | union { |
| 310 | struct proxy *backend; /* target backend */ |
| 311 | char *name; /* target backend name during config parsing */ |
| 312 | } be; |
| 313 | }; |
| 314 | |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 315 | struct redirect_rule { |
| 316 | struct list list; /* list linked to from the proxy */ |
| 317 | struct acl_cond *cond; /* acl condition to meet */ |
| 318 | int type; |
| 319 | int rdr_len; |
| 320 | char *rdr_str; |
| 321 | int code; |
Willy Tarreau | 79da469 | 2008-11-19 20:03:04 +0100 | [diff] [blame] | 322 | unsigned int flags; |
Willy Tarreau | 0140f25 | 2008-11-19 21:07:09 +0100 | [diff] [blame] | 323 | int cookie_len; |
| 324 | char *cookie_str; |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 325 | }; |
| 326 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 327 | extern struct proxy *proxy; |
Willy Tarreau | dcd4771 | 2007-11-04 23:35:08 +0100 | [diff] [blame] | 328 | extern int next_pxid; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 329 | |
| 330 | #endif /* _TYPES_PROXY_H */ |
| 331 | |
| 332 | /* |
| 333 | * Local variables: |
| 334 | * c-indent-level: 8 |
| 335 | * c-basic-offset: 8 |
| 336 | * End: |
| 337 | */ |