Forum Discussion
Pedro_Gonzalez_
Nimbostratus
Nov 17, 2006Persistence with Subdomains
We have been using standard cookie persistence with our www.mycompany.com domain and it has worked fine.
Our new redesign web site is using subdomains for product categories like apparel.mycompany.com, shoes.mycompany.com and now persistence is lost.
F5 tech support suggested we write an iRule to keep a customers session on the same server with the www.mycompany.com but I'm new to iRules and don't have a clue where to start.
I've seen some examples here but nothing like what we need.
Does anyone have any ideas?
Thanks.
Pedro
10 Replies
- hoolio
Cirrostratus
Hi Pedro,
I'm not positive on this, but I think you should be able to set a domain on the persistence cookie that would tell the client to present the cookie for any request to a subdomain on the domain you specify. This works when the node is setting the cookie, but I'm not certain it will work with a cookie the BIG-IP is setting itself.
Can you test it and report back? Note that you'll need to change the name of the cookie you're looking for, from my_persistence_cookie.when HTTP_RESPONSE { if {[HTTP::cookie count] > 0 } { foreach aCookie [HTTP::cookie names] { if { $aCookie == "my_persistence_cookie" } { HTTP::cookie domain $aCookie mycompany.com } } } }
[EDIT: fixed the setting of the domain on the cookie...and removed an extra pair of curly braces]
Aaron - Pedro_Gonzalez_
Nimbostratus
Aaron,
Is the cookie name you mention in the iRule "BIGipServer". The servers are not creating their own cookie. We let the LB automatically do the cookie insert for us now.
Thanks.
Pedro - hoolio
Cirrostratus
That sounds right for the default cookie name. Are you able to test this?
Aaron - Pedro_Gonzalez_
Nimbostratus
I have the iRule setup but I'm waiting for development to setup the correct web site for testing. I'll let you know how I make out. Thanks. - Pedro_Gonzalez_
Nimbostratus
I tried the following iRule and going from www.company.com to apparel.company.com the BigIP sent me to a different server.
when HTTP_RESPONSE {
if {[HTTP::cookie count] > 0 } {
foreach aCookie [HTTP::cookie names] {
if { $aCookie == "BIGipServer" } {
HTTP::cookie domain $aCookie company.com
}
}
}
} - hoolio
Cirrostratus
If you're using cookie insert persistence, the cookie name should start with BIGipServer, but also contain the pool name (Click here).
Try adding a logging statement to log each cookie name to find the exact name of the cookie(s) you want to modify:when HTTP_RESPONSE { if {[HTTP::cookie count] > 0 } { foreach aCookie [HTTP::cookie names] { log local0. "Cookie name: $aCookie" if { $aCookie == "BIGipServer" } { HTTP::cookie domain $aCookie company.com } } } }
If this fails, try using a browser plugin like HTTPwatch for IE or LiveHttpHeaders for FF to see exactly what the client is receiving.
Also, the ability to configure a domain on the persistence cookie might be a good feature to have included by default. If you think so, you might consider opening a case with support and asking for this feature to be added.
Aaron - Pedro_Gonzalez_
Nimbostratus
Aaron,
Your iRule worked great and it's been in production for a week.
Thanks for all your help.
Pedro. - zafer
Nimbostratus
Hello
i tested this irule it didnt work.
i have 2 vip address for http and https and multiple subdomain .abc.com
when i browse www.abc.com then searchin some buyable material then i try to buy it, it redirect to https:// then i change the url in browser xxx.abc.com and then request the same page, i loose my login, it means i loose my persistency, i see multiple different persistency values
what can be problem
not: i use same pool for http and https vip address
regards
zafer - hoolio
Cirrostratus
Hi Zafer,
Do you see the correct domain being set on the persistence cookie? Do you see the client send the persistence cookie when you move from the first VIP to the second VIP?
Aaron - zafer
Nimbostratus
Hi Aaron,
i found problem, bigip cookie name and application cookie name was same.
its working
thanks
zafer
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