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_...
Chris_R_123579
Nimbostratus
Apr 05, 2013Here is the entire rule with IP's changed etc. But this is the meat of it.
when HTTP_REQUEST {
set uri [HTTP::uri]
set host_num 0
set req_cookie [HTTP::cookie "DEVPERSIST"]
if { [string tolower $uri] starts_with "/serv" } {
if { [string tolower $uri] matches_regex {serv[\d]+} } {
scan $uri /serv%d host_num
set path "/"
} else {
scan $uri /serv%d%s host_num 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 {
LB::reselect pool DEV member 10.10.10.2:7085
}
2 {
LB::reselect pool DEV member 10.10.10.3:8080
}
}
}
}
when HTTP_RESPONSE {
if { $host_num != 0 } {
HTTP::header insert Set-Cookie "DEVPERSIST=[HTTP::cookie DEVPERSIST]; Path=/"
log local0. "hostnum here $host_num"
}
}
I haven't rebooted the F5 yet since it serves about 30 different high usage web applications. But I can talk to our sys admins about doing so at some point.
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