Forum Discussion
craig_jones_103
Nimbostratus
Mar 22, 2009Newbe to Irules and I need Help Urgently
Hi there Folks.
I am new to F5 and this is the First IRule that I am trying to get operating and as usual it needed in a rush.
We have a web site "http://a.b.com and normall all ...
Mar 23, 2009
TCL is pretty specific about where you put curly braces and the else statement. I think what the issue is is the two sets of statements (snat and pool) between the "if" and "else". Also, A URL is the form of "protocol:[HTTP::host][HTTP::uri]" so you should leave out the ws.digiticalrecordcenter.com out of the comparison. Also, I prefer to use a switch statement as it's a little better performing than an if.
Give this a shot:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri] {
"/crossdomain.xml" {
snat 10.195.3.162
pool POOL_WS.DRC.COM_EN
}
default {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
}
Another bonus with switch, is that you can use "glob" based wildcards which are faster than regular expressions. So, if you wanted to match based on a pattern you could do something like this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri] {
"/*.xml" {
snat 10.195.3.162
pool POOL_WS.DRC.COM_EN
}
default {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
}
If you want to go the "if" route, it would look like this.
when HTTP_REQUEST {
if { [string tolower [HTTP::uri] equals "/crossdomain.xml" } {
snat 10.195.3.162
pool POOL_WS.DRC.COM_EN
} else {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
One more thing. You didn't mention in your requirements that you needed to snat the connection. What's the reason for including the "snat 10.195.3.162" statement? If a snat is not needed, you might want to leave that one out.
Hope this helps...
-Joe
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
