Forum Discussion
Chris_R_123579
Nimbostratus
Apr 04, 2013variable getting reset during irule execution
'll try to be as descriptive as I can since I'm not well trained in our F5 load balancers ways. Basically I have an iRule that looks something like this(pseudocode):
when HTTP_REQUEST {
set host_...
Kevin_Stewart
Employee
Apr 04, 2013I'm a little curious about your if conditional:
if { [string tolower $uri] matches_regex {serv[\d]+} } {
You're saying that if there's a number after the /serv URI, set the host_name and the path. But then in the else condition, you have this: scan $uri /serv%d%s host_num path. This assumes there's a number after the /serv URI, followed by a path. I would think that host_num wouldn't be set in this condition, considering the /serv URI doesn't have a number after it.
Can you try this minor variation:
when HTTP_REQUEST {
log local0. "here"
set host_num 0
set path "/"
if { [string tolower [HTTP::uri]] starts_with "/serv" } {
log local0. "prefix redirect initiated"
if { [string tolower [HTTP::uri]] matches_regex {serv[\d]+} } {
scan [string tolower [HTTP::uri]] /serv%d%s host_num path
log local0. "uri match found: $host_num"
} else {
scan [string tolower [HTTP::uri]] /serv%s path
}
log local0. "path = $path"
HTTP::uri $path
}
}
when LB_SELECTED {
log local0. "here"
if { [info exists host_num] } {
log local0. "host_num exists: $host_num"
if { $host_num != 0 } {
switch $host_num {
1 {
LB::reselect pool local-pool member 10.70.0.2
log local0. "prefix redirect selecting /serv1"
}
}
}
} else {
log local0. "host_num does not exist"
}
}
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