Count the number of available servers in dynamic backend


#1

Hello,

Can you advise how to set the following ACL, especially nbsrv:

frontend webfarm
bind 11.22.33.44:80

acl MAIN_not_enough_capacity nbsrv([%[req.hdr(host),lower,map(/etc/haproxy/backend.map,bk_default)]]) eq 0
http-request redirect code 301 location http://global-swajm.example.com if MAIN_not_enough_capacity
use_backend %[req.hdr(host),lower,map(/etc/haproxy/backend.map,bk_default)]

use_backend is working perfectly,but I don’t know how to set the same expression for nbsrv:
nbsrv([%[req.hdr(host),lower,map(/etc/haproxy/backend.map,bk_default)]])

This is the error which haproxy returns when I try to restart:
error detected while parsing ACL ‘MAIN_not_enough_capacity’ : missing comma after conv keyword ‘map’ in ACL expression ‘nbsrv([%[req.hdr(host),lower,map(/etc/haproxy/backend.map,bk_default)]])’.

//haproxy version is 1.6.11.

Thanks!