Forum Discussion
2 urls pointing to same VIP
I have a req where we have 2 urls pointing to same VIP. 1 url need to balance across pool of 2 servers without sticky and least connections . 2nd url need to balancer across same pool of 2 servers with sticky and least connections .
Let me know how i can achieve this .
- jaikumar_f5
Noctilucent
Wouldn't it be easier if you just create 2 pools and apply the Irule.
Have a virtual created like below where it has a default pool and your sticky persistence in it,
ltm virtual testvirtual { destination 10.10.10.10:http ip-protocol tcp mask 255.255.255.255 persist { cookie { } } pool abc_pool profiles { http { } tcp { } } rules { pool_selection_irule } }
On the pools have LC as the LB method.
Then put the below code in the Irule pool_selection_irule: Where abc.com is the host where you dont want the persistence to be. And xyz.com is the host where your sticky persistence would be applied automatically.
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "abc.com" { pool abc_pool persist none } "xyz.com" { pool xyz_pool } } }
- Samir_Jha_52506
Noctilucent
Hope two url has same IP? Yes. And pointing to same VIP..
I am thinking bit different way and try with below iRule.
-
As per comments, both case least connection method has used right.. correct me. I will configure pool with least connection method.
-
Attach iRule to VIP n match traffic based on url condition.
. Hope it will work.Not tested till now
when HTTP_REQUEST { if { ([HTTP::host] equals "www.xyz.com")} { persist cookie pool pool1 } elseif { ([HTTP::host] equals "www.pqr.com")} { persist none pool pool1 } else { reject } }
-
- youssef1
Cumulonimbus
Hi,
In this example don't set any cookie profile on your VS. You will manage this need on the irule. And as you point in the same pool you don't need to set it in the irule just set your pool in the VS.
If you need to manage your need using Hostname
when HTTP_REQUEST { set hostname [string tolower [HTTP::host]] switch $hostname { "host1.com" { persist cookie } "host2.com" { do nothing } } }
If you need to manage your need using URI
when HTTP_REQUEST { set uri [string tolower [HTTP::host]] switch -glob $uri { "/uri1*" { persist cookie } "/uri2*" { do nothing } } }
Let me know if you need more details.
And last point, you don't asked it but it's important to keep in mind, if you have multiple pool you need a onconnect profil in order to detach the session or use LTM Policy.
Regards,
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