Forum Discussion

lipos_54863's avatar
lipos_54863
Icon for Nimbostratus rankNimbostratus
Aug 18, 2009

Creating a cookie on the F5s and sharing persistance between HTTP and HTTPS

Hi,

 

 

I'm working on an iRule for creating a cookie on the F5s and sharing the persistence between HTTP and HTTPS.

 

 

HTTP and HTTPS VS are sharing the same POOL since SSL offloading is being done for HTTPS.

 

 

I created something like this:

 

 

when HTTP_RESPONSE {

 

if { [HTTP::cookie exists "cookie_lb"] }{

 

persist add uie [HTTP::cookie "cookie_lb"]

 

log local0.debug "Cookie persist - client IP: [IP::client_addr], Cookie: [HTTP::cookie "cookie_lb"], Server IP: [IP::server_addr]"

 

} else {

 

set a_cookie [expr {int(5000 * rand())}]

 

HTTP::cookie insert name cookie_lb value $a_cookie

 

persist add uie [HTTP::cookie "cookie_lb"]

 

log local0.debug "Create cookie and persist - client IP: [IP::client_addr], Cookie: $a_cookie, Server IP: [IP::server_addr]"

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "cookie_lb"] } {

 

persist uie [HTTP::cookie "cookie_lb"]

 

}

 

}

 

 

Is this the correct approach?

 

Is there a better way of doing it?

4 Replies

  • You can actually do this without an iRule if the requests are going to the same pool. See this post from Deb for details:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=31&tpage=1&view=topic&postid=1753117547

     

     

    Aaron
  • Do you mean that default cookie insert method will work for both HTTP and HTTPS if I will assign the same cookie profile to them??

     

    I'm not sure how the deb comment is related to my situation.
  • Sorry, that wasn't clear. Yes, if the same pool is referenced, you can assign the same cookie insert persistence profile to both the HTTP and HTTPS virtual servers. As the same pool is used for both pools, the same pool member will be selected for requests to either virtual server.

     

     

    Aaron
  • Good to hear. Sorry for any confusion on the incorrect link above.

     

     

    Aaron