I'm trying to setup carp + hoststated as a loadbalancing solution on the loadbalancer I have hoststated with 2 service one and 2 ips on the carp interfaces 1 for dynamic and one for static content the dynamic content works fine but when I try to use both of em the traffic seems to end up on the wrong backend

hoststated config

#
# Macros
#
ext_addr="xxx.xxx.xxx.242"
static_addr="xxx.xxx.xxx.243"
webhost2="192.168.1.142"
static1="192.168.1.32"

table webhosts {
        real port http
        check http "/" code 200
        timeout 1000
        host $webhost2
}
table staticserver {
        real port http
        check http "/unavailable.html" code 200
        timeout 1000
        host $static1
}
table fallback {
        real port http
        check icmp
        host 127.0.0.1
}
service www {
        virtual host $ext_addr port http
        tag HOSTSTATED
        table webhosts
        backup table fallback
}
service static {
        virtual host $static_addr port http
        tag STATIC
        table staticserver
}
pf.conf

ext_if  = "em1"
int_if  = "em0"
web_if  = "carp0"
lan_net = "192.168.1.0/24"
#web_servers = "{ 192.168.1.142 }"
table <webhosts> persist { 192.168.1.142 }
table <staticserver> persist { 192.168.1.32 }
set skip on lo0
scrub in all
nat on $ext_if from !($ext_if) -> ($ext_if:0)

rdr-anchor "hoststated/*"
rdr on $ext_if from any to xxx.xxx.xxx.242 port 80 -> <webhosts> \
     round-robin sticky-address
rdr on $ext_if from any to xxx.xxx.xxx.243 port 80 -> <staticserver> \
     round-robin sticky-address


block in
block out
pass in on $int_if from any to any
pass out on $int_if from any to any
pass out quick on $ext_if proto { tcp udp icmp } all
pass on { $ext_if $int_if } proto carp keep state
pass quick on { em0 } proto pfsync keep state (no-sync)
pass on $ext_if inet proto tcp from any to any port www synproxy state
pass on $ext_if inet proto icmp from any to any



Reply via email to