Forum Discussion

Allwin_179373's avatar
Allwin_179373
Icon for Nimbostratus rankNimbostratus
May 21, 2017

can we direct traffic based on their cookie to a particular server using iRules

Hi,

 

can we direct traffic based on their cookie to a particular server using iRules?

 

The requirement is as below. If mylogin.sgx.com and mylogin.access.sgx URLs contain this cookie- amlbcookie=01, then route all requests to the PDC OpenAM server.

 

If mylogin.sgx.com and mylogin.access.sgx URLs contain this cookie- amlbcookie=03, then route all requests to the SDC OpenAM server.

 

Thanks in advance for your help.

 

2 Replies

  • You can use an iRule with the next condition in order to check if the cookie "amlbcookie" exists

     

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

     

  • I aint good at Irule 🙂 But logic would be like this I believe,

    when HTTP_REQUEST {
            set DEBUG 0
            set PDC_OpenAM_pool ""PDC_OpenAM_pool""
            set SDC_OpenAM_pool ""SDC_OpenAM_pool""
            if { [HTTP::cookie exists ""amlbcookie""] } 
                {
                if { [HTTP::cookie value ""amlbcookie""] equals ""01"" } 
                    {
                    if { $DEBUG } { log local0. ""CLIENT IP is [IP::client_addr] $PDC_OpenAM_pool selected"" }
                    pool $PDC_OpenAM_pool
                    } 
                elseif {[HTTP::cookie value ""amlbcookie""] equals ""03"" } 
                    {
                    if { $DEBUG } { log local0. ""CLIENT IP is [IP::client_addr] $SDC_OpenAM_pool selected"" }
                    pool $SDC_OpenAM_pool
                    }
                }
                      }
    

    You can also use active_members logic to control redundancy.