Forum Discussion
xiaolin_chen_11
Nimbostratus
Jun 21, 2006how to write an iRule to redirect traffic to different pool based on URIs and need do client IP nat
I am a new comer to iRules. Now we have following requirement :
default or main page/site :
https://default.domain.com
siteA
https://ht.domain.com/gw
siteB
http...
dennypayne
Employee
Jun 22, 2006Some things that will help terminology wise:
https://ht.domain.com/gw is a URL, not a URI. A URI is everything after the hostname, so here ht.domain.com is returned by [HTTP::host]. [HTTP::uri] only returns /gw. So you'll need to fix your if statements to reflect that.
What you are referring to as client NAT is called a SNAT on BIG-IP. So you'll need to add a snat statement to the rule where you want that to happen.
Finally, BIG-IP will do the port translation to the pool by default so you don't need to manually set the URI to use the ports.
So you should end up with something like this (I have not validated syntax exactly):
when HTTP_REQUEST {
set myURI [string tolower [HTTP::uri]]
set myHOST [string tolower [HTTP::host]]
if { $myHOST == "ht.domain.com" and $myURI contains "gw" } {
snat automap
pool poolA
} elseif { $myHOST == "ht.domain.com" and $myURI contains "sec" } {
snat automap
pool poolA
} elseif ...
(and so on)
}else { pool Default_Pool }
}Hope that helps,
Denny
Help 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
