Forum Discussion
Rewrite host header to selected member name?
Hi,
I'm trying to create a rule that would rewrite the host header of the request to the actual name of the selected pool member (not its IP address). The reason I am trying to do this is to load balance web sites; The web server needs to know which web site to serve based on the host header, so when somebody tries to access the VIP, I need to be able to rewrite the host header to the name of the selected pool member. I know this can be done in the web server itself, but I need to do it on the BigIP.
I was hoping to create a simple iRule based on the example here: https://devcentral.f5.com/codeshare?sid=671 But according to the documentation, there doesn't seem to be a variable that returns that name:
https://devcentral.f5.com/wiki/iRules.LB__server.ashx
Does anyone know of a way to accomplish this?
Thanks, Dan
3 Replies
- Kevin_Stewart
Employee
I'd probably start by asking where would you get the name information from? Reverse DNS? Or a local mapping?
The first option is a bit more involved and would of course incur some latency, but the second option is relatively straight forward if you maintain an IP-to-hostname mapping in a datagroup.
when HTTP_REQUEST { HTTP::header replace Host [class lookup [LB::server addr] my_host_datagroup] }You might also add a check to make sure the mapping information exists in the datagroup, before trying to replace the Host header, but hopefully this should give you a good idea how it could work.
- Kevin_Stewart
Employee
I don't believe you can get the node name from its IP address. You could, however, create a monitor script that maintains a datagroup based on pool member IPs and member names.
- Dan_Markhasin_1
Nimbostratus
Alright, thanks for your help!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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