Here is the iRule I am using
when HTTP_REQUEST {
set uri [ HTTP::uri ]
if { $uri contains "myapp" } {
find out if session id is defined
set sessionId [ HTTP::cookie "JSESSIONID" ]
if { $sessionId == "" } {
look for auth cookie
set authCookie [ HTTP::cookie "auth.mail.com" ]
set location [HTTP::cookie "mail_location" ]
if { $authCookie != "" and $location != "" } {
if { $location equals "mailloc" } {
pool appserver_pool_1
} elseif {$location equals "docloc" } {
pool appserver_pool_2
}
}
else {
Redirect to authentication page
HTTP::redirect "http://10.10.0.1/auth/"
}
} else {
persist session
persist uie $sessionId 3600
}
}
}
when HTTP_RESPONSE {
set SessionId [HTTP::cookie "JSESSIONID"]
if { $SessionId != "" }{
log "app server has set JSESSIONID $SessionId add persistence"
persist off session id for an hour (3600 seconds)
persist add uie $SessionId 3600
}
}