@eyepulp wrote:
TLDR
Is there a way to read a string value from a map and havepath_begtreat it like a proper pattern to match against?The longer version
We manage thousands of domains through a single haproxy config, and we have a limited number of backends (around 6) servicing various portions of each domain’s needs.Based on customer options, different domains need a different combination of backends for particular routes (the same route might have several backends capable of answering, but it’s specific to each particular domain). This is where it gets messy to hardcode the logic in haproxy, and I’m trying to use maps to keep things very configurable (and we can use the Unix sockets to update the maps).
Currently I’m trying to use a map of domain names as keys with
path_begstyle patterns as values to choose between several backends. However it doesn’t appear path_beg can accept a string pulled from a map for matching – can anyone confirm, or is there another way to accomplish a similar result?Using the examples below and
curlto test I can set some response headers to verify that haproxy is looking up and receiving the correct values from the map. However, it never matches via path_beg to the strings it pulls from the map. If I hardcode the same strings (routes)path_begworks as expected.Thanks for taking a look!
haproxy.cfg
#--------------------------------------------------------------------- frontend http-in bind *:80 http-request set-var(txn.domain) req.hdr(Host),field(1,:),lower use_backend be-aa if { path_beg -i var(txn.domain),map(/usr/src/app/be-aa.routes.map.txt) } use_backend be-bb if { path_beg -i var(txn.domain),map(/usr/src/app/be-bb.routes.map.txt) }be-aa.routes.map.txt
localhost /contactbe-bb.routes.map.txt
localhost /api
Posts: 1
Participants: 1