Forum Discussion
URL based load balancing. How?
Hi,
We are kinda new to F5 and iRules so we don't really know how to create url based load balancing and we are not good at writing iRules. :)
What we want to do is that we have different pools and when example.com is typed into a browser it would direct the a user to the specific pool. When subdomain.example.com is called then it would direct them to another pool.
Could you please help with this?
Thanks in advance.
- RossVermetteNimbostratus
Here's an iRule I use for this type of thing. It uses a "Datagroup" that you can update the http host header to pool mapping to do what you want.
-
Create a Datagroup "HOST_2_POOL_DataGroup" with entries like:
"expample.com" := "APP_Pool01", "subdomain.example.com" := "APP_Pool02",
`
-
Here is the iRule "HTTP-Host-2-Pool-MAP"
`when HTTP_REQUEST { set pool_select_value [class lookup [string tolower [HTTP::host]] HOST_2_POOL_DataGroup] if {[active_members $pool_select_value] > 0 } { log local0.notice "available pool members" pool $pool_select_value } else { HTTP::respond 503 content "No active pool members in pool" } }
-
- Stanislas_Piro2Cumulonimbus
If you're not good at writing iRules, use LTM policy with 2 rules
- HTTP Host equals example.com --> forward pool primary_pool
- HTTP Host equals subdomain.example.com --> forward pool subdomain_pool
- Lee_SutcliffeNacreous
If you just want to do simple pool forwarding based on URI, then you don't need to use iRules anymore. You can use LTM Traffic Profiles, ideal for simple logic especially if you don't know iRules. Can all be configured in the GUI
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