This is an example for doing it with POST data check:
when CLIENT_ACCEPTED {
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
set login 0
set logout 0
switch [HTTP::path] {
"/login" {
if {[HTTP::method] equals POST} {
set login 1
set pool $default_pool
if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{
set content_length [HTTP::header "Content-Length"]
} else {
set content_length 1048576
}
Check if $content_length is not set to 0
if {($content_length > 0)} {
HTTP::collect $content_length
}
}
}
"/logout" {
set logout 1
if {[set cookie_pool [HTTP::cookie value selectpool]] ne ""} {
set pool $cookie_pool
} else {
set pool $default_pool
}
}
default {
if {[set cookie_pool [HTTP::cookie value selectpool]] ne ""} {
set pool $cookie_pool
} else {
set pool $default_pool
}
}
}
pool $pool
}
if HTTP_REQUEST_DATA {
if {$login}{
if {HTTP::payload contains "example.com"}{
set pool test1
} else {
pool $default_pool
}
pool $pool
}
HTTP::release
}
when HTTP_RESPONSE {
if {$logout} {
HTTP::header insert "Set-Cookie" "selectpool=$pool;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;secure"
} elseif {$pool ne $default_pool}{
HTTP::header insert "Set-Cookie" "selectpool=$pool;path=/;secure"
}
}