From: Willy Tarreau Date: Tue, 11 Aug 2015 09:36:45 +0000 (+0200) Subject: MEDIUM: config: emit a warning on a frontend without listener X-Git-Tag: v1.6-dev4~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3934b8c6d85814e1f9eea889110a9197378fd6f;p=thirdparty%2Fhaproxy.git MEDIUM: config: emit a warning on a frontend without listener Commit c6678e2 ("MEDIUM: config: authorize frontend and listen without bind") completely removed the test for bind lines in frontends in order to make it easier for automated tools to generate configs (eg: replacing a bind with another one passing via a temporary config without any bind line). The problem is that some common mistakes are totally hidden now. For example, this apparently valid entry is silently ignored : listen 1.2.3.4:8000 server s1 127.0.0.1:8000 Hint: 1.2.3.4:8000 is mistakenly the proxy name here. Thus instead we now emit a warning to indicate that a frontend was found with no listener. This should be backported to 1.5 to help spot abnormal configurations. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 516580873b..98ccd5de2d 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -7245,6 +7245,12 @@ int check_config_validity() break; } + if ((curproxy->cap & PR_CAP_FE) && LIST_ISEMPTY(&curproxy->conf.listeners)) { + Warning("config : %s '%s' has no 'bind' directive. Please declare it as a backend if this was intended.\n", + proxy_type_str(curproxy), curproxy->id); + err_code |= ERR_WARN; + } + if ((curproxy->cap & PR_CAP_BE) && (curproxy->mode != PR_MODE_HEALTH)) { if (curproxy->lbprm.algo & BE_LB_KIND) { if (curproxy->options & PR_O_TRANSP) {