1

I am trying to setup HAProxy in a way that when a user goes to example.com, they are 301'ed to www.example.com, while keeping intact the users ability to go to sub1.example.com, sub2.example.com, etc, the rule I have been trying to use on the front end is:

http-request redirect code 301 location www.example.com if {hdr_beg(host) -i example.com}

but when I run sudo haproxy -f /etc/haproxy/haproxy.cfg -c to validate of my cfg file, I get the output: error detected in frontend 'https-in' while parsing 'http-request redirect' rule : error in condition: no such ACL : '{hdr_beg(host)'.

1 Answer 1

1

Just add spaces on both sides of your { and }:

http-request redirect code 301 location www.domain1.com if { hdr_beg(host) -i domain1.com }

The characters aren't part of the command but signify that what's between them is an implicit ACL.

1
  • works perfectly! thanks!
    – roomwillow
    Apr 7, 2021 at 2:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .