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 | |
| 5 | Copyright (C) 2000-2006 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 | */ |
| 21 | |
| 22 | #ifndef _TYPES_PROXY_H |
| 23 | #define _TYPES_PROXY_H |
| 24 | |
| 25 | #include <netinet/in.h> |
| 26 | #include <arpa/inet.h> |
| 27 | #include <sys/socket.h> |
| 28 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 29 | #include <common/appsession.h> |
| 30 | #include <common/chtbl.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 31 | #include <common/config.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 32 | #include <common/mini-clist.h> |
| 33 | #include <common/regex.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 34 | |
| 35 | #include <types/buffers.h> |
| 36 | #include <types/session.h> |
| 37 | #include <types/server.h> |
| 38 | |
| 39 | /* values for proxy->state */ |
| 40 | #define PR_STNEW 0 |
| 41 | #define PR_STIDLE 1 |
| 42 | #define PR_STRUN 2 |
| 43 | #define PR_STSTOPPED 3 |
| 44 | #define PR_STPAUSED 4 |
| 45 | #define PR_STERROR 5 |
| 46 | |
| 47 | /* values for proxy->mode */ |
| 48 | #define PR_MODE_TCP 0 |
| 49 | #define PR_MODE_HTTP 1 |
| 50 | #define PR_MODE_HEALTH 2 |
| 51 | |
| 52 | /* return codes for start_proxies */ |
| 53 | #define ERR_NONE 0 /* no error */ |
| 54 | #define ERR_RETRYABLE 1 /* retryable error, may be cumulated */ |
| 55 | #define ERR_FATAL 2 /* fatal error, may be cumulated */ |
| 56 | |
| 57 | |
| 58 | struct listener { |
| 59 | int fd; /* the listen socket */ |
| 60 | struct sockaddr_storage addr; /* the address we listen to */ |
| 61 | struct listener *next; /* next address or NULL */ |
| 62 | }; |
| 63 | |
| 64 | struct proxy { |
| 65 | struct listener *listen; /* the listen addresses and sockets */ |
| 66 | struct in_addr mon_net, mon_mask; /* don't forward connections from this net (network order) FIXME: should support IPv6 */ |
| 67 | int state; /* proxy state */ |
| 68 | struct sockaddr_in dispatch_addr; /* the default address to connect to */ |
| 69 | struct server *srv; /* known servers */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 70 | int srv_act, srv_bck; /* # of running servers */ |
| 71 | int tot_wact, tot_wbck; /* total weights of active and backup servers */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 72 | struct server **srv_map; /* the server map used to apply weights */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 73 | int srv_map_sz; /* the size of the effective server map */ |
| 74 | int srv_rr_idx; /* next server to be elected in round robin mode */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 75 | char *cookie_name; /* name of the cookie to look for */ |
| 76 | int cookie_len; /* strlen(cookie_name), computed only once */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 77 | char *appsession_name; /* name of the cookie to look for */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 78 | int appsession_name_len; /* strlen(appsession_name), computed only once */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 79 | int appsession_len; /* length of the appsession cookie value to be used */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 80 | int appsession_timeout; |
| 81 | CHTbl htbl_proxy; /* Per Proxy hashtable */ |
| 82 | char *capture_name; /* beginning of the name of the cookie to capture */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 83 | int capture_namelen; /* length of the cookie name to match */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 84 | int capture_len; /* length of the string to be captured */ |
| 85 | 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] | 86 | char *monitor_uri; /* a special URI to which we respond with HTTP/200 OK */ |
| 87 | int monitor_uri_len; /* length of the string above. 0 if unused */ |
| 88 | int clitimeout; /* client I/O timeout (in milliseconds) */ |
| 89 | int srvtimeout; /* server I/O timeout (in milliseconds) */ |
| 90 | int contimeout; /* connect timeout (in milliseconds) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 91 | char *id; /* proxy id */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 92 | struct list pendconns; /* pending connections with no server assigned yet */ |
| 93 | int nbpend, nbpend_max; /* number of pending connections with no server assigned yet */ |
| 94 | int totpend; /* total number of pending connections on this instance (for stats) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 95 | unsigned int nbconn, nbconn_max; /* # of active sessions */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 96 | unsigned int cum_conn; /* cumulated number of processed sessions */ |
| 97 | unsigned int maxconn; /* max # of active sessions */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 98 | unsigned failed_conns, failed_resp; /* failed connect() and responses */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 99 | unsigned failed_secu; /* blocked responses because of security concerns */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 100 | int conn_retries; /* maximum number of connect retries */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 101 | int options; /* PR_O_REDISP, PR_O_TRANSP, ... */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 102 | int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 103 | struct sockaddr_in source_addr; /* the address to which we want to bind for connect() */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 104 | struct proxy *next; |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 105 | struct sockaddr_in logsrv1, logsrv2; /* 2 syslog servers */ |
| 106 | signed char logfac1, logfac2; /* log facility for both servers. -1 = disabled */ |
| 107 | int loglev1, loglev2; /* log level for each server, 7 by default */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 108 | int to_log; /* things to be logged (LW_*) */ |
| 109 | struct timeval stop_time; /* date to stop listening, when stopping != 0 */ |
| 110 | int nb_reqadd, nb_rspadd; |
| 111 | struct hdr_exp *req_exp; /* regular expressions for request headers */ |
| 112 | struct hdr_exp *rsp_exp; /* regular expressions for response headers */ |
| 113 | int nb_req_cap, nb_rsp_cap; /* # of headers to be captured */ |
| 114 | struct cap_hdr *req_cap; /* chained list of request headers to be captured */ |
| 115 | struct cap_hdr *rsp_cap; /* chained list of response headers to be captured */ |
| 116 | void *req_cap_pool, *rsp_cap_pool; /* pools of pre-allocated char ** used to build the sessions */ |
| 117 | char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */ |
| 118 | int grace; /* grace time after stop request */ |
Willy Tarreau | f3c6920 | 2006-07-09 16:42:34 +0200 | [diff] [blame] | 119 | char *check_req; /* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */ |
| 120 | int check_len; /* Length of the HTTP or SSL3 request */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 121 | struct { |
| 122 | char *msg400; /* message for error 400 */ |
| 123 | int len400; /* message length for error 400 */ |
| 124 | char *msg403; /* message for error 403 */ |
| 125 | int len403; /* message length for error 403 */ |
| 126 | char *msg408; /* message for error 408 */ |
| 127 | int len408; /* message length for error 408 */ |
| 128 | char *msg500; /* message for error 500 */ |
| 129 | int len500; /* message length for error 500 */ |
| 130 | char *msg502; /* message for error 502 */ |
| 131 | int len502; /* message length for error 502 */ |
| 132 | char *msg503; /* message for error 503 */ |
| 133 | int len503; /* message length for error 503 */ |
| 134 | char *msg504; /* message for error 504 */ |
| 135 | int len504; /* message length for error 504 */ |
| 136 | } errmsg; |
| 137 | }; |
| 138 | |
| 139 | extern struct proxy *proxy; |
| 140 | |
| 141 | #endif /* _TYPES_PROXY_H */ |
| 142 | |
| 143 | /* |
| 144 | * Local variables: |
| 145 | * c-indent-level: 8 |
| 146 | * c-basic-offset: 8 |
| 147 | * End: |
| 148 | */ |