Forum Discussion

Angelo_5130's avatar
Angelo_5130
Icon for Nimbostratus rankNimbostratus
Oct 22, 2010

iRule to rewrite domain not working:(

Hi all,

 

 

I am very new to iRules and I was trying to write an iRule to rewrite the domain in the cookie inserted by the LTM default cookie persistence profile.

 

 

- Virtual Server is defined as HTTPS and the default HTTP profile is associated to it

 

- A Cookie persistence profile is associated to the virtual server:

 

- Parent profile: cookie

 

- Cookie Method: Insert

 

- Cookie name: My_cookie

 

 

By searching in the the forum I found the following:

 

 

when HTTP_RESPONSE {

 

Check if the persistence cookie exists in the response

 

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

 

set the domain attribute on the persistence cookie

 

HTTP::cookie domain "My_cookie" ".mydomain.com"

 

}

 

}

 

 

 

However, when I try to apply the iRule I see that no cookie at all is sent back (instead of the My_cookie one).

 

 

Does anybody have an idea on what might be causing this?

 

 

Thanks a lot in advance!

3 Replies

  • Hi Angelo,

     

     

    If you configure the cookie insert persistence profile to be session based (no timeout), then LTM will only set the cookie when a load balancing decision is made. There isn't generally a need to set it on every response.

     

     

    So if you clear your cookies and retest, you should see LTM setting the cookie.

     

     

    Aaron
  • Hi Angelo,

    I would be surprised if using HTTP::cookie to set the domain on a cookie would cause the cookie to "disappear" from the response. Can you add a log statement before and after the HTTP::cookie command to log the Set-Cookie header values:

    
    when HTTP_RESPONSE {
    
       log local0. "[IP::client_addr]:[TCP::client_port]: Pre Set-Cookies: [HTTP::header values Set-Cookie]"
        Check if the persistence cookie exists in the response
       if {[HTTP::cookie exists "My_cookie"]} {
           set the domain attribute on the persistence cookie
          HTTP::cookie domain "My_cookie" ".mydomain.com"
          log local0. "[IP::client_addr]:[TCP::client_port]: Modified domain on My_cookie"
        }
       log local0. "[IP::client_addr]:[TCP::client_port]: Post Set-Cookies: [HTTP::header values Set-Cookie]"
    }
    

    Aaron
  • Hi Angelo,

     

     

    Thanks for the explanation. That makes sense.

     

     

    Aaron