Using use_backend rules with map files

Hello,

is it possible use use_backend rules with map files multiple times in
one frontend? My small example don’t work. HAProxy returns 503, if no
match in the first map file. it would be great, if HAProxy can continue
the processing of the request.

My example:

global
    log /dev/log    local0
    log /dev/log    local1 notice


defaults
    mode http
    timeout connect 5s
    timeout client 15s
    timeout server 15s


frontend http-in
    bind :8080

    use_backend bk_%[path,map_beg(/etc/haproxy/path2backends.map)]
    use_backend
bk_%[req.hdr(host),lower,map(/etc/haproxy/host2backends.map,stats)]


backend bk_stats
    stats enable
    stats show-legends
    stats realm Haproxy\ Statistics
    stats uri /
    stats refresh 30s


backend bk_host1
    server a1 127.0.0.1:9001


backend bk_host2
    server a2 127.0.0.1:9002


backend bk_path1
    server a3 127.0.0.1:9003


backend bk_path2
    server a4 127.0.0.1:9004

Regards,
Michael

You’re missing a if condition in your first use_backend rule, so it matches all the time.
you can do something like:

use_backend bk_%[path,map_beg(/etc/haproxy/path2backends.map)] if { path,map_beg(/etc/haproxy/path2backends.map) -m found }