Forum Discussion
iRule configuration for sending requests to specific pool members depending on user input
Hello, I'm very new to f5. I need help on configuring an iRule. Here is what I have set up so far and is it possible to configure?
I have a Virtual server that has 3 pool members.
I have also set up a Data Group List that can be reference by the iRule: If any of the below should match the iRule, I want the traffic to go to Pool member A (PoolA_redirect) data group list /Marines /MRT /MRTNET /MRTSurvey /Navy /Protected /RTO /SAAT /SAAT2 /SFTFamily /SFTService /Survey /Images /Resources /MRTEmail /Scripts /Styles /TrainingCenters /UltimateMe
If any of the below should match the iRule, it should be sent to Pool member B (PoolB_redirect) data group list /Programs
And finally, if traffic does not match any of the above, it should go to Pool member C
4 Replies
- Ron_126046
Nimbostratus
Or do I need to set up 3 different pools and redirect to them by putting pool member A in one pool, pool member B in another pool and pool member C in another pool? Not sure if you need a data group for that list of URLs as it's pretty small. If it will change frequently, then externalizing it might be a good idea. Something like this should get you going
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/marines*" - "/mrt*" - "/mrtnet*" - "/mrtsurvey*" - "/navy*" - "/protected*" - "/rto*" - "/saat*" - "/saat2*" - "/sftfamily*" - "/sftservice*" - "/survey*" - "/images*" - "/resources*" - "/mrtemail*" - "/scripts*" - "/styles*" - "/trainingcenters*" - "/ultimateme*" { node 10.10.10.10 80 } "/programs*" { node 10.10.10.20 80 } default { node 10.10.10.30 80 } } }This is assuming that the URLs you mentioned you want to match on partial matches, not exact. The "/Marines_" for instance would match any URL that starts with "/Marines". One caveat is that "/MRTABC" would match on "/MRT_" so you may need to clarify the matches a bit more to ensure you don't get any incorrect assignments.
Also, if it were me, I'd create 3 pools instead of a single pool with 3 members. Assign member 10.10.10.30:80 to the default pool for the virtual and then use the "pool" command instead of "node" in the first two cases. Also, if servers or IP's change, it's a pool configuration change, not an iRule change.
Hope this helps...
-Joe
- Kevin_Stewart
Employee
There's a few ways to do this, but how about this:
Data group (example: my_uri_dg):
"/marines" := "PoolA_redirect" "/mrt" := "PoolA_redirect" "/mrtnet" := "PoolA_redirect" "/mrtsurvey" := "PoolA_redirect" "/navy" := "PoolA_redirect" "/protected" := "PoolA_redirect" "/rto" := "PoolA_redirect" "/saat" := "PoolA_redirect" "/saat2" := "PoolA_redirect" "/sftfamily" := "PoolA_redirect" "/sftservice" := "PoolA_redirect" "/survey" := "PoolA_redirect" "/images" := "PoolA_redirect" "/resources" := "PoolA_redirect" "/mrtemail" := "PoolA_redirect" "/scripts" := "PoolA_redirect" "/styles" := "PoolA_redirect" "/trainingcenters" := "PoolA_redirect" "/ultimateme" := "PoolA_redirect" "/programs" := "PoolB_redirect"And the iRule:
when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with my_uri_dg] } { pool [class match -value [string tolower [HTTP::uri]] starts_with my_uri_dg] } else { pool PoolC_redirect } } - Kevin_Stewart
Employee
Well, you can replace the pool command with a node command and just point to the IP and port of the server directly:
when HTTP_REQUEST { if { [class match... } { node 10.1.1.1 80 } else { node 10.1.1.2 80 } }But, that will eventually stop scaling well. The better option is to create 3 separate pools - one for each app/service. That way if you ever need to add resources for a given application, you just add that to the existing pool and load balancing is built in.
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