From 92c8ac181f1b3804a6ff149ab6c0b63d10be596c Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 13 Nov 2020 12:34:57 +0100 Subject: [PATCH] MINOR: check: report error on incompatible proto If the check mux has been explicitly defined but is incompatible with the selected check type (tcp-check vs http-check), report a warning and prevent haproxy startup. (cherry picked from commit 7c148901837c5deed0f33bc037480faf10cb9a1f) Signed-off-by: Christopher Faulet --- src/check.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/check.c b/src/check.c index fe9f8be..0203e3e 100644 --- a/src/check.c +++ b/src/check.c @@ -1260,6 +1260,15 @@ static int init_srv_check(struct server *srv) (srv->mux_proto->mode == PROTO_MODE_TCP && check_type != TCPCHK_RULES_HTTP_CHK))) { srv->check.mux_proto = srv->mux_proto; } + /* test that check proto is valid if explicitly defined */ + else if (srv->check.mux_proto && + ((srv->check.mux_proto->mode == PROTO_MODE_HTTP && check_type != TCPCHK_RULES_HTTP_CHK) || + (srv->check.mux_proto->mode == PROTO_MODE_TCP && check_type == TCPCHK_RULES_HTTP_CHK))) { + ha_alert("config: %s '%s': server '%s' uses an incompatible MUX protocol for the selected check type\n", + proxy_type_str(srv->proxy), srv->proxy->id, srv->id); + ret |= ERR_ALERT | ERR_FATAL; + goto out; + } /* validate server health-check settings */ -- 1.7.10.4