]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: check default proxy compatibility on "add backend"
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 6 Feb 2026 12:51:02 +0000 (13:51 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 6 Feb 2026 16:28:26 +0000 (17:28 +0100)
This commits completes "add backend" handler with some checks performed
on the specified default proxy instance. These are additional checks
outside of the already existing inheritance rules, specific to dynamic
backends.

For now, a default proxy is considered not compatible if it is not in
mode TCP/HTTP. Also, a default proxy is rejected if it references HTTP
errors. This limitation may be lifted in the future, when HTTP errors
are partiallay reworked.

doc/management.txt
src/proxy.c

index 5a256a8e714d0b2c8dcbdb472cdb486fffc9ebc0..aacbfab6c8a354244f632870a4a5f869fc2ef70c 100644 (file)
@@ -1738,6 +1738,13 @@ add backend <name> from <defproxy> [mode <mode>] [guid <guid>] [ EXPERIMENTAL ]
   in the unpublished state. Once considered ready for traffic, use "publish
   backend" to expose the newly created instance.
 
+  All named default proxies can be used, given that they validate the same
+  inheritance rules applied during configuration parsing. There is some
+  exceptions though, for example when the mode is neither TCP nor HTTP. Another
+  exception is that it is not yet possible to use a default proxies which
+  reference custom HTTP errors, for example via the errorfiles or http-rules
+  keywords.
+
   This command is restricted and can only be issued on sockets configured for
   level "admin". Moreover, this feature is still considered in development so it
   also requires experimental mode (see "experimental-mode on").
index eeed469b5f0073f13d10315817d6496b3204af94..292e72f8db069a298c514497994bf7514a9ea2c3 100644 (file)
@@ -4851,6 +4851,15 @@ static int cli_parse_add_backend(char **args, char *payload, struct appctx *appc
                cli_dynerr(appctx, memprintf(&msg, "Mode is required as '%s' default proxy does not explicitely defines it.\n", def_name));
                return 1;
        }
+       if (defpx->mode != PR_MODE_TCP && defpx->mode != PR_MODE_HTTP) {
+               cli_dynerr(appctx, memprintf(&msg, "Dynamic backends only support TCP or HTTP mode, whereas default proxy '%s' uses 'mode %s'.\n",
+                          def_name, proxy_mode_str(defpx->mode)));
+               return 1;
+       }
+       if (!LIST_ISEMPTY(&defpx->conf.errors)) {
+               cli_dynerr(appctx, memprintf(&msg, "Dynamic backends cannot inherit from default proxy '%s' because it references HTTP errors.\n", def_name));
+               return 1;
+       }
 
        thread_isolate();