Forum Discussion

NateV_219556's avatar
NateV_219556
Icon for Nimbostratus rankNimbostratus
May 08, 2017

http set cookie and a http reply redirect via policy

I am using a multi-rule policy on a new application. I have a requirement to set a cookie and issue a 302 redirect to another website. If I omit the redirect I can see that my cookie is set just fine. However I can't issue a redirect on the same rule and verify that the cookie is being set in any way. Here is what I have within the policy: { http-set-cookie response insert domain .my-domain.com name stop_mobile path / value yes } { http-reply redirect location }

 

1 Reply

  • The default strategy is first-match, so only the first rule is triggered. Change that to all-match, and should work.

    Example from my lab, where I successfully tested this:

    [root@LABBIGIP2:ModuleNotLicensed:Active:Changes Pending] config  tmsh list ltm policy policy1
    ltm policy policy1 {
        controls { forwarding }
        requires { http }
        rules {
            cookie {
                actions {
                    0 {
                        http-set-cookie
                        response
                        insert
                        name stop_mobile
                        path /
                        value yes
                    }
                }
                ordinal 1
            }
            redirect {
                actions {
                    0 {
                        http-reply
                        redirect
                        location http://asm.lab.local/
                    }
                }
                ordinal 2
            }
        }
        strategy all-match
    }