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 05, 2013Fundamentally I don't see anything wrong with the logic. I'm still curious about your else condition though, given that there won't be a number after /serv if this condition is met. I would recommend a bigstart restart on the assumption that NOTHING else has changed other than applying and then removing some iRule logic.
Can you also try this variation of your rule:
when HTTP_REQUEST {
set host_num 0
set req_cookie [HTTP::cookie "DEVPERSIST"]
set path "/"
if { [string tolower [HTTP::uri]] starts_with "/serv" } {
log local0. "starts with /serv"
if { [string tolower [HTTP::uri]] matches_regex {/serv[\d]+} } {
log local0. "match_regex"
scan [string tolower [HTTP::uri]] /serv%d%s host_num path
log local0. "host_num = $host_num"
log local0. "path = $path"
} else {
log local0. "not match_regex"
scan [string tolower [HTTP::uri]] /serv%s path
log local0. "path = $path"
}
snip the host prefix from the URI
HTTP::uri $path
remove the cookie if it's there
if { [HTTP::cookie exists DEVPERSIST] } {
HTTP::cookie remove DEVPERSIST
}
}
}
when LB_SELECTED {
if { $host_num != 0 } {
log local0. "hostnum here $host_num"
redirect the request to the appropriate member
switch $host_num {
1 {
log local0. "selecting member 1"
LB::reselect pool DEV member 10.10.10.2:7085
}
2 {
log local0. "selecting member 2"
LB::reselect pool DEV member 10.10.10.3:8080
}
}
} else {
log local0. "hostnum = 0"
}
}
when HTTP_RESPONSE {
if { $host_num != 0 } {
HTTP::header insert Set-Cookie "DEVPERSIST=[HTTP::cookie DEVPERSIST]; Path=/"
log local0. "hostnum here $host_num"
} else {
log local0. "hostnum = 0"
}
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