Forum Discussion
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.
- fgf_165674
Nimbostratus
You can use an iRule with the next condition in order to check if the cookie "amlbcookie" exists
if { [HTTP::cookie exists "amlbcookie"] }
- jaikumar_f5
Noctilucent
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.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com