Forum Discussion
Mojdeh_Koushki_
Nimbostratus
Oct 14, 2005iRule Script in Ver 9 is not functioning
hello
here is my problem, i have a set of bigip for bunch of web farm on ver 4.5.10, which i have this iRule for it and it is functioning Very Well...
if (getfield(http_uri, '/', 2) matches_regex "[Ww][Ee][Bb][Aa][Pp][Pp]") {
redirect to "https://%h/%u"
}
else {
use pool WebApp-50
}
and now we are upgrading to version 9 and compatable iRule for version 9 is COMPILING but NOT FUNCTIONING ...
here is the script...
when HTTP_REQUEST {
if { [string tolower [getfield [HTTP::uri] '/' 2]] == "webapp" } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
} else {
pool POOL_HTTP_Vlan70
}
}could you please tell me WHY?
thanks alot
Mojdeh
51 Replies
- drteeth_127330Historic F5 AccountIt's fairly obvious from the above log, but getfield doesn't behave in what I would call an intuitive manner. Since the URI path begins with a slash, the first path component is really field 2. So, using getfield on a URI is /two/three/four/five. The first field is always empty. Is that what you were expecting?
- As you can see from the trace, Field2 which comes from the getfield command with the slash in double quotes is getting set correctly.Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : URI: /webnav/navapp1.asp?association_link=lncust1_hunt&brand_cd=huntxx00
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : Field:
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : Lower:
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : slash: '/'
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : Field2: webnav
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : Lower2:
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : slash2: /
Oct 14 14:23:07 tmm tmm[648]: Rule redirect2 : Didn't find match for webapp!
The the blatant item that sticks out is why you are searching for the string "webapp" when all the uri's being passed in start with "/webnav"?
The Rule is working correctly because the first element past the first slash does not equal "webapp".
Also, I would recommend using my "starts_with" example instead of the getfield. getfield would be good if you had to do something with that string after you extracted it but it's overkill for this situation.when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/webnav" } { HTTP::redirect "https://[HTTP::host][HTTP::uri] } else { pool POOL_HTTP_Vlan70 } }
-Joe - Either use an elseif
when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] if { $uri starts_with "/webnav" } { HTTP::redirect "https://[HTTP::host][HTTP::uri] } elseif { $uri starts_with "/webapp" } { HTTP::redirect "https://[HTTP::host][HTTP::uri] } else { pool POOL_HTTP_Vlan70 } }
or you could combine them with two expressions or'ed together.when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] if { ($uri starts_with "/webnav") or ($uri starts_with "/webapp") } { HTTP::redirect "https://[HTTP::host][HTTP::uri] } else { pool POOL_HTTP_Vlan70 } }
Notice that I assigned the lower cased uri to a variable so the tolower wouldn't have to be processed twice.
-Joe - Just make sure you comment out (using "") the log statements once you've got all the kinks worked out. No need for that extra overhead if you don't need it.
-Joe - Mojdeh_Koushki_
Nimbostratus
Joe
i re edit the script to capture the activity to log , but when i apply the iRule, and when i hit the website ... it is just freez there ... do you know why?
thanks - Colin_Walker_12Historic F5 Accountkoushki,
We'd have to see the rule that you're trying to implement before we were able to comment on what might be wrong.
It was obviously working before with the logging lines that Joe recommended, so something must have changed if it's now hanging.
Thanks,
-Colin - Mojdeh_Koushki_
Nimbostratus
well original problem was .... it was not working when we apply iRule ... so originally iRule did not working so Joe's adding line it was just for debug - Mojdeh_Koushki_
Nimbostratus
i have to ask my original question again :
i have this iRule, working in version 4.x , what would be it equal on ver 9.x ?
if (getfield(http_uri, '/', 2) matches_regex "[Ww][Ee][Bb][Aa][Pp][Pp]") {
redirect to "https://%h/%u"
}
else {
use pool WebApp-50
} - Colin_Walker_12Historic F5 AccountThe code for the rule that you're asking about has been well documented in this thread. Joe provided you a solution, and you confirmed that this solution was working for you.
If it is no longer working, then something in that code must have changed.
My recommendation would be to re-copy the code provided to you already, and start from there, as that is known-good code.
There is no need to re-state the original quesiton, as it has already been clearly answered.
-Colin - Mojdeh_Koushki_
Nimbostratus
yes ... i did, i create the new rule.
it is regoznizing webapp and webnav ( buy adding debug lines and check the log ) but then it is not going any where ?!?!?!
iRule tole should be forcing http to https and all request should go to any webserver which load balncer choice to handle the rest of requst
debug showes , iRule undrestand webapp or webnav and redirected but then it is not going any where ... just frezz there ... it does not pick any webservers
do you want to test it by yourself and see what i mean
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
