Hi Willy,

This small series adds support for "use-server" rules in "defaults" sections,
so that a common set of rules can be shared across all backends inheriting from
a given defaults section, the same way "http-request" and "tcp-request" rules
already work.

Since a "defaults" section has no servers of its own, a static server name
could never be resolved there. For that reason, only the dynamic (log-format)
form is accepted, e.g.:

defaults
    mode http
    use-server "%[req.hdr(x-srv)]" if { req.hdr(x-srv) -m found }

backend b1
    server s1 ...
    server s2 …

A plain server name in a defaults section is rejected at parse time with a
clear error. At request time, a backend evaluates its own "use-server" rules
first, then the ones inherited from its defaults section (reached through the
existing px->defpx reference, so no rule is duplicated or copied).

Implementation notes:
- The static/dynamic classification that was inlined in proxy_finalize() is
factored into a small helper and reused by a new proxy_resolve_server_rules(),
called from check_config_validity() for the defaults proxies that
proxy_finalize() skips.
- The inherited rules are owned by the defaults proxy and freed in
defaults_px_free().

The series is doc'd and comes with a regtest covering both the dynamic
inheritance path and the parse-time rejection of a static name.

Best regards,

Benedict and Alexander

Attachment: 0001-MEDIUM-proxy-support-use-server-rules-in-defaults-se.patch
Description: 0001-MEDIUM-proxy-support-use-server-rules-in-defaults-se.patch

Attachment: 0002-DOC-configuration-allow-use-server-in-defaults-secti.patch
Description: 0002-DOC-configuration-allow-use-server-in-defaults-secti.patch

Attachment: 0003-REGTESTS-server-test-use-server-rules-in-a-defaults-.patch
Description: 0003-REGTESTS-server-test-use-server-rules-in-a-defaults-.patch

Reply via email to