Search code examples
regexhaproxy

Regex inside HAProxy configuration to match any character


I want to redirect a certain type of URLs 301 if they are not on https to http. The syntax of the regex somehow does not work:

redirect scheme https code 301 if { hdr(Host) -i ^project-.*$ } !{ ssl_fc }

it should match project-de, project-us, etc..

Without regex the line works perfectly.


Solution

  • Use -m modificator: if { hdr(Host) -m reg -i ^project-.*$ } or if { hdr(Host) -m beg -i project- }