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,
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
string map
command to make the replacement more dynamic- Yann_Desmarest_Aug 28, 2017Nacreous
Using string map :
when HTTP_REQUEST { if { [HTTP::host] contains "xyz.externaldomain.com" } { set new_host [string map {externaldomain internaldomain} [HTTP::host]] HTTP::header replace Host $new_host } }
- N_67263Aug 28, 2017Nimbostratus
hey Yann....thanks a ton. I think the logic should work. However, we would like to use the new domain to do a lookup and what ever is the IP returned use that IP address in the node to forward the traffic.
Let me work on some extension of iRule with the logic you provided
- N_67263Aug 28, 2017Nimbostratus
This is the iRule that I have mapped out, still does not work. :( any comments?
when HTTP_REQUEST { if { [HTTP::host] contains "externaldomain.com" } { set new_host [string map {externaldomain internaldomain} [HTTP::host]] set ips [lindex [RESOLV::lookup -a [$new_host]] 0] node $ips [TCP::local_port] } }
- Yann_Desmarest_Aug 29, 2017Nacreous
Hi,
Are you sure that you resolve the new_host ?
when RULE_INIT { set static::dns "1.1.1.1" } when HTTP_REQUEST { if { [HTTP::host] contains "externaldomain.com" } { set new_host [string map {externaldomain internaldomain} [HTTP::host]] set ips [lindex [RESOLV::lookup @$static::dns -a $new_host] 0] node $ips [TCP::local_port] } }
- N_67263Aug 29, 2017Nimbostratus
thanks again Yann... to ensure that DNS is not causing a issue I have put the hostname as a static host entry on the F5 itself.
- Kai_WilkeAug 29, 2017MVP
Interesting approach. You use
within an iRule to query a STATIC HOST entry. How about skipping[RESOLV::lookup]
and putting the resolved IP directly into your iRule?[RESOLV::lookup]
Cheers, Kai
- N_67263Aug 30, 2017Nimbostratus
yes, it does seem that DNS is messgin up something here. I have commented the same below. Again, I would not know how to set the IP of the node with iRule. :(
any comments there are well? Sorry for the bugging but trying to get the familiarity.
- N_67263Aug 30, 2017Nimbostratus
The DNS is just not responding. The queries resolve correctky when I do a lookup from the Linux Kernel and the TMSH. Could there be anything different the iRule needs?
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