If I were to use map_reg then I’d have to have all regexes in the backends.map file, and I don’t want to do that. I ended up creating an acl, then putting a use_backend entry if before the use_backend on the map, like this:
acl is_statsurl hdr(host) -m end stats.domain.com
use_backend back-stats if is_statsurl
use_backend %[req.hdr(host),lower,map_dom(/etc/haproxy/backends.map)]
that way all *.stats.domain.com requests are routed to the stats backend, while others route via the map.
having difficulty getting mapping to work in my setup. As its currently defined i have a frontend redirect from http (html mode) to https (tcp mode), with the default_backend set in https (in tcp mode) as i do all ssl termination on the backend servers where i host a multisite cert *.stage.mydomain.com
current working
frontend localhost_http
bind *:80
mode http
option forwardfor except 127.0.0.0/8
option http-buffer-request
maxconn 100000
redirect scheme https
Im trying to add domain mapping to allow multiple backends by making the following changes to my frontend while still allowing the multi-site cert and domains to be served to mybackend1
changed for mapping
frontend localhost_https
… #default_backend mybackend1
use_backend %[req.hdr(host),lower,map_dom(/etc/haproxy/maps/hosts.map,mybackend1)]
backend mybackend1
…
backend mybackend2
…
contents of hosts.map: #domainname backendname
*.stage.mydomain.com mybackend1 api.mydomain.com mybackend2
however when i make the change above suddenly i am getting termination errors on all my domains and none will resolve.