Forum Discussion
opers13_3280
Jan 30, 2012Nimbostratus
iRule to redirect based on client username
I'm looking for an iRule to redirect specific clients to specific pools based on their username.
I'm finding examples based on source IP but not usernames.
Thanks
hooleylist
Jan 30, 2012Cirrostratus
If you're using basic HTTP auth, you can parse the username with HTTP::username:
http://devcentral.f5.com/wiki/iRules.http__username.ashx
You can map the username to pool name using a data group. To do the lookup, you can use class match -value:
when CLIENT_ACCEPTED {
Save the VS default pool name
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
Check if the basic auth username is present
if {[HTTP::username] ne ""}{
Check if the default
set pool_name [class match -value [HTTP::username] equals user_to_pool_dg]
if {$pool_name ne ""}{
Select the pool and exit the iRule event
pool $pool_name
return
}
}
If we are still in the iRule, a pool was not selected so pick the default pool
pool $default_pool
}
Aaron
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