Forum Discussion
BRUCE_A_NOLAN_1
Nov 15, 2017Nimbostratus
How can I insert pool member IP into cookie when using Universal Persistence profile / iRule?
I am using the Universal Persistence Profile / iRule example from DevCentral to persist on the JSESSIONID. Is there a way to insert the destination pool member into the cookie so that it can be deco...
Simon_Blakely
Nov 15, 2017Employee
Is there a way to insert the destination pool member into the cookie so that it can be decoded
What cookie?
With UIE persistence there is no load-balancing cookie - the JSESSIONID cookie value is used as the index into an in-memory table on the LTM to retrieve the persistence information.You cannot modify the JSESSIONID cookie, because that will impact the server that is relying on the JSESSIONID value for session information.
You can add your own cookie or header to the response to include the server IP address into the response:
HTTP::cookie insert node_cookie [getfield [IP::server_addr] "%" 1"]
or
HTTP::header insert X-NODE-IP [getfield [IP::server_addr] "%" 1"]
but this can only be done in development and would be a very bad idea to use in a live environment.
when HTTP_RESPONSE {
Check if there is a jsessionid cookie in the response
if { [HTTP::cookie "JSESSIONID"] ne "" }{
Persist off of the cookie value with a timeout of 20 mins (1200 seconds)
persist add uie [string tolower [HTTP::cookie "JSESSIONID"]] 1200
log local0. "$log_prefix: Added persistence record from cookie: [persist lookup uie [string tolower [HTTP::cookie "JSESSIONID"]]]"
HTTP::cookie insert node_cookie [getfield [IP::server_addr] "%" 1"]
}
}
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