Forum Discussion
So this is basically simple - as you say, you just rewrite the Host header. The question is how the BIG-IP knows what to rewrite it to. If it were me, i'd use a simple switch statement as a start and work out from there how to improve it. Ultimately i'd probably create an iApp so I had a nice GUI, but that's just me!
when LB_SELECTED {
switch -exact -- [LB::server name] {
"server1" { HTTP::host "www.example1.com" }
"server2" { HTTP::host "www.example2.com" }
}
}
You'll also want to include some logging to start with, and error handling
- crodriguezNov 24, 2020Ret. Employee
Nice! You beat me to the punch as I got distracted while preparing my response below. Note that [LB::server name] does not return the actual pool member or node name but rather a 3-element list containing the configuration name of the pool, the selected member's IP address, and service port. For example:
/Common/fqdn_pool 172.16.20.1 80
- PeteWhiteNov 24, 2020EmployeeYour solution is more graceful, as with all things F5 you can do it in multiple ways. The only thing you should consider is if there is no match. Good point about LB::server
- crodriguezNov 24, 2020Ret. Employee
Absolutely agree on setting a default Host header if there is no match. Also, Pete's approach with a switch statement is preferable if you have only a handful of node IP addresses to map to FQDNs (up to about 15). Better performing than a datagroup.