Forum Discussion
astokes_6920
Nimbostratus
Nov 11, 2010Rewrite host header to specific pool member
I've done basic host header rewrites rules in the past but I've just received an odd request that's beyond me. I'm scrapping together a solution from multiple posts but haven't got anything to pass y...
hoolio
Cirrostratus
Nov 11, 2010Hi,
So what do you want to rewrite the Host header to? Is it always the same value? Or do you want to rewrite it to something specific to the selected pool member?
For a static Host header rewrite you can use a rule like this:
when HTTP_REQUEST {
Set the Host header to www.example.com
HTTP::header replace Host "www.example.com"
}
To rewrite the Host header to something based on the selected pool member, you can use the HTTP_REQUEST_SEND event. You'll need to force the evaluation of the code into the clientside context as this event is in the serverside context.
From: http://devcentral.f5.com/wiki/default.aspx/iRules/HTTP_REQUEST_SEND
when HTTP_REQUEST_SEND {
Need to force the host header replacement and HTTP:: commands into the clientside context
as the HTTP_REQUEST_SEND event is in the serverside context
clientside {
Replace the HTTP host header with the selected server IP and port
HTTP::header replace Host "[LB::server addr]:[LB::server port]"
}
}
If you want to map the IP:port to a name, you could use a datagroup and the class command (10.x) or the findclass command (9.x) to look up the corresponding value. If you need to do this and want help, please provide details on the logic you want to implement.
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects