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