Forum Discussion
parse cookie content company code to specific pools?
We require a special iRule to parse the cookie for company codes and direct them to a specific pool. For example each client will have an unencrypted cookie that will contain a unique company code ie. (A1, B1, and C1). We would like to direct clients to a specific pool based on that company code.
A1 goes to pool POOL1
B1 goes to pool POOL2
C1 goes to pool POOL3
and so forth...
Is there something we could craft that would allow this logic to work properly? Any help is greatly appreciated. Thx!
4 Replies
- Kevin_Stewart
Employee
A cookie is generally a key-value pair, so is the A1, B1, C1 a key or a value?
For example, if it's a value (assuming the cookie name is "COMPANY_CODE"):when HTTP_REQUEST { switch { [HTTP::cookie "COMPANY_CODE"] } { "A1" { pool POOL1 } "B1" { pool POOL2 } "C1" { pool POOL3 } default { reject } } }
Of course this doesn't work if the cookie is passed AFTER the initial request. Do you have an out-of-band mechanism to distribute the cookies, or will the user connection initially without the cookie and hope to get one at some point? - JCMATTOS_41723
Nimbostratus
Thanks Kevin! I did verify it is an embedded value so this rule should work nicely then? I'll test it out and see how it goes. Thx again!
- JCMATTOS_41723
Nimbostratus
So after digging into this more. Looks like the initial client request doesn't receive the cookie until successful login. Once the successful login the cookie is issued corresponding to a user to a unique company code. After testing this irule it seems to be inconsistent and not working properly, is it because of the cookie not being in the initial request? Is there a way to get this to work under these circumstances?
when HTTP_REQUEST {
switch [HTTP::cookie "UserInfo"] {
"COMPANYID=A1" {
log local0. " matched COMPANYID=A1 in cookie UserInfo "
pool DEV-POOL1-80 }
"COMPANYID=B1" {
log local0. " matched COMPANYID=B1 in cookie UserInfo "
pool DEV-POOL2-80 }
"COMPANYID=C1" {
log local0. " matched COMPANYID=C1 in cookie UserInfo "
pool DEV-POOL3-80 }
}
} - nitass
Employee
are you using oneconnect? if not, would it be possible to try?
sol9800: Using an iRule to load balance HTTP requests to multiple pools
http://support.f5.com/kb/en-us/solutions/public/9000/800/sol9800.html
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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