Forum Discussion

TechT's avatar
TechT
Icon for Nimbostratus rankNimbostratus
Jun 17, 2015

JSESSION ID and redirect

iRULE1 : I have a VIP which will redirect to specific URI when they see the HTTP Request which works fine and i have an irule for same which is below :

 

===== when HTTP_REQUEST { if { not ([HTTP::uri] starts_with "/example") } { HTTP::uri /example[HTTP::uri] }

 

}

iRULE2 : And i have below JSESSIONID irule which is based on cookie persistence.

 

===== when HTTP_RESPONSE { if { [HTTP::cookie exists "JSESSIONID"] } { persist add uie [HTTP::cookie "JSESSIONID"] } } when HTTP_REQUEST { if { [HTTP::cookie exists "JSESSIONID"] } { persist uie [HTTP::cookie "JSESSIONID"] }

 

}

when i have these 2 iRules together on a VIP, redirect request works, but jsession ID doesnt persist, but when i remove the iRULE1 from the iRule list, JSESSION ID persist. I would like to have an iRule where both the condition meets here. let me know if someone can help

 

2 Replies

  • Structurally, those should work together. I suspect that, when you perform the transparent rewrite, the server does not set the JSESSIONID for that set of URIs. That is, if a request is made for

    http://your.site.com/example/...
    then JSESSIONID is not set. That would explain why the second iRule does not appear to fire when the first is set. It's trivial to test. Change iRule 2 as follows:

    when HTTP_RESPONSE { 
        if { [HTTP::cookie exists "JSESSIONID"] } { 
            persist add uie [HTTP::cookie "JSESSIONID"] 
        } else {
            log local0. "No JSESSIONID cookie is present in the response"
        }
    } 
    

    Then check /var/log/ltm after making a request.

    If my suspicion is correct, then the fix requires a change to the server behavior, rather than BIG-IP (or you could switch to BIG-IP Cookie persistence).