]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: proxy: remove http-errors limitation for dynamic backends
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 Mar 2026 15:22:11 +0000 (16:22 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Mar 2026 10:14:07 +0000 (11:14 +0100)
Use proxy_check_http_errors() on defaults proxy instances. This will
emit alert messages for errorfiles directives referencing a non-existing
http-errors section, or a warning if an explicitely listed status code
is not present in the target section.

This is a small behavior changes, as previouly this was only performed
for regular proxies. Thus, errorfile/errorfiles directives in an unused
defaults were never checked.

This may prevent startup of haproxy with a configuration file previously
considered as valid. However, this change is considered as necessary to
be able to use http-errors with dynamic backends. Any invalid defaults
will be detected on startup, rather than having to discover it at
runtime via "add backend" invokation.

Thus, any restriction on http-errors usage is now lifted for the
creation of dynamic backends.

doc/management.txt
src/cfgparse.c
src/proxy.c

index 21899435636adedfc95cfc896b2c787cb08983bc..bdd52b4cc7abc67a5d4395abb42163660a55e5ef 100644 (file)
@@ -1740,10 +1740,7 @@ add backend <name> from <defproxy> [mode <mode>] [guid <guid>] [ EXPERIMENTAL ]
 
   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.
+  exceptions though, for example when the mode is neither TCP nor HTTP.
 
   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
index 03578b144ad34e44ab09642fa9f94bca9baa8589..d89acfeb68398147a90f8189f3fc2d7c77c1d493 100644 (file)
@@ -63,6 +63,7 @@
 #include <haproxy/global.h>
 #include <haproxy/http_ana.h>
 #include <haproxy/http_rules.h>
+#include <haproxy/http_htx.h>
 #include <haproxy/lb_chash.h>
 #include <haproxy/lb_fas.h>
 #include <haproxy/lb_fwlc.h>
@@ -2392,6 +2393,8 @@ int check_config_validity()
                else {
                        cfgerr += acl_find_targets(defpx);
                }
+
+               err_code |= proxy_check_http_errors(defpx);
        }
 
        /* starting to initialize the main proxies list */
index a72370aa438068629f20693fb7963433b1fcc8ee..2efef109031fbc339971f0fafb1a7947120554b1 100644 (file)
@@ -4918,10 +4918,6 @@ static int cli_parse_add_backend(char **args, char *payload, struct appctx *appc
                           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();