Redirect scheme with regex?

I have tried to use regular expression, but without luck.

We have a SSL wildcard sertificate for * and which to add use a redirect like this:

redirect schema https if { hdr(host} -i ^.*\.foobar\.com } !{ ssl_fc }

but without luck. I ended up with a lot of lines like this:

redirect schema https if { hdr(host) -i } !{ ssl_fc }

Which cause a lot of extra maintenance each time we add a new host. We need this since we also have a few customers that do not use SSL (like and they shall not be redirected to use https.

Is there a way to make haproxy support wildecard with redirect as described above?

Remove the ^ at the beginning of the regex, or it will never match a subdomain.

You don’t need regex for this though, this should suffice:
hdr(host) -m end

I’d better suggest:

hdr_dom(host) -m end