Forum Discussion

Sara_92620's avatar
Sara_92620
Icon for Nimbostratus rankNimbostratus
Aug 17, 2012

Choose pool based on /uri content with cookies

Hey all.

 

I'm sure this is probably a pretty simple issue, but I've been all over the boards and I can't seem to get it to work. I have two sites that share a public IP Address.

 

I've written an iRule that picks a pool based on a flag in the URI (/fms2). The server does not include /fms2, so I use a string command to redact that part of the URI. All of that is working great, although the server doesn't reply back with pointers that include /fms2 in the URI and thusly information is getting lost. I'm trying to use a pool_cookie to get it to work, but no luck. Here's my iRule, please let me know what I"m doing wrong:

 

 

when HTTP_REQUEST {

 

Default to not setting a pool cookie

 

set pool_cookie ""

 

 

Check URI set to lower case with wildcard matching

 

switch -glob [string tolower [HTTP::uri]] {

 

"/fms2*" {

 

pool fms2-staging_pool

 

HTTP::uri [string range [HTTP::uri] [string first "/" [HTTP::uri] 1] end]

 

set pool_cookie fms2

 

HTTP::header replace Host "fms2-staging.ith.local"

 

}

 

default_pool {

 

Check if user has pool cookie

 

switch [HTTP::cookie pool_selector] {

 

"fms2" {

 

pool fms2-staging_pool

 

}

 

default {

 

pool fms1-test

 

}

 

}

 

}

 

}

 

}

 

when HTTP_RESPONSE {

 

 

Set a pool selector cookie if a FMS2 pool was selected in request

 

if {$pool_cookie ne ""}{

 

HTTP::cookie insert name pool_selector value $pool_cookie

 

}

 

}

 

 

 

 

Thanks very much. –Sara