Forum Discussion
hooleylist
Jan 28, 2010Cirrostratus
I think that's clearer now. So you can force a load balancing selection in CLIENT_ACCEPTED and then rewrite the port to the one you've calculated. I'm not sure whether you can use the pool command if the IP:port you're specifying isn't defined as a pool member. So give this a try and if it doesn't work, try changing the pool command to node :
when CLIENT_ACCEPTED {
log local0. "[IP::client_addr]:[TCP::client_port]: New connection to [IP::local_addr]:[TCP::local_port]"
Calculate destination port based on destination port and IP address
switch [TCP::local_port] {
443 {
set port [expr {[getfield [IP::local_addr] "." 4] + 2000}]
}
8443 {
set port [expr {[getfield [IP::local_addr] "." 4] + 3000}]
}
default {
Take some default action? For now, set this to some arbitrary value
If this should be the same value as 443 requests,
you could remove the 443 case and just use this default to catch it
set port [expr {[getfield [IP::local_addr] "." 4] + 2000}]
}
}
log local0. "[IP::client_addr]:[TCP::client_port]: Selecting pool by TCP listener: $port"
Force a load balancing selection
set pool_selection [LB::select]
log local0. "[IP::client_addr]:[TCP::client_port]: LB selection: $pool_selection"
Replace the selected pool member port with the calculated port
And use eval to make the load balancing selection
eval [lreplace $pool_selection 4 4 $port]
Or without the intermediate variables:
eval [lreplace [LB::select] 4 4 $port]
log local0. "[IP::client_addr]:[TCP::client_port]: Using [lreplace $pool_selection 4 4 $port]"
}
when SERVER_CONNECTED {
Debug logging. Remove/comment out this event when done testing
log local0. "[IP::client_addr]:[TCP::client_port]: Connected to [IP::server_addr]:[TCP::server_port]"
}
Aaron