Forum Discussion
Dec 15, 2015
Hi,
I would apply the header insertion in the context of LB_SELECTED. The iRule below shows another option to insert real hostname to be retrieved from an array:when RULE_INIT {
array set static::node_hostname {
10.131.131.63 host1.lb-net.bit
10.131.131.64 host2.lb-net.bit
}
}
when LB_SELECTED {
if {[HTTP::header exists Host]} {
HTTP::header replace Host [getfield [array get static::node_hostname [LB::server addr]] " " 2]
HTTP::header replace Host "[LB::server addr]:[LB::server port]"
} else {
HTTP::header insert Host "[LB::server addr]:[LB::server port]"
}
}
Be aware, that servers may send absolute redirects containing the hostname they received in the clients request which may not be resolved by the client.
So perhaps you will need some additional iRule logic to rewrite redirects and the payload containing references. Thanks, Stephan