HAProxy community

Set a header from a file string match


The following rules in my haproxy config search for a url fragment against lines in a text file and use the result to choose a back-end.

acl aws_path_us urlp_sub -i -f /etc/haproxy/aws_clients_us
acl aws_path_us path_sub -i -f /etc/haproxy/aws_clients_us
acl aws_referer_us req.hdr(Referer) -i -m sub -f /etc/haproxy/aws_clients_us
acl aws_cookie_us req.hdr(Cookie) -i -m sub -f /etc/haproxy/aws_clients_us

use_backend wms_cloud_us if aws_path_us or aws_referer_us or aws_cookie_us or aws_param_us

I would like to set a header with the results of the match. Example:

url is: https://www.foo.com/abc123/default.html

textfile contains:


This will match on “abc123”. I would like to set a header with value “abc123”. As an added bonus, I would like to set the header text forced to lower case regardless of the case of the URL or the text in the file.

Is either or both of these requirements possible?

Many thanks.