Forum Discussion
Sudhir_Sanil_88
May 19, 2006Historic F5 Account
irule to select pool based on fqdn
Hi,
I need an irule which can select the pool ( pool A or pool B) based on following criteria.
Example : web1.xyz.com and web2.xyz.com both resolve to same IP Address say 10.10.10.1, a virtual server is created 10.10.10.1:80
When the user hits url http://web1.xyz.com then he should be sent to pool A and when the user hits url http://web2.xyz.com then he should be sent to pool B.
Thanks!
- You can use a if statement:
when HTTP_REQUEST { if { [HTTP::host] eq "web1.xyz.com" } { pool poolA } elseif { [HTTP::host] eq "web2.xyz.com" } { pool poolB } }
when HTTP_REQUEST { switch [HTTP::host] { "web1.xyz.com" { pool poolA } "web2.xyz.com" { pool poolB } } }
- jba3126
Cirrostratus
We have something very similar to this. Is it possible to have two different FQDN point to the same VIP and have them select pools based on FQDN? - The fqdn will be stored in the HTTP::host value. Here's how you could do it with a switch statement. An if/elseif would work just as well.
when HTTP_REQUEST { switch [HTTP::host] { uat.site1.com { pool pool_a } conv.site1.com { pool pool_b } default { log local0. "Uknown site: [HTTP::host]" } } }
- jba3126
Cirrostratus
If we have the following iRule currently applied to the VIP, how will this play into what we are wanting to do? - If you are doing a redirect to an HTTPS virtual, then assigning a pool doesn't make much sense in this rule. I would apply the redirect iRule to the HTTP virtual and apply the host matching iRule to the HTTPS virtual.
- jba3126
Cirrostratus
Good point. We will apply the iRule in our lab to test and see how the application works with the pool selection. Thanks so much for your time! - jba3126
Cirrostratus
I have but one last question that was passed on by one of my co-workers. Will this preserve the URI? I ask because behind each URL is two applications. The trailing URI /blah1 and /blah2 point to two different applications. The way our devs. have Appache configured as best I understand, is to parse the HTTP request for the URI (/blah1 or /blah2) to determine which application pool to send the request to. - Using the pool command to assign a pool to the current connection will not effect any of the protocol specific data. The host headers, URI, POST data, and everything else will remain the same. This just instructs our load balancing engine which pool of servers to choose from.
- Shawn_89418
Nimbostratus
Can you select a pool based on what comes after the fqdn? For instance - hoolio
Cirrostratus
Hi Shawn,
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects