I need to create a basic iRule that keeps persistence based on JSESSION and load balances accordingly otherwise. I have tried all the standard persistence methods but it always goes back to defaulting to source IP. I have found quite a few example iRules but most of them get very involved. Can someone get me an example of how a basic iRule for session persistence using JSESSION would be??
Here’s a simplified version of the rule given in this thread Click here
when HTTP_REQUEST {
set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]
if { $jsess != "" } {
persist uie $jsess
}
}
This should enable persistence based on the jsessionid in the uri, assuming it matches the format the findstr command in this example is looking for ( jsessionid=x…y; ).
This should be pretty straight forward. There are literally hundreds of examples of this sort of thing in the forums if you look around a little. It’s always best to use the search function or even just browse around to see if there are answers to the questions you have, as many people are working on or have worked on similar rules that can help each other with their experience.
In any event, it would look like this:
when HTTP_REQUEST {
set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]
if { $jsess != "" } {
persist uie $jsess
} else {
pool yourPool
}
}
I am getting inconsistant results. Sometimes the persistence works and sometimes it does not. After using some ethereal traces I found that even using an iRule to do JSESSIONID persistence it also uses source port. Is there anyway to write a rule that will only look at the JSESSIONID and not the source port??