Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4714

Dynamic backend switching using nbsrv with Host header

$
0
0

Hi
I am using haproxy 2.4.7, and I would like to dynamically route to the correct backend, if the backend has available servers.
I struggle to find the correct syntax using nbsrv().

The error I am getting is:

# haproxy -c -f /etc/haproxy/haproxy.cfg
[NOTICE]   (31364) : haproxy version is 2.4.7-b5e51a5
[NOTICE]   (31364) : path to executable is /sbin/haproxy
[ALERT]    (31364) : parsing [/etc/haproxy/haproxy.cfg:18] : error detected while parsing switching rule : missing comma after fetch keyword 'nbsrv' in ACL expression 'nbsrv(%[req.hdr(host)])'.
[ALERT]    (31364) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT]    (31364) : Fatal errors found in configuration.

The error missing comma kind of doesn’t make sense to me.

How can this be done?
Here is my example config:

global
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    log         /dev/log local0 debug
    user        haproxy
    group       haproxy
    daemon
    default-path config

defaults
    timeout connect         10s
    timeout client          1m
    timeout server          1m

frontend EXT_WEB
    bind 10.11.12.13:80
    mode http
    use_backend %[req.hdr(host)]   if { hdr(host) -i -f acls/ishost_applications.acl } { nbsrv(%[req.hdr(host)]) gt 0 }
}

backend app01.test.net
    mode http
    server app01.test.net 10.11.12.101:80

backend app02.test.net
    mode http
    server app02.test.net 10.11.12.102:80

The acl file has the following contents:

# cat acls/ishost_applications.acl
app01.test.net
app02.test.net

Many thanks
Toni

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>