From 07195a1af442aa93979f2452e42ff0209fbca3e9 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 6 Feb 2026 13:51:02 +0100 Subject: [PATCH] MINOR: proxy: check default proxy compatibility on "add backend" 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 | 7 +++++++ src/proxy.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/doc/management.txt b/doc/management.txt index 5a256a8e7..aacbfab6c 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1738,6 +1738,13 @@ add backend from [mode ] [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"). diff --git a/src/proxy.c b/src/proxy.c index eeed469b5..292e72f8d 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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(); -- 2.47.3