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 traffic to this has to be redirected to HTTPS://a.b.com except that is if the URL is http://a.b.com/cd.xml na dif it is we need it to go to the pool "POOL_A.B.COM" on http.
I have tried the following rules with the errors given.
IRULE
when HTTP_REQUEST {
if {[HTTP::uri] equals {ws.digitalrecordcenter.com/crossdomain.xml}} {snat 10.195.3.162} {pool POOL_WS.DRC.COM_EN
} else {HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
ERROR
01070151:3: Rule [Irule_WS.HTTP-to-HTTPS_301] error:
line 2: [deprecated usage, use else or elseif] [ ]
line 2: [undefined procedure: else] [if {[HTTP::uri] equals {ws.digitalrecordcenter.com/crossdomain.xml}} {snat 10.195.3.162} {pool POOL_WS.DRC.COM_EN
} else {HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}]
and also
IRULE
when HTTP_REQUEST {
if {[HTTP::uri] equals "ws.digitalrecordcenter.com/crossdomain.xml"} {
snat 10.195.3.162} {pool POOL_WS.DRC.COM_EN
}
elseif {[HTTP::uri] equals "ws.digitalrecordcenter.com"} {
HTTP::redirect https://ws.digitalrecordcenter.com/]
}
}
ERROR
01070151:3: Rule [Irule_WS.HTTP-to-HTTPS_301] error:
line 3: [deprecated usage, use else or elseif] [ ]
line 2: [undefined procedure: elseif] [if {[HTTP::uri] equals "ws.digitalrecordcenter.com/crossdomain.xml"} {
snat 10.195.3.162} {pool POOL_WS.DRC.COM_EN
}
elseif {[HTTP::uri] equals "ws.digitalrecordcenter.com"} {
HTTP::redirect https://ws.digitalrecordcenter.com/]
}]
Can any of you guys give an explanation to a complete novice as to what the Irule might be or where I am going wrong on this.
any help you can offer would be greatly apprecaited.
Regards.
Craig Jones
- 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.
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] } } }
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] } } }
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] } }
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