]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config/proxy: Warn if a TCP proxy without backend is upgradable to HTTP
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 31 Mar 2021 15:13:49 +0000 (17:13 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Apr 2021 11:24:34 +0000 (13:24 +0200)
If a 'switch-mode http' tcp action is configured on a listener with no
backend, a warning is displayed to remember HTTP connections cannot be
routed to TCP servers. Indeed, backend connection is still established using
the proxy mode.

src/cfgparse.c

index 7f82409ed945b796217f53871556ef8294842771..6f8522e41e5f0ef9145ff821b59dc146f3d142e5 100644 (file)
@@ -2554,6 +2554,14 @@ int check_config_validity()
                        }
                }
 
+               /* Warn is a switch-mode http is used on a TCP listener with servers but no backend */
+               if (!curproxy->defbe.name && LIST_ISEMPTY(&curproxy->switching_rules) && curproxy->srv) {
+                       if ((curproxy->options & PR_O_HTTP_UPG) && curproxy->mode == PR_MODE_TCP)
+                               ha_warning("Proxy '%s' : 'switch-mode http' configured for a %s %s with no backend. "
+                                          "Incoming connections upgraded to HTTP cannot be routed to TCP servers\n",
+                                          curproxy->id, proxy_mode_str(curproxy->mode), proxy_type_str(curproxy));
+               }
+
                if (curproxy->table && curproxy->table->peers.name) {
                        struct peers *curpeers;