Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | #include <netdb.h> |
| 5 | #include <ctype.h> |
| 6 | #include <pwd.h> |
| 7 | #include <grp.h> |
| 8 | #include <errno.h> |
| 9 | #include <sys/types.h> |
| 10 | #include <sys/stat.h> |
| 11 | #include <fcntl.h> |
| 12 | #include <unistd.h> |
| 13 | |
Willy Tarreau | dcc048a | 2020-06-04 19:11:43 +0200 | [diff] [blame] | 14 | #include <haproxy/acl.h> |
Eric Salama | 7cea606 | 2020-10-02 11:58:19 +0200 | [diff] [blame] | 15 | #include <haproxy/buf.h> |
Willy Tarreau | 278161c | 2020-06-04 11:18:28 +0200 | [diff] [blame] | 16 | #include <haproxy/capture-t.h> |
Willy Tarreau | 6be7849 | 2020-06-05 00:00:29 +0200 | [diff] [blame] | 17 | #include <haproxy/cfgparse.h> |
Willy Tarreau | 4aa573d | 2020-06-04 18:21:56 +0200 | [diff] [blame] | 18 | #include <haproxy/check.h> |
Willy Tarreau | 0a3bd39 | 2020-06-04 08:52:38 +0200 | [diff] [blame] | 19 | #include <haproxy/compression-t.h> |
Willy Tarreau | 7ea393d | 2020-06-04 18:02:10 +0200 | [diff] [blame] | 20 | #include <haproxy/connection.h> |
Willy Tarreau | bcc6733 | 2020-06-05 15:31:31 +0200 | [diff] [blame] | 21 | #include <haproxy/extcheck.h> |
Willy Tarreau | b7fc4c4 | 2021-10-06 18:56:42 +0200 | [diff] [blame] | 22 | #include <haproxy/http_ana.h> |
Willy Tarreau | 8773533 | 2020-06-04 09:08:41 +0200 | [diff] [blame] | 23 | #include <haproxy/http_htx.h> |
Willy Tarreau | c761f84 | 2020-06-04 11:40:28 +0200 | [diff] [blame] | 24 | #include <haproxy/http_rules.h> |
Willy Tarreau | 213e990 | 2020-06-04 14:58:24 +0200 | [diff] [blame] | 25 | #include <haproxy/listener.h> |
Willy Tarreau | 36979d9 | 2020-06-05 17:27:29 +0200 | [diff] [blame] | 26 | #include <haproxy/log.h> |
Willy Tarreau | 872f2ea | 2020-06-04 18:46:44 +0200 | [diff] [blame] | 27 | #include <haproxy/peers.h> |
Willy Tarreau | b255105 | 2020-06-09 09:07:15 +0200 | [diff] [blame] | 28 | #include <haproxy/protocol.h> |
Willy Tarreau | a264d96 | 2020-06-04 22:29:18 +0200 | [diff] [blame] | 29 | #include <haproxy/proxy.h> |
Willy Tarreau | e6ce10b | 2020-06-04 15:33:47 +0200 | [diff] [blame] | 30 | #include <haproxy/sample.h> |
Willy Tarreau | 1e56f92 | 2020-06-04 23:20:13 +0200 | [diff] [blame] | 31 | #include <haproxy/server.h> |
Willy Tarreau | 2eec9b5 | 2020-06-04 19:58:55 +0200 | [diff] [blame] | 32 | #include <haproxy/stats-t.h> |
Willy Tarreau | 872f2ea | 2020-06-04 18:46:44 +0200 | [diff] [blame] | 33 | #include <haproxy/stick_table.h> |
Willy Tarreau | b255105 | 2020-06-09 09:07:15 +0200 | [diff] [blame] | 34 | #include <haproxy/tcpcheck.h> |
Willy Tarreau | e9dcb3c | 2021-05-08 13:00:23 +0200 | [diff] [blame] | 35 | #include <haproxy/tools.h> |
Willy Tarreau | b255105 | 2020-06-09 09:07:15 +0200 | [diff] [blame] | 36 | #include <haproxy/uri_auth.h> |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 37 | |
Willy Tarreau | c0ff679 | 2021-03-12 09:14:19 +0100 | [diff] [blame] | 38 | /* some keywords that are still being parsed using strcmp() and are not |
| 39 | * registered anywhere. They are used as suggestions for mistyped words. |
| 40 | */ |
| 41 | static const char *common_kw_list[] = { |
| 42 | "listen", "frontend", "backend", "defaults", "server", |
| 43 | "default-server", "server-template", "bind", "monitor-net", |
| 44 | "monitor-uri", "mode", "id", "description", "disabled", "enabled", |
| 45 | "bind-process", "acl", "dynamic-cookie-key", "cookie", "email-alert", |
| 46 | "persist", "appsession", "load-server-state-from-file", |
| 47 | "server-state-file-name", "max-session-srv-conns", "capture", |
| 48 | "retries", "http-request", "http-response", "http-after-response", |
| 49 | "http-send-name-header", "block", "redirect", "use_backend", |
| 50 | "use-server", "force-persist", "ignore-persist", "force-persist", |
| 51 | "stick-table", "stick", "stats", "option", "default_backend", |
| 52 | "http-reuse", "monitor", "transparent", "maxconn", "backlog", |
Willy Tarreau | eb77824 | 2021-06-11 16:27:10 +0200 | [diff] [blame] | 53 | "fullconn", "dispatch", "balance", "hash-type", |
Willy Tarreau | c0ff679 | 2021-03-12 09:14:19 +0100 | [diff] [blame] | 54 | "hash-balance-factor", "unique-id-format", "unique-id-header", |
| 55 | "log-format", "log-format-sd", "log-tag", "log", "source", "usesrc", |
Remi Tricot-Le Breton | fe21fe7 | 2021-08-31 12:08:52 +0200 | [diff] [blame] | 56 | "error-log-format", |
Willy Tarreau | c0ff679 | 2021-03-12 09:14:19 +0100 | [diff] [blame] | 57 | NULL /* must be last */ |
| 58 | }; |
Willy Tarreau | 7d0c143 | 2021-02-12 12:29:28 +0100 | [diff] [blame] | 59 | |
Willy Tarreau | 31a3cea | 2021-03-15 11:11:55 +0100 | [diff] [blame] | 60 | static const char *common_options[] = { |
Willy Tarreau | 6ba6984 | 2021-06-11 16:01:50 +0200 | [diff] [blame] | 61 | "httpclose", "http-server-close", "http-keep-alive", |
Willy Tarreau | d2f2537 | 2021-06-11 16:06:29 +0200 | [diff] [blame] | 62 | "redispatch", "httplog", "tcplog", "tcpka", "httpchk", |
Willy Tarreau | 31a3cea | 2021-03-15 11:11:55 +0100 | [diff] [blame] | 63 | "ssl-hello-chk", "smtpchk", "pgsql-check", "redis-check", |
| 64 | "mysql-check", "ldap-check", "spop-check", "tcp-check", |
| 65 | "external-check", "forwardfor", "original-to", |
| 66 | NULL /* must be last */ |
| 67 | }; |
| 68 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 69 | /* Report a warning if a rule is placed after a 'tcp-request session' rule. |
| 70 | * Return 1 if the warning has been emitted, otherwise 0. |
| 71 | */ |
| 72 | int warnif_rule_after_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg) |
| 73 | { |
| 74 | if (!LIST_ISEMPTY(&proxy->tcp_req.l5_rules)) { |
| 75 | ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'tcp-request session' rule will still be processed before.\n", |
| 76 | file, line, arg); |
| 77 | return 1; |
| 78 | } |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | /* Report a warning if a rule is placed after a 'tcp-request content' rule. |
| 83 | * Return 1 if the warning has been emitted, otherwise 0. |
| 84 | */ |
| 85 | int warnif_rule_after_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg) |
| 86 | { |
| 87 | if (!LIST_ISEMPTY(&proxy->tcp_req.inspect_rules)) { |
| 88 | ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'tcp-request content' rule will still be processed before.\n", |
| 89 | file, line, arg); |
| 90 | return 1; |
| 91 | } |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | /* Report a warning if a rule is placed after a 'monitor fail' rule. |
| 96 | * Return 1 if the warning has been emitted, otherwise 0. |
| 97 | */ |
| 98 | int warnif_rule_after_monitor(struct proxy *proxy, const char *file, int line, const char *arg) |
| 99 | { |
| 100 | if (!LIST_ISEMPTY(&proxy->mon_fail_cond)) { |
| 101 | ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'monitor fail' rule will still be processed before.\n", |
| 102 | file, line, arg); |
| 103 | return 1; |
| 104 | } |
| 105 | return 0; |
| 106 | } |
| 107 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 108 | /* Report a warning if a rule is placed after an 'http_request' rule. |
| 109 | * Return 1 if the warning has been emitted, otherwise 0. |
| 110 | */ |
| 111 | int warnif_rule_after_http_req(struct proxy *proxy, const char *file, int line, const char *arg) |
| 112 | { |
| 113 | if (!LIST_ISEMPTY(&proxy->http_req_rules)) { |
| 114 | ha_warning("parsing [%s:%d] : a '%s' rule placed after an 'http-request' rule will still be processed before.\n", |
| 115 | file, line, arg); |
| 116 | return 1; |
| 117 | } |
| 118 | return 0; |
| 119 | } |
| 120 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 121 | /* Report a warning if a rule is placed after a redirect rule. |
| 122 | * Return 1 if the warning has been emitted, otherwise 0. |
| 123 | */ |
| 124 | int warnif_rule_after_redirect(struct proxy *proxy, const char *file, int line, const char *arg) |
| 125 | { |
| 126 | if (!LIST_ISEMPTY(&proxy->redirect_rules)) { |
| 127 | ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'redirect' rule will still be processed before.\n", |
| 128 | file, line, arg); |
| 129 | return 1; |
| 130 | } |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | /* Report a warning if a rule is placed after a 'use_backend' rule. |
| 135 | * Return 1 if the warning has been emitted, otherwise 0. |
| 136 | */ |
| 137 | int warnif_rule_after_use_backend(struct proxy *proxy, const char *file, int line, const char *arg) |
| 138 | { |
| 139 | if (!LIST_ISEMPTY(&proxy->switching_rules)) { |
| 140 | ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'use_backend' rule will still be processed before.\n", |
| 141 | file, line, arg); |
| 142 | return 1; |
| 143 | } |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | /* Report a warning if a rule is placed after a 'use-server' rule. |
| 148 | * Return 1 if the warning has been emitted, otherwise 0. |
| 149 | */ |
| 150 | int warnif_rule_after_use_server(struct proxy *proxy, const char *file, int line, const char *arg) |
| 151 | { |
| 152 | if (!LIST_ISEMPTY(&proxy->server_rules)) { |
| 153 | ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'use-server' rule will still be processed before.\n", |
| 154 | file, line, arg); |
| 155 | return 1; |
| 156 | } |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | /* report a warning if a redirect rule is dangerously placed */ |
| 161 | int warnif_misplaced_redirect(struct proxy *proxy, const char *file, int line, const char *arg) |
| 162 | { |
| 163 | return warnif_rule_after_use_backend(proxy, file, line, arg) || |
| 164 | warnif_rule_after_use_server(proxy, file, line, arg); |
| 165 | } |
| 166 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 167 | /* report a warning if an http-request rule is dangerously placed */ |
| 168 | int warnif_misplaced_http_req(struct proxy *proxy, const char *file, int line, const char *arg) |
| 169 | { |
Christopher Faulet | 1b6adb4 | 2019-07-17 15:33:14 +0200 | [diff] [blame] | 170 | return warnif_rule_after_redirect(proxy, file, line, arg) || |
| 171 | warnif_misplaced_redirect(proxy, file, line, arg); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* report a warning if a block rule is dangerously placed */ |
Christopher Faulet | 8c3b63a | 2019-07-17 15:19:51 +0200 | [diff] [blame] | 175 | int warnif_misplaced_monitor(struct proxy *proxy, const char *file, int line, const char *arg) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 176 | { |
| 177 | return warnif_rule_after_http_req(proxy, file, line, arg) || |
| 178 | warnif_misplaced_http_req(proxy, file, line, arg); |
| 179 | } |
| 180 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 181 | /* report a warning if a "tcp request content" rule is dangerously placed */ |
| 182 | int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg) |
| 183 | { |
| 184 | return warnif_rule_after_monitor(proxy, file, line, arg) || |
| 185 | warnif_misplaced_monitor(proxy, file, line, arg); |
| 186 | } |
| 187 | |
| 188 | /* report a warning if a "tcp request session" rule is dangerously placed */ |
| 189 | int warnif_misplaced_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg) |
| 190 | { |
| 191 | return warnif_rule_after_tcp_cont(proxy, file, line, arg) || |
| 192 | warnif_misplaced_tcp_cont(proxy, file, line, arg); |
| 193 | } |
| 194 | |
| 195 | /* report a warning if a "tcp request connection" rule is dangerously placed */ |
| 196 | int warnif_misplaced_tcp_conn(struct proxy *proxy, const char *file, int line, const char *arg) |
| 197 | { |
| 198 | return warnif_rule_after_tcp_sess(proxy, file, line, arg) || |
| 199 | warnif_misplaced_tcp_sess(proxy, file, line, arg); |
| 200 | } |
| 201 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 202 | int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) |
| 203 | { |
| 204 | static struct proxy *curproxy = NULL; |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 205 | static struct proxy *curr_defproxy = NULL; |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 206 | static struct proxy *last_defproxy = NULL; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 207 | const char *err; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 208 | int rc; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 209 | int err_code = 0; |
| 210 | struct acl_cond *cond = NULL; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 211 | char *errmsg = NULL; |
| 212 | struct bind_conf *bind_conf; |
| 213 | |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 214 | if (!last_defproxy) { |
| 215 | /* we need a default proxy and none was created yet */ |
Amaury Denoyelle | 476b9ad | 2021-03-23 17:27:05 +0100 | [diff] [blame] | 216 | last_defproxy = alloc_new_proxy("", PR_CAP_DEF|PR_CAP_LISTEN, &errmsg); |
| 217 | proxy_preset_defaults(last_defproxy); |
| 218 | |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 219 | curr_defproxy = last_defproxy; |
| 220 | if (!last_defproxy) { |
| 221 | ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg); |
| 222 | err_code |= ERR_ALERT | ERR_ABORT; |
| 223 | goto out; |
| 224 | } |
Willy Tarreau | 7d0c143 | 2021-02-12 12:29:28 +0100 | [diff] [blame] | 225 | } |
| 226 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 227 | if (strcmp(args[0], "listen") == 0) |
Amaury Denoyelle | b979f59 | 2021-05-07 15:12:20 +0200 | [diff] [blame] | 228 | rc = PR_CAP_LISTEN | PR_CAP_LB; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 229 | else if (strcmp(args[0], "frontend") == 0) |
Amaury Denoyelle | b979f59 | 2021-05-07 15:12:20 +0200 | [diff] [blame] | 230 | rc = PR_CAP_FE | PR_CAP_LB; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 231 | else if (strcmp(args[0], "backend") == 0) |
Amaury Denoyelle | b979f59 | 2021-05-07 15:12:20 +0200 | [diff] [blame] | 232 | rc = PR_CAP_BE | PR_CAP_LB; |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 233 | else if (strcmp(args[0], "defaults") == 0) { |
| 234 | /* "defaults" must first delete the last no-name defaults if any */ |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 235 | curr_defproxy = NULL; |
| 236 | rc = PR_CAP_DEF | PR_CAP_LISTEN; |
| 237 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 238 | else |
| 239 | rc = PR_CAP_NONE; |
| 240 | |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 241 | if ((rc & PR_CAP_LISTEN) && !(rc & PR_CAP_DEF)) { /* new proxy */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 242 | if (!*args[1]) { |
Willy Tarreau | b2ec994 | 2021-02-12 13:28:22 +0100 | [diff] [blame] | 243 | ha_alert("parsing [%s:%d] : '%s' expects an <id> argument\n", |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 244 | file, linenum, args[0]); |
| 245 | err_code |= ERR_ALERT | ERR_ABORT; |
| 246 | goto out; |
| 247 | } |
| 248 | |
| 249 | err = invalid_char(args[1]); |
| 250 | if (err) { |
| 251 | ha_alert("parsing [%s:%d] : character '%c' is not permitted in '%s' name '%s'.\n", |
| 252 | file, linenum, *err, args[0], args[1]); |
| 253 | err_code |= ERR_ALERT | ERR_FATAL; |
| 254 | } |
| 255 | |
| 256 | curproxy = (rc & PR_CAP_FE) ? proxy_fe_by_name(args[1]) : proxy_be_by_name(args[1]); |
| 257 | if (curproxy) { |
| 258 | ha_alert("Parsing [%s:%d]: %s '%s' has the same name as %s '%s' declared at %s:%d.\n", |
| 259 | file, linenum, proxy_cap_str(rc), args[1], proxy_type_str(curproxy), |
| 260 | curproxy->id, curproxy->conf.file, curproxy->conf.line); |
| 261 | err_code |= ERR_ALERT | ERR_FATAL; |
| 262 | } |
| 263 | |
Emeric Brun | b0c331f | 2020-10-07 17:05:59 +0200 | [diff] [blame] | 264 | curproxy = log_forward_by_name(args[1]); |
| 265 | if (curproxy) { |
| 266 | ha_alert("Parsing [%s:%d]: %s '%s' has the same name as log forward section '%s' declared at %s:%d.\n", |
| 267 | file, linenum, proxy_cap_str(rc), args[1], |
| 268 | curproxy->id, curproxy->conf.file, curproxy->conf.line); |
| 269 | err_code |= ERR_ALERT | ERR_FATAL; |
| 270 | } |
| 271 | |
Willy Tarreau | 7c0b4d8 | 2021-02-12 14:58:08 +0100 | [diff] [blame] | 272 | if ((*args[2] && (!*args[3] || strcmp(args[2], "from") != 0)) || |
| 273 | alertif_too_many_args(3, file, linenum, args, &err_code)) { |
Willy Tarreau | 7683893 | 2021-02-12 08:49:47 +0100 | [diff] [blame] | 274 | if (rc & PR_CAP_FE) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 275 | ha_alert("parsing [%s:%d] : please use the 'bind' keyword for listening addresses.\n", file, linenum); |
| 276 | goto out; |
| 277 | } |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 278 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 279 | |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 280 | if (rc & PR_CAP_LISTEN) { /* new proxy or defaults section */ |
Willy Tarreau | 7c0b4d8 | 2021-02-12 14:58:08 +0100 | [diff] [blame] | 281 | const char *name = args[1]; |
| 282 | int arg = 2; |
| 283 | |
| 284 | if (rc & PR_CAP_DEF && strcmp(args[1], "from") == 0 && *args[2] && !*args[3]) { |
| 285 | // also support "defaults from blah" (no name then) |
| 286 | arg = 1; |
| 287 | name = ""; |
| 288 | } |
| 289 | |
| 290 | /* only regular proxies inherit from the previous defaults section */ |
| 291 | if (!(rc & PR_CAP_DEF)) |
| 292 | curr_defproxy = last_defproxy; |
| 293 | |
| 294 | if (strcmp(args[arg], "from") == 0) { |
| 295 | curr_defproxy = proxy_find_by_name(args[arg+1], PR_CAP_DEF, 0); |
| 296 | |
| 297 | if (!curr_defproxy) { |
| 298 | ha_alert("parsing [%s:%d] : defaults section '%s' not found for %s '%s'.\n", file, linenum, args[arg+1], proxy_cap_str(rc), name); |
| 299 | err_code |= ERR_ALERT | ERR_ABORT; |
| 300 | goto out; |
| 301 | } |
| 302 | |
| 303 | if (ebpt_next_dup(&curr_defproxy->conf.by_name)) { |
| 304 | struct proxy *px2 = container_of(ebpt_next_dup(&curr_defproxy->conf.by_name), struct proxy, conf.by_name); |
| 305 | |
| 306 | ha_alert("parsing [%s:%d] : ambiguous defaults section name '%s' referenced by %s '%s' exists at least at %s:%d and %s:%d.\n", |
| 307 | file, linenum, args[arg+1], proxy_cap_str(rc), name, |
| 308 | curr_defproxy->conf.file, curr_defproxy->conf.line, px2->conf.file, px2->conf.line); |
| 309 | err_code |= ERR_ALERT | ERR_FATAL; |
| 310 | } |
| 311 | |
| 312 | err = invalid_char(args[arg+1]); |
| 313 | if (err) { |
| 314 | ha_alert("parsing [%s:%d] : character '%c' is not permitted in defaults section name '%s' when designated by its name (section found at %s:%d).\n", |
| 315 | file, linenum, *err, args[arg+1], curr_defproxy->conf.file, curr_defproxy->conf.line); |
| 316 | err_code |= ERR_ALERT | ERR_FATAL; |
| 317 | } |
Christopher Faulet | b405420 | 2021-10-12 18:57:43 +0200 | [diff] [blame] | 318 | curr_defproxy->flags |= PR_FL_EXPLICIT_REF; |
| 319 | } |
| 320 | else if (curr_defproxy) |
| 321 | curr_defproxy->flags |= PR_FL_IMPLICIT_REF; |
| 322 | |
| 323 | if (curr_defproxy && (curr_defproxy->flags & (PR_FL_EXPLICIT_REF|PR_FL_IMPLICIT_REF)) == (PR_FL_EXPLICIT_REF|PR_FL_IMPLICIT_REF)) { |
| 324 | ha_alert("parsing [%s:%d] : defaults section '%s' (declared at %s:%d) is explicitly referenced by another proxy and implicitly used here." |
| 325 | " To avoid any ambiguity don't mix both usage. Add a last defaults section not explicitly used or always use explicit references.\n", |
| 326 | file, linenum, curr_defproxy->id, curr_defproxy->conf.file, curr_defproxy->conf.line); |
| 327 | err_code |= ERR_WARN; |
Willy Tarreau | 7c0b4d8 | 2021-02-12 14:58:08 +0100 | [diff] [blame] | 328 | } |
| 329 | |
Amaury Denoyelle | 476b9ad | 2021-03-23 17:27:05 +0100 | [diff] [blame] | 330 | curproxy = parse_new_proxy(name, rc, file, linenum, curr_defproxy); |
Willy Tarreau | 7683893 | 2021-02-12 08:49:47 +0100 | [diff] [blame] | 331 | if (!curproxy) { |
Willy Tarreau | 7683893 | 2021-02-12 08:49:47 +0100 | [diff] [blame] | 332 | err_code |= ERR_ALERT | ERR_ABORT; |
Christopher Faulet | 76edc0f | 2020-01-13 15:52:01 +0100 | [diff] [blame] | 333 | goto out; |
| 334 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 335 | |
Christopher Faulet | ee08d6c | 2021-10-13 15:40:15 +0200 | [diff] [blame] | 336 | if (curr_defproxy && (!LIST_ISEMPTY(&curr_defproxy->http_req_rules) || |
| 337 | !LIST_ISEMPTY(&curr_defproxy->http_res_rules) || |
| 338 | !LIST_ISEMPTY(&curr_defproxy->http_after_res_rules) || |
| 339 | !LIST_ISEMPTY(&curr_defproxy->tcp_req.l4_rules) || |
| 340 | !LIST_ISEMPTY(&curr_defproxy->tcp_req.l5_rules) || |
| 341 | !LIST_ISEMPTY(&curr_defproxy->tcp_req.inspect_rules) || |
| 342 | !LIST_ISEMPTY(&curr_defproxy->tcp_rep.inspect_rules))) { |
| 343 | /* If the current default proxy defines TCP/HTTP rules, the |
| 344 | * current proxy will keep a reference on it. But some sanity |
| 345 | * checks are performed first: |
| 346 | * |
| 347 | * - It cannot be used to init a defaults section |
| 348 | * - It cannot be used to init a listen section |
| 349 | * - It cannot be used to init backend and frontend sections at |
| 350 | * same time. It can be used to init several sections of the |
| 351 | * same type only. |
| 352 | * - It cannot define L4/L5 TCP rules if it is used to init |
| 353 | * backend sections. |
| 354 | * - It cannot define 'tcp-response content' rules if it |
| 355 | * is used to init frontend sections. |
| 356 | * |
| 357 | * If no error is found, refcount of the default proxy is incremented. |
| 358 | */ |
| 359 | |
| 360 | /* Note: Add tcpcheck_rules too if unresolve args become allowed in defaults section */ |
| 361 | if (rc & PR_CAP_DEF) { |
| 362 | ha_alert("parsing [%s:%d]: a defaults section cannot inherit from a defaults section defining TCP/HTTP rules (defaults section at %s:%d).\n", |
| 363 | file, linenum, curr_defproxy->conf.file, curr_defproxy->conf.line); |
| 364 | err_code |= ERR_ALERT | ERR_ABORT; |
| 365 | } |
| 366 | else if ((rc & PR_CAP_LISTEN) == PR_CAP_LISTEN) { |
| 367 | ha_alert("parsing [%s:%d]: a listen section cannot inherit from a defaults section defining TCP/HTTP rules.\n", |
| 368 | file, linenum); |
| 369 | err_code |= ERR_ALERT | ERR_ABORT; |
| 370 | } |
| 371 | else { |
| 372 | char defcap = (curr_defproxy->cap & PR_CAP_LISTEN); |
| 373 | |
| 374 | if ((defcap == PR_CAP_BE || defcap == PR_CAP_FE) && (rc & PR_CAP_LISTEN) != defcap) { |
| 375 | ha_alert("parsing [%s:%d]: frontends and backends cannot inherit from the same defaults section" |
| 376 | " if it defines TCP/HTTP rules (defaults section at %s:%d).\n", |
| 377 | file, linenum, curr_defproxy->conf.file, curr_defproxy->conf.line); |
| 378 | err_code |= ERR_ALERT | ERR_ABORT; |
| 379 | } |
| 380 | else if (!(rc & PR_CAP_FE) && (!LIST_ISEMPTY(&curr_defproxy->tcp_req.l4_rules) || |
| 381 | !LIST_ISEMPTY(&curr_defproxy->tcp_req.l5_rules))) { |
| 382 | ha_alert("parsing [%s:%d]: a backend section cannot inherit from a defaults section defining" |
| 383 | " 'tcp-request connection' or 'tcp-request session' rules (defaults section at %s:%d).\n", |
| 384 | file, linenum, curr_defproxy->conf.file, curr_defproxy->conf.line); |
| 385 | err_code |= ERR_ALERT | ERR_ABORT; |
| 386 | } |
| 387 | else if (!(rc & PR_CAP_BE) && !LIST_ISEMPTY(&curr_defproxy->tcp_rep.inspect_rules)) { |
| 388 | ha_alert("parsing [%s:%d]: a frontend section cannot inherit from a defaults section defining" |
| 389 | " 'tcp-response content' rules (defaults section at %s:%d).\n", |
| 390 | file, linenum, curr_defproxy->conf.file, curr_defproxy->conf.line); |
| 391 | err_code |= ERR_ALERT | ERR_ABORT; |
| 392 | } |
| 393 | else { |
| 394 | curr_defproxy->cap = (curr_defproxy->cap & ~PR_CAP_LISTEN) | (rc & PR_CAP_LISTEN); |
| 395 | proxy_ref_defaults(curproxy, curr_defproxy); |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
Christopher Faulet | 6ff7de5 | 2021-10-13 15:18:36 +0200 | [diff] [blame] | 400 | if (curr_defproxy && (curr_defproxy->tcpcheck_rules.flags & TCPCHK_RULES_PROTO_CHK) && |
| 401 | (curproxy->cap & PR_CAP_LISTEN) == PR_CAP_BE) { |
| 402 | /* If the current default proxy defines tcpcheck rules, the |
| 403 | * current proxy will keep a reference on it. but only if the |
| 404 | * current proxy has the backend capability. |
| 405 | */ |
| 406 | proxy_ref_defaults(curproxy, curr_defproxy); |
| 407 | } |
| 408 | |
Willy Tarreau | e90904d | 2021-02-12 14:08:31 +0100 | [diff] [blame] | 409 | if (rc & PR_CAP_DEF) { |
| 410 | /* last and current proxies must be updated to this one */ |
| 411 | curr_defproxy = last_defproxy = curproxy; |
| 412 | } else { |
| 413 | /* regular proxies are in a list */ |
| 414 | curproxy->next = proxies_list; |
| 415 | proxies_list = curproxy; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 416 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 417 | goto out; |
| 418 | } |
| 419 | else if (curproxy == NULL) { |
| 420 | ha_alert("parsing [%s:%d] : 'listen' or 'defaults' expected.\n", file, linenum); |
| 421 | err_code |= ERR_ALERT | ERR_FATAL; |
| 422 | goto out; |
| 423 | } |
| 424 | |
| 425 | /* update the current file and line being parsed */ |
| 426 | curproxy->conf.args.file = curproxy->conf.file; |
| 427 | curproxy->conf.args.line = linenum; |
| 428 | |
| 429 | /* Now let's parse the proxy-specific keywords */ |
Amaury Denoyelle | 30c0537 | 2021-03-08 16:36:46 +0100 | [diff] [blame] | 430 | if ((strcmp(args[0], "server") == 0)) { |
| 431 | err_code |= parse_server(file, linenum, args, |
| 432 | curproxy, curr_defproxy, |
| 433 | SRV_PARSE_PARSE_ADDR); |
| 434 | |
| 435 | if (err_code & ERR_FATAL) |
| 436 | goto out; |
| 437 | } |
| 438 | else if (strcmp(args[0], "default-server") == 0) { |
| 439 | err_code |= parse_server(file, linenum, args, |
| 440 | curproxy, curr_defproxy, |
| 441 | SRV_PARSE_DEFAULT_SERVER); |
| 442 | |
| 443 | if (err_code & ERR_FATAL) |
| 444 | goto out; |
| 445 | } |
| 446 | else if (strcmp(args[0], "server-template") == 0) { |
| 447 | err_code |= parse_server(file, linenum, args, |
| 448 | curproxy, curr_defproxy, |
| 449 | SRV_PARSE_TEMPLATE|SRV_PARSE_PARSE_ADDR); |
| 450 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 451 | if (err_code & ERR_FATAL) |
| 452 | goto out; |
| 453 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 454 | else if (strcmp(args[0], "bind") == 0) { /* new listen addresses */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 455 | struct listener *l; |
| 456 | int cur_arg; |
| 457 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 458 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 459 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 460 | err_code |= ERR_ALERT | ERR_FATAL; |
| 461 | goto out; |
| 462 | } |
| 463 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 464 | err_code |= ERR_WARN; |
| 465 | |
| 466 | if (!*(args[1])) { |
| 467 | ha_alert("parsing [%s:%d] : '%s' expects {<path>|[addr1]:port1[-end1]}{,[addr]:port[-end]}... as arguments.\n", |
| 468 | file, linenum, args[0]); |
| 469 | err_code |= ERR_ALERT | ERR_FATAL; |
| 470 | goto out; |
| 471 | } |
| 472 | |
| 473 | bind_conf = bind_conf_alloc(curproxy, file, linenum, args[1], xprt_get(XPRT_RAW)); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 474 | if (!bind_conf) |
| 475 | goto alloc_error; |
| 476 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 477 | /* use default settings for unix sockets */ |
Willy Tarreau | 6e459d7 | 2020-09-03 07:09:09 +0200 | [diff] [blame] | 478 | bind_conf->settings.ux.uid = global.unix_bind.ux.uid; |
| 479 | bind_conf->settings.ux.gid = global.unix_bind.ux.gid; |
| 480 | bind_conf->settings.ux.mode = global.unix_bind.ux.mode; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 481 | |
| 482 | /* NOTE: the following line might create several listeners if there |
| 483 | * are comma-separated IPs or port ranges. So all further processing |
| 484 | * will have to be applied to all listeners created after last_listen. |
| 485 | */ |
| 486 | if (!str2listener(args[1], curproxy, bind_conf, file, linenum, &errmsg)) { |
| 487 | if (errmsg && *errmsg) { |
| 488 | indent_msg(&errmsg, 2); |
| 489 | ha_alert("parsing [%s:%d] : '%s' : %s\n", file, linenum, args[0], errmsg); |
| 490 | } |
| 491 | else |
| 492 | ha_alert("parsing [%s:%d] : '%s' : error encountered while parsing listening address '%s'.\n", |
| 493 | file, linenum, args[0], args[1]); |
| 494 | err_code |= ERR_ALERT | ERR_FATAL; |
| 495 | goto out; |
| 496 | } |
| 497 | |
| 498 | list_for_each_entry(l, &bind_conf->listeners, by_bind) { |
| 499 | /* Set default global rights and owner for unix bind */ |
| 500 | global.maxsock++; |
| 501 | } |
| 502 | |
| 503 | cur_arg = 2; |
| 504 | while (*(args[cur_arg])) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 505 | struct bind_kw *kw; |
Willy Tarreau | 433b05f | 2021-03-12 10:14:07 +0100 | [diff] [blame] | 506 | const char *best; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 507 | |
| 508 | kw = bind_find_kw(args[cur_arg]); |
| 509 | if (kw) { |
| 510 | char *err = NULL; |
| 511 | int code; |
| 512 | |
| 513 | if (!kw->parse) { |
| 514 | ha_alert("parsing [%s:%d] : '%s %s' : '%s' option is not implemented in this version (check build options).\n", |
| 515 | file, linenum, args[0], args[1], args[cur_arg]); |
| 516 | cur_arg += 1 + kw->skip ; |
| 517 | err_code |= ERR_ALERT | ERR_FATAL; |
| 518 | goto out; |
| 519 | } |
| 520 | |
| 521 | code = kw->parse(args, cur_arg, curproxy, bind_conf, &err); |
| 522 | err_code |= code; |
| 523 | |
| 524 | if (code) { |
| 525 | if (err && *err) { |
| 526 | indent_msg(&err, 2); |
Emeric Brun | 0655c9b | 2019-10-17 16:45:56 +0200 | [diff] [blame] | 527 | if (((code & (ERR_WARN|ERR_ALERT)) == ERR_WARN)) |
| 528 | ha_warning("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], err); |
| 529 | else |
| 530 | ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], err); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 531 | } |
| 532 | else |
| 533 | ha_alert("parsing [%s:%d] : '%s %s' : error encountered while processing '%s'.\n", |
| 534 | file, linenum, args[0], args[1], args[cur_arg]); |
| 535 | if (code & ERR_FATAL) { |
| 536 | free(err); |
| 537 | cur_arg += 1 + kw->skip; |
| 538 | goto out; |
| 539 | } |
| 540 | } |
| 541 | free(err); |
| 542 | cur_arg += 1 + kw->skip; |
| 543 | continue; |
| 544 | } |
| 545 | |
Willy Tarreau | 433b05f | 2021-03-12 10:14:07 +0100 | [diff] [blame] | 546 | best = bind_find_best_kw(args[cur_arg]); |
| 547 | if (best) |
| 548 | ha_alert("parsing [%s:%d] : '%s %s' unknown keyword '%s'; did you mean '%s' maybe ?\n", |
| 549 | file, linenum, args[0], args[1], args[cur_arg], best); |
| 550 | else |
| 551 | ha_alert("parsing [%s:%d] : '%s %s' unknown keyword '%s'.\n", |
| 552 | file, linenum, args[0], args[1], args[cur_arg]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 553 | |
| 554 | err_code |= ERR_ALERT | ERR_FATAL; |
| 555 | goto out; |
| 556 | } |
| 557 | goto out; |
| 558 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 559 | else if (strcmp(args[0], "monitor-net") == 0) { /* set the range of IPs to ignore */ |
Willy Tarreau | 9e9919d | 2020-10-14 15:55:23 +0200 | [diff] [blame] | 560 | ha_alert("parsing [%s:%d] : 'monitor-net' doesn't exist anymore. Please use 'http-request return status 200 if { src %s }' instead.\n", file, linenum, args[1]); |
| 561 | err_code |= ERR_ALERT | ERR_FATAL; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 562 | goto out; |
| 563 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 564 | else if (strcmp(args[0], "monitor-uri") == 0) { /* set the URI to intercept */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 565 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 566 | err_code |= ERR_WARN; |
| 567 | |
| 568 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 569 | goto out; |
| 570 | |
| 571 | if (!*args[1]) { |
| 572 | ha_alert("parsing [%s:%d] : '%s' expects an URI.\n", |
| 573 | file, linenum, args[0]); |
| 574 | err_code |= ERR_ALERT | ERR_FATAL; |
| 575 | goto out; |
| 576 | } |
| 577 | |
| 578 | free(curproxy->monitor_uri); |
| 579 | curproxy->monitor_uri_len = strlen(args[1]); |
| 580 | curproxy->monitor_uri = calloc(1, curproxy->monitor_uri_len + 1); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 581 | if (!curproxy->monitor_uri) |
| 582 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 583 | memcpy(curproxy->monitor_uri, args[1], curproxy->monitor_uri_len); |
| 584 | curproxy->monitor_uri[curproxy->monitor_uri_len] = '\0'; |
| 585 | |
| 586 | goto out; |
| 587 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 588 | else if (strcmp(args[0], "mode") == 0) { /* sets the proxy mode */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 589 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 590 | goto out; |
| 591 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 592 | if (strcmp(args[1], "http") == 0) curproxy->mode = PR_MODE_HTTP; |
| 593 | else if (strcmp(args[1], "tcp") == 0) curproxy->mode = PR_MODE_TCP; |
| 594 | else if (strcmp(args[1], "health") == 0) { |
Willy Tarreau | 77e0dae | 2020-10-14 15:44:27 +0200 | [diff] [blame] | 595 | ha_alert("parsing [%s:%d] : 'mode health' doesn't exist anymore. Please use 'http-request return status 200' instead.\n", file, linenum); |
| 596 | err_code |= ERR_ALERT | ERR_FATAL; |
| 597 | goto out; |
| 598 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 599 | else { |
| 600 | ha_alert("parsing [%s:%d] : unknown proxy mode '%s'.\n", file, linenum, args[1]); |
| 601 | err_code |= ERR_ALERT | ERR_FATAL; |
| 602 | goto out; |
| 603 | } |
| 604 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 605 | else if (strcmp(args[0], "id") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 606 | struct eb32_node *node; |
| 607 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 608 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 609 | ha_alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", |
| 610 | file, linenum, args[0]); |
| 611 | err_code |= ERR_ALERT | ERR_FATAL; |
| 612 | goto out; |
| 613 | } |
| 614 | |
| 615 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 616 | goto out; |
| 617 | |
| 618 | if (!*args[1]) { |
| 619 | ha_alert("parsing [%s:%d]: '%s' expects an integer argument.\n", |
| 620 | file, linenum, args[0]); |
| 621 | err_code |= ERR_ALERT | ERR_FATAL; |
| 622 | goto out; |
| 623 | } |
| 624 | |
| 625 | curproxy->uuid = atol(args[1]); |
| 626 | curproxy->conf.id.key = curproxy->uuid; |
| 627 | curproxy->options |= PR_O_FORCED_ID; |
| 628 | |
| 629 | if (curproxy->uuid <= 0) { |
| 630 | ha_alert("parsing [%s:%d]: custom id has to be > 0.\n", |
| 631 | file, linenum); |
| 632 | err_code |= ERR_ALERT | ERR_FATAL; |
| 633 | goto out; |
| 634 | } |
| 635 | |
| 636 | node = eb32_lookup(&used_proxy_id, curproxy->uuid); |
| 637 | if (node) { |
| 638 | struct proxy *target = container_of(node, struct proxy, conf.id); |
| 639 | ha_alert("parsing [%s:%d]: %s %s reuses same custom id as %s %s (declared at %s:%d).\n", |
| 640 | file, linenum, proxy_type_str(curproxy), curproxy->id, |
| 641 | proxy_type_str(target), target->id, target->conf.file, target->conf.line); |
| 642 | err_code |= ERR_ALERT | ERR_FATAL; |
| 643 | goto out; |
| 644 | } |
| 645 | eb32_insert(&used_proxy_id, &curproxy->conf.id); |
| 646 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 647 | else if (strcmp(args[0], "description") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 648 | int i, len=0; |
| 649 | char *d; |
| 650 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 651 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 652 | ha_alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", |
| 653 | file, linenum, args[0]); |
| 654 | err_code |= ERR_ALERT | ERR_FATAL; |
| 655 | goto out; |
| 656 | } |
| 657 | |
| 658 | if (!*args[1]) { |
| 659 | ha_alert("parsing [%s:%d]: '%s' expects a string argument.\n", |
| 660 | file, linenum, args[0]); |
| 661 | return -1; |
| 662 | } |
| 663 | |
| 664 | for (i = 1; *args[i]; i++) |
| 665 | len += strlen(args[i]) + 1; |
| 666 | |
| 667 | d = calloc(1, len); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 668 | if (!d) |
| 669 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 670 | curproxy->desc = d; |
| 671 | |
| 672 | d += snprintf(d, curproxy->desc + len - d, "%s", args[1]); |
| 673 | for (i = 2; *args[i]; i++) |
| 674 | d += snprintf(d, curproxy->desc + len - d, " %s", args[i]); |
| 675 | |
| 676 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 677 | else if (strcmp(args[0], "disabled") == 0) { /* disables this proxy */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 678 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 679 | goto out; |
Christopher Faulet | dfd10ab | 2021-10-06 14:24:19 +0200 | [diff] [blame] | 680 | curproxy->flags |= PR_FL_DISABLED; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 681 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 682 | else if (strcmp(args[0], "enabled") == 0) { /* enables this proxy (used to revert a disabled default) */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 683 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 684 | goto out; |
Christopher Faulet | dfd10ab | 2021-10-06 14:24:19 +0200 | [diff] [blame] | 685 | curproxy->flags &= ~PR_FL_DISABLED; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 686 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 687 | else if (strcmp(args[0], "bind-process") == 0) { /* enable this proxy only on some processes */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 688 | int cur_arg = 1; |
| 689 | unsigned long set = 0; |
| 690 | |
| 691 | while (*args[cur_arg]) { |
| 692 | if (strcmp(args[cur_arg], "all") == 0) { |
| 693 | set = 0; |
| 694 | break; |
| 695 | } |
Willy Tarreau | 72faef3 | 2021-06-15 08:36:30 +0200 | [diff] [blame] | 696 | if (parse_process_number(args[cur_arg], &set, 1, NULL, &errmsg)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 697 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 698 | err_code |= ERR_ALERT | ERR_FATAL; |
| 699 | goto out; |
| 700 | } |
| 701 | cur_arg++; |
| 702 | } |
Willy Tarreau | b54ca70 | 2021-06-15 11:37:35 +0200 | [diff] [blame] | 703 | ha_warning("parsing [%s:%d]: '%s' has no effect, is deprecated, and will be removed in version 2.7.\n", |
| 704 | file, linenum, args[0]); |
| 705 | err_code |= ERR_WARN; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 706 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 707 | else if (strcmp(args[0], "acl") == 0) { /* add an ACL */ |
Christopher Faulet | ee08d6c | 2021-10-13 15:40:15 +0200 | [diff] [blame] | 708 | if ((curproxy->cap & PR_CAP_DEF) && strlen(curproxy->id) == 0) { |
| 709 | ha_alert("parsing [%s:%d] : '%s' not allowed in anonymous 'defaults' section.\n", file, linenum, args[0]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 710 | err_code |= ERR_ALERT | ERR_FATAL; |
| 711 | goto out; |
| 712 | } |
| 713 | |
| 714 | err = invalid_char(args[1]); |
| 715 | if (err) { |
| 716 | ha_alert("parsing [%s:%d] : character '%c' is not permitted in acl name '%s'.\n", |
| 717 | file, linenum, *err, args[1]); |
| 718 | err_code |= ERR_ALERT | ERR_FATAL; |
| 719 | goto out; |
| 720 | } |
| 721 | |
Tim Duesterhus | 0cf811a | 2020-02-05 21:00:50 +0100 | [diff] [blame] | 722 | if (strcasecmp(args[1], "or") == 0) { |
Tim Duesterhus | f1bc24c | 2020-02-06 22:04:03 +0100 | [diff] [blame] | 723 | ha_alert("parsing [%s:%d] : acl name '%s' will never match. 'or' is used to express a " |
Tim Duesterhus | 0cf811a | 2020-02-05 21:00:50 +0100 | [diff] [blame] | 724 | "logical disjunction within a condition.\n", |
| 725 | file, linenum, args[1]); |
| 726 | err_code |= ERR_ALERT | ERR_FATAL; |
| 727 | goto out; |
| 728 | } |
| 729 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 730 | if (parse_acl((const char **)args + 1, &curproxy->acl, &errmsg, &curproxy->conf.args, file, linenum) == NULL) { |
| 731 | ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n", |
| 732 | file, linenum, args[1], errmsg); |
| 733 | err_code |= ERR_ALERT | ERR_FATAL; |
| 734 | goto out; |
| 735 | } |
| 736 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 737 | else if (strcmp(args[0], "dynamic-cookie-key") == 0) { /* Dynamic cookies secret key */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 738 | |
| 739 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 740 | err_code |= ERR_WARN; |
| 741 | |
| 742 | if (*(args[1]) == 0) { |
| 743 | ha_alert("parsing [%s:%d] : '%s' expects <secret_key> as argument.\n", |
| 744 | file, linenum, args[0]); |
| 745 | err_code |= ERR_ALERT | ERR_FATAL; |
| 746 | goto out; |
| 747 | } |
| 748 | free(curproxy->dyncookie_key); |
| 749 | curproxy->dyncookie_key = strdup(args[1]); |
| 750 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 751 | else if (strcmp(args[0], "cookie") == 0) { /* cookie name */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 752 | int cur_arg; |
| 753 | |
| 754 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 755 | err_code |= ERR_WARN; |
| 756 | |
| 757 | if (*(args[1]) == 0) { |
| 758 | ha_alert("parsing [%s:%d] : '%s' expects <cookie_name> as argument.\n", |
| 759 | file, linenum, args[0]); |
| 760 | err_code |= ERR_ALERT | ERR_FATAL; |
| 761 | goto out; |
| 762 | } |
| 763 | |
| 764 | curproxy->ck_opts = 0; |
| 765 | curproxy->cookie_maxidle = curproxy->cookie_maxlife = 0; |
Willy Tarreau | 61cfdf4 | 2021-02-20 10:46:51 +0100 | [diff] [blame] | 766 | ha_free(&curproxy->cookie_domain); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 767 | free(curproxy->cookie_name); |
| 768 | curproxy->cookie_name = strdup(args[1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 769 | if (!curproxy->cookie_name) |
| 770 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 771 | curproxy->cookie_len = strlen(curproxy->cookie_name); |
| 772 | |
| 773 | cur_arg = 2; |
| 774 | while (*(args[cur_arg])) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 775 | if (strcmp(args[cur_arg], "rewrite") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 776 | curproxy->ck_opts |= PR_CK_RW; |
| 777 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 778 | else if (strcmp(args[cur_arg], "indirect") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 779 | curproxy->ck_opts |= PR_CK_IND; |
| 780 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 781 | else if (strcmp(args[cur_arg], "insert") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 782 | curproxy->ck_opts |= PR_CK_INS; |
| 783 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 784 | else if (strcmp(args[cur_arg], "nocache") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 785 | curproxy->ck_opts |= PR_CK_NOC; |
| 786 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 787 | else if (strcmp(args[cur_arg], "postonly") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 788 | curproxy->ck_opts |= PR_CK_POST; |
| 789 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 790 | else if (strcmp(args[cur_arg], "preserve") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 791 | curproxy->ck_opts |= PR_CK_PSV; |
| 792 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 793 | else if (strcmp(args[cur_arg], "prefix") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 794 | curproxy->ck_opts |= PR_CK_PFX; |
| 795 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 796 | else if (strcmp(args[cur_arg], "httponly") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 797 | curproxy->ck_opts |= PR_CK_HTTPONLY; |
| 798 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 799 | else if (strcmp(args[cur_arg], "secure") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 800 | curproxy->ck_opts |= PR_CK_SECURE; |
| 801 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 802 | else if (strcmp(args[cur_arg], "domain") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 803 | if (!*args[cur_arg + 1]) { |
| 804 | ha_alert("parsing [%s:%d]: '%s' expects <domain> as argument.\n", |
| 805 | file, linenum, args[cur_arg]); |
| 806 | err_code |= ERR_ALERT | ERR_FATAL; |
| 807 | goto out; |
| 808 | } |
| 809 | |
Joao Morais | e158375 | 2019-10-30 21:04:00 -0300 | [diff] [blame] | 810 | if (!strchr(args[cur_arg + 1], '.')) { |
| 811 | /* rfc6265, 5.2.3 The Domain Attribute */ |
| 812 | ha_warning("parsing [%s:%d]: domain '%s' contains no embedded dot," |
| 813 | " this configuration may not work properly (see RFC6265#5.2.3).\n", |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 814 | file, linenum, args[cur_arg + 1]); |
| 815 | err_code |= ERR_WARN; |
| 816 | } |
| 817 | |
| 818 | err = invalid_domainchar(args[cur_arg + 1]); |
| 819 | if (err) { |
| 820 | ha_alert("parsing [%s:%d]: character '%c' is not permitted in domain name '%s'.\n", |
| 821 | file, linenum, *err, args[cur_arg + 1]); |
| 822 | err_code |= ERR_ALERT | ERR_FATAL; |
| 823 | goto out; |
| 824 | } |
| 825 | |
| 826 | if (!curproxy->cookie_domain) { |
| 827 | curproxy->cookie_domain = strdup(args[cur_arg + 1]); |
| 828 | } else { |
| 829 | /* one domain was already specified, add another one by |
| 830 | * building the string which will be returned along with |
| 831 | * the cookie. |
| 832 | */ |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 833 | memprintf(&curproxy->cookie_domain, "%s; domain=%s", curproxy->cookie_domain, args[cur_arg+1]); |
| 834 | } |
| 835 | |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 836 | if (!curproxy->cookie_domain) |
| 837 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 838 | cur_arg++; |
| 839 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 840 | else if (strcmp(args[cur_arg], "maxidle") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 841 | unsigned int maxidle; |
| 842 | const char *res; |
| 843 | |
| 844 | if (!*args[cur_arg + 1]) { |
| 845 | ha_alert("parsing [%s:%d]: '%s' expects <idletime> in seconds as argument.\n", |
| 846 | file, linenum, args[cur_arg]); |
| 847 | err_code |= ERR_ALERT | ERR_FATAL; |
| 848 | goto out; |
| 849 | } |
| 850 | |
| 851 | res = parse_time_err(args[cur_arg + 1], &maxidle, TIME_UNIT_S); |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 852 | if (res == PARSE_TIME_OVER) { |
| 853 | ha_alert("parsing [%s:%d]: timer overflow in argument <%s> to <%s>, maximum value is 2147483647 s (~68 years).\n", |
| 854 | file, linenum, args[cur_arg+1], args[cur_arg]); |
| 855 | err_code |= ERR_ALERT | ERR_FATAL; |
| 856 | goto out; |
| 857 | } |
| 858 | else if (res == PARSE_TIME_UNDER) { |
| 859 | ha_alert("parsing [%s:%d]: timer underflow in argument <%s> to <%s>, minimum non-null value is 1 s.\n", |
| 860 | file, linenum, args[cur_arg+1], args[cur_arg]); |
| 861 | err_code |= ERR_ALERT | ERR_FATAL; |
| 862 | goto out; |
| 863 | } |
| 864 | else if (res) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 865 | ha_alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n", |
| 866 | file, linenum, *res, args[cur_arg]); |
| 867 | err_code |= ERR_ALERT | ERR_FATAL; |
| 868 | goto out; |
| 869 | } |
| 870 | curproxy->cookie_maxidle = maxidle; |
| 871 | cur_arg++; |
| 872 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 873 | else if (strcmp(args[cur_arg], "maxlife") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 874 | unsigned int maxlife; |
| 875 | const char *res; |
| 876 | |
| 877 | if (!*args[cur_arg + 1]) { |
| 878 | ha_alert("parsing [%s:%d]: '%s' expects <lifetime> in seconds as argument.\n", |
| 879 | file, linenum, args[cur_arg]); |
| 880 | err_code |= ERR_ALERT | ERR_FATAL; |
| 881 | goto out; |
| 882 | } |
| 883 | |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 884 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 885 | res = parse_time_err(args[cur_arg + 1], &maxlife, TIME_UNIT_S); |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 886 | if (res == PARSE_TIME_OVER) { |
| 887 | ha_alert("parsing [%s:%d]: timer overflow in argument <%s> to <%s>, maximum value is 2147483647 s (~68 years).\n", |
| 888 | file, linenum, args[cur_arg+1], args[cur_arg]); |
| 889 | err_code |= ERR_ALERT | ERR_FATAL; |
| 890 | goto out; |
| 891 | } |
| 892 | else if (res == PARSE_TIME_UNDER) { |
| 893 | ha_alert("parsing [%s:%d]: timer underflow in argument <%s> to <%s>, minimum non-null value is 1 s.\n", |
| 894 | file, linenum, args[cur_arg+1], args[cur_arg]); |
| 895 | err_code |= ERR_ALERT | ERR_FATAL; |
| 896 | goto out; |
| 897 | } |
| 898 | else if (res) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 899 | ha_alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n", |
| 900 | file, linenum, *res, args[cur_arg]); |
| 901 | err_code |= ERR_ALERT | ERR_FATAL; |
| 902 | goto out; |
| 903 | } |
| 904 | curproxy->cookie_maxlife = maxlife; |
| 905 | cur_arg++; |
| 906 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 907 | else if (strcmp(args[cur_arg], "dynamic") == 0) { /* Dynamic persistent cookies secret key */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 908 | |
| 909 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[cur_arg], NULL)) |
| 910 | err_code |= ERR_WARN; |
| 911 | curproxy->ck_opts |= PR_CK_DYNAMIC; |
| 912 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 913 | else if (strcmp(args[cur_arg], "attr") == 0) { |
Christopher Faulet | 2f53390 | 2020-01-21 11:06:48 +0100 | [diff] [blame] | 914 | char *val; |
| 915 | if (!*args[cur_arg + 1]) { |
| 916 | ha_alert("parsing [%s:%d]: '%s' expects <value> as argument.\n", |
| 917 | file, linenum, args[cur_arg]); |
| 918 | err_code |= ERR_ALERT | ERR_FATAL; |
| 919 | goto out; |
| 920 | } |
| 921 | val = args[cur_arg + 1]; |
| 922 | while (*val) { |
Willy Tarreau | 9080711 | 2020-02-25 08:16:33 +0100 | [diff] [blame] | 923 | if (iscntrl((unsigned char)*val) || *val == ';') { |
Christopher Faulet | 2f53390 | 2020-01-21 11:06:48 +0100 | [diff] [blame] | 924 | ha_alert("parsing [%s:%d]: character '%%x%02X' is not permitted in attribute value.\n", |
| 925 | file, linenum, *val); |
| 926 | err_code |= ERR_ALERT | ERR_FATAL; |
| 927 | goto out; |
| 928 | } |
| 929 | val++; |
| 930 | } |
| 931 | /* don't add ';' for the first attribute */ |
| 932 | if (!curproxy->cookie_attrs) |
| 933 | curproxy->cookie_attrs = strdup(args[cur_arg + 1]); |
| 934 | else |
| 935 | memprintf(&curproxy->cookie_attrs, "%s; %s", curproxy->cookie_attrs, args[cur_arg + 1]); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 936 | |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 937 | if (!curproxy->cookie_attrs) |
| 938 | goto alloc_error; |
Christopher Faulet | 2f53390 | 2020-01-21 11:06:48 +0100 | [diff] [blame] | 939 | cur_arg++; |
| 940 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 941 | |
| 942 | else { |
Christopher Faulet | 2f53390 | 2020-01-21 11:06:48 +0100 | [diff] [blame] | 943 | ha_alert("parsing [%s:%d] : '%s' supports 'rewrite', 'insert', 'prefix', 'indirect', 'nocache', 'postonly', 'domain', 'maxidle', 'dynamic', 'maxlife' and 'attr' options.\n", |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 944 | file, linenum, args[0]); |
| 945 | err_code |= ERR_ALERT | ERR_FATAL; |
| 946 | goto out; |
| 947 | } |
| 948 | cur_arg++; |
| 949 | } |
| 950 | if (!POWEROF2(curproxy->ck_opts & (PR_CK_RW|PR_CK_IND))) { |
| 951 | ha_alert("parsing [%s:%d] : cookie 'rewrite' and 'indirect' modes are incompatible.\n", |
| 952 | file, linenum); |
| 953 | err_code |= ERR_ALERT | ERR_FATAL; |
| 954 | } |
| 955 | |
| 956 | if (!POWEROF2(curproxy->ck_opts & (PR_CK_RW|PR_CK_INS|PR_CK_PFX))) { |
| 957 | ha_alert("parsing [%s:%d] : cookie 'rewrite', 'insert' and 'prefix' modes are incompatible.\n", |
| 958 | file, linenum); |
| 959 | err_code |= ERR_ALERT | ERR_FATAL; |
| 960 | } |
| 961 | |
| 962 | if ((curproxy->ck_opts & (PR_CK_PSV | PR_CK_INS | PR_CK_IND)) == PR_CK_PSV) { |
| 963 | ha_alert("parsing [%s:%d] : cookie 'preserve' requires at least 'insert' or 'indirect'.\n", |
| 964 | file, linenum); |
| 965 | err_code |= ERR_ALERT | ERR_FATAL; |
| 966 | } |
| 967 | }/* end else if (!strcmp(args[0], "cookie")) */ |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 968 | else if (strcmp(args[0], "email-alert") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 969 | if (*(args[1]) == 0) { |
| 970 | ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", |
| 971 | file, linenum, args[0]); |
| 972 | err_code |= ERR_ALERT | ERR_FATAL; |
| 973 | goto out; |
| 974 | } |
| 975 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 976 | if (strcmp(args[1], "from") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 977 | if (*(args[1]) == 0) { |
| 978 | ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", |
| 979 | file, linenum, args[1]); |
| 980 | err_code |= ERR_ALERT | ERR_FATAL; |
| 981 | goto out; |
| 982 | } |
| 983 | free(curproxy->email_alert.from); |
| 984 | curproxy->email_alert.from = strdup(args[2]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 985 | if (!curproxy->email_alert.from) |
| 986 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 987 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 988 | else if (strcmp(args[1], "mailers") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 989 | if (*(args[1]) == 0) { |
| 990 | ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", |
| 991 | file, linenum, args[1]); |
| 992 | err_code |= ERR_ALERT | ERR_FATAL; |
| 993 | goto out; |
| 994 | } |
| 995 | free(curproxy->email_alert.mailers.name); |
| 996 | curproxy->email_alert.mailers.name = strdup(args[2]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 997 | if (!curproxy->email_alert.mailers.name) |
| 998 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 999 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1000 | else if (strcmp(args[1], "myhostname") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1001 | if (*(args[1]) == 0) { |
| 1002 | ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", |
| 1003 | file, linenum, args[1]); |
| 1004 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1005 | goto out; |
| 1006 | } |
| 1007 | free(curproxy->email_alert.myhostname); |
| 1008 | curproxy->email_alert.myhostname = strdup(args[2]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1009 | if (!curproxy->email_alert.myhostname) |
| 1010 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1011 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1012 | else if (strcmp(args[1], "level") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1013 | curproxy->email_alert.level = get_log_level(args[2]); |
| 1014 | if (curproxy->email_alert.level < 0) { |
| 1015 | ha_alert("parsing [%s:%d] : unknown log level '%s' after '%s'\n", |
| 1016 | file, linenum, args[1], args[2]); |
| 1017 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1018 | goto out; |
| 1019 | } |
| 1020 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1021 | else if (strcmp(args[1], "to") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1022 | if (*(args[1]) == 0) { |
| 1023 | ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", |
| 1024 | file, linenum, args[1]); |
| 1025 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1026 | goto out; |
| 1027 | } |
| 1028 | free(curproxy->email_alert.to); |
| 1029 | curproxy->email_alert.to = strdup(args[2]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1030 | if (!curproxy->email_alert.to) |
| 1031 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1032 | } |
| 1033 | else { |
| 1034 | ha_alert("parsing [%s:%d] : email-alert: unknown argument '%s'.\n", |
| 1035 | file, linenum, args[1]); |
| 1036 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1037 | goto out; |
| 1038 | } |
| 1039 | /* Indicate that the email_alert is at least partially configured */ |
| 1040 | curproxy->email_alert.set = 1; |
| 1041 | }/* end else if (!strcmp(args[0], "email-alert")) */ |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1042 | else if (strcmp(args[0], "persist") == 0) { /* persist */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1043 | if (*(args[1]) == 0) { |
| 1044 | ha_alert("parsing [%s:%d] : missing persist method.\n", |
| 1045 | file, linenum); |
| 1046 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1047 | goto out; |
| 1048 | } |
| 1049 | |
| 1050 | if (!strncmp(args[1], "rdp-cookie", 10)) { |
| 1051 | curproxy->options2 |= PR_O2_RDPC_PRST; |
| 1052 | |
| 1053 | if (*(args[1] + 10) == '(') { /* cookie name */ |
| 1054 | const char *beg, *end; |
| 1055 | |
| 1056 | beg = args[1] + 11; |
| 1057 | end = strchr(beg, ')'); |
| 1058 | |
| 1059 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 1060 | goto out; |
| 1061 | |
| 1062 | if (!end || end == beg) { |
| 1063 | ha_alert("parsing [%s:%d] : persist rdp-cookie(name)' requires an rdp cookie name.\n", |
| 1064 | file, linenum); |
| 1065 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1066 | goto out; |
| 1067 | } |
| 1068 | |
| 1069 | free(curproxy->rdp_cookie_name); |
| 1070 | curproxy->rdp_cookie_name = my_strndup(beg, end - beg); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1071 | if (!curproxy->rdp_cookie_name) |
| 1072 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1073 | curproxy->rdp_cookie_len = end-beg; |
| 1074 | } |
| 1075 | else if (*(args[1] + 10) == '\0') { /* default cookie name 'msts' */ |
| 1076 | free(curproxy->rdp_cookie_name); |
| 1077 | curproxy->rdp_cookie_name = strdup("msts"); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1078 | if (!curproxy->rdp_cookie_name) |
| 1079 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1080 | curproxy->rdp_cookie_len = strlen(curproxy->rdp_cookie_name); |
| 1081 | } |
| 1082 | else { /* syntax */ |
| 1083 | ha_alert("parsing [%s:%d] : persist rdp-cookie(name)' requires an rdp cookie name.\n", |
| 1084 | file, linenum); |
| 1085 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1086 | goto out; |
| 1087 | } |
| 1088 | } |
| 1089 | else { |
| 1090 | ha_alert("parsing [%s:%d] : unknown persist method.\n", |
| 1091 | file, linenum); |
| 1092 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1093 | goto out; |
| 1094 | } |
| 1095 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1096 | else if (strcmp(args[0], "appsession") == 0) { /* cookie name */ |
Tim Duesterhus | 473c283 | 2019-05-06 01:19:52 +0200 | [diff] [blame] | 1097 | ha_alert("parsing [%s:%d] : '%s' is not supported anymore since HAProxy 1.6.\n", file, linenum, args[0]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1098 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1099 | goto out; |
| 1100 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1101 | else if (strcmp(args[0], "load-server-state-from-file") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1102 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 1103 | err_code |= ERR_WARN; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1104 | if (strcmp(args[1], "global") == 0) { /* use the file pointed to by global server-state-file directive */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1105 | curproxy->load_server_state_from_file = PR_SRV_STATE_FILE_GLOBAL; |
| 1106 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1107 | else if (strcmp(args[1], "local") == 0) { /* use the server-state-file-name variable to locate the server-state file */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1108 | curproxy->load_server_state_from_file = PR_SRV_STATE_FILE_LOCAL; |
| 1109 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1110 | else if (strcmp(args[1], "none") == 0) { /* don't use server-state-file directive for this backend */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1111 | curproxy->load_server_state_from_file = PR_SRV_STATE_FILE_NONE; |
| 1112 | } |
| 1113 | else { |
| 1114 | ha_alert("parsing [%s:%d] : '%s' expects 'global', 'local' or 'none'. Got '%s'\n", |
| 1115 | file, linenum, args[0], args[1]); |
| 1116 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1117 | goto out; |
| 1118 | } |
| 1119 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1120 | else if (strcmp(args[0], "server-state-file-name") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1121 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 1122 | err_code |= ERR_WARN; |
Christopher Faulet | 583b6de | 2021-02-12 09:27:10 +0100 | [diff] [blame] | 1123 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1124 | goto out; |
Christopher Faulet | 583b6de | 2021-02-12 09:27:10 +0100 | [diff] [blame] | 1125 | |
Willy Tarreau | 61cfdf4 | 2021-02-20 10:46:51 +0100 | [diff] [blame] | 1126 | ha_free(&curproxy->server_state_file_name); |
Christopher Faulet | 583b6de | 2021-02-12 09:27:10 +0100 | [diff] [blame] | 1127 | |
| 1128 | if (*(args[1]) == 0 || strcmp(args[1], "use-backend-name") == 0) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1129 | curproxy->server_state_file_name = strdup(curproxy->id); |
| 1130 | else |
| 1131 | curproxy->server_state_file_name = strdup(args[1]); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1132 | |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1133 | if (!curproxy->server_state_file_name) |
| 1134 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1135 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1136 | else if (strcmp(args[0], "max-session-srv-conns") == 0) { |
Olivier Houchard | a4d4fdf | 2018-12-14 19:27:06 +0100 | [diff] [blame] | 1137 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 1138 | err_code |= ERR_WARN; |
| 1139 | if (*(args[1]) == 0) { |
| 1140 | ha_alert("parsine [%s:%d] : '%s' expects a number. Got no argument\n", |
| 1141 | file, linenum, args[0]); |
| 1142 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1143 | goto out; |
| 1144 | } |
| 1145 | curproxy->max_out_conns = atoi(args[1]); |
| 1146 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1147 | else if (strcmp(args[0], "capture") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1148 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 1149 | err_code |= ERR_WARN; |
| 1150 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1151 | if (strcmp(args[1], "cookie") == 0) { /* name of a cookie to capture */ |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1152 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1153 | ha_alert("parsing [%s:%d] : '%s %s' not allowed in 'defaults' section.\n", file, linenum, args[0], args[1]); |
| 1154 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1155 | goto out; |
| 1156 | } |
| 1157 | |
| 1158 | if (alertif_too_many_args_idx(4, 1, file, linenum, args, &err_code)) |
| 1159 | goto out; |
| 1160 | |
| 1161 | if (*(args[4]) == 0) { |
| 1162 | ha_alert("parsing [%s:%d] : '%s' expects 'cookie' <cookie_name> 'len' <len>.\n", |
| 1163 | file, linenum, args[0]); |
| 1164 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1165 | goto out; |
| 1166 | } |
| 1167 | free(curproxy->capture_name); |
| 1168 | curproxy->capture_name = strdup(args[2]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1169 | if (!curproxy->capture_name) |
| 1170 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1171 | curproxy->capture_namelen = strlen(curproxy->capture_name); |
| 1172 | curproxy->capture_len = atol(args[4]); |
| 1173 | curproxy->to_log |= LW_COOKIE; |
| 1174 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1175 | else if (strcmp(args[1], "request") == 0 && strcmp(args[2], "header") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1176 | struct cap_hdr *hdr; |
| 1177 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1178 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1179 | ha_alert("parsing [%s:%d] : '%s %s' not allowed in 'defaults' section.\n", file, linenum, args[0], args[1]); |
| 1180 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1181 | goto out; |
| 1182 | } |
| 1183 | |
| 1184 | if (alertif_too_many_args_idx(4, 1, file, linenum, args, &err_code)) |
| 1185 | goto out; |
| 1186 | |
| 1187 | if (*(args[3]) == 0 || strcmp(args[4], "len") != 0 || *(args[5]) == 0) { |
| 1188 | ha_alert("parsing [%s:%d] : '%s %s' expects 'header' <header_name> 'len' <len>.\n", |
| 1189 | file, linenum, args[0], args[1]); |
| 1190 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1191 | goto out; |
| 1192 | } |
| 1193 | |
| 1194 | hdr = calloc(1, sizeof(*hdr)); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1195 | if (!hdr) |
| 1196 | goto req_caphdr_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1197 | hdr->next = curproxy->req_cap; |
| 1198 | hdr->name = strdup(args[3]); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1199 | if (!hdr->name) |
| 1200 | goto req_caphdr_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1201 | hdr->namelen = strlen(args[3]); |
| 1202 | hdr->len = atol(args[5]); |
| 1203 | hdr->pool = create_pool("caphdr", hdr->len + 1, MEM_F_SHARED); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1204 | if (!hdr->pool) { |
| 1205 | req_caphdr_alloc_error: |
| 1206 | if (hdr) |
| 1207 | ha_free(&hdr->name); |
| 1208 | ha_free(&hdr); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1209 | goto alloc_error; |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1210 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1211 | hdr->index = curproxy->nb_req_cap++; |
| 1212 | curproxy->req_cap = hdr; |
| 1213 | curproxy->to_log |= LW_REQHDR; |
| 1214 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1215 | else if (strcmp(args[1], "response") == 0 && strcmp(args[2], "header") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1216 | struct cap_hdr *hdr; |
| 1217 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1218 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1219 | ha_alert("parsing [%s:%d] : '%s %s' not allowed in 'defaults' section.\n", file, linenum, args[0], args[1]); |
| 1220 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1221 | goto out; |
| 1222 | } |
| 1223 | |
| 1224 | if (alertif_too_many_args_idx(4, 1, file, linenum, args, &err_code)) |
| 1225 | goto out; |
| 1226 | |
| 1227 | if (*(args[3]) == 0 || strcmp(args[4], "len") != 0 || *(args[5]) == 0) { |
| 1228 | ha_alert("parsing [%s:%d] : '%s %s' expects 'header' <header_name> 'len' <len>.\n", |
| 1229 | file, linenum, args[0], args[1]); |
| 1230 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1231 | goto out; |
| 1232 | } |
| 1233 | hdr = calloc(1, sizeof(*hdr)); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1234 | if (!hdr) |
| 1235 | goto res_caphdr_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1236 | hdr->next = curproxy->rsp_cap; |
| 1237 | hdr->name = strdup(args[3]); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1238 | if (!hdr->name) |
| 1239 | goto res_caphdr_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1240 | hdr->namelen = strlen(args[3]); |
| 1241 | hdr->len = atol(args[5]); |
| 1242 | hdr->pool = create_pool("caphdr", hdr->len + 1, MEM_F_SHARED); |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1243 | if (!hdr->pool) { |
| 1244 | res_caphdr_alloc_error: |
| 1245 | if (hdr) |
| 1246 | ha_free(&hdr->name); |
| 1247 | ha_free(&hdr); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1248 | goto alloc_error; |
Christopher Faulet | b45a7d4 | 2021-04-12 18:46:52 +0200 | [diff] [blame] | 1249 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1250 | hdr->index = curproxy->nb_rsp_cap++; |
| 1251 | curproxy->rsp_cap = hdr; |
| 1252 | curproxy->to_log |= LW_RSPHDR; |
| 1253 | } |
| 1254 | else { |
| 1255 | ha_alert("parsing [%s:%d] : '%s' expects 'cookie' or 'request header' or 'response header'.\n", |
| 1256 | file, linenum, args[0]); |
| 1257 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1258 | goto out; |
| 1259 | } |
| 1260 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1261 | else if (strcmp(args[0], "retries") == 0) { /* connection retries */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1262 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 1263 | err_code |= ERR_WARN; |
| 1264 | |
| 1265 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 1266 | goto out; |
| 1267 | |
| 1268 | if (*(args[1]) == 0) { |
| 1269 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument (dispatch counts for one).\n", |
| 1270 | file, linenum, args[0]); |
| 1271 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1272 | goto out; |
| 1273 | } |
| 1274 | curproxy->conn_retries = atol(args[1]); |
| 1275 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1276 | else if (strcmp(args[0], "http-request") == 0) { /* request access control: allow/deny/auth */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1277 | struct act_rule *rule; |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1278 | int where = 0; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1279 | |
Christopher Faulet | ee08d6c | 2021-10-13 15:40:15 +0200 | [diff] [blame] | 1280 | if ((curproxy->cap & PR_CAP_DEF) && strlen(curproxy->id) == 0) { |
| 1281 | ha_alert("parsing [%s:%d] : '%s' not allowed in anonymous 'defaults' section.\n", file, linenum, args[0]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1282 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1283 | goto out; |
| 1284 | } |
| 1285 | |
| 1286 | if (!LIST_ISEMPTY(&curproxy->http_req_rules) && |
| 1287 | !LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->cond && |
Christopher Faulet | 245cf79 | 2019-12-18 14:58:12 +0100 | [diff] [blame] | 1288 | (LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->flags & ACT_FLAG_FINAL)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1289 | ha_warning("parsing [%s:%d]: previous '%s' action is final and has no condition attached, further entries are NOOP.\n", |
| 1290 | file, linenum, args[0]); |
| 1291 | err_code |= ERR_WARN; |
| 1292 | } |
| 1293 | |
| 1294 | rule = parse_http_req_cond((const char **)args + 1, file, linenum, curproxy); |
| 1295 | |
| 1296 | if (!rule) { |
| 1297 | err_code |= ERR_ALERT | ERR_ABORT; |
| 1298 | goto out; |
| 1299 | } |
| 1300 | |
| 1301 | err_code |= warnif_misplaced_http_req(curproxy, file, linenum, args[0]); |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1302 | |
| 1303 | if (curproxy->cap & PR_CAP_FE) |
| 1304 | where |= SMP_VAL_FE_HRQ_HDR; |
| 1305 | if (curproxy->cap & PR_CAP_BE) |
| 1306 | where |= SMP_VAL_BE_HRQ_HDR; |
| 1307 | err_code |= warnif_cond_conflicts(rule->cond, where, file, linenum); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1308 | |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1309 | LIST_APPEND(&curproxy->http_req_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1310 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1311 | else if (strcmp(args[0], "http-response") == 0) { /* response access control */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1312 | struct act_rule *rule; |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1313 | int where = 0; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1314 | |
Christopher Faulet | ee08d6c | 2021-10-13 15:40:15 +0200 | [diff] [blame] | 1315 | if ((curproxy->cap & PR_CAP_DEF) && strlen(curproxy->id) == 0) { |
| 1316 | ha_alert("parsing [%s:%d] : '%s' not allowed in anonymous 'defaults' section.\n", file, linenum, args[0]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1317 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1318 | goto out; |
| 1319 | } |
| 1320 | |
| 1321 | if (!LIST_ISEMPTY(&curproxy->http_res_rules) && |
| 1322 | !LIST_PREV(&curproxy->http_res_rules, struct act_rule *, list)->cond && |
Christopher Faulet | 245cf79 | 2019-12-18 14:58:12 +0100 | [diff] [blame] | 1323 | (LIST_PREV(&curproxy->http_res_rules, struct act_rule *, list)->flags & ACT_FLAG_FINAL)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1324 | ha_warning("parsing [%s:%d]: previous '%s' action is final and has no condition attached, further entries are NOOP.\n", |
| 1325 | file, linenum, args[0]); |
| 1326 | err_code |= ERR_WARN; |
| 1327 | } |
| 1328 | |
| 1329 | rule = parse_http_res_cond((const char **)args + 1, file, linenum, curproxy); |
| 1330 | |
| 1331 | if (!rule) { |
| 1332 | err_code |= ERR_ALERT | ERR_ABORT; |
| 1333 | goto out; |
| 1334 | } |
| 1335 | |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1336 | if (curproxy->cap & PR_CAP_FE) |
| 1337 | where |= SMP_VAL_FE_HRS_HDR; |
| 1338 | if (curproxy->cap & PR_CAP_BE) |
| 1339 | where |= SMP_VAL_BE_HRS_HDR; |
| 1340 | err_code |= warnif_cond_conflicts(rule->cond, where, file, linenum); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1341 | |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1342 | LIST_APPEND(&curproxy->http_res_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1343 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1344 | else if (strcmp(args[0], "http-after-response") == 0) { |
Christopher Faulet | 6d0c3df | 2020-01-22 09:26:35 +0100 | [diff] [blame] | 1345 | struct act_rule *rule; |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1346 | int where = 0; |
Christopher Faulet | ee08d6c | 2021-10-13 15:40:15 +0200 | [diff] [blame] | 1347 | if ((curproxy->cap & PR_CAP_DEF) && strlen(curproxy->id) == 0) { |
| 1348 | ha_alert("parsing [%s:%d] : '%s' not allowed in anonymous 'defaults' section.\n", file, linenum, args[0]); |
Christopher Faulet | 6d0c3df | 2020-01-22 09:26:35 +0100 | [diff] [blame] | 1349 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1350 | goto out; |
| 1351 | } |
| 1352 | |
| 1353 | if (!LIST_ISEMPTY(&curproxy->http_after_res_rules) && |
| 1354 | !LIST_PREV(&curproxy->http_after_res_rules, struct act_rule *, list)->cond && |
| 1355 | (LIST_PREV(&curproxy->http_after_res_rules, struct act_rule *, list)->flags & ACT_FLAG_FINAL)) { |
| 1356 | ha_warning("parsing [%s:%d]: previous '%s' action is final and has no condition attached, further entries are NOOP.\n", |
| 1357 | file, linenum, args[0]); |
| 1358 | err_code |= ERR_WARN; |
| 1359 | } |
| 1360 | |
| 1361 | rule = parse_http_after_res_cond((const char **)args + 1, file, linenum, curproxy); |
| 1362 | |
| 1363 | if (!rule) { |
| 1364 | err_code |= ERR_ALERT | ERR_ABORT; |
| 1365 | goto out; |
| 1366 | } |
| 1367 | |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1368 | if (curproxy->cap & PR_CAP_FE) |
| 1369 | where |= SMP_VAL_FE_HRS_HDR; |
| 1370 | if (curproxy->cap & PR_CAP_BE) |
| 1371 | where |= SMP_VAL_BE_HRS_HDR; |
| 1372 | err_code |= warnif_cond_conflicts(rule->cond, where, file, linenum); |
Christopher Faulet | 6d0c3df | 2020-01-22 09:26:35 +0100 | [diff] [blame] | 1373 | |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1374 | LIST_APPEND(&curproxy->http_after_res_rules, &rule->list); |
Christopher Faulet | 6d0c3df | 2020-01-22 09:26:35 +0100 | [diff] [blame] | 1375 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1376 | else if (strcmp(args[0], "http-send-name-header") == 0) { /* send server name in request header */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1377 | /* set the header name and length into the proxy structure */ |
| 1378 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 1379 | err_code |= ERR_WARN; |
| 1380 | |
| 1381 | if (!*args[1]) { |
| 1382 | ha_alert("parsing [%s:%d] : '%s' requires a header string.\n", |
| 1383 | file, linenum, args[0]); |
| 1384 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1385 | goto out; |
| 1386 | } |
| 1387 | |
Christopher Faulet | dabcc8e | 2019-10-02 10:45:55 +0200 | [diff] [blame] | 1388 | /* set the desired header name, in lower case */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1389 | free(curproxy->server_id_hdr_name); |
| 1390 | curproxy->server_id_hdr_name = strdup(args[1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1391 | if (!curproxy->server_id_hdr_name) |
| 1392 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1393 | curproxy->server_id_hdr_len = strlen(curproxy->server_id_hdr_name); |
Christopher Faulet | dabcc8e | 2019-10-02 10:45:55 +0200 | [diff] [blame] | 1394 | ist2bin_lc(curproxy->server_id_hdr_name, ist2(curproxy->server_id_hdr_name, curproxy->server_id_hdr_len)); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1395 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1396 | else if (strcmp(args[0], "block") == 0) { |
Tim Duesterhus | 7b7c47f | 2019-05-14 20:57:57 +0200 | [diff] [blame] | 1397 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. Use 'http-request deny' which uses the exact same syntax.\n", file, linenum, args[0]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1398 | |
Tim Duesterhus | 7b7c47f | 2019-05-14 20:57:57 +0200 | [diff] [blame] | 1399 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1400 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1401 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1402 | else if (strcmp(args[0], "redirect") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1403 | struct redirect_rule *rule; |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1404 | int where = 0; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1405 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1406 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1407 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 1408 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1409 | goto out; |
| 1410 | } |
| 1411 | |
| 1412 | if ((rule = http_parse_redirect_rule(file, linenum, curproxy, (const char **)args + 1, &errmsg, 0, 0)) == NULL) { |
| 1413 | ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing redirect rule : %s.\n", |
| 1414 | file, linenum, proxy_type_str(curproxy), curproxy->id, errmsg); |
| 1415 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1416 | goto out; |
| 1417 | } |
| 1418 | |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1419 | LIST_APPEND(&curproxy->redirect_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1420 | err_code |= warnif_misplaced_redirect(curproxy, file, linenum, args[0]); |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1421 | |
| 1422 | if (curproxy->cap & PR_CAP_FE) |
| 1423 | where |= SMP_VAL_FE_HRQ_HDR; |
| 1424 | if (curproxy->cap & PR_CAP_BE) |
| 1425 | where |= SMP_VAL_BE_HRQ_HDR; |
| 1426 | err_code |= warnif_cond_conflicts(rule->cond, where, file, linenum); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1427 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1428 | else if (strcmp(args[0], "use_backend") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1429 | struct switching_rule *rule; |
| 1430 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1431 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1432 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 1433 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1434 | goto out; |
| 1435 | } |
| 1436 | |
| 1437 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 1438 | err_code |= ERR_WARN; |
| 1439 | |
| 1440 | if (*(args[1]) == 0) { |
| 1441 | ha_alert("parsing [%s:%d] : '%s' expects a backend name.\n", file, linenum, args[0]); |
| 1442 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1443 | goto out; |
| 1444 | } |
| 1445 | |
| 1446 | if (strcmp(args[2], "if") == 0 || strcmp(args[2], "unless") == 0) { |
| 1447 | if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) { |
| 1448 | ha_alert("parsing [%s:%d] : error detected while parsing switching rule : %s.\n", |
| 1449 | file, linenum, errmsg); |
| 1450 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1451 | goto out; |
| 1452 | } |
| 1453 | |
| 1454 | err_code |= warnif_cond_conflicts(cond, SMP_VAL_FE_SET_BCK, file, linenum); |
| 1455 | } |
| 1456 | else if (*args[2]) { |
| 1457 | ha_alert("parsing [%s:%d] : unexpected keyword '%s' after switching rule, only 'if' and 'unless' are allowed.\n", |
| 1458 | file, linenum, args[2]); |
| 1459 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1460 | goto out; |
| 1461 | } |
| 1462 | |
| 1463 | rule = calloc(1, sizeof(*rule)); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1464 | if (!rule) |
| 1465 | goto use_backend_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1466 | rule->cond = cond; |
| 1467 | rule->be.name = strdup(args[1]); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1468 | if (!rule->be.name) |
| 1469 | goto use_backend_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1470 | rule->line = linenum; |
| 1471 | rule->file = strdup(file); |
| 1472 | if (!rule->file) { |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1473 | use_backend_alloc_error: |
| 1474 | if (cond) |
| 1475 | prune_acl_cond(cond); |
| 1476 | ha_free(&cond); |
| 1477 | if (rule) |
| 1478 | ha_free(&(rule->be.name)); |
| 1479 | ha_free(&rule); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1480 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1481 | } |
| 1482 | LIST_INIT(&rule->list); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1483 | LIST_APPEND(&curproxy->switching_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1484 | } |
| 1485 | else if (strcmp(args[0], "use-server") == 0) { |
| 1486 | struct server_rule *rule; |
| 1487 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1488 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1489 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 1490 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1491 | goto out; |
| 1492 | } |
| 1493 | |
| 1494 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 1495 | err_code |= ERR_WARN; |
| 1496 | |
| 1497 | if (*(args[1]) == 0) { |
| 1498 | ha_alert("parsing [%s:%d] : '%s' expects a server name.\n", file, linenum, args[0]); |
| 1499 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1500 | goto out; |
| 1501 | } |
| 1502 | |
| 1503 | if (strcmp(args[2], "if") != 0 && strcmp(args[2], "unless") != 0) { |
| 1504 | ha_alert("parsing [%s:%d] : '%s' requires either 'if' or 'unless' followed by a condition.\n", |
| 1505 | file, linenum, args[0]); |
| 1506 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1507 | goto out; |
| 1508 | } |
| 1509 | |
| 1510 | if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) { |
| 1511 | ha_alert("parsing [%s:%d] : error detected while parsing switching rule : %s.\n", |
| 1512 | file, linenum, errmsg); |
| 1513 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1514 | goto out; |
| 1515 | } |
| 1516 | |
| 1517 | err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_SET_SRV, file, linenum); |
| 1518 | |
| 1519 | rule = calloc(1, sizeof(*rule)); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1520 | if (!rule) |
| 1521 | goto use_server_alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1522 | rule->cond = cond; |
| 1523 | rule->srv.name = strdup(args[1]); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1524 | if (!rule->srv.name) |
| 1525 | goto use_server_alloc_error; |
Jerome Magnin | 824186b | 2020-03-29 09:37:12 +0200 | [diff] [blame] | 1526 | rule->line = linenum; |
| 1527 | rule->file = strdup(file); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1528 | if (!rule->file) { |
| 1529 | use_server_alloc_error: |
| 1530 | if (cond) |
| 1531 | prune_acl_cond(cond); |
| 1532 | ha_free(&cond); |
| 1533 | if (rule) |
| 1534 | ha_free(&(rule->srv.name)); |
| 1535 | ha_free(&rule); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1536 | goto alloc_error; |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1537 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1538 | LIST_INIT(&rule->list); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1539 | LIST_APPEND(&curproxy->server_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1540 | curproxy->be_req_ana |= AN_REQ_SRV_RULES; |
| 1541 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1542 | else if ((strcmp(args[0], "force-persist") == 0) || |
| 1543 | (strcmp(args[0], "ignore-persist") == 0)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1544 | struct persist_rule *rule; |
| 1545 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1546 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1547 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 1548 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1549 | goto out; |
| 1550 | } |
| 1551 | |
| 1552 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 1553 | err_code |= ERR_WARN; |
| 1554 | |
| 1555 | if (strcmp(args[1], "if") != 0 && strcmp(args[1], "unless") != 0) { |
| 1556 | ha_alert("parsing [%s:%d] : '%s' requires either 'if' or 'unless' followed by a condition.\n", |
| 1557 | file, linenum, args[0]); |
| 1558 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1559 | goto out; |
| 1560 | } |
| 1561 | |
| 1562 | if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 1, &errmsg)) == NULL) { |
| 1563 | ha_alert("parsing [%s:%d] : error detected while parsing a '%s' rule : %s.\n", |
| 1564 | file, linenum, args[0], errmsg); |
| 1565 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1566 | goto out; |
| 1567 | } |
| 1568 | |
| 1569 | /* note: BE_REQ_CNT is the first one after FE_SET_BCK, which is |
| 1570 | * where force-persist is applied. |
| 1571 | */ |
| 1572 | err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_REQ_CNT, file, linenum); |
| 1573 | |
| 1574 | rule = calloc(1, sizeof(*rule)); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1575 | if (!rule) { |
| 1576 | if (cond) |
| 1577 | prune_acl_cond(cond); |
| 1578 | ha_free(&cond); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1579 | goto alloc_error; |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1580 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1581 | rule->cond = cond; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1582 | if (strcmp(args[0], "force-persist") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1583 | rule->type = PERSIST_TYPE_FORCE; |
| 1584 | } else { |
| 1585 | rule->type = PERSIST_TYPE_IGNORE; |
| 1586 | } |
| 1587 | LIST_INIT(&rule->list); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1588 | LIST_APPEND(&curproxy->persist_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1589 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1590 | else if (strcmp(args[0], "stick-table") == 0) { |
Frédéric Lécaille | 1b8e68e | 2019-03-14 07:07:41 +0100 | [diff] [blame] | 1591 | struct stktable *other; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1592 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1593 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1594 | ha_alert("parsing [%s:%d] : 'stick-table' is not supported in 'defaults' section.\n", |
| 1595 | file, linenum); |
| 1596 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1597 | goto out; |
| 1598 | } |
| 1599 | |
Frédéric Lécaille | 1b8e68e | 2019-03-14 07:07:41 +0100 | [diff] [blame] | 1600 | other = stktable_find_by_name(curproxy->id); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1601 | if (other) { |
| 1602 | ha_alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n", |
Frédéric Lécaille | 1b8e68e | 2019-03-14 07:07:41 +0100 | [diff] [blame] | 1603 | file, linenum, curproxy->id, |
| 1604 | other->proxy ? proxy_cap_str(other->proxy->cap) : "peers", |
| 1605 | other->proxy ? other->id : other->peers.p->id, |
| 1606 | other->conf.file, other->conf.line); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1607 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1608 | goto out; |
| 1609 | } |
| 1610 | |
Frédéric Lécaille | 1b8e68e | 2019-03-14 07:07:41 +0100 | [diff] [blame] | 1611 | curproxy->table = calloc(1, sizeof *curproxy->table); |
| 1612 | if (!curproxy->table) { |
| 1613 | ha_alert("parsing [%s:%d]: '%s %s' : memory allocation failed\n", |
| 1614 | file, linenum, args[0], args[1]); |
| 1615 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1616 | goto out; |
| 1617 | } |
| 1618 | |
Frédéric Lécaille | c02766a | 2019-03-20 15:06:55 +0100 | [diff] [blame] | 1619 | err_code |= parse_stick_table(file, linenum, args, curproxy->table, |
| 1620 | curproxy->id, curproxy->id, NULL); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1621 | if (err_code & ERR_FATAL) { |
| 1622 | ha_free(&curproxy->table); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1623 | goto out; |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1624 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1625 | |
Frédéric Lécaille | d456aa4 | 2019-03-08 14:47:00 +0100 | [diff] [blame] | 1626 | /* Store the proxy in the stick-table. */ |
| 1627 | curproxy->table->proxy = curproxy; |
Frédéric Lécaille | 1b8e68e | 2019-03-14 07:07:41 +0100 | [diff] [blame] | 1628 | |
| 1629 | stktable_store_name(curproxy->table); |
| 1630 | curproxy->table->next = stktables_list; |
| 1631 | stktables_list = curproxy->table; |
Frédéric Lécaille | 015e4d7 | 2019-03-19 14:55:01 +0100 | [diff] [blame] | 1632 | |
| 1633 | /* Add this proxy to the list of proxies which refer to its stick-table. */ |
| 1634 | if (curproxy->table->proxies_list != curproxy) { |
| 1635 | curproxy->next_stkt_ref = curproxy->table->proxies_list; |
| 1636 | curproxy->table->proxies_list = curproxy; |
| 1637 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1638 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1639 | else if (strcmp(args[0], "stick") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1640 | struct sticking_rule *rule; |
| 1641 | struct sample_expr *expr; |
| 1642 | int myidx = 0; |
| 1643 | const char *name = NULL; |
| 1644 | int flags; |
| 1645 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1646 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1647 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 1648 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1649 | goto out; |
| 1650 | } |
| 1651 | |
| 1652 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) { |
| 1653 | err_code |= ERR_WARN; |
| 1654 | goto out; |
| 1655 | } |
| 1656 | |
| 1657 | myidx++; |
| 1658 | if ((strcmp(args[myidx], "store") == 0) || |
| 1659 | (strcmp(args[myidx], "store-request") == 0)) { |
| 1660 | myidx++; |
| 1661 | flags = STK_IS_STORE; |
| 1662 | } |
| 1663 | else if (strcmp(args[myidx], "store-response") == 0) { |
| 1664 | myidx++; |
| 1665 | flags = STK_IS_STORE | STK_ON_RSP; |
| 1666 | } |
| 1667 | else if (strcmp(args[myidx], "match") == 0) { |
| 1668 | myidx++; |
| 1669 | flags = STK_IS_MATCH; |
| 1670 | } |
| 1671 | else if (strcmp(args[myidx], "on") == 0) { |
| 1672 | myidx++; |
| 1673 | flags = STK_IS_MATCH | STK_IS_STORE; |
| 1674 | } |
| 1675 | else { |
| 1676 | ha_alert("parsing [%s:%d] : '%s' expects 'on', 'match', or 'store'.\n", file, linenum, args[0]); |
| 1677 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1678 | goto out; |
| 1679 | } |
| 1680 | |
| 1681 | if (*(args[myidx]) == 0) { |
| 1682 | ha_alert("parsing [%s:%d] : '%s' expects a fetch method.\n", file, linenum, args[0]); |
| 1683 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1684 | goto out; |
| 1685 | } |
| 1686 | |
| 1687 | curproxy->conf.args.ctx = ARGC_STK; |
Willy Tarreau | e3b57bf | 2020-02-14 16:50:14 +0100 | [diff] [blame] | 1688 | expr = sample_parse_expr(args, &myidx, file, linenum, &errmsg, &curproxy->conf.args, NULL); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1689 | if (!expr) { |
| 1690 | ha_alert("parsing [%s:%d] : '%s': %s\n", file, linenum, args[0], errmsg); |
| 1691 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1692 | goto out; |
| 1693 | } |
| 1694 | |
| 1695 | if (flags & STK_ON_RSP) { |
| 1696 | if (!(expr->fetch->val & SMP_VAL_BE_STO_RUL)) { |
| 1697 | ha_alert("parsing [%s:%d] : '%s': fetch method '%s' extracts information from '%s', none of which is available for 'store-response'.\n", |
| 1698 | file, linenum, args[0], expr->fetch->kw, sample_src_names(expr->fetch->use)); |
| 1699 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1700 | free(expr); |
| 1701 | goto out; |
| 1702 | } |
| 1703 | } else { |
| 1704 | if (!(expr->fetch->val & SMP_VAL_BE_SET_SRV)) { |
| 1705 | ha_alert("parsing [%s:%d] : '%s': fetch method '%s' extracts information from '%s', none of which is available during request.\n", |
| 1706 | file, linenum, args[0], expr->fetch->kw, sample_src_names(expr->fetch->use)); |
| 1707 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1708 | free(expr); |
| 1709 | goto out; |
| 1710 | } |
| 1711 | } |
| 1712 | |
Christopher Faulet | 711ed6a | 2019-07-16 14:16:10 +0200 | [diff] [blame] | 1713 | /* check if we need to allocate an http_txn struct for HTTP parsing */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1714 | curproxy->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY); |
| 1715 | |
| 1716 | if (strcmp(args[myidx], "table") == 0) { |
| 1717 | myidx++; |
| 1718 | name = args[myidx++]; |
| 1719 | } |
| 1720 | |
| 1721 | if (strcmp(args[myidx], "if") == 0 || strcmp(args[myidx], "unless") == 0) { |
| 1722 | if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + myidx, &errmsg)) == NULL) { |
| 1723 | ha_alert("parsing [%s:%d] : '%s': error detected while parsing sticking condition : %s.\n", |
| 1724 | file, linenum, args[0], errmsg); |
| 1725 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1726 | free(expr); |
| 1727 | goto out; |
| 1728 | } |
| 1729 | } |
| 1730 | else if (*(args[myidx])) { |
| 1731 | ha_alert("parsing [%s:%d] : '%s': unknown keyword '%s'.\n", |
| 1732 | file, linenum, args[0], args[myidx]); |
| 1733 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1734 | free(expr); |
| 1735 | goto out; |
| 1736 | } |
| 1737 | if (flags & STK_ON_RSP) |
| 1738 | err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_STO_RUL, file, linenum); |
| 1739 | else |
| 1740 | err_code |= warnif_cond_conflicts(cond, SMP_VAL_BE_SET_SRV, file, linenum); |
| 1741 | |
| 1742 | rule = calloc(1, sizeof(*rule)); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1743 | if (!rule) { |
| 1744 | if (cond) |
| 1745 | prune_acl_cond(cond); |
| 1746 | ha_free(&cond); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1747 | goto alloc_error; |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1748 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1749 | rule->cond = cond; |
| 1750 | rule->expr = expr; |
| 1751 | rule->flags = flags; |
| 1752 | rule->table.name = name ? strdup(name) : NULL; |
| 1753 | LIST_INIT(&rule->list); |
| 1754 | if (flags & STK_ON_RSP) |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1755 | LIST_APPEND(&curproxy->storersp_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1756 | else |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1757 | LIST_APPEND(&curproxy->sticking_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1758 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1759 | else if (strcmp(args[0], "stats") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 1760 | if (!(curproxy->cap & PR_CAP_DEF) && curproxy->uri_auth == curr_defproxy->uri_auth) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1761 | curproxy->uri_auth = NULL; /* we must detach from the default config */ |
| 1762 | |
| 1763 | if (!*args[1]) { |
| 1764 | goto stats_error_parsing; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1765 | } else if (strcmp(args[1], "admin") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1766 | struct stats_admin_rule *rule; |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1767 | int where = 0; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1768 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1769 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1770 | ha_alert("parsing [%s:%d]: '%s %s' not allowed in 'defaults' section.\n", file, linenum, args[0], args[1]); |
| 1771 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1772 | goto out; |
| 1773 | } |
| 1774 | |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1775 | if (!stats_check_init_uri_auth(&curproxy->uri_auth)) |
| 1776 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1777 | |
| 1778 | if (strcmp(args[2], "if") != 0 && strcmp(args[2], "unless") != 0) { |
| 1779 | ha_alert("parsing [%s:%d] : '%s %s' requires either 'if' or 'unless' followed by a condition.\n", |
| 1780 | file, linenum, args[0], args[1]); |
| 1781 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1782 | goto out; |
| 1783 | } |
| 1784 | if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) { |
| 1785 | ha_alert("parsing [%s:%d] : error detected while parsing a '%s %s' rule : %s.\n", |
| 1786 | file, linenum, args[0], args[1], errmsg); |
| 1787 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1788 | goto out; |
| 1789 | } |
| 1790 | |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1791 | if (curproxy->cap & PR_CAP_FE) |
| 1792 | where |= SMP_VAL_FE_HRQ_HDR; |
| 1793 | if (curproxy->cap & PR_CAP_BE) |
| 1794 | where |= SMP_VAL_BE_HRQ_HDR; |
| 1795 | err_code |= warnif_cond_conflicts(cond, where, file, linenum); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1796 | |
| 1797 | rule = calloc(1, sizeof(*rule)); |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1798 | if (!rule) { |
| 1799 | if (cond) |
| 1800 | prune_acl_cond(cond); |
| 1801 | ha_free(&cond); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1802 | goto alloc_error; |
Christopher Faulet | 2e848a9 | 2021-04-12 16:28:30 +0200 | [diff] [blame] | 1803 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1804 | rule->cond = cond; |
| 1805 | LIST_INIT(&rule->list); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1806 | LIST_APPEND(&curproxy->uri_auth->admin_rules, &rule->list); |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1807 | } else if (strcmp(args[1], "uri") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1808 | if (*(args[2]) == 0) { |
| 1809 | ha_alert("parsing [%s:%d] : 'uri' needs an URI prefix.\n", file, linenum); |
| 1810 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1811 | goto out; |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1812 | } else if (!stats_set_uri(&curproxy->uri_auth, args[2])) |
| 1813 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1814 | } else if (strcmp(args[1], "realm") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1815 | if (*(args[2]) == 0) { |
| 1816 | ha_alert("parsing [%s:%d] : 'realm' needs an realm name.\n", file, linenum); |
| 1817 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1818 | goto out; |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1819 | } else if (!stats_set_realm(&curproxy->uri_auth, args[2])) |
| 1820 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1821 | } else if (strcmp(args[1], "refresh") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1822 | unsigned interval; |
| 1823 | |
| 1824 | err = parse_time_err(args[2], &interval, TIME_UNIT_S); |
Willy Tarreau | 9faebe3 | 2019-06-07 19:00:37 +0200 | [diff] [blame] | 1825 | if (err == PARSE_TIME_OVER) { |
| 1826 | ha_alert("parsing [%s:%d]: timer overflow in argument <%s> to stats refresh interval, maximum value is 2147483647 s (~68 years).\n", |
| 1827 | file, linenum, args[2]); |
| 1828 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1829 | goto out; |
| 1830 | } |
| 1831 | else if (err == PARSE_TIME_UNDER) { |
| 1832 | ha_alert("parsing [%s:%d]: timer underflow in argument <%s> to stats refresh interval, minimum non-null value is 1 s.\n", |
| 1833 | file, linenum, args[2]); |
| 1834 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1835 | goto out; |
| 1836 | } |
| 1837 | else if (err) { |
| 1838 | ha_alert("parsing [%s:%d]: unexpected character '%c' in argument to stats refresh interval.\n", |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1839 | file, linenum, *err); |
| 1840 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1841 | goto out; |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1842 | } else if (!stats_set_refresh(&curproxy->uri_auth, interval)) |
| 1843 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1844 | } else if (strcmp(args[1], "http-request") == 0) { /* request access control: allow/deny/auth */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1845 | struct act_rule *rule; |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1846 | int where = 0; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1847 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 1848 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1849 | ha_alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 1850 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1851 | goto out; |
| 1852 | } |
| 1853 | |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1854 | if (!stats_check_init_uri_auth(&curproxy->uri_auth)) |
| 1855 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1856 | |
| 1857 | if (!LIST_ISEMPTY(&curproxy->uri_auth->http_req_rules) && |
| 1858 | !LIST_PREV(&curproxy->uri_auth->http_req_rules, struct act_rule *, list)->cond) { |
| 1859 | ha_warning("parsing [%s:%d]: previous '%s' action has no condition attached, further entries are NOOP.\n", |
| 1860 | file, linenum, args[0]); |
| 1861 | err_code |= ERR_WARN; |
| 1862 | } |
| 1863 | |
| 1864 | rule = parse_http_req_cond((const char **)args + 2, file, linenum, curproxy); |
| 1865 | |
| 1866 | if (!rule) { |
| 1867 | err_code |= ERR_ALERT | ERR_ABORT; |
| 1868 | goto out; |
| 1869 | } |
| 1870 | |
Christopher Faulet | 7a06ffb | 2021-10-13 17:22:17 +0200 | [diff] [blame] | 1871 | if (curproxy->cap & PR_CAP_FE) |
| 1872 | where |= SMP_VAL_FE_HRQ_HDR; |
| 1873 | if (curproxy->cap & PR_CAP_BE) |
| 1874 | where |= SMP_VAL_BE_HRQ_HDR; |
| 1875 | err_code |= warnif_cond_conflicts(rule->cond, where, file, linenum); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1876 | LIST_APPEND(&curproxy->uri_auth->http_req_rules, &rule->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1877 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1878 | } else if (strcmp(args[1], "auth") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1879 | if (*(args[2]) == 0) { |
| 1880 | ha_alert("parsing [%s:%d] : 'auth' needs a user:password account.\n", file, linenum); |
| 1881 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1882 | goto out; |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1883 | } else if (!stats_add_auth(&curproxy->uri_auth, args[2])) |
| 1884 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1885 | } else if (strcmp(args[1], "scope") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1886 | if (*(args[2]) == 0) { |
| 1887 | ha_alert("parsing [%s:%d] : 'scope' needs a proxy name.\n", file, linenum); |
| 1888 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1889 | goto out; |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1890 | } else if (!stats_add_scope(&curproxy->uri_auth, args[2])) |
| 1891 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1892 | } else if (strcmp(args[1], "enable") == 0) { |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1893 | if (!stats_check_init_uri_auth(&curproxy->uri_auth)) |
| 1894 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1895 | } else if (strcmp(args[1], "hide-version") == 0) { |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1896 | if (!stats_set_flag(&curproxy->uri_auth, STAT_HIDEVER)) |
| 1897 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1898 | } else if (strcmp(args[1], "show-legends") == 0) { |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1899 | if (!stats_set_flag(&curproxy->uri_auth, STAT_SHLGNDS)) |
| 1900 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1901 | } else if (strcmp(args[1], "show-modules") == 0) { |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1902 | if (!stats_set_flag(&curproxy->uri_auth, STAT_SHMODULES)) |
| 1903 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1904 | } else if (strcmp(args[1], "show-node") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1905 | |
| 1906 | if (*args[2]) { |
| 1907 | int i; |
| 1908 | char c; |
| 1909 | |
| 1910 | for (i=0; args[2][i]; i++) { |
| 1911 | c = args[2][i]; |
| 1912 | if (!isupper((unsigned char)c) && !islower((unsigned char)c) && |
| 1913 | !isdigit((unsigned char)c) && c != '_' && c != '-' && c != '.') |
| 1914 | break; |
| 1915 | } |
| 1916 | |
| 1917 | if (!i || args[2][i]) { |
| 1918 | ha_alert("parsing [%s:%d]: '%s %s' invalid node name - should be a string" |
| 1919 | "with digits(0-9), letters(A-Z, a-z), hyphen(-) or underscode(_).\n", |
| 1920 | file, linenum, args[0], args[1]); |
| 1921 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1922 | goto out; |
| 1923 | } |
| 1924 | } |
| 1925 | |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1926 | if (!stats_set_node(&curproxy->uri_auth, args[2])) |
| 1927 | goto alloc_error; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1928 | } else if (strcmp(args[1], "show-desc") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1929 | char *desc = NULL; |
| 1930 | |
| 1931 | if (*args[2]) { |
| 1932 | int i, len=0; |
| 1933 | char *d; |
| 1934 | |
| 1935 | for (i = 2; *args[i]; i++) |
| 1936 | len += strlen(args[i]) + 1; |
| 1937 | |
| 1938 | desc = d = calloc(1, len); |
| 1939 | |
| 1940 | d += snprintf(d, desc + len - d, "%s", args[2]); |
| 1941 | for (i = 3; *args[i]; i++) |
| 1942 | d += snprintf(d, desc + len - d, " %s", args[i]); |
| 1943 | } |
| 1944 | |
| 1945 | if (!*args[2] && !global.desc) |
| 1946 | ha_warning("parsing [%s:%d]: '%s' requires a parameter or 'desc' to be set in the global section.\n", |
| 1947 | file, linenum, args[1]); |
| 1948 | else { |
| 1949 | if (!stats_set_desc(&curproxy->uri_auth, desc)) { |
| 1950 | free(desc); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 1951 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1952 | } |
| 1953 | free(desc); |
| 1954 | } |
| 1955 | } else { |
| 1956 | stats_error_parsing: |
| 1957 | ha_alert("parsing [%s:%d]: %s '%s', expects 'admin', 'uri', 'realm', 'auth', 'scope', 'enable', 'hide-version', 'show-node', 'show-desc' or 'show-legends'.\n", |
| 1958 | file, linenum, *args[1]?"unknown stats parameter":"missing keyword in", args[*args[1]?1:0]); |
| 1959 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1960 | goto out; |
| 1961 | } |
| 1962 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1963 | else if (strcmp(args[0], "option") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1964 | int optnum; |
| 1965 | |
| 1966 | if (*(args[1]) == '\0') { |
| 1967 | ha_alert("parsing [%s:%d]: '%s' expects an option name.\n", |
| 1968 | file, linenum, args[0]); |
| 1969 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1970 | goto out; |
| 1971 | } |
| 1972 | |
| 1973 | for (optnum = 0; cfg_opts[optnum].name; optnum++) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1974 | if (strcmp(args[1], cfg_opts[optnum].name) == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 1975 | if (cfg_opts[optnum].cap == PR_CAP_NONE) { |
| 1976 | ha_alert("parsing [%s:%d]: option '%s' is not supported due to build options.\n", |
| 1977 | file, linenum, cfg_opts[optnum].name); |
| 1978 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1979 | goto out; |
| 1980 | } |
| 1981 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 1982 | goto out; |
| 1983 | |
| 1984 | if (warnifnotcap(curproxy, cfg_opts[optnum].cap, file, linenum, args[1], NULL)) { |
| 1985 | err_code |= ERR_WARN; |
| 1986 | goto out; |
| 1987 | } |
| 1988 | |
| 1989 | curproxy->no_options &= ~cfg_opts[optnum].val; |
| 1990 | curproxy->options &= ~cfg_opts[optnum].val; |
| 1991 | |
| 1992 | switch (kwm) { |
| 1993 | case KWM_STD: |
| 1994 | curproxy->options |= cfg_opts[optnum].val; |
| 1995 | break; |
| 1996 | case KWM_NO: |
| 1997 | curproxy->no_options |= cfg_opts[optnum].val; |
| 1998 | break; |
| 1999 | case KWM_DEF: /* already cleared */ |
| 2000 | break; |
| 2001 | } |
| 2002 | |
| 2003 | goto out; |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | for (optnum = 0; cfg_opts2[optnum].name; optnum++) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2008 | if (strcmp(args[1], cfg_opts2[optnum].name) == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2009 | if (cfg_opts2[optnum].cap == PR_CAP_NONE) { |
| 2010 | ha_alert("parsing [%s:%d]: option '%s' is not supported due to build options.\n", |
| 2011 | file, linenum, cfg_opts2[optnum].name); |
| 2012 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2013 | goto out; |
| 2014 | } |
| 2015 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2016 | goto out; |
| 2017 | if (warnifnotcap(curproxy, cfg_opts2[optnum].cap, file, linenum, args[1], NULL)) { |
| 2018 | err_code |= ERR_WARN; |
| 2019 | goto out; |
| 2020 | } |
| 2021 | |
| 2022 | curproxy->no_options2 &= ~cfg_opts2[optnum].val; |
| 2023 | curproxy->options2 &= ~cfg_opts2[optnum].val; |
| 2024 | |
| 2025 | switch (kwm) { |
| 2026 | case KWM_STD: |
| 2027 | curproxy->options2 |= cfg_opts2[optnum].val; |
| 2028 | break; |
| 2029 | case KWM_NO: |
| 2030 | curproxy->no_options2 |= cfg_opts2[optnum].val; |
| 2031 | break; |
| 2032 | case KWM_DEF: /* already cleared */ |
| 2033 | break; |
| 2034 | } |
| 2035 | goto out; |
| 2036 | } |
| 2037 | } |
| 2038 | |
| 2039 | /* HTTP options override each other. They can be cancelled using |
| 2040 | * "no option xxx" which only switches to default mode if the mode |
| 2041 | * was this one (useful for cancelling options set in defaults |
| 2042 | * sections). |
| 2043 | */ |
Willy Tarreau | 6ba6984 | 2021-06-11 16:01:50 +0200 | [diff] [blame] | 2044 | if (strcmp(args[1], "forceclose") == 0) { |
| 2045 | ha_alert("parsing [%s:%d]: option '%s' is not supported any more since HAProxy 2.0, please just remove it, or use 'option httpclose' if absolutely needed.\n", |
| 2046 | file, linenum, args[1]); |
| 2047 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2048 | goto out; |
| 2049 | } |
| 2050 | else if (strcmp(args[1], "httpclose") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2051 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2052 | goto out; |
| 2053 | if (kwm == KWM_STD) { |
| 2054 | curproxy->options &= ~PR_O_HTTP_MODE; |
| 2055 | curproxy->options |= PR_O_HTTP_CLO; |
| 2056 | goto out; |
| 2057 | } |
| 2058 | else if (kwm == KWM_NO) { |
| 2059 | if ((curproxy->options & PR_O_HTTP_MODE) == PR_O_HTTP_CLO) |
| 2060 | curproxy->options &= ~PR_O_HTTP_MODE; |
| 2061 | goto out; |
| 2062 | } |
| 2063 | } |
| 2064 | else if (strcmp(args[1], "http-server-close") == 0) { |
| 2065 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2066 | goto out; |
| 2067 | if (kwm == KWM_STD) { |
| 2068 | curproxy->options &= ~PR_O_HTTP_MODE; |
| 2069 | curproxy->options |= PR_O_HTTP_SCL; |
| 2070 | goto out; |
| 2071 | } |
| 2072 | else if (kwm == KWM_NO) { |
| 2073 | if ((curproxy->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL) |
| 2074 | curproxy->options &= ~PR_O_HTTP_MODE; |
| 2075 | goto out; |
| 2076 | } |
| 2077 | } |
| 2078 | else if (strcmp(args[1], "http-keep-alive") == 0) { |
| 2079 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2080 | goto out; |
| 2081 | if (kwm == KWM_STD) { |
| 2082 | curproxy->options &= ~PR_O_HTTP_MODE; |
| 2083 | curproxy->options |= PR_O_HTTP_KAL; |
| 2084 | goto out; |
| 2085 | } |
| 2086 | else if (kwm == KWM_NO) { |
| 2087 | if ((curproxy->options & PR_O_HTTP_MODE) == PR_O_HTTP_KAL) |
| 2088 | curproxy->options &= ~PR_O_HTTP_MODE; |
| 2089 | goto out; |
| 2090 | } |
| 2091 | } |
| 2092 | else if (strcmp(args[1], "http-tunnel") == 0) { |
Willy Tarreau | d2f2537 | 2021-06-11 16:06:29 +0200 | [diff] [blame] | 2093 | ha_alert("parsing [%s:%d]: option '%s' is not supported any more since HAProxy 2.1, please just remove it, it shouldn't be needed.\n", |
Christopher Faulet | 73e8ede | 2019-07-16 15:04:46 +0200 | [diff] [blame] | 2094 | file, linenum, args[1]); |
Willy Tarreau | d2f2537 | 2021-06-11 16:06:29 +0200 | [diff] [blame] | 2095 | err_code |= ERR_ALERT | ERR_FATAL; |
Christopher Faulet | 73e8ede | 2019-07-16 15:04:46 +0200 | [diff] [blame] | 2096 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2097 | } |
| 2098 | |
| 2099 | /* Redispatch can take an integer argument that control when the |
| 2100 | * resispatch occurs. All values are relative to the retries option. |
| 2101 | * This can be cancelled using "no option xxx". |
| 2102 | */ |
| 2103 | if (strcmp(args[1], "redispatch") == 0) { |
| 2104 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[1], NULL)) { |
| 2105 | err_code |= ERR_WARN; |
| 2106 | goto out; |
| 2107 | } |
| 2108 | |
| 2109 | curproxy->no_options &= ~PR_O_REDISP; |
| 2110 | curproxy->options &= ~PR_O_REDISP; |
| 2111 | |
| 2112 | switch (kwm) { |
| 2113 | case KWM_STD: |
| 2114 | curproxy->options |= PR_O_REDISP; |
| 2115 | curproxy->redispatch_after = -1; |
| 2116 | if(*args[2]) { |
| 2117 | curproxy->redispatch_after = atol(args[2]); |
| 2118 | } |
| 2119 | break; |
| 2120 | case KWM_NO: |
| 2121 | curproxy->no_options |= PR_O_REDISP; |
| 2122 | curproxy->redispatch_after = 0; |
| 2123 | break; |
| 2124 | case KWM_DEF: /* already cleared */ |
| 2125 | break; |
| 2126 | } |
| 2127 | goto out; |
| 2128 | } |
| 2129 | |
Willy Tarreau | 2524123 | 2021-07-18 19:18:56 +0200 | [diff] [blame] | 2130 | if (strcmp(args[1], "http_proxy") == 0) { |
| 2131 | ha_alert("parsing [%s:%d]: option '%s' is not supported any more since HAProxy 2.5. This option stopped working in HAProxy 1.9 and usually had nasty side effects. It can be more reliably implemented with combinations of 'http-request set-dst' and 'http-request set-uri', and even 'http-request do-resolve' if DNS resolution is desired.\n", |
| 2132 | file, linenum, args[1]); |
| 2133 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2134 | goto out; |
| 2135 | } |
| 2136 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2137 | if (kwm != KWM_STD) { |
| 2138 | ha_alert("parsing [%s:%d]: negation/default is not supported for option '%s'.\n", |
| 2139 | file, linenum, args[1]); |
| 2140 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2141 | goto out; |
| 2142 | } |
| 2143 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2144 | if (strcmp(args[1], "httplog") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2145 | char *logformat; |
| 2146 | /* generate a complete HTTP log */ |
| 2147 | logformat = default_http_log_format; |
| 2148 | if (*(args[2]) != '\0') { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2149 | if (strcmp(args[2], "clf") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2150 | curproxy->options2 |= PR_O2_CLFLOG; |
| 2151 | logformat = clf_http_log_format; |
| 2152 | } else { |
| 2153 | ha_alert("parsing [%s:%d] : keyword '%s' only supports option 'clf'.\n", file, linenum, args[1]); |
| 2154 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2155 | goto out; |
| 2156 | } |
| 2157 | if (alertif_too_many_args_idx(1, 1, file, linenum, args, &err_code)) |
| 2158 | goto out; |
| 2159 | } |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2160 | if (curproxy->conf.logformat_string && curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2161 | char *oldlogformat = "log-format"; |
| 2162 | char *clflogformat = ""; |
| 2163 | |
| 2164 | if (curproxy->conf.logformat_string == default_http_log_format) |
| 2165 | oldlogformat = "option httplog"; |
| 2166 | else if (curproxy->conf.logformat_string == default_tcp_log_format) |
| 2167 | oldlogformat = "option tcplog"; |
| 2168 | else if (curproxy->conf.logformat_string == clf_http_log_format) |
| 2169 | oldlogformat = "option httplog clf"; |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2170 | else if (curproxy->conf.logformat_string == default_https_log_format) |
| 2171 | oldlogformat = "option httpslog"; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2172 | if (logformat == clf_http_log_format) |
| 2173 | clflogformat = " clf"; |
| 2174 | ha_warning("parsing [%s:%d]: 'option httplog%s' overrides previous '%s' in 'defaults' section.\n", |
| 2175 | file, linenum, clflogformat, oldlogformat); |
| 2176 | } |
| 2177 | if (curproxy->conf.logformat_string != default_http_log_format && |
| 2178 | curproxy->conf.logformat_string != default_tcp_log_format && |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2179 | curproxy->conf.logformat_string != clf_http_log_format && |
| 2180 | curproxy->conf.logformat_string != default_https_log_format) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2181 | free(curproxy->conf.logformat_string); |
| 2182 | curproxy->conf.logformat_string = logformat; |
| 2183 | |
| 2184 | free(curproxy->conf.lfs_file); |
| 2185 | curproxy->conf.lfs_file = strdup(curproxy->conf.args.file); |
| 2186 | curproxy->conf.lfs_line = curproxy->conf.args.line; |
| 2187 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2188 | if (!(curproxy->cap & PR_CAP_DEF) && !(curproxy->cap & PR_CAP_FE)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2189 | ha_warning("parsing [%s:%d] : backend '%s' : 'option httplog' directive is ignored in backends.\n", |
| 2190 | file, linenum, curproxy->id); |
| 2191 | err_code |= ERR_WARN; |
| 2192 | } |
| 2193 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2194 | else if (strcmp(args[1], "tcplog") == 0) { |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2195 | if (curproxy->conf.logformat_string && curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2196 | char *oldlogformat = "log-format"; |
| 2197 | |
| 2198 | if (curproxy->conf.logformat_string == default_http_log_format) |
| 2199 | oldlogformat = "option httplog"; |
| 2200 | else if (curproxy->conf.logformat_string == default_tcp_log_format) |
| 2201 | oldlogformat = "option tcplog"; |
| 2202 | else if (curproxy->conf.logformat_string == clf_http_log_format) |
| 2203 | oldlogformat = "option httplog clf"; |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2204 | else if (curproxy->conf.logformat_string == default_https_log_format) |
| 2205 | oldlogformat = "option httpslog"; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2206 | ha_warning("parsing [%s:%d]: 'option tcplog' overrides previous '%s' in 'defaults' section.\n", |
| 2207 | file, linenum, oldlogformat); |
| 2208 | } |
| 2209 | /* generate a detailed TCP log */ |
| 2210 | if (curproxy->conf.logformat_string != default_http_log_format && |
| 2211 | curproxy->conf.logformat_string != default_tcp_log_format && |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2212 | curproxy->conf.logformat_string != clf_http_log_format && |
| 2213 | curproxy->conf.logformat_string != default_https_log_format) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2214 | free(curproxy->conf.logformat_string); |
| 2215 | curproxy->conf.logformat_string = default_tcp_log_format; |
| 2216 | |
| 2217 | free(curproxy->conf.lfs_file); |
| 2218 | curproxy->conf.lfs_file = strdup(curproxy->conf.args.file); |
| 2219 | curproxy->conf.lfs_line = curproxy->conf.args.line; |
| 2220 | |
| 2221 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2222 | goto out; |
| 2223 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2224 | if (!(curproxy->cap & PR_CAP_DEF) && !(curproxy->cap & PR_CAP_FE)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2225 | ha_warning("parsing [%s:%d] : backend '%s' : 'option tcplog' directive is ignored in backends.\n", |
| 2226 | file, linenum, curproxy->id); |
| 2227 | err_code |= ERR_WARN; |
| 2228 | } |
| 2229 | } |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2230 | else if (strcmp(args[1], "httpslog") == 0) { |
| 2231 | char *logformat; |
| 2232 | /* generate a complete HTTP log */ |
| 2233 | logformat = default_https_log_format; |
| 2234 | if (curproxy->conf.logformat_string && curproxy->cap & PR_CAP_DEF) { |
| 2235 | char *oldlogformat = "log-format"; |
| 2236 | |
| 2237 | if (curproxy->conf.logformat_string == default_http_log_format) |
| 2238 | oldlogformat = "option httplog"; |
| 2239 | else if (curproxy->conf.logformat_string == default_tcp_log_format) |
| 2240 | oldlogformat = "option tcplog"; |
| 2241 | else if (curproxy->conf.logformat_string == clf_http_log_format) |
| 2242 | oldlogformat = "option httplog clf"; |
| 2243 | else if (curproxy->conf.logformat_string == default_https_log_format) |
| 2244 | oldlogformat = "option httpslog"; |
| 2245 | ha_warning("parsing [%s:%d]: 'option httplog' overrides previous '%s' in 'defaults' section.\n", |
| 2246 | file, linenum, oldlogformat); |
| 2247 | } |
| 2248 | if (curproxy->conf.logformat_string != default_http_log_format && |
| 2249 | curproxy->conf.logformat_string != default_tcp_log_format && |
| 2250 | curproxy->conf.logformat_string != clf_http_log_format && |
| 2251 | curproxy->conf.logformat_string != default_https_log_format) |
| 2252 | free(curproxy->conf.logformat_string); |
| 2253 | curproxy->conf.logformat_string = logformat; |
| 2254 | |
| 2255 | free(curproxy->conf.lfs_file); |
| 2256 | curproxy->conf.lfs_file = strdup(curproxy->conf.args.file); |
| 2257 | curproxy->conf.lfs_line = curproxy->conf.args.line; |
| 2258 | |
| 2259 | if (!(curproxy->cap & PR_CAP_DEF) && !(curproxy->cap & PR_CAP_FE)) { |
| 2260 | ha_warning("parsing [%s:%d] : backend '%s' : 'option httpslog' directive is ignored in backends.\n", |
| 2261 | file, linenum, curproxy->id); |
| 2262 | err_code |= ERR_WARN; |
| 2263 | } |
| 2264 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2265 | else if (strcmp(args[1], "tcpka") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2266 | /* enable TCP keep-alives on client and server streams */ |
| 2267 | if (warnifnotcap(curproxy, PR_CAP_BE | PR_CAP_FE, file, linenum, args[1], NULL)) |
| 2268 | err_code |= ERR_WARN; |
| 2269 | |
| 2270 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2271 | goto out; |
| 2272 | |
| 2273 | if (curproxy->cap & PR_CAP_FE) |
| 2274 | curproxy->options |= PR_O_TCP_CLI_KA; |
| 2275 | if (curproxy->cap & PR_CAP_BE) |
| 2276 | curproxy->options |= PR_O_TCP_SRV_KA; |
| 2277 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2278 | else if (strcmp(args[1], "httpchk") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2279 | err_code |= proxy_parse_httpchk_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 6c2a743 | 2020-04-09 14:48:48 +0200 | [diff] [blame] | 2280 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2281 | goto out; |
| 2282 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2283 | else if (strcmp(args[1], "ssl-hello-chk") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2284 | err_code |= proxy_parse_ssl_hello_chk_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 811f78c | 2020-04-01 11:10:27 +0200 | [diff] [blame] | 2285 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2286 | goto out; |
| 2287 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2288 | else if (strcmp(args[1], "smtpchk") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2289 | err_code |= proxy_parse_smtpchk_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | fbcc77c | 2020-04-01 20:54:05 +0200 | [diff] [blame] | 2290 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2291 | goto out; |
| 2292 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2293 | else if (strcmp(args[1], "pgsql-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2294 | err_code |= proxy_parse_pgsql_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | ce35507 | 2020-04-02 11:44:39 +0200 | [diff] [blame] | 2295 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2296 | goto out; |
| 2297 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2298 | else if (strcmp(args[1], "redis-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2299 | err_code |= proxy_parse_redis_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 33f05df | 2020-04-01 11:08:50 +0200 | [diff] [blame] | 2300 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2301 | goto out; |
| 2302 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2303 | else if (strcmp(args[1], "mysql-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2304 | err_code |= proxy_parse_mysql_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | f2b3be5 | 2020-04-02 18:07:37 +0200 | [diff] [blame] | 2305 | if (err_code & ERR_FATAL) |
| 2306 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2307 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2308 | else if (strcmp(args[1], "ldap-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2309 | err_code |= proxy_parse_ldap_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 1997eca | 2020-04-03 23:13:50 +0200 | [diff] [blame] | 2310 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2311 | goto out; |
| 2312 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2313 | else if (strcmp(args[1], "spop-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2314 | err_code |= proxy_parse_spop_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 267b01b | 2020-04-04 10:27:09 +0200 | [diff] [blame] | 2315 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2316 | goto out; |
| 2317 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2318 | else if (strcmp(args[1], "tcp-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2319 | err_code |= proxy_parse_tcp_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 430e480 | 2020-04-09 15:28:16 +0200 | [diff] [blame] | 2320 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2321 | goto out; |
| 2322 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2323 | else if (strcmp(args[1], "external-check") == 0) { |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 2324 | err_code |= proxy_parse_external_check_opt(args, 0, curproxy, curr_defproxy, file, linenum); |
Christopher Faulet | 6f55791 | 2020-04-09 15:58:50 +0200 | [diff] [blame] | 2325 | if (err_code & ERR_FATAL) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2326 | goto out; |
| 2327 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2328 | else if (strcmp(args[1], "forwardfor") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2329 | int cur_arg; |
| 2330 | |
| 2331 | /* insert x-forwarded-for field, but not for the IP address listed as an except. |
Christopher Faulet | 3193037 | 2019-07-15 10:16:58 +0200 | [diff] [blame] | 2332 | * set default options (ie: bitfield, header name, etc) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2333 | */ |
| 2334 | |
| 2335 | curproxy->options |= PR_O_FWDFOR | PR_O_FF_ALWAYS; |
| 2336 | |
| 2337 | free(curproxy->fwdfor_hdr_name); |
| 2338 | curproxy->fwdfor_hdr_name = strdup(DEF_XFORWARDFOR_HDR); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2339 | if (!curproxy->fwdfor_hdr_name) |
| 2340 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2341 | curproxy->fwdfor_hdr_len = strlen(DEF_XFORWARDFOR_HDR); |
Christopher Faulet | 5d1def6 | 2021-02-26 09:19:15 +0100 | [diff] [blame] | 2342 | curproxy->except_xff_net.family = AF_UNSPEC; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2343 | |
| 2344 | /* loop to go through arguments - start at 2, since 0+1 = "option" "forwardfor" */ |
| 2345 | cur_arg = 2; |
| 2346 | while (*(args[cur_arg])) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2347 | if (strcmp(args[cur_arg], "except") == 0) { |
Christopher Faulet | 5d1def6 | 2021-02-26 09:19:15 +0100 | [diff] [blame] | 2348 | unsigned char mask; |
| 2349 | int i; |
| 2350 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2351 | /* suboption except - needs additional argument for it */ |
Christopher Faulet | 5d1def6 | 2021-02-26 09:19:15 +0100 | [diff] [blame] | 2352 | if (*(args[cur_arg+1]) && |
| 2353 | str2net(args[cur_arg+1], 1, &curproxy->except_xff_net.addr.v4.ip, &curproxy->except_xff_net.addr.v4.mask)) { |
| 2354 | curproxy->except_xff_net.family = AF_INET; |
| 2355 | curproxy->except_xff_net.addr.v4.ip.s_addr &= curproxy->except_xff_net.addr.v4.mask.s_addr; |
| 2356 | } |
| 2357 | else if (*(args[cur_arg+1]) && |
| 2358 | str62net(args[cur_arg+1], &curproxy->except_xff_net.addr.v6.ip, &mask)) { |
| 2359 | curproxy->except_xff_net.family = AF_INET6; |
| 2360 | len2mask6(mask, &curproxy->except_xff_net.addr.v6.mask); |
| 2361 | for (i = 0; i < 16; i++) |
| 2362 | curproxy->except_xff_net.addr.v6.ip.s6_addr[i] &= curproxy->except_xff_net.addr.v6.mask.s6_addr[i]; |
| 2363 | } |
| 2364 | else { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2365 | ha_alert("parsing [%s:%d] : '%s %s %s' expects <address>[/mask] as argument.\n", |
| 2366 | file, linenum, args[0], args[1], args[cur_arg]); |
| 2367 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2368 | goto out; |
| 2369 | } |
| 2370 | /* flush useless bits */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2371 | cur_arg += 2; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2372 | } else if (strcmp(args[cur_arg], "header") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2373 | /* suboption header - needs additional argument for it */ |
| 2374 | if (*(args[cur_arg+1]) == 0) { |
| 2375 | ha_alert("parsing [%s:%d] : '%s %s %s' expects <header_name> as argument.\n", |
| 2376 | file, linenum, args[0], args[1], args[cur_arg]); |
| 2377 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2378 | goto out; |
| 2379 | } |
| 2380 | free(curproxy->fwdfor_hdr_name); |
| 2381 | curproxy->fwdfor_hdr_name = strdup(args[cur_arg+1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2382 | if (!curproxy->fwdfor_hdr_name) |
| 2383 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2384 | curproxy->fwdfor_hdr_len = strlen(curproxy->fwdfor_hdr_name); |
| 2385 | cur_arg += 2; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2386 | } else if (strcmp(args[cur_arg], "if-none") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2387 | curproxy->options &= ~PR_O_FF_ALWAYS; |
| 2388 | cur_arg += 1; |
| 2389 | } else { |
| 2390 | /* unknown suboption - catchall */ |
| 2391 | ha_alert("parsing [%s:%d] : '%s %s' only supports optional values: 'except', 'header' and 'if-none'.\n", |
| 2392 | file, linenum, args[0], args[1]); |
| 2393 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2394 | goto out; |
| 2395 | } |
| 2396 | } /* end while loop */ |
| 2397 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2398 | else if (strcmp(args[1], "originalto") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2399 | int cur_arg; |
| 2400 | |
| 2401 | /* insert x-original-to field, but not for the IP address listed as an except. |
| 2402 | * set default options (ie: bitfield, header name, etc) |
| 2403 | */ |
| 2404 | |
| 2405 | curproxy->options |= PR_O_ORGTO; |
| 2406 | |
| 2407 | free(curproxy->orgto_hdr_name); |
| 2408 | curproxy->orgto_hdr_name = strdup(DEF_XORIGINALTO_HDR); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2409 | if (!curproxy->orgto_hdr_name) |
| 2410 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2411 | curproxy->orgto_hdr_len = strlen(DEF_XORIGINALTO_HDR); |
Christopher Faulet | 5d1def6 | 2021-02-26 09:19:15 +0100 | [diff] [blame] | 2412 | curproxy->except_xot_net.family = AF_UNSPEC; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2413 | |
| 2414 | /* loop to go through arguments - start at 2, since 0+1 = "option" "originalto" */ |
| 2415 | cur_arg = 2; |
| 2416 | while (*(args[cur_arg])) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2417 | if (strcmp(args[cur_arg], "except") == 0) { |
Christopher Faulet | 5d1def6 | 2021-02-26 09:19:15 +0100 | [diff] [blame] | 2418 | unsigned char mask; |
| 2419 | int i; |
| 2420 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2421 | /* suboption except - needs additional argument for it */ |
Christopher Faulet | 5d1def6 | 2021-02-26 09:19:15 +0100 | [diff] [blame] | 2422 | if (*(args[cur_arg+1]) && |
| 2423 | str2net(args[cur_arg+1], 1, &curproxy->except_xot_net.addr.v4.ip, &curproxy->except_xot_net.addr.v4.mask)) { |
| 2424 | curproxy->except_xot_net.family = AF_INET; |
| 2425 | curproxy->except_xot_net.addr.v4.ip.s_addr &= curproxy->except_xot_net.addr.v4.mask.s_addr; |
| 2426 | } |
| 2427 | else if (*(args[cur_arg+1]) && |
| 2428 | str62net(args[cur_arg+1], &curproxy->except_xot_net.addr.v6.ip, &mask)) { |
| 2429 | curproxy->except_xot_net.family = AF_INET6; |
| 2430 | len2mask6(mask, &curproxy->except_xot_net.addr.v6.mask); |
| 2431 | for (i = 0; i < 16; i++) |
| 2432 | curproxy->except_xot_net.addr.v6.ip.s6_addr[i] &= curproxy->except_xot_net.addr.v6.mask.s6_addr[i]; |
| 2433 | } |
| 2434 | else { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2435 | ha_alert("parsing [%s:%d] : '%s %s %s' expects <address>[/mask] as argument.\n", |
| 2436 | file, linenum, args[0], args[1], args[cur_arg]); |
| 2437 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2438 | goto out; |
| 2439 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2440 | cur_arg += 2; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2441 | } else if (strcmp(args[cur_arg], "header") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2442 | /* suboption header - needs additional argument for it */ |
| 2443 | if (*(args[cur_arg+1]) == 0) { |
| 2444 | ha_alert("parsing [%s:%d] : '%s %s %s' expects <header_name> as argument.\n", |
| 2445 | file, linenum, args[0], args[1], args[cur_arg]); |
| 2446 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2447 | goto out; |
| 2448 | } |
| 2449 | free(curproxy->orgto_hdr_name); |
| 2450 | curproxy->orgto_hdr_name = strdup(args[cur_arg+1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2451 | if (!curproxy->orgto_hdr_name) |
| 2452 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2453 | curproxy->orgto_hdr_len = strlen(curproxy->orgto_hdr_name); |
| 2454 | cur_arg += 2; |
| 2455 | } else { |
| 2456 | /* unknown suboption - catchall */ |
| 2457 | ha_alert("parsing [%s:%d] : '%s %s' only supports optional values: 'except' and 'header'.\n", |
| 2458 | file, linenum, args[0], args[1]); |
| 2459 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2460 | goto out; |
| 2461 | } |
| 2462 | } /* end while loop */ |
| 2463 | } |
| 2464 | else { |
Willy Tarreau | 31a3cea | 2021-03-15 11:11:55 +0100 | [diff] [blame] | 2465 | const char *best = proxy_find_best_option(args[1], common_options); |
| 2466 | |
| 2467 | if (best) |
| 2468 | ha_alert("parsing [%s:%d] : unknown option '%s'; did you mean '%s' maybe ?\n", file, linenum, args[1], best); |
| 2469 | else |
| 2470 | ha_alert("parsing [%s:%d] : unknown option '%s'.\n", file, linenum, args[1]); |
| 2471 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2472 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2473 | goto out; |
| 2474 | } |
| 2475 | goto out; |
| 2476 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2477 | else if (strcmp(args[0], "default_backend") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2478 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 2479 | err_code |= ERR_WARN; |
| 2480 | |
| 2481 | if (*(args[1]) == 0) { |
| 2482 | ha_alert("parsing [%s:%d] : '%s' expects a backend name.\n", file, linenum, args[0]); |
| 2483 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2484 | goto out; |
| 2485 | } |
| 2486 | free(curproxy->defbe.name); |
| 2487 | curproxy->defbe.name = strdup(args[1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2488 | if (!curproxy->defbe.name) |
| 2489 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2490 | |
| 2491 | if (alertif_too_many_args_idx(1, 0, file, linenum, args, &err_code)) |
| 2492 | goto out; |
| 2493 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2494 | else if (strcmp(args[0], "redispatch") == 0 || strcmp(args[0], "redisp") == 0) { |
Tim Duesterhus | dac168b | 2019-05-14 20:57:58 +0200 | [diff] [blame] | 2495 | ha_alert("parsing [%s:%d] : keyword '%s' directive is not supported anymore since HAProxy 2.1. Use 'option redispatch'.\n", file, linenum, args[0]); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2496 | |
Tim Duesterhus | dac168b | 2019-05-14 20:57:58 +0200 | [diff] [blame] | 2497 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2498 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2499 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2500 | else if (strcmp(args[0], "http-reuse") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2501 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 2502 | err_code |= ERR_WARN; |
| 2503 | |
| 2504 | if (strcmp(args[1], "never") == 0) { |
| 2505 | /* enable a graceful server shutdown on an HTTP 404 response */ |
| 2506 | curproxy->options &= ~PR_O_REUSE_MASK; |
| 2507 | curproxy->options |= PR_O_REUSE_NEVR; |
| 2508 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2509 | goto out; |
| 2510 | } |
| 2511 | else if (strcmp(args[1], "safe") == 0) { |
| 2512 | /* enable a graceful server shutdown on an HTTP 404 response */ |
| 2513 | curproxy->options &= ~PR_O_REUSE_MASK; |
| 2514 | curproxy->options |= PR_O_REUSE_SAFE; |
| 2515 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2516 | goto out; |
| 2517 | } |
| 2518 | else if (strcmp(args[1], "aggressive") == 0) { |
| 2519 | curproxy->options &= ~PR_O_REUSE_MASK; |
| 2520 | curproxy->options |= PR_O_REUSE_AGGR; |
| 2521 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2522 | goto out; |
| 2523 | } |
| 2524 | else if (strcmp(args[1], "always") == 0) { |
| 2525 | /* enable a graceful server shutdown on an HTTP 404 response */ |
| 2526 | curproxy->options &= ~PR_O_REUSE_MASK; |
| 2527 | curproxy->options |= PR_O_REUSE_ALWS; |
| 2528 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 2529 | goto out; |
| 2530 | } |
| 2531 | else { |
| 2532 | ha_alert("parsing [%s:%d] : '%s' only supports 'never', 'safe', 'aggressive', 'always'.\n", file, linenum, args[0]); |
| 2533 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2534 | goto out; |
| 2535 | } |
| 2536 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2537 | else if (strcmp(args[0], "monitor") == 0) { |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2538 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2539 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 2540 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2541 | goto out; |
| 2542 | } |
| 2543 | |
| 2544 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 2545 | err_code |= ERR_WARN; |
| 2546 | |
| 2547 | if (strcmp(args[1], "fail") == 0) { |
| 2548 | /* add a condition to fail monitor requests */ |
| 2549 | if (strcmp(args[2], "if") != 0 && strcmp(args[2], "unless") != 0) { |
| 2550 | ha_alert("parsing [%s:%d] : '%s %s' requires either 'if' or 'unless' followed by a condition.\n", |
| 2551 | file, linenum, args[0], args[1]); |
| 2552 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2553 | goto out; |
| 2554 | } |
| 2555 | |
| 2556 | err_code |= warnif_misplaced_monitor(curproxy, file, linenum, "monitor fail"); |
| 2557 | if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) { |
| 2558 | ha_alert("parsing [%s:%d] : error detected while parsing a '%s %s' condition : %s.\n", |
| 2559 | file, linenum, args[0], args[1], errmsg); |
| 2560 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2561 | goto out; |
| 2562 | } |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 2563 | LIST_APPEND(&curproxy->mon_fail_cond, &cond->list); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2564 | } |
| 2565 | else { |
| 2566 | ha_alert("parsing [%s:%d] : '%s' only supports 'fail'.\n", file, linenum, args[0]); |
| 2567 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2568 | goto out; |
| 2569 | } |
| 2570 | } |
Willy Tarreau | e573323 | 2019-05-22 19:24:06 +0200 | [diff] [blame] | 2571 | #ifdef USE_TPROXY |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2572 | else if (strcmp(args[0], "transparent") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2573 | /* enable transparent proxy connections */ |
| 2574 | curproxy->options |= PR_O_TRANSP; |
| 2575 | if (alertif_too_many_args(0, file, linenum, args, &err_code)) |
| 2576 | goto out; |
| 2577 | } |
| 2578 | #endif |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2579 | else if (strcmp(args[0], "maxconn") == 0) { /* maxconn */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2580 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], " Maybe you want 'fullconn' instead ?")) |
| 2581 | err_code |= ERR_WARN; |
| 2582 | |
| 2583 | if (*(args[1]) == 0) { |
| 2584 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 2585 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2586 | goto out; |
| 2587 | } |
| 2588 | curproxy->maxconn = atol(args[1]); |
| 2589 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 2590 | goto out; |
| 2591 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2592 | else if (strcmp(args[0], "backlog") == 0) { /* backlog */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2593 | if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) |
| 2594 | err_code |= ERR_WARN; |
| 2595 | |
| 2596 | if (*(args[1]) == 0) { |
| 2597 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 2598 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2599 | goto out; |
| 2600 | } |
| 2601 | curproxy->backlog = atol(args[1]); |
| 2602 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 2603 | goto out; |
| 2604 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2605 | else if (strcmp(args[0], "fullconn") == 0) { /* fullconn */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2606 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], " Maybe you want 'maxconn' instead ?")) |
| 2607 | err_code |= ERR_WARN; |
| 2608 | |
| 2609 | if (*(args[1]) == 0) { |
| 2610 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 2611 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2612 | goto out; |
| 2613 | } |
| 2614 | curproxy->fullconn = atol(args[1]); |
| 2615 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 2616 | goto out; |
| 2617 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2618 | else if (strcmp(args[0], "grace") == 0) { /* grace time (ms) */ |
Willy Tarreau | eb77824 | 2021-06-11 16:27:10 +0200 | [diff] [blame] | 2619 | ha_alert("parsing [%s:%d]: the '%s' keyword is not supported any more since HAProxy version 2.5.\n", |
Willy Tarreau | ab0a519 | 2020-10-09 19:07:01 +0200 | [diff] [blame] | 2620 | file, linenum, args[0]); |
Willy Tarreau | eb77824 | 2021-06-11 16:27:10 +0200 | [diff] [blame] | 2621 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2622 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2623 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2624 | else if (strcmp(args[0], "dispatch") == 0) { /* dispatch address */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2625 | struct sockaddr_storage *sk; |
| 2626 | int port1, port2; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2627 | |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2628 | if (curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2629 | ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]); |
| 2630 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2631 | goto out; |
| 2632 | } |
| 2633 | else if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 2634 | err_code |= ERR_WARN; |
| 2635 | |
Willy Tarreau | 65ec4e3 | 2020-09-16 19:17:08 +0200 | [diff] [blame] | 2636 | sk = str2sa_range(args[1], NULL, &port1, &port2, NULL, NULL, |
| 2637 | &errmsg, NULL, NULL, |
| 2638 | PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_STREAM | PA_O_XPRT | PA_O_CONNECT); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2639 | if (!sk) { |
| 2640 | ha_alert("parsing [%s:%d] : '%s' : %s\n", file, linenum, args[0], errmsg); |
| 2641 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2642 | goto out; |
| 2643 | } |
| 2644 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2645 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 2646 | goto out; |
| 2647 | |
| 2648 | curproxy->dispatch_addr = *sk; |
| 2649 | curproxy->options |= PR_O_DISPATCH; |
| 2650 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2651 | else if (strcmp(args[0], "balance") == 0) { /* set balancing with optional algorithm */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2652 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 2653 | err_code |= ERR_WARN; |
| 2654 | |
| 2655 | if (backend_parse_balance((const char **)args + 1, &errmsg, curproxy) < 0) { |
| 2656 | ha_alert("parsing [%s:%d] : %s %s\n", file, linenum, args[0], errmsg); |
| 2657 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2658 | goto out; |
| 2659 | } |
| 2660 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2661 | else if (strcmp(args[0], "hash-type") == 0) { /* set hashing method */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2662 | /** |
| 2663 | * The syntax for hash-type config element is |
| 2664 | * hash-type {map-based|consistent} [[<algo>] avalanche] |
| 2665 | * |
| 2666 | * The default hash function is sdbm for map-based and sdbm+avalanche for consistent. |
| 2667 | */ |
| 2668 | curproxy->lbprm.algo &= ~(BE_LB_HASH_TYPE | BE_LB_HASH_FUNC | BE_LB_HASH_MOD); |
| 2669 | |
| 2670 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 2671 | err_code |= ERR_WARN; |
| 2672 | |
| 2673 | if (strcmp(args[1], "consistent") == 0) { /* use consistent hashing */ |
| 2674 | curproxy->lbprm.algo |= BE_LB_HASH_CONS; |
| 2675 | } |
| 2676 | else if (strcmp(args[1], "map-based") == 0) { /* use map-based hashing */ |
| 2677 | curproxy->lbprm.algo |= BE_LB_HASH_MAP; |
| 2678 | } |
| 2679 | else if (strcmp(args[1], "avalanche") == 0) { |
| 2680 | ha_alert("parsing [%s:%d] : experimental feature '%s %s' is not supported anymore, please use '%s map-based sdbm avalanche' instead.\n", file, linenum, args[0], args[1], args[0]); |
| 2681 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2682 | goto out; |
| 2683 | } |
| 2684 | else { |
| 2685 | ha_alert("parsing [%s:%d] : '%s' only supports 'consistent' and 'map-based'.\n", file, linenum, args[0]); |
| 2686 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2687 | goto out; |
| 2688 | } |
| 2689 | |
| 2690 | /* set the hash function to use */ |
| 2691 | if (!*args[2]) { |
| 2692 | /* the default algo is sdbm */ |
| 2693 | curproxy->lbprm.algo |= BE_LB_HFCN_SDBM; |
| 2694 | |
| 2695 | /* if consistent with no argument, then avalanche modifier is also applied */ |
| 2696 | if ((curproxy->lbprm.algo & BE_LB_HASH_TYPE) == BE_LB_HASH_CONS) |
| 2697 | curproxy->lbprm.algo |= BE_LB_HMOD_AVAL; |
| 2698 | } else { |
| 2699 | /* set the hash function */ |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2700 | if (strcmp(args[2], "sdbm") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2701 | curproxy->lbprm.algo |= BE_LB_HFCN_SDBM; |
| 2702 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2703 | else if (strcmp(args[2], "djb2") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2704 | curproxy->lbprm.algo |= BE_LB_HFCN_DJB2; |
| 2705 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2706 | else if (strcmp(args[2], "wt6") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2707 | curproxy->lbprm.algo |= BE_LB_HFCN_WT6; |
| 2708 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2709 | else if (strcmp(args[2], "crc32") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2710 | curproxy->lbprm.algo |= BE_LB_HFCN_CRC32; |
| 2711 | } |
| 2712 | else { |
| 2713 | ha_alert("parsing [%s:%d] : '%s' only supports 'sdbm', 'djb2', 'crc32', or 'wt6' hash functions.\n", file, linenum, args[0]); |
| 2714 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2715 | goto out; |
| 2716 | } |
| 2717 | |
| 2718 | /* set the hash modifier */ |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2719 | if (strcmp(args[3], "avalanche") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2720 | curproxy->lbprm.algo |= BE_LB_HMOD_AVAL; |
| 2721 | } |
| 2722 | else if (*args[3]) { |
| 2723 | ha_alert("parsing [%s:%d] : '%s' only supports 'avalanche' as a modifier for hash functions.\n", file, linenum, args[0]); |
| 2724 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2725 | goto out; |
| 2726 | } |
| 2727 | } |
| 2728 | } |
| 2729 | else if (strcmp(args[0], "hash-balance-factor") == 0) { |
| 2730 | if (*(args[1]) == 0) { |
| 2731 | ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); |
| 2732 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2733 | goto out; |
| 2734 | } |
Willy Tarreau | 76e84f5 | 2019-01-14 16:50:58 +0100 | [diff] [blame] | 2735 | curproxy->lbprm.hash_balance_factor = atol(args[1]); |
| 2736 | if (curproxy->lbprm.hash_balance_factor != 0 && curproxy->lbprm.hash_balance_factor <= 100) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2737 | ha_alert("parsing [%s:%d] : '%s' must be 0 or greater than 100.\n", file, linenum, args[0]); |
| 2738 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2739 | goto out; |
| 2740 | } |
| 2741 | } |
| 2742 | else if (strcmp(args[0], "unique-id-format") == 0) { |
| 2743 | if (!*(args[1])) { |
| 2744 | ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]); |
| 2745 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2746 | goto out; |
| 2747 | } |
| 2748 | if (*(args[2])) { |
| 2749 | ha_alert("parsing [%s:%d] : %s expects only one argument, don't forget to escape spaces!\n", file, linenum, args[0]); |
| 2750 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2751 | goto out; |
| 2752 | } |
| 2753 | free(curproxy->conf.uniqueid_format_string); |
| 2754 | curproxy->conf.uniqueid_format_string = strdup(args[1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2755 | if (!curproxy->conf.uniqueid_format_string) |
| 2756 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2757 | |
| 2758 | free(curproxy->conf.uif_file); |
| 2759 | curproxy->conf.uif_file = strdup(curproxy->conf.args.file); |
| 2760 | curproxy->conf.uif_line = curproxy->conf.args.line; |
| 2761 | } |
| 2762 | |
| 2763 | else if (strcmp(args[0], "unique-id-header") == 0) { |
Tim Duesterhus | 0643b0e | 2020-03-05 17:56:35 +0100 | [diff] [blame] | 2764 | char *copy; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2765 | if (!*(args[1])) { |
| 2766 | ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]); |
| 2767 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2768 | goto out; |
| 2769 | } |
Tim Duesterhus | 0643b0e | 2020-03-05 17:56:35 +0100 | [diff] [blame] | 2770 | copy = strdup(args[1]); |
| 2771 | if (copy == NULL) { |
| 2772 | ha_alert("parsing [%s:%d] : failed to allocate memory for unique-id-header\n", file, linenum); |
| 2773 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2774 | goto out; |
| 2775 | } |
| 2776 | |
| 2777 | istfree(&curproxy->header_unique_id); |
| 2778 | curproxy->header_unique_id = ist(copy); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2779 | } |
| 2780 | |
| 2781 | else if (strcmp(args[0], "log-format") == 0) { |
| 2782 | if (!*(args[1])) { |
| 2783 | ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]); |
| 2784 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2785 | goto out; |
| 2786 | } |
| 2787 | if (*(args[2])) { |
| 2788 | ha_alert("parsing [%s:%d] : %s expects only one argument, don't forget to escape spaces!\n", file, linenum, args[0]); |
| 2789 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2790 | goto out; |
| 2791 | } |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2792 | if (curproxy->conf.logformat_string && curproxy->cap & PR_CAP_DEF) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2793 | char *oldlogformat = "log-format"; |
| 2794 | |
| 2795 | if (curproxy->conf.logformat_string == default_http_log_format) |
| 2796 | oldlogformat = "option httplog"; |
| 2797 | else if (curproxy->conf.logformat_string == default_tcp_log_format) |
| 2798 | oldlogformat = "option tcplog"; |
| 2799 | else if (curproxy->conf.logformat_string == clf_http_log_format) |
| 2800 | oldlogformat = "option httplog clf"; |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2801 | else if (curproxy->conf.logformat_string == default_https_log_format) |
| 2802 | oldlogformat = "option httpslog"; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2803 | ha_warning("parsing [%s:%d]: 'log-format' overrides previous '%s' in 'defaults' section.\n", |
| 2804 | file, linenum, oldlogformat); |
| 2805 | } |
| 2806 | if (curproxy->conf.logformat_string != default_http_log_format && |
| 2807 | curproxy->conf.logformat_string != default_tcp_log_format && |
Remi Tricot-Le Breton | 98b930d | 2021-07-29 09:45:52 +0200 | [diff] [blame] | 2808 | curproxy->conf.logformat_string != clf_http_log_format && |
| 2809 | curproxy->conf.logformat_string != default_https_log_format) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2810 | free(curproxy->conf.logformat_string); |
| 2811 | curproxy->conf.logformat_string = strdup(args[1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2812 | if (!curproxy->conf.logformat_string) |
| 2813 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2814 | |
| 2815 | free(curproxy->conf.lfs_file); |
| 2816 | curproxy->conf.lfs_file = strdup(curproxy->conf.args.file); |
| 2817 | curproxy->conf.lfs_line = curproxy->conf.args.line; |
| 2818 | |
| 2819 | /* get a chance to improve log-format error reporting by |
| 2820 | * reporting the correct line-number when possible. |
| 2821 | */ |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2822 | if (!(curproxy->cap & PR_CAP_DEF) && !(curproxy->cap & PR_CAP_FE)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2823 | ha_warning("parsing [%s:%d] : backend '%s' : 'log-format' directive is ignored in backends.\n", |
| 2824 | file, linenum, curproxy->id); |
| 2825 | err_code |= ERR_WARN; |
| 2826 | } |
| 2827 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2828 | else if (strcmp(args[0], "log-format-sd") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2829 | if (!*(args[1])) { |
| 2830 | ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]); |
| 2831 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2832 | goto out; |
| 2833 | } |
| 2834 | if (*(args[2])) { |
| 2835 | ha_alert("parsing [%s:%d] : %s expects only one argument, don't forget to escape spaces!\n", file, linenum, args[0]); |
| 2836 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2837 | goto out; |
| 2838 | } |
| 2839 | |
| 2840 | if (curproxy->conf.logformat_sd_string != default_rfc5424_sd_log_format) |
| 2841 | free(curproxy->conf.logformat_sd_string); |
| 2842 | curproxy->conf.logformat_sd_string = strdup(args[1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2843 | if (!curproxy->conf.logformat_sd_string) |
| 2844 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2845 | |
| 2846 | free(curproxy->conf.lfsd_file); |
| 2847 | curproxy->conf.lfsd_file = strdup(curproxy->conf.args.file); |
| 2848 | curproxy->conf.lfsd_line = curproxy->conf.args.line; |
| 2849 | |
| 2850 | /* get a chance to improve log-format-sd error reporting by |
| 2851 | * reporting the correct line-number when possible. |
| 2852 | */ |
Willy Tarreau | 5d095c2 | 2021-02-12 10:15:59 +0100 | [diff] [blame] | 2853 | if (!(curproxy->cap & PR_CAP_DEF) && !(curproxy->cap & PR_CAP_FE)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2854 | ha_warning("parsing [%s:%d] : backend '%s' : 'log-format-sd' directive is ignored in backends.\n", |
| 2855 | file, linenum, curproxy->id); |
| 2856 | err_code |= ERR_WARN; |
| 2857 | } |
| 2858 | } |
Remi Tricot-Le Breton | fe21fe7 | 2021-08-31 12:08:52 +0200 | [diff] [blame] | 2859 | else if (strcmp(args[0], "error-log-format") == 0) { |
| 2860 | if (!*(args[1])) { |
| 2861 | ha_alert("parsing [%s:%d] : %s expects an argument.\n", file, linenum, args[0]); |
| 2862 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2863 | goto out; |
| 2864 | } |
| 2865 | if (*(args[2])) { |
| 2866 | ha_alert("parsing [%s:%d] : %s expects only one argument, don't forget to escape spaces!\n", file, linenum, args[0]); |
| 2867 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2868 | goto out; |
| 2869 | } |
| 2870 | if (curproxy->conf.error_logformat_string && curproxy->cap & PR_CAP_DEF) { |
| 2871 | ha_warning("parsing [%s:%d]: 'error-log-format' overrides previous 'error-log-format' in 'defaults' section.\n", |
| 2872 | file, linenum); |
| 2873 | } |
| 2874 | free(curproxy->conf.error_logformat_string); |
| 2875 | curproxy->conf.error_logformat_string = strdup(args[1]); |
| 2876 | if (!curproxy->conf.error_logformat_string) |
| 2877 | goto alloc_error; |
| 2878 | |
| 2879 | free(curproxy->conf.elfs_file); |
| 2880 | curproxy->conf.elfs_file = strdup(curproxy->conf.args.file); |
| 2881 | curproxy->conf.elfs_line = curproxy->conf.args.line; |
| 2882 | |
| 2883 | /* get a chance to improve log-format error reporting by |
| 2884 | * reporting the correct line-number when possible. |
| 2885 | */ |
| 2886 | if (!(curproxy->cap & PR_CAP_DEF) && !(curproxy->cap & PR_CAP_FE)) { |
| 2887 | ha_warning("parsing [%s:%d] : backend '%s' : 'error-log-format' directive is ignored in backends.\n", |
| 2888 | file, linenum, curproxy->id); |
| 2889 | err_code |= ERR_WARN; |
| 2890 | } |
| 2891 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2892 | else if (strcmp(args[0], "log-tag") == 0) { /* tag to report to syslog */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2893 | if (*(args[1]) == 0) { |
| 2894 | ha_alert("parsing [%s:%d] : '%s' expects a tag for use in syslog.\n", file, linenum, args[0]); |
| 2895 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2896 | goto out; |
| 2897 | } |
| 2898 | chunk_destroy(&curproxy->log_tag); |
Eric Salama | 7cea606 | 2020-10-02 11:58:19 +0200 | [diff] [blame] | 2899 | chunk_initlen(&curproxy->log_tag, strdup(args[1]), strlen(args[1]), strlen(args[1])); |
| 2900 | if (b_orig(&curproxy->log_tag) == NULL) { |
| 2901 | chunk_destroy(&curproxy->log_tag); |
| 2902 | ha_alert("parsing [%s:%d]: cannot allocate memory for '%s'.\n", file, linenum, args[0]); |
| 2903 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2904 | goto out; |
| 2905 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2906 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2907 | else if (strcmp(args[0], "log") == 0) { /* "no log" or "log ..." */ |
Emeric Brun | 9533a70 | 2021-04-02 10:13:43 +0200 | [diff] [blame] | 2908 | if (!parse_logsrv(args, &curproxy->logsrvs, (kwm == KWM_NO), file, linenum, &errmsg)) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2909 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 2910 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2911 | goto out; |
| 2912 | } |
| 2913 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2914 | else if (strcmp(args[0], "source") == 0) { /* address to which we bind when connecting */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2915 | int cur_arg; |
| 2916 | int port1, port2; |
| 2917 | struct sockaddr_storage *sk; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2918 | |
| 2919 | if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) |
| 2920 | err_code |= ERR_WARN; |
| 2921 | |
| 2922 | if (!*args[1]) { |
| 2923 | ha_alert("parsing [%s:%d] : '%s' expects <addr>[:<port>], and optionally '%s' <addr>, and '%s' <name>.\n", |
| 2924 | file, linenum, "source", "usesrc", "interface"); |
| 2925 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2926 | goto out; |
| 2927 | } |
| 2928 | |
Christopher Faulet | 3193037 | 2019-07-15 10:16:58 +0200 | [diff] [blame] | 2929 | /* we must first clear any optional default setting */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2930 | curproxy->conn_src.opts &= ~CO_SRC_TPROXY_MASK; |
Willy Tarreau | 61cfdf4 | 2021-02-20 10:46:51 +0100 | [diff] [blame] | 2931 | ha_free(&curproxy->conn_src.iface_name); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2932 | curproxy->conn_src.iface_len = 0; |
| 2933 | |
Willy Tarreau | 65ec4e3 | 2020-09-16 19:17:08 +0200 | [diff] [blame] | 2934 | sk = str2sa_range(args[1], NULL, &port1, &port2, NULL, NULL, |
| 2935 | &errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2936 | if (!sk) { |
| 2937 | ha_alert("parsing [%s:%d] : '%s %s' : %s\n", |
| 2938 | file, linenum, args[0], args[1], errmsg); |
| 2939 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2940 | goto out; |
| 2941 | } |
| 2942 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2943 | curproxy->conn_src.source_addr = *sk; |
| 2944 | curproxy->conn_src.opts |= CO_SRC_BIND; |
| 2945 | |
| 2946 | cur_arg = 2; |
| 2947 | while (*(args[cur_arg])) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2948 | if (strcmp(args[cur_arg], "usesrc") == 0) { /* address to use outside */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2949 | #if defined(CONFIG_HAP_TRANSPARENT) |
| 2950 | if (!*args[cur_arg + 1]) { |
| 2951 | ha_alert("parsing [%s:%d] : '%s' expects <addr>[:<port>], 'client', or 'clientip' as argument.\n", |
| 2952 | file, linenum, "usesrc"); |
| 2953 | err_code |= ERR_ALERT | ERR_FATAL; |
| 2954 | goto out; |
| 2955 | } |
| 2956 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2957 | if (strcmp(args[cur_arg + 1], "client") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2958 | curproxy->conn_src.opts &= ~CO_SRC_TPROXY_MASK; |
| 2959 | curproxy->conn_src.opts |= CO_SRC_TPROXY_CLI; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 2960 | } else if (strcmp(args[cur_arg + 1], "clientip") == 0) { |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2961 | curproxy->conn_src.opts &= ~CO_SRC_TPROXY_MASK; |
| 2962 | curproxy->conn_src.opts |= CO_SRC_TPROXY_CIP; |
| 2963 | } else if (!strncmp(args[cur_arg + 1], "hdr_ip(", 7)) { |
| 2964 | char *name, *end; |
| 2965 | |
| 2966 | name = args[cur_arg+1] + 7; |
Willy Tarreau | 9080711 | 2020-02-25 08:16:33 +0100 | [diff] [blame] | 2967 | while (isspace((unsigned char)*name)) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2968 | name++; |
| 2969 | |
| 2970 | end = name; |
Willy Tarreau | 9080711 | 2020-02-25 08:16:33 +0100 | [diff] [blame] | 2971 | while (*end && !isspace((unsigned char)*end) && *end != ',' && *end != ')') |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2972 | end++; |
| 2973 | |
| 2974 | curproxy->conn_src.opts &= ~CO_SRC_TPROXY_MASK; |
| 2975 | curproxy->conn_src.opts |= CO_SRC_TPROXY_DYN; |
Amaury Denoyelle | 69c5c3a | 2021-01-26 14:35:22 +0100 | [diff] [blame] | 2976 | free(curproxy->conn_src.bind_hdr_name); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2977 | curproxy->conn_src.bind_hdr_name = calloc(1, end - name + 1); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 2978 | if (!curproxy->conn_src.bind_hdr_name) |
| 2979 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2980 | curproxy->conn_src.bind_hdr_len = end - name; |
| 2981 | memcpy(curproxy->conn_src.bind_hdr_name, name, end - name); |
| 2982 | curproxy->conn_src.bind_hdr_name[end-name] = '\0'; |
| 2983 | curproxy->conn_src.bind_hdr_occ = -1; |
| 2984 | |
| 2985 | /* now look for an occurrence number */ |
Willy Tarreau | 9080711 | 2020-02-25 08:16:33 +0100 | [diff] [blame] | 2986 | while (isspace((unsigned char)*end)) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2987 | end++; |
| 2988 | if (*end == ',') { |
| 2989 | end++; |
| 2990 | name = end; |
| 2991 | if (*end == '-') |
| 2992 | end++; |
Willy Tarreau | 9080711 | 2020-02-25 08:16:33 +0100 | [diff] [blame] | 2993 | while (isdigit((unsigned char)*end)) |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 2994 | end++; |
| 2995 | curproxy->conn_src.bind_hdr_occ = strl2ic(name, end-name); |
| 2996 | } |
| 2997 | |
| 2998 | if (curproxy->conn_src.bind_hdr_occ < -MAX_HDR_HISTORY) { |
| 2999 | ha_alert("parsing [%s:%d] : usesrc hdr_ip(name,num) does not support negative" |
| 3000 | " occurrences values smaller than %d.\n", |
| 3001 | file, linenum, MAX_HDR_HISTORY); |
| 3002 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3003 | goto out; |
| 3004 | } |
| 3005 | } else { |
| 3006 | struct sockaddr_storage *sk; |
| 3007 | |
Willy Tarreau | 65ec4e3 | 2020-09-16 19:17:08 +0200 | [diff] [blame] | 3008 | sk = str2sa_range(args[cur_arg + 1], NULL, &port1, &port2, NULL, NULL, |
| 3009 | &errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3010 | if (!sk) { |
| 3011 | ha_alert("parsing [%s:%d] : '%s %s' : %s\n", |
| 3012 | file, linenum, args[cur_arg], args[cur_arg+1], errmsg); |
| 3013 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3014 | goto out; |
| 3015 | } |
| 3016 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3017 | curproxy->conn_src.tproxy_addr = *sk; |
| 3018 | curproxy->conn_src.opts |= CO_SRC_TPROXY_ADDR; |
| 3019 | } |
| 3020 | global.last_checks |= LSTCHK_NETADM; |
| 3021 | #else /* no TPROXY support */ |
| 3022 | ha_alert("parsing [%s:%d] : '%s' not allowed here because support for TPROXY was not compiled in.\n", |
| 3023 | file, linenum, "usesrc"); |
| 3024 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3025 | goto out; |
| 3026 | #endif |
| 3027 | cur_arg += 2; |
| 3028 | continue; |
| 3029 | } |
| 3030 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3031 | if (strcmp(args[cur_arg], "interface") == 0) { /* specifically bind to this interface */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3032 | #ifdef SO_BINDTODEVICE |
| 3033 | if (!*args[cur_arg + 1]) { |
| 3034 | ha_alert("parsing [%s:%d] : '%s' : missing interface name.\n", |
| 3035 | file, linenum, args[0]); |
| 3036 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3037 | goto out; |
| 3038 | } |
| 3039 | free(curproxy->conn_src.iface_name); |
| 3040 | curproxy->conn_src.iface_name = strdup(args[cur_arg + 1]); |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 3041 | if (!curproxy->conn_src.iface_name) |
| 3042 | goto alloc_error; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3043 | curproxy->conn_src.iface_len = strlen(curproxy->conn_src.iface_name); |
| 3044 | global.last_checks |= LSTCHK_NETADM; |
| 3045 | #else |
| 3046 | ha_alert("parsing [%s:%d] : '%s' : '%s' option not implemented.\n", |
| 3047 | file, linenum, args[0], args[cur_arg]); |
| 3048 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3049 | goto out; |
| 3050 | #endif |
| 3051 | cur_arg += 2; |
| 3052 | continue; |
| 3053 | } |
| 3054 | ha_alert("parsing [%s:%d] : '%s' only supports optional keywords '%s' and '%s'.\n", |
| 3055 | file, linenum, args[0], "interface", "usesrc"); |
| 3056 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3057 | goto out; |
| 3058 | } |
| 3059 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3060 | else if (strcmp(args[0], "usesrc") == 0) { /* address to use outside: needs "source" first */ |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3061 | ha_alert("parsing [%s:%d] : '%s' only allowed after a '%s' statement.\n", |
| 3062 | file, linenum, "usesrc", "source"); |
| 3063 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3064 | goto out; |
| 3065 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3066 | else if (strcmp(args[0], "cliexp") == 0 || strcmp(args[0], "reqrep") == 0) { /* replace request header from a regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3067 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
Willy Tarreau | 262c3f1 | 2019-12-17 06:52:51 +0100 | [diff] [blame] | 3068 | "Use 'http-request replace-path', 'http-request replace-uri' or 'http-request replace-header' instead.\n", |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3069 | file, linenum, args[0]); |
| 3070 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3071 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3072 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3073 | else if (strcmp(args[0], "reqdel") == 0) { /* delete request header from a regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3074 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3075 | "Use 'http-request del-header' instead.\n", file, linenum, args[0]); |
| 3076 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3077 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3078 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3079 | else if (strcmp(args[0], "reqdeny") == 0) { /* deny a request if a header matches this regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3080 | ha_alert("parsing [%s:%d] : The '%s' not supported anymore since HAProxy 2.1. " |
| 3081 | "Use 'http-request deny' instead.\n", file, linenum, args[0]); |
| 3082 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3083 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3084 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3085 | else if (strcmp(args[0], "reqpass") == 0) { /* pass this header without allowing or denying the request */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3086 | ha_alert("parsing [%s:%d] : The '%s' not supported anymore since HAProxy 2.1.\n", file, linenum, args[0]); |
| 3087 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3088 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3089 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3090 | else if (strcmp(args[0], "reqallow") == 0) { /* allow a request if a header matches this regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3091 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3092 | "Use 'http-request allow' instead.\n", file, linenum, args[0]); |
| 3093 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3094 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3095 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3096 | else if (strcmp(args[0], "reqtarpit") == 0) { /* tarpit a request if a header matches this regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3097 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3098 | "Use 'http-request tarpit' instead.\n", file, linenum, args[0]); |
| 3099 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3100 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3101 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3102 | else if (strcmp(args[0], "reqirep") == 0) { /* replace request header from a regex, ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3103 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3104 | "Use 'http-request replace-header' instead.\n", file, linenum, args[0]); |
| 3105 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3106 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3107 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3108 | else if (strcmp(args[0], "reqidel") == 0) { /* delete request header from a regex ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3109 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3110 | "Use 'http-request del-header' instead.\n", file, linenum, args[0]); |
| 3111 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3112 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3113 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3114 | else if (strcmp(args[0], "reqideny") == 0) { /* deny a request if a header matches this regex ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3115 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3116 | "Use 'http-request deny' instead.\n", file, linenum, args[0]); |
| 3117 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3118 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3119 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3120 | else if (strcmp(args[0], "reqipass") == 0) { /* pass this header without allowing or denying the request */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3121 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1.\n", file, linenum, args[0]); |
| 3122 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3123 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3124 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3125 | else if (strcmp(args[0], "reqiallow") == 0) { /* allow a request if a header matches this regex ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3126 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3127 | "Use 'http-request allow' instead.\n", file, linenum, args[0]); |
| 3128 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3129 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3130 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3131 | else if (strcmp(args[0], "reqitarpit") == 0) { /* tarpit a request if a header matches this regex ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3132 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3133 | "Use 'http-request tarpit' instead.\n", file, linenum, args[0]); |
| 3134 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3135 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3136 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3137 | else if (strcmp(args[0], "reqadd") == 0) { /* add request header */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3138 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3139 | "Use 'http-request add-header' instead.\n", file, linenum, args[0]); |
| 3140 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3141 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3142 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3143 | else if (strcmp(args[0], "srvexp") == 0 || strcmp(args[0], "rsprep") == 0) { /* replace response header from a regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3144 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3145 | "Use 'http-response replace-header' instead.\n", file, linenum, args[0]); |
| 3146 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3147 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3148 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3149 | else if (strcmp(args[0], "rspdel") == 0) { /* delete response header from a regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3150 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3151 | "Use 'http-response del-header' .\n", file, linenum, args[0]); |
| 3152 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3153 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3154 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3155 | else if (strcmp(args[0], "rspdeny") == 0) { /* block response header from a regex */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3156 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3157 | "Use 'http-response deny' instead.\n", file, linenum, args[0]); |
| 3158 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3159 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3160 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3161 | else if (strcmp(args[0], "rspirep") == 0) { /* replace response header from a regex ignoring case */ |
Balvinder Singh Rawat | def595e | 2020-03-14 12:11:50 +0530 | [diff] [blame] | 3162 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3163 | "Use 'http-response replace-header' instead.\n", file, linenum, args[0]); |
| 3164 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3165 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3166 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3167 | else if (strcmp(args[0], "rspidel") == 0) { /* delete response header from a regex ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3168 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3169 | "Use 'http-response del-header' instead.\n", file, linenum, args[0]); |
| 3170 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3171 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3172 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3173 | else if (strcmp(args[0], "rspideny") == 0) { /* block response header from a regex ignoring case */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3174 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3175 | "Use 'http-response deny' instead.\n", file, linenum, args[0]); |
| 3176 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3177 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3178 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 3179 | else if (strcmp(args[0], "rspadd") == 0) { /* add response header */ |
Christopher Faulet | a6a56e6 | 2019-07-17 15:13:28 +0200 | [diff] [blame] | 3180 | ha_alert("parsing [%s:%d] : The '%s' directive is not supported anymore since HAProxy 2.1. " |
| 3181 | "Use 'http-response add-header' instead.\n", file, linenum, args[0]); |
| 3182 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3183 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3184 | } |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3185 | else { |
| 3186 | struct cfg_kw_list *kwl; |
Willy Tarreau | c0ff679 | 2021-03-12 09:14:19 +0100 | [diff] [blame] | 3187 | const char *best; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3188 | int index; |
| 3189 | |
| 3190 | list_for_each_entry(kwl, &cfg_keywords.list, list) { |
| 3191 | for (index = 0; kwl->kw[index].kw != NULL; index++) { |
| 3192 | if (kwl->kw[index].section != CFG_LISTEN) |
| 3193 | continue; |
| 3194 | if (strcmp(kwl->kw[index].kw, args[0]) == 0) { |
Amaury Denoyelle | d2e53cd | 2021-05-06 16:21:39 +0200 | [diff] [blame] | 3195 | if (check_kw_experimental(&kwl->kw[index], file, linenum, &errmsg)) { |
Amaury Denoyelle | 86c1d0f | 2021-05-07 15:07:21 +0200 | [diff] [blame] | 3196 | ha_alert("%s\n", errmsg); |
Amaury Denoyelle | d2e53cd | 2021-05-06 16:21:39 +0200 | [diff] [blame] | 3197 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3198 | goto out; |
| 3199 | } |
| 3200 | |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3201 | /* prepare error message just in case */ |
Willy Tarreau | ab3410c | 2021-02-12 12:17:30 +0100 | [diff] [blame] | 3202 | rc = kwl->kw[index].parse(args, CFG_LISTEN, curproxy, curr_defproxy, file, linenum, &errmsg); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3203 | if (rc < 0) { |
| 3204 | ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg); |
| 3205 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3206 | goto out; |
| 3207 | } |
| 3208 | else if (rc > 0) { |
| 3209 | ha_warning("parsing [%s:%d] : %s\n", file, linenum, errmsg); |
| 3210 | err_code |= ERR_WARN; |
| 3211 | goto out; |
| 3212 | } |
| 3213 | goto out; |
| 3214 | } |
| 3215 | } |
| 3216 | } |
| 3217 | |
Willy Tarreau | c0ff679 | 2021-03-12 09:14:19 +0100 | [diff] [blame] | 3218 | best = cfg_find_best_match(args[0], &cfg_keywords.list, CFG_LISTEN, common_kw_list); |
| 3219 | if (best) |
| 3220 | ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section; did you mean '%s' maybe ?\n", file, linenum, args[0], cursection, best); |
| 3221 | else |
| 3222 | ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection); |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3223 | err_code |= ERR_ALERT | ERR_FATAL; |
| 3224 | goto out; |
| 3225 | } |
| 3226 | out: |
| 3227 | free(errmsg); |
| 3228 | return err_code; |
Christopher Faulet | b15625a | 2021-04-12 21:31:45 +0200 | [diff] [blame] | 3229 | |
| 3230 | alloc_error: |
| 3231 | ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); |
| 3232 | err_code |= ERR_ALERT | ERR_ABORT; |
| 3233 | goto out; |
Willy Tarreau | 3a1f5fd | 2018-11-11 15:40:36 +0100 | [diff] [blame] | 3234 | } |