diff --git a/doc/configuration.txt b/doc/configuration.txt index c0aeb3ab9..194ce23ac 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -1914,6 +1914,10 @@ bind-process [ all | odd | even | [-] ] ... Each "bind" line may further be limited to a subset of the proxy's processes, please consult the "process" bind keyword in section 5.1. + When a frontend has no explicit "bind-process" line, it tries to bind to all + the processes referenced by its "bind" lines. That means that frontends can + easily adapt to their listeners' processes. + If some backends are referenced by frontends bound to other processes, the backend automatically inherits the frontend's processes. diff --git a/src/cfgparse.c b/src/cfgparse.c index c932a9bf8..32b91a334 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -7309,11 +7309,47 @@ out_uri_auth_compat: } /* At this point, target names have already been resolved */ + + /* Make each frontend inherit bind-process from its listeners when not specified. */ + for (curproxy = proxy; curproxy; curproxy = curproxy->next) { + if (curproxy->bind_proc) + continue; + + list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) { + unsigned long mask; + + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL; + curproxy->bind_proc |= mask; + } + + if (!curproxy->bind_proc) + curproxy->bind_proc = ~0UL; + } + + if (global.stats_fe) { + list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { + unsigned long mask; + + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL; + global.stats_fe->bind_proc |= mask; + } + if (!global.stats_fe->bind_proc) + global.stats_fe->bind_proc = ~0UL; + } + + /* propagate bindings from frontends to backends */ for (curproxy = proxy; curproxy; curproxy = curproxy->next) { if (curproxy->cap & PR_CAP_FE) propagate_processes(curproxy, NULL); } + /* Bind each unbound backend to all processes when not specified. */ + for (curproxy = proxy; curproxy; curproxy = curproxy->next) { + if (curproxy->bind_proc) + continue; + curproxy->bind_proc = ~0UL; + } + /* automatically compute fullconn if not set. We must not do it in the * loop above because cross-references are not yet fully resolved. */