Forum Discussion
Mike_McCardle_1
Nimbostratus
Dec 19, 2006Basic iRule not working after upgrade
Hello All,
After an upgrade from 4.5.10 to 9.1.1, I cannot for the life of me get this iRule to work. it's pretty basic but for whatever reason, it doesn't want to work. I have a VS listening on port 80 for web traffic coming in. based on the URI it will be directed to 1 of 3 pools I have setup. The HTTP requests will all come into http://webhost.domain.com/____ . At the end of the request (URI) will either be /Jive, /WebNow, or a couple other strings. I need to direct requests containing "jive" to the Jive-Web pool, requests that contain "webnow" to the WebNow pool, and all others to the Weblogic pool. Any help is appreciated. Thank you.
when HTTP_REQUEST {
if { [HTTP::uri] matches "/jive" } {
use pool Jive_Web
}
elseif { [HTTP::uri] matches"/webnow" }{
use pool WebNow
}
else {
persist cookie insert wldevpool
use pool Weblogic
}
}
3 Replies
- Mike_McCardle_1
Nimbostratus
wrong script in there, I was trying to play with different commands to get it to work. this is the one that was upgraded and I am trying to use:
when HTTP_REQUEST {
if { [HTTP::uri] =="/jive" } {
use pool Jive_Web
}
elseif { [HTTP::uri] =="/webnow" }{
use pool WebNow
}
else {
persist cookie insert wldevpool
use pool Weblogic
}
}
thanks. - Deb_Allen_18Historic F5 AccountYou mentioned that you want to direct traffic if the URI "contains" that string, which may be the problem. Try using the "contains" or "starts_with" operator instead. You might also want to make the comparison case-insensitive, and a switch statement might be in order as well -- try one of these:
or:when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/jive" }{ pool Jive_Web } elseif { [string tolower[HTTP::uri]] contains "/webnow" }{ pool WebNow } else { persist cookie insert wldevpool pool Weblogic } }when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { Adjust wildcards as necessary. "/jive* is equivalent to "starts_with /jive" "*jive* is equivalent to "contains jive" "/jive*" { pool Jive_Web } "/webnow*" { pool WebNow } default { persist cookie insert wldevpool use pool Weblogic } } }
HTH
/deb - Mike_McCardle_1
Nimbostratus
Thank you much! I switched it to use the contains and the tolower command and all is well. Thanks for the input!
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