Forum Discussion
opers13_3280
Nimbostratus
Jan 30, 2012iRule 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
5 Replies
- Chris_Phillips
Nimbostratus
well source IP or usernames are just arbitrary fields, It is very trivial to change the data source you are using. It could depend where you are getting the username from, as that could take all sorts of forms and you've not said if this is an HTTP header, cookie value etc.
In the simple exampels given here, just change the variable you are using for the input of the switch http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/21726/showtab/groupforums/Default.aspx - hoolio
Cirrostratus
Do you want to do a mapping for all clients to specific pools, or just a subset of users?
As Chris said, how you do this depends on what authentication method you're using. If you confirm that we can help with examples of selecting a pool based on username.
Aaron - opers13_3280
Nimbostratus
Just a subset of users to specific pools and HTTP is the authentication method.
Thank you! - hoolio
Cirrostratus
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 - opers13_3280
Nimbostratus
Thank you - I will try that
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
