Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 5b4c2b5 | 2009-10-03 11:21:53 +0200 | [diff] [blame] | 2 | * include/types/proxy.h |
| 3 | * This file defines everything related to proxies. |
| 4 | * |
Willy Tarreau | ff011f2 | 2011-01-06 17:51:27 +0100 | [diff] [blame] | 5 | * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu |
Willy Tarreau | 5b4c2b5 | 2009-10-03 11:21:53 +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 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 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 | c7e4238 | 2012-08-24 19:22:53 +0200 | [diff] [blame] | 30 | #include <common/chunk.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 31 | #include <common/config.h> |
Willy Tarreau | 35b51c6 | 2018-09-10 15:38:55 +0200 | [diff] [blame] | 32 | #include <common/http.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 | a8cff1d | 2007-04-09 16:10:57 +0200 | [diff] [blame] | 35 | #include <common/tools.h> |
Christopher Faulet | ff8abcd | 2017-06-02 15:33:24 +0200 | [diff] [blame] | 36 | #include <common/hathreads.h> |
| 37 | |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 38 | #include <eb32tree.h> |
Willy Tarreau | f79d950 | 2014-03-15 07:22:35 +0100 | [diff] [blame] | 39 | #include <ebistree.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 40 | |
Willy Tarreau | eb0c614 | 2007-05-07 00:53:22 +0200 | [diff] [blame] | 41 | #include <types/acl.h> |
Willy Tarreau | 5b4c2b5 | 2009-10-03 11:21:53 +0200 | [diff] [blame] | 42 | #include <types/backend.h> |
Willy Tarreau | 638698d | 2020-03-11 14:10:23 +0100 | [diff] [blame] | 43 | #include <types/checks.h> |
Krzysztof Piotr Oledzki | 052d4fd | 2009-10-04 14:52:57 +0200 | [diff] [blame] | 44 | #include <types/counters.h> |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 45 | #include <types/filters.h> |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 46 | #include <types/freq_ctr.h> |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 47 | #include <types/listener.h> |
Robert Tsai | 81ae195 | 2007-12-05 10:47:29 +0100 | [diff] [blame] | 48 | #include <types/log.h> |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 49 | #include <types/obj_type.h> |
Willy Tarreau | cd3b094 | 2012-04-27 21:52:18 +0200 | [diff] [blame] | 50 | #include <types/sample.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 51 | #include <types/server.h> |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 52 | #include <types/stick_table.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 53 | |
| 54 | /* values for proxy->state */ |
Willy Tarreau | 8379c17 | 2013-12-06 21:29:13 +0100 | [diff] [blame] | 55 | enum pr_state { |
Willy Tarreau | 562515c | 2011-07-25 08:11:52 +0200 | [diff] [blame] | 56 | PR_STNEW = 0, /* proxy has not been initialized yet */ |
| 57 | PR_STREADY, /* proxy has been initialized and is ready */ |
| 58 | PR_STFULL, /* frontend is full (maxconn reached) */ |
| 59 | PR_STPAUSED, /* frontend is paused (during hot restart) */ |
| 60 | PR_STSTOPPED, /* proxy is stopped (end of a restart) */ |
| 61 | PR_STERROR, /* proxy experienced an unrecoverable error */ |
Willy Tarreau | 8379c17 | 2013-12-06 21:29:13 +0100 | [diff] [blame] | 62 | } __attribute__((packed)); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 63 | |
| 64 | /* values for proxy->mode */ |
Willy Tarreau | 8379c17 | 2013-12-06 21:29:13 +0100 | [diff] [blame] | 65 | enum pr_mode { |
| 66 | PR_MODE_TCP = 0, |
| 67 | PR_MODE_HTTP, |
| 68 | PR_MODE_HEALTH, |
William Lallemand | cf62f7e | 2018-10-26 14:47:40 +0200 | [diff] [blame] | 69 | PR_MODE_CLI, |
Willy Tarreau | 8379c17 | 2013-12-06 21:29:13 +0100 | [diff] [blame] | 70 | } __attribute__((packed)); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 71 | |
Baptiste Assmann | e11cfcd | 2015-08-19 16:44:03 +0200 | [diff] [blame] | 72 | enum PR_SRV_STATE_FILE { |
| 73 | PR_SRV_STATE_FILE_UNSPEC = 0, |
| 74 | PR_SRV_STATE_FILE_NONE, |
| 75 | PR_SRV_STATE_FILE_GLOBAL, |
| 76 | PR_SRV_STATE_FILE_LOCAL, |
| 77 | }; |
| 78 | |
| 79 | |
Willy Tarreau | 977b8e4 | 2006-12-29 14:19:17 +0100 | [diff] [blame] | 80 | /* flag values for proxy->cap. This is a bitmask of capabilities supported by the proxy */ |
| 81 | #define PR_CAP_NONE 0x0000 |
| 82 | #define PR_CAP_FE 0x0001 |
| 83 | #define PR_CAP_BE 0x0002 |
Christopher Faulet | 898566e | 2016-10-26 11:06:28 +0200 | [diff] [blame] | 84 | #define PR_CAP_LISTEN (PR_CAP_FE|PR_CAP_BE) |
Willy Tarreau | 977b8e4 | 2006-12-29 14:19:17 +0100 | [diff] [blame] | 85 | |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 86 | /* bits for proxy->options */ |
| 87 | #define PR_O_REDISP 0x00000001 /* allow reconnection to dispatch in case of errors */ |
| 88 | #define PR_O_TRANSP 0x00000002 /* transparent mode : use original DEST as dispatch */ |
Willy Tarreau | d8fecee | 2015-08-05 14:12:31 +0200 | [diff] [blame] | 89 | |
| 90 | /* HTTP server-side reuse */ |
| 91 | #define PR_O_REUSE_NEVR 0x00000000 /* never reuse a shared connection */ |
| 92 | #define PR_O_REUSE_SAFE 0x00000004 /* only reuse a shared connection when it's safe to do so */ |
| 93 | #define PR_O_REUSE_AGGR 0x00000008 /* aggressively reuse a shared connection */ |
| 94 | #define PR_O_REUSE_ALWS 0x0000000C /* always reuse a shared connection */ |
| 95 | #define PR_O_REUSE_MASK 0x0000000C /* mask to retrieve shared connection preferences */ |
| 96 | |
| 97 | /* unused: 0x10 */ |
Willy Tarreau | 9420b12 | 2013-12-15 18:58:25 +0100 | [diff] [blame] | 98 | #define PR_O_PREF_LAST 0x00000020 /* prefer last server */ |
Willy Tarreau | 1620ec3 | 2011-08-06 17:05:02 +0200 | [diff] [blame] | 99 | #define PR_O_DISPATCH 0x00000040 /* use dispatch mode */ |
Willy Tarreau | 0d1fdf7 | 2015-05-27 16:44:02 +0200 | [diff] [blame] | 100 | #define PR_O_FORCED_ID 0x00000080 /* proxy's ID was forced in the configuration */ |
Willy Tarreau | 87cf514 | 2011-08-19 22:57:24 +0200 | [diff] [blame] | 101 | #define PR_O_FWDFOR 0x00000100 /* conditionally insert x-forwarded-for with client address */ |
Willy Tarreau | 0f228a0 | 2015-05-01 15:37:53 +0200 | [diff] [blame] | 102 | #define PR_O_IGNORE_PRB 0x00000200 /* ignore empty requests (aborts and timeouts) */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 103 | #define PR_O_NULLNOLOG 0x00000400 /* a connect without request will not be logged */ |
Willy Tarreau | 9fbe18e | 2015-05-01 22:42:08 +0200 | [diff] [blame] | 104 | #define PR_O_WREQ_BODY 0x00000800 /* always wait for the HTTP request body */ |
| 105 | /* unused: 0x1000 */ |
Willy Tarreau | 87cf514 | 2011-08-19 22:57:24 +0200 | [diff] [blame] | 106 | #define PR_O_FF_ALWAYS 0x00002000 /* always set x-forwarded-for */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 107 | #define PR_O_PERSIST 0x00004000 /* server persistence stays effective even when server is down */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 108 | #define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the stream to complete */ |
Willy Tarreau | 02bce8b | 2014-01-30 00:15:28 +0100 | [diff] [blame] | 109 | /* unused: 0x00010000 */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 110 | #define PR_O_CHK_CACHE 0x00020000 /* require examination of cacheability of the 'set-cookie' field */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 111 | #define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side streams */ |
| 112 | #define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side streams */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 113 | #define PR_O_USE_ALL_BK 0x00100000 /* load-balance between backup servers */ |
Willy Tarreau | 02bce8b | 2014-01-30 00:15:28 +0100 | [diff] [blame] | 114 | /* unused: 0x00020000 */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 115 | #define PR_O_TCP_NOLING 0x00400000 /* disable lingering on client and server connections */ |
| 116 | #define PR_O_ABRT_CLOSE 0x00800000 /* immediately abort request when client closes */ |
Willy Tarreau | 3168223 | 2007-11-29 15:38:04 +0100 | [diff] [blame] | 117 | |
Willy Tarreau | 70dffda | 2014-01-30 03:07:23 +0100 | [diff] [blame] | 118 | #define PR_O_HTTP_KAL 0x00000000 /* HTTP keep-alive mode (http-keep-alive) */ |
Christopher Faulet | 315b39c | 2018-09-21 16:26:19 +0200 | [diff] [blame] | 119 | #define PR_O_HTTP_CLO 0x01000000 /* HTTP close mode (httpclose) */ |
| 120 | #define PR_O_HTTP_SCL 0x02000000 /* HTTP server close mode (http-server-close) */ |
Christopher Faulet | 73e8ede | 2019-07-16 15:04:46 +0200 | [diff] [blame] | 121 | #define PR_O_HTTP_MODE 0x03000000 /* MASK to retrieve the HTTP mode */ |
| 122 | /* unused: 0x04000000 */ |
Christopher Faulet | 315b39c | 2018-09-21 16:26:19 +0200 | [diff] [blame] | 123 | |
Baptiste Assmann | 69e273f | 2013-12-11 00:52:19 +0100 | [diff] [blame] | 124 | #define PR_O_TCPCHK_SSL 0x08000000 /* at least one TCPCHECK connect rule requires SSL */ |
Joseph Herlant | 59dd295 | 2018-11-15 11:46:55 -0800 | [diff] [blame] | 125 | #define PR_O_CONTSTATS 0x10000000 /* continuous counters */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 126 | #define PR_O_HTTP_PROXY 0x20000000 /* Enable stream to use HTTP proxy operations */ |
Willy Tarreau | 48494c0 | 2007-11-30 10:41:39 +0100 | [diff] [blame] | 127 | #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] | 128 | #define PR_O_ORGTO 0x80000000 /* insert x-original-to with destination address */ |
Willy Tarreau | 66aa61f | 2009-01-18 21:44:07 +0100 | [diff] [blame] | 129 | |
| 130 | /* bits for proxy->options2 */ |
| 131 | #define PR_O2_SPLIC_REQ 0x00000001 /* transfer requests using linux kernel's splice() */ |
| 132 | #define PR_O2_SPLIC_RTR 0x00000002 /* transfer responses using linux kernel's splice() */ |
| 133 | #define PR_O2_SPLIC_AUT 0x00000004 /* automatically use linux kernel's splice() */ |
| 134 | #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] | 135 | #define PR_O2_REQBUG_OK 0x00000008 /* let buggy requests pass through */ |
| 136 | #define PR_O2_RSPBUG_OK 0x00000010 /* let buggy responses pass through */ |
Willy Tarreau | c9bd0cc | 2009-05-10 11:57:02 +0200 | [diff] [blame] | 137 | #define PR_O2_NOLOGNORM 0x00000020 /* don't log normal traffic, only errors and retries */ |
| 138 | #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] | 139 | #define PR_O2_SMARTACC 0x00000080 /* don't immediately ACK request after accept */ |
Willy Tarreau | d88edf2 | 2009-06-14 15:48:17 +0200 | [diff] [blame] | 140 | #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] | 141 | #define PR_O2_RDPC_PRST 0x00000200 /* Actvate rdp cookie analyser */ |
Emeric Brun | 3a058f3 | 2009-06-30 18:26:00 +0200 | [diff] [blame] | 142 | #define PR_O2_CLFLOG 0x00000400 /* log into clf format */ |
Krzysztof Piotr Oledzki | 213014e | 2009-09-27 15:50:02 +0200 | [diff] [blame] | 143 | #define PR_O2_LOGHCHKS 0x00000800 /* log health checks */ |
Jamie Gloudon | 801a0a3 | 2012-08-25 00:18:33 -0400 | [diff] [blame] | 144 | #define PR_O2_INDEPSTR 0x00001000 /* independent streams, don't update rex on write */ |
Krzysztof Piotr Oledzki | aeebf9b | 2009-10-04 15:43:17 +0200 | [diff] [blame] | 145 | #define PR_O2_SOCKSTAT 0x00002000 /* collect & provide separate statistics for sockets */ |
Cyril Bonté | b21570a | 2009-11-29 20:04:48 +0100 | [diff] [blame] | 146 | |
Christopher Faulet | 98fbe95 | 2019-07-22 16:18:24 +0200 | [diff] [blame] | 147 | #define PR_O2_H1_ADJ_BUGCLI 0x00008000 /* adjust the case of h1 headers of the response for bogus clients */ |
| 148 | #define PR_O2_H1_ADJ_BUGSRV 0x00004000 /* adjust the case of h1 headers of the request for bogus servers */ |
| 149 | |
| 150 | /* unused: 0x00010000 */ |
Cyril Bonté | b21570a | 2009-11-29 20:04:48 +0100 | [diff] [blame] | 151 | |
Willy Tarreau | 1620ec3 | 2011-08-06 17:05:02 +0200 | [diff] [blame] | 152 | #define PR_O2_NODELAY 0x00020000 /* fully interactive mode, never delay outgoing data */ |
Willy Tarreau | 88d349d | 2010-01-25 12:15:43 +0100 | [diff] [blame] | 153 | #define PR_O2_USE_PXHDR 0x00040000 /* use Proxy-Connection for proxy requests */ |
Willy Tarreau | ef78104 | 2010-01-27 11:53:01 +0100 | [diff] [blame] | 154 | #define PR_O2_CHK_SNDST 0x00080000 /* send the state of each server along with HTTP health checks */ |
William Lallemand | b7ff6a3 | 2012-03-02 14:35:21 +0100 | [diff] [blame] | 155 | |
| 156 | #define PR_O2_SRC_ADDR 0x00100000 /* get the source ip and port for logs */ |
| 157 | |
Willy Tarreau | 8a8e1d9 | 2010-04-05 16:15:16 +0200 | [diff] [blame] | 158 | #define PR_O2_FAKE_KA 0x00200000 /* pretend we do keep-alive with server eventhough we close */ |
Christopher Faulet | e5870d8 | 2020-04-15 11:32:03 +0200 | [diff] [blame] | 159 | /* unused : 0x00400000..0x80000000 */ |
Rauf Kuliyev | 38b4156 | 2011-01-04 15:14:13 +0100 | [diff] [blame] | 160 | |
Willy Tarreau | 1620ec3 | 2011-08-06 17:05:02 +0200 | [diff] [blame] | 161 | /* server health checks */ |
| 162 | #define PR_O2_CHK_NONE 0x00000000 /* no L7 health checks configured (TCP by default) */ |
Baptiste Assmann | 5ecb77f | 2013-10-06 23:24:13 +0200 | [diff] [blame] | 163 | #define PR_O2_TCPCHK_CHK 0x90000000 /* use TCPCHK check for server health */ |
Simon Horman | 98637e5 | 2014-06-20 12:30:16 +0900 | [diff] [blame] | 164 | #define PR_O2_EXT_CHK 0xA0000000 /* use external command for server health */ |
Christopher Faulet | 267b01b | 2020-04-04 10:27:09 +0200 | [diff] [blame] | 165 | /* unused: 0xB0000000 to 0xF000000, reserved for health checks */ |
Willy Tarreau | 1620ec3 | 2011-08-06 17:05:02 +0200 | [diff] [blame] | 166 | #define PR_O2_CHK_ANY 0xF0000000 /* Mask to cover any check */ |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 167 | /* end of proxy->options2 */ |
| 168 | |
Willy Tarreau | 6740213 | 2012-05-31 20:40:20 +0200 | [diff] [blame] | 169 | /* Cookie settings for pr->ck_opts */ |
Willy Tarreau | b5ba17e | 2012-05-31 20:43:11 +0200 | [diff] [blame] | 170 | #define PR_CK_RW 0x00000001 /* rewrite all direct cookies with the right serverid */ |
| 171 | #define PR_CK_IND 0x00000002 /* keep only indirect cookies */ |
| 172 | #define PR_CK_INS 0x00000004 /* insert cookies when not accessing a server directly */ |
| 173 | #define PR_CK_PFX 0x00000008 /* rewrite all cookies by prefixing the right serverid */ |
| 174 | #define PR_CK_ANY (PR_CK_RW | PR_CK_IND | PR_CK_INS | PR_CK_PFX) |
| 175 | #define PR_CK_NOC 0x00000010 /* add a 'Cache-control' header with the cookie */ |
| 176 | #define PR_CK_POST 0x00000020 /* don't insert cookies for requests other than a POST */ |
| 177 | #define PR_CK_PSV 0x00000040 /* cookie ... preserve */ |
Willy Tarreau | 4992dd2 | 2012-05-31 21:02:17 +0200 | [diff] [blame] | 178 | #define PR_CK_HTTPONLY 0x00000080 /* emit the "HttpOnly" attribute */ |
| 179 | #define PR_CK_SECURE 0x00000100 /* emit the "Secure" attribute */ |
Olivier Houchard | 4e69404 | 2017-03-14 20:01:29 +0100 | [diff] [blame] | 180 | #define PR_CK_DYNAMIC 0x00000200 /* create dynamic cookies for each server */ |
Willy Tarreau | 6740213 | 2012-05-31 20:40:20 +0200 | [diff] [blame] | 181 | |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 182 | /* bits for sticking rules */ |
| 183 | #define STK_IS_MATCH 0x00000001 /* match on request fetch */ |
| 184 | #define STK_IS_STORE 0x00000002 /* store on request fetch */ |
| 185 | #define STK_ON_RSP 0x00000004 /* store on response fetch */ |
Hervé COMMOWICK | 698ae00 | 2010-01-12 09:25:13 +0100 | [diff] [blame] | 186 | |
Baptiste Assmann | 8a027cc | 2015-07-03 11:03:33 +0200 | [diff] [blame] | 187 | /* diff bits for proxy_find_best_match */ |
| 188 | #define PR_FBM_MISMATCH_ID 0x01 |
| 189 | #define PR_FBM_MISMATCH_NAME 0x02 |
| 190 | #define PR_FBM_MISMATCH_PROXYTYPE 0x04 |
| 191 | |
Olivier Houchard | a254a37 | 2019-04-05 15:30:12 +0200 | [diff] [blame] | 192 | /* Bits for the different retry causes */ |
| 193 | #define PR_RE_CONN_FAILED 0x00000001 /* Retry if we failed to connect */ |
| 194 | #define PR_RE_DISCONNECTED 0x00000002 /* Retry if we got disconnected with no answer */ |
| 195 | #define PR_RE_TIMEOUT 0x00000004 /* Retry if we got a server timeout before we got any data */ |
| 196 | #define PR_RE_404 0x00000008 /* Retry if we got a 404 */ |
| 197 | #define PR_RE_408 0x00000010 /* Retry if we got a 408 */ |
| 198 | #define PR_RE_425 0x00000020 /* Retry if we got a 425 */ |
| 199 | #define PR_RE_500 0x00000040 /* Retry if we got a 500 */ |
| 200 | #define PR_RE_501 0x00000080 /* Retry if we got a 501 */ |
| 201 | #define PR_RE_502 0x00000100 /* Retry if we got a 502 */ |
| 202 | #define PR_RE_503 0x00000200 /* Retry if we got a 503 */ |
| 203 | #define PR_RE_504 0x00000400 /* Retry if we got a 504 */ |
| 204 | #define PR_RE_STATUS_MASK (PR_RE_404 | PR_RE_408 | PR_RE_425 | \ |
| 205 | PR_RE_425 | PR_RE_500 | PR_RE_501 | \ |
| 206 | PR_RE_502 | PR_RE_503 | PR_RE_504) |
Olivier Houchard | 865d839 | 2019-05-03 22:46:27 +0200 | [diff] [blame] | 207 | /* 0x00000800, 0x00001000, 0x00002000, 0x00004000 and 0x00008000 unused, |
| 208 | * reserved for eventual future status codes |
| 209 | */ |
| 210 | #define PR_RE_EARLY_ERROR 0x00010000 /* Retry if we failed at sending early data */ |
Olivier Houchard | e3249a9 | 2019-05-03 23:01:47 +0200 | [diff] [blame] | 211 | #define PR_RE_JUNK_REQUEST 0x00020000 /* We received an incomplete or garbage response */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 212 | struct stream; |
Thierry FOURNIER | ac836ba | 2014-12-16 15:41:18 +0100 | [diff] [blame] | 213 | |
Willy Tarreau | 7480f32 | 2018-09-06 19:41:22 +0200 | [diff] [blame] | 214 | struct http_snapshot { |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 215 | unsigned int sid; /* ID of the faulty stream */ |
Willy Tarreau | 078272e | 2010-12-12 12:46:33 +0100 | [diff] [blame] | 216 | unsigned int state; /* message state before the error (when saved) */ |
Willy Tarreau | d04b1bc | 2012-05-08 11:03:10 +0200 | [diff] [blame] | 217 | unsigned int b_flags; /* buffer flags */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 218 | unsigned int s_flags; /* stream flags */ |
Willy Tarreau | 7480f32 | 2018-09-06 19:41:22 +0200 | [diff] [blame] | 219 | |
Willy Tarreau | d04b1bc | 2012-05-08 11:03:10 +0200 | [diff] [blame] | 220 | unsigned int t_flags; /* transaction flags */ |
| 221 | unsigned int m_flags; /* message flags */ |
Willy Tarreau | d04b1bc | 2012-05-08 11:03:10 +0200 | [diff] [blame] | 222 | unsigned long long m_clen; /* chunk len for this message */ |
| 223 | unsigned long long m_blen; /* body len for this message */ |
Willy Tarreau | 7480f32 | 2018-09-06 19:41:22 +0200 | [diff] [blame] | 224 | }; |
| 225 | |
Christopher Faulet | e44769b | 2018-11-29 23:01:45 +0100 | [diff] [blame] | 226 | struct h1_snapshot { |
| 227 | unsigned int state; /* H1 message state when the error occurred */ |
| 228 | unsigned int c_flags; /* H1 connection flags */ |
| 229 | unsigned int s_flags; /* H1 stream flags */ |
| 230 | unsigned int m_flags; /* H1 message flags */ |
| 231 | unsigned long long m_clen; /* chunk len for this message */ |
| 232 | unsigned long long m_blen; /* body len for this message */ |
| 233 | }; |
| 234 | |
Willy Tarreau | 7480f32 | 2018-09-06 19:41:22 +0200 | [diff] [blame] | 235 | union error_snapshot_ctx { |
| 236 | struct http_snapshot http; |
Christopher Faulet | e44769b | 2018-11-29 23:01:45 +0100 | [diff] [blame] | 237 | struct h1_snapshot h1; |
Willy Tarreau | 7480f32 | 2018-09-06 19:41:22 +0200 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | struct error_snapshot { |
| 241 | /**** common part ****/ |
| 242 | struct timeval when; /* date of this event, (tv_sec == 0) means "never" */ |
| 243 | /* @16 */ |
Willy Tarreau | 4bc7d90 | 2018-09-07 20:07:17 +0200 | [diff] [blame] | 244 | void (*show)(struct buffer *, const struct error_snapshot *); /* dump function */ |
Willy Tarreau | 7480f32 | 2018-09-06 19:41:22 +0200 | [diff] [blame] | 245 | unsigned long long buf_ofs; /* relative position of the buffer's input inside its container */ |
| 246 | /* @32 */ |
| 247 | unsigned int buf_out; /* pending output bytes _before_ the buffer's input (0..buf->data-1) */ |
| 248 | unsigned int buf_len; /* original length of the last invalid request/response (0..buf->data-1-buf_out) */ |
| 249 | unsigned int buf_err; /* buffer-relative position where the error was detected (0..len-1) */ |
| 250 | unsigned int buf_wrap; /* buffer-relative position where the buffer is expected to wrap (1..buf_size) */ |
| 251 | /* @48 */ |
| 252 | struct proxy *oe; /* other end = frontend or backend involved */ |
| 253 | struct server *srv; /* server associated with the error (or NULL) */ |
| 254 | /* @64 */ |
| 255 | unsigned int ev_id; /* event number (counter incremented for each capture) */ |
| 256 | /* @68: 4 bytes hole here */ |
| 257 | struct sockaddr_storage src; /* client's address */ |
| 258 | |
| 259 | /**** protocol-specific part ****/ |
| 260 | union error_snapshot_ctx ctx; |
Willy Tarreau | 4bc7d90 | 2018-09-07 20:07:17 +0200 | [diff] [blame] | 261 | char buf[0]; /* copy of the beginning of the message for bufsize bytes */ |
Willy Tarreau | f073a83 | 2009-03-01 23:21:47 +0100 | [diff] [blame] | 262 | }; |
| 263 | |
Simon Horman | 0ba0e4a | 2015-01-30 11:23:00 +0900 | [diff] [blame] | 264 | struct email_alert { |
| 265 | struct list list; |
Christopher Faulet | 5d503fc | 2020-03-30 20:34:34 +0200 | [diff] [blame] | 266 | struct tcpcheck_rules rules; |
Christopher Faulet | 0108bb3 | 2017-10-20 21:34:32 +0200 | [diff] [blame] | 267 | struct server *srv; |
Simon Horman | 0ba0e4a | 2015-01-30 11:23:00 +0900 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | struct email_alertq { |
| 271 | struct list email_alerts; |
| 272 | struct check check; /* Email alerts are implemented using existing check |
| 273 | * code even though they are not checks. This structure |
| 274 | * is as a parameter to the check code. |
| 275 | * Each check corresponds to a mailer */ |
Christopher Faulet | 9dcf9b6 | 2017-11-13 10:34:01 +0100 | [diff] [blame] | 276 | __decl_hathreads(HA_SPINLOCK_T lock); |
Simon Horman | 0ba0e4a | 2015-01-30 11:23:00 +0900 | [diff] [blame] | 277 | }; |
| 278 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 279 | struct proxy { |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 280 | enum obj_type obj_type; /* object type == OBJ_TYPE_PROXY */ |
Willy Tarreau | 8379c17 | 2013-12-06 21:29:13 +0100 | [diff] [blame] | 281 | enum pr_state state; /* proxy state, one of PR_* */ |
| 282 | enum pr_mode mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */ |
| 283 | char cap; /* supported capabilities (PR_CAP_*) */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 284 | unsigned int maxconn; /* max # of active streams on the frontend */ |
Willy Tarreau | 8379c17 | 2013-12-06 21:29:13 +0100 | [diff] [blame] | 285 | |
Willy Tarreau | 35d66b0 | 2007-01-02 00:28:21 +0100 | [diff] [blame] | 286 | int options; /* PR_O_REDISP, PR_O_TRANSP, ... */ |
Willy Tarreau | 66aa61f | 2009-01-18 21:44:07 +0100 | [diff] [blame] | 287 | int options2; /* PR_O2_* */ |
Olivier Houchard | a4d4fdf | 2018-12-14 19:27:06 +0100 | [diff] [blame] | 288 | int max_out_conns; /* Max number of idling connections we keep for a session */ |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 289 | struct in_addr mon_net, mon_mask; /* don't forward connections from this net (network order) FIXME: should support IPv6 */ |
Willy Tarreau | 6740213 | 2012-05-31 20:40:20 +0200 | [diff] [blame] | 290 | unsigned int ck_opts; /* PR_CK_* (cookie options) */ |
Willy Tarreau | c1a2167 | 2009-08-16 22:37:44 +0200 | [diff] [blame] | 291 | unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */ |
Willy Tarreau | 4e5b828 | 2009-08-16 22:57:50 +0200 | [diff] [blame] | 292 | unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */ |
Willy Tarreau | 25320b2 | 2013-03-24 07:22:08 +0100 | [diff] [blame] | 293 | unsigned int http_needed; /* non-null if HTTP analyser may be used */ |
Willy Tarreau | 5fdfb91 | 2007-01-01 23:11:07 +0100 | [diff] [blame] | 294 | union { |
| 295 | struct proxy *be; /* default backend, or NULL if none set */ |
| 296 | char *name; /* default backend name during config parse */ |
| 297 | } defbe; |
Willy Tarreau | eb0c614 | 2007-05-07 00:53:22 +0200 | [diff] [blame] | 298 | struct list acl; /* ACL declared on this proxy */ |
Willy Tarreau | e365c0b | 2013-06-11 16:06:12 +0200 | [diff] [blame] | 299 | struct list http_req_rules; /* HTTP request rules: allow/deny/... */ |
| 300 | struct list http_res_rules; /* HTTP response rules: allow/deny/... */ |
Christopher Faulet | 6d0c3df | 2020-01-22 09:26:35 +0100 | [diff] [blame] | 301 | struct list http_after_res_rules; /* HTTP final response rules: set-header/del-header/... */ |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 302 | struct list redirect_rules; /* content redirecting rules (chained) */ |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 303 | struct list switching_rules; /* content switching rules (chained) */ |
Cyril Bonté | 47fdd8e | 2010-04-25 00:00:51 +0200 | [diff] [blame] | 304 | struct list persist_rules; /* 'force-persist' and 'ignore-persist' rules (chained) */ |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 305 | struct list sticking_rules; /* content sticking rules (chained) */ |
| 306 | struct list storersp_rules; /* content store response rules (chained) */ |
Willy Tarreau | 4a5cade | 2012-04-05 21:09:48 +0200 | [diff] [blame] | 307 | struct list server_rules; /* server switching rules (chained) */ |
Willy Tarreau | b686644 | 2008-07-14 23:54:42 +0200 | [diff] [blame] | 308 | struct { /* TCP request processing */ |
Willy Tarreau | c7e961e | 2008-08-17 17:13:47 +0200 | [diff] [blame] | 309 | unsigned int inspect_delay; /* inspection delay */ |
Willy Tarreau | b686644 | 2008-07-14 23:54:42 +0200 | [diff] [blame] | 310 | struct list inspect_rules; /* inspection rules */ |
Willy Tarreau | ab78619 | 2010-05-23 22:39:25 +0200 | [diff] [blame] | 311 | struct list l4_rules; /* layer4 rules */ |
Willy Tarreau | 620408f | 2016-10-21 16:37:51 +0200 | [diff] [blame] | 312 | struct list l5_rules; /* layer5 rules */ |
Willy Tarreau | b686644 | 2008-07-14 23:54:42 +0200 | [diff] [blame] | 313 | } tcp_req; |
Emeric Brun | 97679e7 | 2010-09-23 17:56:44 +0200 | [diff] [blame] | 314 | struct { /* TCP request processing */ |
| 315 | unsigned int inspect_delay; /* inspection delay */ |
| 316 | struct list inspect_rules; /* inspection rules */ |
| 317 | } tcp_rep; |
Krzysztof Piotr Oledzki | c6df066 | 2010-01-05 16:38:49 +0100 | [diff] [blame] | 318 | struct server *srv, defsrv; /* known servers; default server configuration */ |
Willy Tarreau | a511084 | 2017-11-26 08:41:31 +0100 | [diff] [blame] | 319 | struct lbprm lbprm; /* load-balancing parameters */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 320 | int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */ |
Andrew Rodland | e168feb | 2016-10-25 12:48:17 -0400 | [diff] [blame] | 321 | int served; /* # of active sessions currently being served */ |
Willy Tarreau | a511084 | 2017-11-26 08:41:31 +0100 | [diff] [blame] | 322 | int cookie_len; /* strlen(cookie_name), computed only once */ |
Krzysztof Piotr Oledzki | 1acf217 | 2008-05-29 23:03:34 +0200 | [diff] [blame] | 323 | char *cookie_domain; /* domain used to insert the cookie */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 324 | char *cookie_name; /* name of the cookie to look for */ |
Christopher Faulet | 2f53390 | 2020-01-21 11:06:48 +0100 | [diff] [blame] | 325 | char *cookie_attrs; /* list of attributes to add to the cookie */ |
Olivier Houchard | 4e69404 | 2017-03-14 20:01:29 +0100 | [diff] [blame] | 326 | char *dyncookie_key; /* Secret key used to generate dynamic persistent cookies */ |
Willy Tarreau | 3193685 | 2010-10-06 16:59:56 +0200 | [diff] [blame] | 327 | unsigned int cookie_maxidle; /* max idle time for this cookie */ |
| 328 | unsigned int cookie_maxlife; /* max life time for this cookie */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 329 | char *rdp_cookie_name; /* name of the RDP cookie to look for */ |
Willy Tarreau | a511084 | 2017-11-26 08:41:31 +0100 | [diff] [blame] | 330 | int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 331 | char *capture_name; /* beginning of the name of the cookie to capture */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 332 | int capture_namelen; /* length of the cookie name to match */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 333 | int capture_len; /* length of the string to be captured */ |
| 334 | struct uri_auth *uri_auth; /* if non-NULL, the (list of) per-URI authentications */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 335 | int max_ka_queue; /* 1+maximum requests in queue accepted for reusing a K-A conn (0=none) */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 336 | int monitor_uri_len; /* length of the string above. 0 if unused */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 337 | char *monitor_uri; /* a special URI to which we respond with HTTP/200 OK */ |
Willy Tarreau | b80c230 | 2007-11-30 20:51:32 +0100 | [diff] [blame] | 338 | 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] | 339 | struct { /* WARNING! check proxy_reset_timeouts() in proxy.h !!! */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 340 | int client; /* client I/O timeout (in ticks) */ |
| 341 | int tarpit; /* tarpit timeout, defaults to connect if unspecified */ |
| 342 | int queue; /* queue timeout, defaults to connect if unspecified */ |
| 343 | int connect; /* connect timeout (in ticks) */ |
| 344 | int server; /* server I/O timeout (in ticks) */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 345 | int httpreq; /* maximum time for complete HTTP request */ |
Willy Tarreau | b16a574 | 2010-01-10 14:46:16 +0100 | [diff] [blame] | 346 | int httpka; /* maximum time for a new HTTP request when using keep-alive */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 347 | int check; /* maximum time for complete check */ |
Willy Tarreau | ce887fd | 2012-05-12 12:50:00 +0200 | [diff] [blame] | 348 | int tunnel; /* I/O timeout to use in tunnel mode (in ticks) */ |
Willy Tarreau | 05cdd96 | 2014-05-10 14:30:07 +0200 | [diff] [blame] | 349 | int clientfin; /* timeout to apply to client half-closed connections */ |
| 350 | int serverfin; /* timeout to apply to server half-closed connections */ |
Willy Tarreau | 1fa3126 | 2007-12-03 00:36:16 +0100 | [diff] [blame] | 351 | } timeout; |
Krzysztof Piotr Oledzki | 48cb2ae | 2009-10-02 22:51:14 +0200 | [diff] [blame] | 352 | char *id, *desc; /* proxy id (name) and description */ |
Patrick Hemmer | 0355dab | 2018-05-11 12:52:31 -0400 | [diff] [blame] | 353 | struct eb_root pendconns; /* pending connections with no server assigned yet */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 354 | int nbpend; /* number of pending connections with no server assigned yet */ |
Willy Tarreau | 1c47f85 | 2006-07-09 08:22:27 +0200 | [diff] [blame] | 355 | int totpend; /* total number of pending connections on this instance (for stats) */ |
Patrick Hemmer | da282f4 | 2018-05-11 12:52:31 -0400 | [diff] [blame] | 356 | unsigned int queue_idx; /* number of pending connections which have been de-queued */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 357 | unsigned int feconn, beconn; /* # of active frontend and backends streams */ |
Willy Tarreau | d9b587f | 2010-02-26 10:05:55 +0100 | [diff] [blame] | 358 | struct freq_ctr fe_req_per_sec; /* HTTP requests per second on the frontend */ |
Willy Tarreau | b36b424 | 2010-06-04 20:59:39 +0200 | [diff] [blame] | 359 | struct freq_ctr fe_conn_per_sec; /* received connections per second on the frontend */ |
| 360 | struct freq_ctr fe_sess_per_sec; /* accepted sessions per second on the frontend (after tcp rules) */ |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 361 | 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] | 362 | 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] | 363 | unsigned int fullconn; /* #conns on backend above which servers are used at full load */ |
Emeric Brun | 3f78357 | 2017-01-12 11:21:28 +0100 | [diff] [blame] | 364 | unsigned int tot_fe_maxconn; /* #maxconn of frontends linked to that backend, it is used to compute fullconn */ |
Willy Tarreau | 7ac51f6 | 2007-03-25 16:00:04 +0200 | [diff] [blame] | 365 | 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] | 366 | struct in_addr except_to; /* don't x-original-to for this address. */ |
| 367 | struct in_addr except_mask_to; /* the netmask for except_to. */ |
Ross West | af72a1d | 2008-08-03 10:51:45 +0200 | [diff] [blame] | 368 | char *fwdfor_hdr_name; /* header to use - default: "x-forwarded-for" */ |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 369 | char *orgto_hdr_name; /* header to use - default: "x-original-to" */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 370 | int fwdfor_hdr_len; /* length of "x-forwarded-for" header */ |
Maik Broemme | 2850cb4 | 2009-04-17 18:53:21 +0200 | [diff] [blame] | 371 | int orgto_hdr_len; /* length of "x-original-to" header */ |
Mark Lamourine | c2247f0 | 2012-01-04 13:02:01 -0500 | [diff] [blame] | 372 | char *server_id_hdr_name; /* the header to use to send the server id (name) */ |
| 373 | int server_id_hdr_len; /* the length of the id (name) header... name */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 374 | int conn_retries; /* maximum number of connect retries */ |
Olivier Houchard | a254a37 | 2019-04-05 15:30:12 +0200 | [diff] [blame] | 375 | unsigned int retry_type; /* Type of retry allowed */ |
Joseph Lynch | 726ab71 | 2015-05-11 23:25:34 -0700 | [diff] [blame] | 376 | int redispatch_after; /* number of retries before redispatch */ |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 377 | unsigned down_trans; /* up-down transitions */ |
| 378 | unsigned down_time; /* total time the proxy was down */ |
Willy Tarreau | a511084 | 2017-11-26 08:41:31 +0100 | [diff] [blame] | 379 | unsigned int log_count; /* number of logs produced by the frontend */ |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 380 | time_t last_change; /* last time, when the state was changed */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 381 | int (*accept)(struct stream *s); /* application layer's accept() */ |
Willy Tarreau | ef9a360 | 2012-12-08 22:29:20 +0100 | [diff] [blame] | 382 | struct conn_src conn_src; /* connection source settings */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 383 | enum obj_type *default_target; /* default target to use for accepted streams or NULL */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 384 | struct proxy *next; |
Frédéric Lécaille | 015e4d7 | 2019-03-19 14:55:01 +0100 | [diff] [blame] | 385 | struct proxy *next_stkt_ref; /* Link to the list of proxies which refer to the same stick-table. */ |
Willy Tarreau | 7346acb | 2014-08-28 15:03:15 +0200 | [diff] [blame] | 386 | |
William Lallemand | 0f99e34 | 2011-10-12 17:50:54 +0200 | [diff] [blame] | 387 | struct list logsrvs; |
William Lallemand | 723b73a | 2012-02-08 16:37:49 +0100 | [diff] [blame] | 388 | struct list logformat; /* log_format linked list */ |
Dragan Dosen | 0b85ece | 2015-09-25 19:17:44 +0200 | [diff] [blame] | 389 | struct list logformat_sd; /* log_format linked list for the RFC5424 structured-data part */ |
Willy Tarreau | 83061a8 | 2018-07-13 11:56:34 +0200 | [diff] [blame] | 390 | struct buffer log_tag; /* override default syslog tag */ |
Tim Duesterhus | 0643b0e | 2020-03-05 17:56:35 +0100 | [diff] [blame] | 391 | struct ist header_unique_id; /* unique-id header */ |
William Lallemand | a73203e | 2012-03-12 12:48:57 +0100 | [diff] [blame] | 392 | struct list format_unique_id; /* unique-id format */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 393 | int to_log; /* things to be logged (LW_*) */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 394 | int stop_time; /* date to stop listening, when stopping != 0 (int ticks) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 395 | int nb_req_cap, nb_rsp_cap; /* # of headers to be captured */ |
| 396 | struct cap_hdr *req_cap; /* chained list of request headers to be captured */ |
| 397 | struct cap_hdr *rsp_cap; /* chained list of response headers to be captured */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 398 | struct pool_head *req_cap_pool, /* pools of pre-allocated char ** used to build the streams */ |
Willy Tarreau | cf7f320 | 2007-05-13 22:46:04 +0200 | [diff] [blame] | 399 | *rsp_cap_pool; |
Willy Tarreau | ae9bea0 | 2016-11-25 14:44:52 +0100 | [diff] [blame] | 400 | struct be_counters be_counters; /* backend statistics counters */ |
| 401 | struct fe_counters fe_counters; /* frontend statistics counters */ |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 402 | |
Olivier Houchard | 859dc80 | 2019-08-08 15:47:21 +0200 | [diff] [blame] | 403 | struct mt_list listener_queue; /* list of the temporarily limited listeners because of lack of a proxy resource */ |
Frédéric Lécaille | 1b8e68e | 2019-03-14 07:07:41 +0100 | [diff] [blame] | 404 | struct stktable *table; /* table for storing sticking streams */ |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 405 | |
Willy Tarreau | d1a33e3 | 2012-10-04 00:14:33 +0200 | [diff] [blame] | 406 | struct task *task; /* the associated task, mandatory to manage rate limiting, stopping and resource shortage, NULL if disabled */ |
Christopher Faulet | 5d503fc | 2020-03-30 20:34:34 +0200 | [diff] [blame] | 407 | struct tcpcheck_rules tcpcheck_rules; /* tcp-check send / expect rules */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 408 | int grace; /* grace time after stop request */ |
Simon Horman | 98637e5 | 2014-06-20 12:30:16 +0900 | [diff] [blame] | 409 | char *check_command; /* Command to use for external agent checks */ |
| 410 | char *check_path; /* PATH environment to use for external agent checks */ |
Christopher Faulet | 40e8569 | 2020-05-14 17:34:31 +0200 | [diff] [blame] | 411 | struct http_reply *replies[HTTP_ERR_SIZE]; /* HTTP replies for known errors */ |
Willy Tarreau | dcd4771 | 2007-11-04 23:35:08 +0100 | [diff] [blame] | 412 | int uuid; /* universally unique proxy ID, used for SNMP */ |
Willy Tarreau | c73ce2b | 2008-01-06 10:55:10 +0100 | [diff] [blame] | 413 | unsigned int backlog; /* force the frontend's listen backlog */ |
Willy Tarreau | a9db57e | 2013-01-18 11:29:29 +0100 | [diff] [blame] | 414 | unsigned long bind_proc; /* bitmask of processes using this proxy */ |
Willy Tarreau | 7b81563 | 2011-10-21 18:51:57 +0200 | [diff] [blame] | 415 | |
| 416 | /* warning: these structs are huge, keep them at the bottom */ |
| 417 | struct sockaddr_storage dispatch_addr; /* the default address to connect to */ |
Willy Tarreau | c55015e | 2018-09-07 19:02:32 +0200 | [diff] [blame] | 418 | struct error_snapshot *invalid_req, *invalid_rep; /* captures of last errors */ |
Willy Tarreau | 84b57da | 2009-06-14 11:10:45 +0200 | [diff] [blame] | 419 | |
| 420 | /* used only during configuration parsing */ |
| 421 | int no_options; /* PR_O_REDISP, PR_O_TRANSP, ... */ |
| 422 | int no_options2; /* PR_O2_* */ |
Krzysztof Piotr Oledzki | 052d4fd | 2009-10-04 14:52:57 +0200 | [diff] [blame] | 423 | |
Willy Tarreau | 90a570f | 2009-10-04 20:54:54 +0200 | [diff] [blame] | 424 | struct { |
Willy Tarreau | 8113a5d | 2012-10-04 08:01:43 +0200 | [diff] [blame] | 425 | char *file; /* file where the section appears */ |
Willy Tarreau | 53fb4ae | 2009-10-04 23:04:08 +0200 | [diff] [blame] | 426 | struct eb32_node id; /* place in the tree of used IDs */ |
Willy Tarreau | a511084 | 2017-11-26 08:41:31 +0100 | [diff] [blame] | 427 | int line; /* line where the section appears */ |
Willy Tarreau | 53fb4ae | 2009-10-04 23:04:08 +0200 | [diff] [blame] | 428 | struct eb_root used_listener_id;/* list of listener IDs in use */ |
| 429 | struct eb_root used_server_id; /* list of server IDs in use */ |
Frédéric Lécaille | 84d6046 | 2019-05-17 14:29:15 +0200 | [diff] [blame] | 430 | struct eb_root used_server_name; /* list of server names in use */ |
Willy Tarreau | 2a65ff0 | 2012-09-13 17:54:29 +0200 | [diff] [blame] | 431 | struct list bind; /* list of bind settings */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 432 | struct list listeners; /* list of listeners belonging to this frontend */ |
Christopher Faulet | 76edc0f | 2020-01-13 15:52:01 +0100 | [diff] [blame] | 433 | struct list errors; /* list of all custom error files */ |
Willy Tarreau | a4312fa | 2013-04-02 16:34:32 +0200 | [diff] [blame] | 434 | struct arg_list args; /* sample arg list that need to be resolved */ |
Willy Tarreau | f79d950 | 2014-03-15 07:22:35 +0100 | [diff] [blame] | 435 | struct ebpt_node by_name; /* proxies are stored sorted by name here */ |
Willy Tarreau | 62a6123 | 2013-04-12 18:13:46 +0200 | [diff] [blame] | 436 | char *logformat_string; /* log format string */ |
| 437 | char *lfs_file; /* file name where the logformat string appears (strdup) */ |
| 438 | int lfs_line; /* file name where the logformat string appears */ |
Willy Tarreau | 62a6123 | 2013-04-12 18:13:46 +0200 | [diff] [blame] | 439 | int uif_line; /* file name where the unique-id-format string appears */ |
Willy Tarreau | 4edd683 | 2014-08-28 14:36:36 +0200 | [diff] [blame] | 440 | char *uif_file; /* file name where the unique-id-format string appears (strdup) */ |
| 441 | char *uniqueid_format_string; /* unique-id format string */ |
Dragan Dosen | 0b85ece | 2015-09-25 19:17:44 +0200 | [diff] [blame] | 442 | char *logformat_sd_string; /* log format string for the RFC5424 structured-data part */ |
| 443 | char *lfsd_file; /* file name where the structured-data logformat string for RFC5424 appears (strdup) */ |
| 444 | int lfsd_line; /* file name where the structured-data logformat string for RFC5424 appears */ |
Willy Tarreau | 90a570f | 2009-10-04 20:54:54 +0200 | [diff] [blame] | 445 | } conf; /* config information */ |
Willy Tarreau | 258a14b | 2010-07-13 16:24:48 +0200 | [diff] [blame] | 446 | void *parent; /* parent of the proxy when applicable */ |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 447 | struct comp *comp; /* http compression */ |
Simon Horman | 9dc4996 | 2015-01-30 11:22:59 +0900 | [diff] [blame] | 448 | |
| 449 | struct { |
| 450 | union { |
| 451 | struct mailers *m; /* Mailer to send email alerts via */ |
| 452 | char *name; |
| 453 | } mailers; |
Simon Horman | 0ba0e4a | 2015-01-30 11:23:00 +0900 | [diff] [blame] | 454 | char *from; /* Address to send email alerts from */ |
| 455 | char *to; /* Address(es) to send email alerts to */ |
Simon Horman | 9dc4996 | 2015-01-30 11:22:59 +0900 | [diff] [blame] | 456 | char *myhostname; /* Identity to use in HELO command sent to mailer */ |
Simon Horman | 64e3416 | 2015-02-06 11:11:57 +0900 | [diff] [blame] | 457 | int level; /* Maximum syslog level of messages to send |
| 458 | * email alerts for */ |
| 459 | int set; /* True if email_alert settings are present */ |
Simon Horman | 0ba0e4a | 2015-01-30 11:23:00 +0900 | [diff] [blame] | 460 | struct email_alertq *queues; /* per-mailer alerts queues */ |
Simon Horman | 9dc4996 | 2015-01-30 11:22:59 +0900 | [diff] [blame] | 461 | } email_alert; |
Baptiste Assmann | e11cfcd | 2015-08-19 16:44:03 +0200 | [diff] [blame] | 462 | |
| 463 | int load_server_state_from_file; /* location of the file containing server state. |
| 464 | * flag PR_SRV_STATE_FILE_* */ |
| 465 | char *server_state_file_name; /* used when load_server_state_from_file is set to |
| 466 | * PR_SRV_STATE_FILE_LOCAL. Give a specific file name for |
| 467 | * this backend. If not specified or void, then the backend |
| 468 | * name is used |
| 469 | */ |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 470 | struct list filter_configs; /* list of the filters that are declared on this proxy */ |
Willy Tarreau | 5e83d99 | 2019-07-30 11:59:34 +0200 | [diff] [blame] | 471 | __decl_hathreads(HA_SPINLOCK_T lock); /* may be taken under the server's lock */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 472 | }; |
| 473 | |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 474 | struct switching_rule { |
| 475 | struct list list; /* list linked to from the proxy */ |
| 476 | struct acl_cond *cond; /* acl condition to meet */ |
Bertrand Jacquin | 702d44f | 2013-11-19 11:43:06 +0100 | [diff] [blame] | 477 | int dynamic; /* this is a dynamic rule using the logformat expression */ |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 478 | union { |
| 479 | struct proxy *backend; /* target backend */ |
| 480 | char *name; /* target backend name during config parsing */ |
Bertrand Jacquin | 702d44f | 2013-11-19 11:43:06 +0100 | [diff] [blame] | 481 | struct list expr; /* logformat expression to use for dynamic rules */ |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 482 | } be; |
Thierry FOURNIER / OZON.IO | 4ed1c95 | 2016-11-24 23:57:54 +0100 | [diff] [blame] | 483 | char *file; |
| 484 | int line; |
Willy Tarreau | 55ea757 | 2007-06-17 19:56:27 +0200 | [diff] [blame] | 485 | }; |
| 486 | |
Willy Tarreau | 4a5cade | 2012-04-05 21:09:48 +0200 | [diff] [blame] | 487 | struct server_rule { |
| 488 | struct list list; /* list linked to from the proxy */ |
| 489 | struct acl_cond *cond; /* acl condition to meet */ |
Jerome Magnin | 824186b | 2020-03-29 09:37:12 +0200 | [diff] [blame] | 490 | int dynamic; |
Willy Tarreau | 4a5cade | 2012-04-05 21:09:48 +0200 | [diff] [blame] | 491 | union { |
| 492 | struct server *ptr; /* target server */ |
| 493 | char *name; /* target server name during config parsing */ |
| 494 | } srv; |
Jerome Magnin | 824186b | 2020-03-29 09:37:12 +0200 | [diff] [blame] | 495 | struct list expr; /* logformat expression to use for dynamic rules */ |
| 496 | char *file; |
| 497 | int line; |
Willy Tarreau | 4a5cade | 2012-04-05 21:09:48 +0200 | [diff] [blame] | 498 | }; |
| 499 | |
Cyril Bonté | 47fdd8e | 2010-04-25 00:00:51 +0200 | [diff] [blame] | 500 | struct persist_rule { |
Willy Tarreau | 4de9149 | 2010-01-22 19:10:05 +0100 | [diff] [blame] | 501 | struct list list; /* list linked to from the proxy */ |
| 502 | struct acl_cond *cond; /* acl condition to meet */ |
Cyril Bonté | 47fdd8e | 2010-04-25 00:00:51 +0200 | [diff] [blame] | 503 | int type; |
Willy Tarreau | 4de9149 | 2010-01-22 19:10:05 +0100 | [diff] [blame] | 504 | }; |
| 505 | |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 506 | struct sticking_rule { |
| 507 | struct list list; /* list linked to from the proxy */ |
| 508 | struct acl_cond *cond; /* acl condition to meet */ |
Willy Tarreau | 1278578 | 2012-04-27 21:37:17 +0200 | [diff] [blame] | 509 | struct sample_expr *expr; /* fetch expr to fetch key */ |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 510 | int flags; /* STK_* */ |
| 511 | union { |
| 512 | struct stktable *t; /* target table */ |
| 513 | char *name; /* target table name during config parsing */ |
| 514 | } table; |
| 515 | }; |
| 516 | |
| 517 | |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 518 | struct redirect_rule { |
| 519 | struct list list; /* list linked to from the proxy */ |
| 520 | struct acl_cond *cond; /* acl condition to meet */ |
| 521 | int type; |
| 522 | int rdr_len; |
| 523 | char *rdr_str; |
Thierry FOURNIER | d18cd0f | 2013-11-29 12:15:45 +0100 | [diff] [blame] | 524 | struct list rdr_fmt; |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 525 | int code; |
Willy Tarreau | 79da469 | 2008-11-19 20:03:04 +0100 | [diff] [blame] | 526 | unsigned int flags; |
Willy Tarreau | 0140f25 | 2008-11-19 21:07:09 +0100 | [diff] [blame] | 527 | int cookie_len; |
| 528 | char *cookie_str; |
Willy Tarreau | b463dfb | 2008-06-07 23:08:56 +0200 | [diff] [blame] | 529 | }; |
| 530 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 531 | /* some of the most common options which are also the easiest to handle */ |
| 532 | struct cfg_opt { |
| 533 | const char *name; |
| 534 | unsigned int val; |
| 535 | unsigned int cap; |
| 536 | unsigned int checks; |
| 537 | unsigned int mode; |
| 538 | }; |
| 539 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 540 | #endif /* _TYPES_PROXY_H */ |
| 541 | |
| 542 | /* |
| 543 | * Local variables: |
| 544 | * c-indent-level: 8 |
| 545 | * c-basic-offset: 8 |
| 546 | * End: |
| 547 | */ |