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!
10 Replies
- 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 } }
or with a switch statement:when HTTP_REQUEST { switch [HTTP::host] { "web1.xyz.com" { pool poolA } "web2.xyz.com" { pool poolB } } }
I've been told that switch statements are let CPU intensive but it's really probably a toss in this situation. Use which ever method is easier for you to follow
-Joe - 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?
Example:
https://uat.site1.com/blah1
https://uat.site1.com/blah2
Resolves to 10.0.1.25
and
https://conv.site1.com/blah1
https://conv.site1.com/blah2
Resolves to 10.0.1.25
Could we parse the header and send them to a particular pool? We would need preserve the URI. The only other thing I can think of is we do a http to https:// redirector via an iRule.
Thanks to anyone that replies!
Regards -
/ja - 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]" } } }
-Joe - jba3126
Cirrostratus
If we have the following iRule currently applied to the VIP, how will this play into what we are wanting to do?
when HTTP_REQUEST {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
thanks and best regards -
/ja - 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.
-Joe - 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!
Regards -
/ja - 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.
So the end goal is to have one VIP point to two pools. Have the iRule parse the host header (preserving the URI if possible) and send it to the appropriate pool.
For UAT Site -
https://uat.site1.com/blah1 (/blah1 goes to application 1)
https://uat.site1.com/blah2 (/blah2 goes to application 2)
Resolves to 10.0.1.25
and
For Conversion Site -
https://conv.site1.com/blah1 (/blah1 goes to application 1)
https://conv.site1.com/blah2 (/blah2 goes to application 2)
Resolves to 10.0.1.25 - 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.
-Joe - Shawn_89418
Nimbostratus
Can you select a pool based on what comes after the fqdn? For instance
For UAT Site -
https://uat.site1.com/blah1 (/blah1 goes to application 1)
https://uat.site1.com/blah2 (/blah2 goes to application 2)
https://uat.site1.com/blah3 (/blah2 goes to application 3)
where /blah1 goes to application 1 which is in pool 1
and /blah2 goes to application 2 which is in pool 2
and /blah3 goes to application 3 which is in pool 3
and so on? - hoolio
Cirrostratus
Hi Shawn,
I replied to your post here:
https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/aft/2163314/asg/50/Default.aspx
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
