Forum Discussion
iRule which strips of the domain name and replaces that with another domain name.
- Aug 28, 2017
Hi,
Maybe the following irule may help you :
when HTTP_REQUEST { if { [HTTP::host] contains "xyz.externaldomain.com" } { HTTP::header replace Host "xyz.internaldomain.com" } }
You may also use
command to make the replacement more dynamicstring map
Hi N,
please don't open multiple question for the same topic. It doesn't make sense if independent people spend their valuable time to answer your redundant questions over and over...
https://devcentral.f5.com/questions/understanding-the-host-in-the-http-request-55264
https://devcentral.f5.com/questions/node-autoselection-using-dns-55263
Note: I've already told you to add some error handles to your iRule, to become able to indentify where it breaks. In addition to that I've linked K12225 [click me] to make sure the DNS on your F5 allows recursive DNS queries. I've also speak out the recommendation to setup a DNS Virtual Server to become able to query a pool of redundant DNS servers.
Well, based on your latest requirements (added external / internal DNS domain conversation) the resulting iRule code would look like that...
when HTTP_REQUEST {
if { [HTTP::host] eq "xyz.externaldomain.com" } then {
set ips [lindex [RESOLV::lookup -a "[getfield [HTTP::host] "." 1].internaldomain.com"] 0]
log local0.debug "Debug: Resolved address for \"[getfield [HTTP::host] "." 1].internaldomain.com\" = \"$ips\""
if { $ips ne "" } then {
node $ips [TCP::local_port]
} else {
HTTP::respond 504 content "Bad Request - unknown HOST value"
}
} else {
HTTP::respond 504 content "Bad Request - wrong HOST value"
}
}
Cheers, Kai
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