Forum Discussion
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 } }
Interested if you get this working, as you normally don't want to let the outside world know about your internal environment.
But one thought, could your application finger print the responce for you rather than the f5?
Might be worth running a tcpdump on what you have and see if there is something already there you could be looking at,.- InselljAltostratus
PSFletchTheTek Thanks for the reply, yeah we are only doing it on an internal web farm. So no outside world to worry about, thank goodness š¤£ Plus I wanted it to be a global thing as there is more than one site being hosted on the pool servers. Would be easy peasy doing it per app, but too many of them to warrent updating them all, unfortunately.
Great idea about the tcpdump, will be a good way to see if it is going the direction I am thinking it is. I will mention you in any solution found if you like š
Well you might as well collect this variable in the SERVER_CONNECTED event ..
If I get it right the purpose of your header will be identify the server in the farm during tshoot - IMHO having the IP address as the header value is a pretty good information for doing that .. so I think the iRule might be as easy aswhen SERVER_CONNECTED { set xserveron [IP::server_addr] } when HTTP_REQUEST_SEND { clientside { HTTP::header insert "X-Server-On" "$xserveron" } }
- InselljAltostratus
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 } }
Glad you got a working soltuion!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com