Nikolay_Matveev
Feb 12, 2015Nimbostratus
select a pool based on source IP and then amend headers based on selected pool
Hi,
Could you advise how I can achieve the following goal, please?
I have two web servers - external (3rd party - server1.external.com) and internal (server2.internal.com). I need to present these two servers to internal users as appname.internal.com but make load balancing decision based on source IP of internal users.
I have now worked out how I can trick the remote server (substituting Host and Location headers in requests and responses accordingly) but I am struggling to combine this with pool selection based on IP.
Should it be something like this?
when CLIENT_ACCEPTED {
}
when HTTP_REQUEST {
if {
the header replacement below works fine
HTTP::header replace host "server1.external.com"
}
else {
HTTP::header replace host "server2.internal.com"
}
}
when HTTP_RESPONSE {
Rewrite the Location header for redirects
if { [HTTP::header exists Location] }{
HTTP::header replace Location [string map {"https://server1.external.com" "https://appname.internal.com"} [HTTP::header Location]]
}
}