]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: warn when some HTTP rules are used in a TCP proxy
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Mar 2017 10:49:21 +0000 (11:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Mar 2017 10:49:21 +0000 (11:49 +0100)
Surprizingly, http-request, http-response, block, redirect, and capture
rules did not cause a warning to be emitted when used in a TCP proxy, so
let's fix this.

This patch may be backported to older versions as it helps spotting
configuration issues.

src/cfgparse.c

index d4021c58b845071b9e5c311d63d44e6fca34e318..9d04f0284a42d5ef447e19f8f01b70412a7762ed 100644 (file)
@@ -8500,6 +8500,36 @@ out_uri_auth_compat:
                                curproxy->uri_auth = NULL;
                        }
 
+                       if (curproxy->capture_name) {
+                               Warning("config : 'capture' statement ignored for %s '%s' as it requires HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                       }
+
+                       if (!LIST_ISEMPTY(&curproxy->http_req_rules)) {
+                               Warning("config : 'http-request' rules ignored for %s '%s' as they require HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                       }
+
+                       if (!LIST_ISEMPTY(&curproxy->http_res_rules)) {
+                               Warning("config : 'http-response' rules ignored for %s '%s' as they require HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                       }
+
+                       if (!LIST_ISEMPTY(&curproxy->block_rules)) {
+                               Warning("config : 'block' rules ignored for %s '%s' as they require HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                       }
+
+                       if (!LIST_ISEMPTY(&curproxy->redirect_rules)) {
+                               Warning("config : 'redirect' rules ignored for %s '%s' as they require HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                       }
+
                        if (curproxy->options & (PR_O_FWDFOR | PR_O_FF_ALWAYS)) {
                                Warning("config : 'option %s' ignored for %s '%s' as it requires HTTP mode.\n",
                                        "forwardfor", proxy_type_str(curproxy), curproxy->id);