Forum Discussion

K-D's avatar
K-D
Icon for Nimbostratus rankNimbostratus
Nov 02, 2022

REWRITE PROFILE SET-COOKIE ERROR

Hello everyone, 

I am fairly new to F5.I need your help. I have a client that need URI translation from their external domain to the internal domain. I tried doing that using a rewrite profile.The initial translation works , the problem is some request like login and registration do not work. The response will say the request cannot be submitted. On the page developer tools. It is talking about the Set-cookie "This Attempt to set a cookie via Set-Cookie was blocked because its Domain attributewas invalid with regards to the current host".

The example for the mapping is :  external URL is example.org/ which is to be mapped to discussion.example.org/education.

In the response headers the domain in the sessioncookie is discussion.example.org/education

 

I have also tried to do the Set-Cookie rule to map the Client domain to the Server domain.I do not know what Im doing wrong. Kindly help.

Regards.

 

    • K-D's avatar
      K-D
      Icon for Nimbostratus rankNimbostratus

      Thank you Mihaic,

      but the cookie rewrite did not work , it is still complaining about the error:

      "This Attempt to set a cookie via Set-Cookie was blocked because its Domain attributewas invalid with regards to the current host", in the browser.

      In the Set-Cookie header the internal domain is not translated back to the external domain .I dont understand why. But I guess that is what is confusing the browser .

      Is there no way I could achieve the same solution (URI translation) using iRules.Im a novice in iRules. any help will be greatly appreciated. Thank you in advance.

      Regards.

  • K-D's avatar
    K-D
    Icon for Nimbostratus rankNimbostratus

    Good day ,

    Kindly assist with the following :

    I want to replace the path in the cookie returned from the server so that it can match what is defined in the Rewrite Profile for translation. Will the following iRule be efficient?

    when HTTP_RESPONSE {

     set Cookies [HTTP::cookie names]

     

    foreach mycookie $Cookies {

    if {[HTTP::cookie path $mycookie] eq “/Internet”}{

    set ckval [HTTP::cookie value $mycookie]

    set ckdomain [HTTP::cookie domain $mycookie]

    set ckpath [string map -nocase {"/Internet" "/Internet/"} [HTTP::cookie path $mycookie]]

    HTTP::cookie remove $mycookie

    HTTP::cookie insert name $mycookie value $ckval domain $ckdomain path $ckpath

    }elseif{[HTTP::cookie path $mycookie] eq “/Mobile”}{

    set ckval [HTTP::cookie value $mycookie]

    set ckdomain [HTTP::cookie domain $mycookie]

    set ckpath [string map -nocase {"/Mobile" "/ Mobile/"} [HTTP::cookie path $mycookie]]

    HTTP::cookie remove $mycookie

    HTTP::cookie insert name $mycookie value $ckval domain $ckdomain path $ckpath

    }

    Thank you in advance.

    Regards.