Ok, I understand now why you're doing like that :)

Let me update Willy's example:


frontend site1
        bind :80

        monitor-uri /check
        monitor fail if { nbsrv(local) le 0 }

        acl local_ok nbsrv(local) gt 0
        acl site2_ok nbsrv(site2) gt 0
        acl site3_ok nbsrv(site3) gt 0

        acl is_site1 hdr_sub(cookie) SERVERID=a
        acl is_site2 hdr_sub(cookie) SERVERID=b
        acl is_site3 hdr_sub(cookie) SERVERID=c

        use_backend site2 if is_site2 site2_ok
        use_backend site3 if is_site3 site3_ok
        use_backend site2 if !local_ok site2_ok
        use_backend site3 if !local_ok site3_ok

        default_backend local

    backend local
        # handles site1's traffic as well as non-site specific traffic
        # all cookies are prefixed with "a"
        cookie SERVERID
        server srv1 1.0.0.1:80 cookie a1 check
        server srv2 1.0.0.1:80 cookie a2 check
        server srv3 1.0.0.1:80 cookie a3 check

    backend site2
        # reroute traffic to site 2's load balancer
        option httpchk GET /check
        server site2 2.2.2.2:80 check

    backend site3
        # reroute traffic to site 2's load balancer
        option httpchk GET /check
        server site3 3.3.3.3:80 check




Note that I have not tested this example, so there may be some mistake.
The idea here is to count the number of available server in a backend,
then take routing decision based on this information.
Each site must monitor its local backend and provide it's status to
other (monitor* lines) and pick up status from remote backend.

Tell me if you managed to configure your setup.

cheers

Reply via email to