Forum Discussion
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 test2@example.com send to pool2. Essentially, after successfully logged in have tried to save the user ID in the table. However, the issue is when test1 logs in, test2 cannot login. Not sure what I am doing wrong. Is there any limitation on table? I assumed it should be session based when used from different browsers. Any help on this will be highly appreciated.
F5 version: 12.1
Cheers.
Best regards
Hyder
- Vijay_ECirrus
There shouldn't be anything that prevents the normal operation. It would also depend on your iRule. Is it possible to provide your iRule ?
- Stanislas_Piro2Cumulonimbus
Hi,
Instead of storing user Id in table, send back a cookie to the user containing pool1 or pool2 (or user id)
In request, if the cookie contains pool1, forward to pool1...
- Stanislas_Piro2Cumulonimbus
Hi,
You can try something like that
when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { set logout 0 switch [HTTP::path] { "/login" { define condition to select pool2 if some condition { set pool pool2 } else { set pool $default_pool } "/logout" { set logout 1 if {[set cookie_pool [HTTP::cookie value selectpool]] ne ""} { set pool $cookie_pool } } default { if {[set cookie_pool [HTTP::cookie value selectpool]] ne ""} { set pool $cookie_pool } } } pool $pool } 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" } }
- Stanislas_Piro2Cumulonimbus
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
* 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