I am using a key - value mapping in HAProxy like this:
use_backend %[req.hdr(host),lower,map_dom(/etc/haproxy/clusters.map)] if !letsencrypt-acl
/etc/haproxy/clusters.map
is filled with domain and backend mappings. This works well.
Now, I also need to be able to route by IP. In other words, I want to be able to add an IP to the map file (/etc/haproxy/clusters.map
) with a corresponding backend. In order to do this, I changed my config to:
use_backend %[req.hdr(host),lower,map_dom(/etc/haproxy/clusters.map)] if !letsencrypt-acl
use_backend %[req.hdr(ip),lower,map_dom(/etc/haproxy/clusters.map)]
use_backend bk_letsencrypt if letsencrypt-acl
This actually seems to work well, but is this the recommended way to go about this?