Forum Discussion
Change Host header for each node in a pool
I need to change the host header on each pool member. IE the incomming host header is 1.site.com. I set up a pool of servers, but each needs to have its OWN host header. a.something.local b.something.local c.something.local I never want to advertise the .local hosts to the client, should all just be 1.site.com. What is the best way to achieve this?
- Vijay_ECirrus
Why does it have to have its own host header ? If the goal is for the server to take specific action based on the header, can you insert the header at the F5 instead of changing the host header ?
Hi Barry,
Have seen these requirements in the past and there's been lot of solutions shared too. Don't want to reinvent the wheel, follow these links and you'll find the solutions,
Rewrite Host Header to Server IP:port
Rewrite Host Header to Server Name
You'd have to create a Data Group and an Irule for this.
Data Group:
ltm data-group internal ip_to_host_dg { records { 1.1.1.1 { data host1.example.com } 1.1.1.2 { data host2.example.com } 1.1.1.5 { data host3.example.com } } type string }
Irule:
when HTTP_REQUEST_SEND { clientside { set host_header_value [class match -value [IP::server_addr] equals ip_to_host_dg] if {$host_header_value ne ""}{ HTTP::header replace Host $host_header_value } } }
Again you can modify the host header for the http response back to the client. hope this helps.
- youssef1Cumulonimbus
Hi,
try this:
You just need to modify IP by your backend IP and needed host.
when LB_SELECTED { if { [LB::server addr] eq "10.1.1.1" } { set host "1.site.com" } elseif { [LB::server addr] eq "10.1.1.2" } { set host "2.site.com" } elseif { [LB::server addr] eq "10.1.1.3" } { set host "3.site.com" } else { set host [HTTP::header "Host"] } } HTTP_REQUEST_RELEASE { if { [HTTP::header exists "Host"] } { HTTP::header replace Host $host } else { HTTP::header insert Host $host } } }
Keep me in touch. regards,
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