Forum Discussion
iRule replace HTTP Host header for virtual Host
Hi DevCentral community.
I would like to create an iRule that replaces the HTTP Host header in order to select a virtual host.
(watch out there is APM in place)
Client request:
Host : xxx.test.local
F5 to Server:
Host : test.it
F5 to Client:
Host: xxx.test.local
Version 11
Anyone can help me?
Thanks in advance,
Best Regards,
M.
3 Replies
- MDPF5_152674
Altostratus
Please, can you confirm that the correct iRule events are: Client to server replace : HTTP_REQUEST Server to client replace: HTTP_RESPONSE Thanks - Walter_Kacynski
Cirrostratus
The Host header does not return to the client, so HTTP_RESPONSE does not apply.
Try this
when HTTP_REQUEST { if {[HTTP::host] equals "xxx.test.local"} { [HTTP::host] test.it } } - william_gonzalez
Altostratus
Try this, it works for me:
Create a Datagroup partnering Ip + name (SERVER HOST HEADER) from servers you want to load balance.
After create this, copy this iRule and change "name_datagroup" you have previously created.
when HTTP_REQUEST_SEND { clientside { set host_header_value [class match -value [IP::server_addr] equals **name_datagroup**] Check if the lookup returned a value if {$host_header_value ne ""}{ Replace the host header value HTTP::header replace Host $host_header_value } } }
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