diff --git a/doc/configuration.txt b/doc/configuration.txt index 0e69b206c..ba7cb960e 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -4391,9 +4391,12 @@ http-request capture [ len | id ] If the keyword "id" is used instead of "len", the action tries to store the captured string in a previously declared capture slot. This is useful to run captures in backends. The slot id can be declared by a previous directive - "http-request capture" or with the "declare capture" keyword. If the slot - doesn't exist, then HAProxy fails parsing the configuration to prevent - unexpected behavior at run time. + "http-request capture" or with the "declare capture" keyword. + + When using this action in a backend, double check that the relevant + frontend(s) have the required capture slots otherwise, this rule will be + ignored at run time. This can't be detected at configuration parsing time + due to HAProxy's ability to dynamically resolve backend name at runtime. http-request del-acl() [ { if | unless } ] @@ -5097,8 +5100,11 @@ http-response capture id [ { if | unless } ] This is useful to run captures in backends. The slot id can be declared by a previous directive "http-response capture" or with the "declare capture" keyword. - If the slot doesn't exist, then HAProxy fails parsing the configuration - to prevent unexpected behavior at run time. + + When using this action in a backend, double check that the relevant + frontend(s) have the required capture slots otherwise, this rule will be + ignored at run time. This can't be detected at configuration parsing time + due to HAProxy's ability to dynamically resolve backend name at runtime. http-response del-acl() [ { if | unless } ] diff --git a/src/http_act.c b/src/http_act.c index 774df140a..a7f9e119d 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -494,7 +494,10 @@ static int check_http_req_capture(struct act_rule *rule, struct proxy *px, char if (rule->action_ptr != http_action_req_capture_by_id) return 1; - if (rule->arg.capid.idx >= px->nb_req_cap) { + /* capture slots can only be declared in frontends, so we can't check their + * existence in backends at configuration parsing step + */ + if (px->cap & PR_CAP_FE && rule->arg.capid.idx >= px->nb_req_cap) { memprintf(err, "unable to find capture id '%d' referenced by http-request capture rule", rule->arg.capid.idx); return 0;