Set Header for Pool items and return it in the Virtual IP (VIP)
Hi,
We have a Virtual IP (VIP) setup which load balances requests to a pool of servers. We need to be able to add in a response header depending on which pool server responds. This is so that we can diagnose which server has been hit in the pool if there are any issues.
We followed this guide and adjusted it appropriately so it added the header and matched the IP's for the pool members. But it isn't working. From my limited knowledge of iRules, I think it might be applying the header in the wrong direction and it is passing the header on to the pool members.
Whereas we need the header to show in the response which the VIP returns to the requesting client.
iRule:
when HTTP_REQUEST_SEND {
clientside {
set xserveron_header_value [class match -value [IP::server_addr] equals webfarm_headers]
if {$xserveron_header_value ne ""}{
HTTP::header insert X-Server-On $xserveron_header_value
}
}
}
Data Group (IP's and Servers changed):
ltm data-group internal webfarm_headers {
records {
x.x.x.x {
data server1
}
y.y.y.y {
data server2
}
}
type string
}
Found a solution š CA_Valli PSFletchTheTek
when HTTP_RESPONSE { set xserveron_header_value [class match -value [IP::server_addr] equals webfarm_headers] if {$xserveron_header_value ne ""}{ HTTP::header insert X-Server-On $xserveron_header_value } }