Forum Discussion

mark_58181's avatar
mark_58181
Icon for Nimbostratus rankNimbostratus
Jun 06, 2007

Persistence across different load balancers

Hi folks,

 

 

I'm trying to implement persistence across multiple v9 BigIPs using a part of the URL as my persistence key. To make a long story short what I'd like to do is have specific URLs target specific servers.

 

 

For exmaple:

 

http://www.example.com/200/file (which would have several VIPs located on different load balancers) would be mapped to node 1.2.3.200. If the node's last IP octet isn't in the beginning of the URI, then it would default to using a server pool.

 

 

Here's the iRule I've put together so far, but for some reason it's not working.

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] matches_regex {^/[0-9]+/.*$} } { URI starts with /XXX/

 

log local0.info "Rule matched regex"

 

set mynode "1.2.3.[substr [HTTP::uri] 1 "/"]"

 

log local0.info "Setting node to $mynode"

 

if {[catch {node $mynode 80}]} {

 

log local0.info "was not able to set node"

 

} else {

 

log local0.info "node set successfully"

 

}

 

} else {

 

log local0.info "Rule did not match regex [HTTP::uri]"

 

pool Normal_web_Pool

 

}

 

}

 

The logs seem to indicate that it works, but for some reason the traffic isn't hitting the node it should be. I've also tried some variations on this:

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] matches_regex {^/[0-9]+/.*$} } { URI starts with /XXX/

 

log local0.info "Rule matched regex"

 

set mynode "1.2.3.[substr [HTTP::uri] 1 "/"]"

 

log local0.info "Setting node to $mynode"

 

pool Normal_web_Pool member $mynode 80

 

} else {

 

log local0.info "Rule did not match regex [HTTP::uri]"

 

pool Normal_web_Pool

 

}

 

}

 

 

Neither of these seem to work. Anyone have some ideas?

 

 

Thanks,

 

 

Mark
  • Nevermind, works fine (just need to make some changes to the profile)