Forum Discussion

Jay_Prasanth_13's avatar
Jay_Prasanth_13
Icon for Nimbostratus rankNimbostratus
Oct 13, 2014

After applying secure and httponly flag , 404 redirects not working

Hi, Below is the iRule I created to set secure and httponly flag.

 

when HTTP_RESPONSE { HTTP::cookie secure "JSESSIONID" enable set ck [HTTP::header values "Set-Cookie"] HTTP::header remove "Set-Cookie" foreach acookie $ck { if {$acookie starts_with "JSESSIONID"} { HTTP::header insert "Set-Cookie" "${acookie}; HttpOnly; Secure" } else { HTTP::header insert "Set-Cookie" "${acookie}; HttpOnly; Secure" } } }

 

Now the issue is after implementing this iRule , 404 redirects not working

 

GET output shows "500 read failed:"

 

4 Replies

  • Hello Jay,

     

    404 means page not found, nothing with redirect here. What could happen is that browser doesn't link what he find inside the page delivered by the bigip. can you have a look to a tcpdump to see if anything wrong in the content.

     

    you could also modify your irule to address only specific response code.

     

  • Hello Arnaud ,

     

    Thanks for the immediate reply , I do know 404 is page not found. Let me elaborate more on the issue.

     

    Here is the issue in detail..

     

    • We have redirect for http error code 404 , which redirects to a separate url, below is the iRule for this job.

    when HTTP_RESPONSE {

     

    if { [HTTP::status] eq "404" } { HTTP::redirect "https://xxx.com/yy/404" } }

     

    • Recently we implement httponly and secure flag for all our websites (iRule in this thread)
    • Sites working fine , all is good at this point.
    • If URL is mistyped it should supposed to redirect to https://xxx.com/yy/404 , which is not working (was working prior implementing httponly and secure flag )
    • GET https://xxx.com/blahblah shows "500 read failed:"
    • tcpdump didn’t help much.

    Let me know if not clear.

     

  • oky much clear to me now ! there must be a priority issue here (

     

    https://devcentral.f5.com/articles/-the101-irules-101-events-amp-priorities )

     

    assuming you have 2 different irules here. If you put first the cookie one , then the redirect one in the irule list in the gui this is working in my lab. you can re order irules from the gui/ressource tab, up/down buttons. the other way around give you an RST for iRule execution error : TCL error: /Common/irule_cookie_flag - Operation not supported (line 3) invoked from within "HTTP::header remove "Set-Cookie" "

     

    reason being i suspect that you try to modify cookies in your response while you already crafted it for redirect.

     

  • Awesome , Thanks Arnaud.

     

    Placed cookie first and redirect iRule second, it worked.