version and all headers are ignored, but the request must at least be valid
at the HTTP level. This keyword may only be used with an HTTP-mode frontend.
- Monitor requests are processed very early. It is not possible to block nor
- divert them using ACLs. They cannot be logged either, and it is the intended
- purpose. They are only used to report HAProxy's health to an upper component,
- nothing more. However, it is possible to add any number of conditions using
- "monitor fail" and ACLs so that the result can be adjusted to whatever check
- can be imagined (most often the number of available servers in a backend).
+ Monitor requests are processed very early, just after the request is parsed
+ and even before any "http-request" or "block" rulesets. The only rulesets
+ applied before are the tcp-request ones. They cannot be logged either, and it
+ is the intended purpose. They are only used to report HAProxy's health to an
+ upper component, nothing more. However, it is possible to add any number of
+ conditions using "monitor fail" and ACLs so that the result can be adjusted
+ to whatever check can be imagined (most often the number of available servers
+ in a backend).
Example :
# Use /haproxy_test to report haproxy's status
return 0;
}
+/* Report a warning if a rule is placed after a 'monitor fail' rule.
+ * Return 1 if the warning has been emitted, otherwise 0.
+ */
+int warnif_rule_after_monitor(struct proxy *proxy, const char *file, int line, const char *arg)
+{
+ if (!LIST_ISEMPTY(&proxy->mon_fail_cond)) {
+ ha_warning("parsing [%s:%d] : a '%s' rule placed after a 'monitor fail' rule will still be processed before.\n",
+ file, line, arg);
+ return 1;
+ }
+ return 0;
+}
+
/* Report a warning if a rule is placed after a 'block' rule.
* Return 1 if the warning has been emitted, otherwise 0.
*/
warnif_misplaced_http_req(proxy, file, line, arg);
}
-/* report a warning if a "tcp request content" rule is dangerously placed */
-int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg)
+/* report a warning if a block rule is dangerously placed */
+int warnif_misplaced_monitor(struct proxy *proxy, const char *file, int line, const char *arg)
{
return warnif_rule_after_block(proxy, file, line, arg) ||
warnif_misplaced_block(proxy, file, line, arg);
}
+/* report a warning if a "tcp request content" rule is dangerously placed */
+int warnif_misplaced_tcp_cont(struct proxy *proxy, const char *file, int line, const char *arg)
+{
+ return warnif_rule_after_monitor(proxy, file, line, arg) ||
+ warnif_misplaced_monitor(proxy, file, line, arg);
+}
+
/* report a warning if a "tcp request session" rule is dangerously placed */
int warnif_misplaced_tcp_sess(struct proxy *proxy, const char *file, int line, const char *arg)
{
goto out;
}
+ err_code |= warnif_misplaced_monitor(curproxy, file, linenum, "monitor fail");
if ((cond = build_acl_cond(file, linenum, &curproxy->acl, curproxy, (const char **)args + 2, &errmsg)) == NULL) {
ha_alert("parsing [%s:%d] : error detected while parsing a '%s %s' condition : %s.\n",
file, linenum, args[0], args[1], errmsg);