Forum Discussion
Fereda_187281
Nimbostratus
Dec 14, 2015Irule-Replace URL with random node specific and Port
Hi all;
I want to do that when client a request url : than irule replace specific port). Another client request same url: than irule replace specific port).
So my specific irule could...
StephanManthey
Nacreous
Dec 14, 2015Hi,
I would apply the header insertion in the context of LB_SELECTED. The iRule below shows another option to insert real hostname to be retrieved from an array:when RULE_INIT {
array set static::node_hostname {
10.131.131.63 host1.lb-net.bit
10.131.131.64 host2.lb-net.bit
}
}
when LB_SELECTED {
if {[HTTP::header exists Host]} {
HTTP::header replace Host [getfield [array get static::node_hostname [LB::server addr]] " " 2]
HTTP::header replace Host "[LB::server addr]:[LB::server port]"
} else {
HTTP::header insert Host "[LB::server addr]:[LB::server port]"
}
}
Be aware, that servers may send absolute redirects containing the hostname they received in the clients request which may not be resolved by the client.
So perhaps you will need some additional iRule logic to rewrite redirects and the payload containing references. Thanks, StephanHelp guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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