Varnish VCL: Case Insensitive Regex

By default, a regex match in Varnish happens case sensitive. If you want to use a case insensitive check, you can use the (?i) flag.

This is a normal, case sensitive regex check:

if (req.http.host ~ "^domain.(be|nl|com)$") {
  ...
}

To make the same check case insensitive, add the (?i) modifier at the beginning.

if (req.http.host ~ "(?i)^domain.(be|nl|com)$") {
  ...
}

Odd as it may be, some people type in their domain names with caps, and the browser does not convert those to lowercase on submit. Though in practice, every Host-header is treated as a lowercase value in all webserver configs.