Forum Discussion
Raimar_Melchior
Nimbostratus
Jul 13, 2005Cookie Persistence with iRule
Hi everybody,
I want to achieve cookie persistence by means of extracting a string from a cookie and directing the client to the appropriate pool member based on that unique string. It would also be nice when a match would be logged.
Cookie: BBIGipServerpoola=353479690.11465.0000;JServSessionId1111...
1111 is the unique string which should be extracted (1111 identifies node1 and 2222 identifies node2). The pool has only this two members.
I would be very pleased when someone could give me a sample iRule on this.
Thanks
cyb
1 Reply
- Martin_MachacekHistoric F5 AccountAssuming that your unique identifier is really part of the cookie name and not the cookie value, following configuration should work:
class my_nodes { "1111 10.1.1.1:80" "2222 10.1.1.2:80" } pool my_pool { select mapclass2node(findstr(http_header("Cookie"), "JServSessionId", 14, 4), my_nodes) member 10.1.1.1:80 member 10.1.1.2:80 } virtual 1.2.3.4:80 { use pool my_pool }
The basic idea is to use the mapclass2node function to select a node based on unique identifier parsed out of the Cookie header. The call to the findstr function above returns 4 characters at offset 14 after matching string JServSessionId.If the id cannot be parsed out of the cookie or if the cookie header is not present or if the unique id does not match any entry in the class, BIG-IP will loadbalance the request based on loadbalancing method defined for the pool (round-robin in the example above).
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
