Forum Discussion
Hyder_141209
Jul 13, 2017Altostratus
User ID based pool selection
hi there!
I am trying to write one iRule to select the pool based on user ID. For example, when the user tries to login, grab the ID of test1@example.com and send to pool1 and for other user ID ...
Stanislas_Piro2
Jul 25, 2017Cumulonimbus
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"
}
}
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