Forum Discussion
Directing traffic to a specific pool member
I would like to forward traffic to a specific pool member depending on what the URL is. Currently I have an iRule that directs traffic to 1 of 5 pools depending on the URL. Instead of having to create 1 pool for each server, I would like to create 1 pool that contains all 5 servers as members.
Here's the iRule I am using. Can you please let me know if this is good enough or if there is a better way? Thank you!
when HTTP_REQUEST {
set param_1 "/paymentResponse1.jsp"
set param_2 "/paymentResponse2.jsp"
set param_3 "/paymentResponse3.jsp"
set param_4 "/paymentResponse4.jsp"
set param_5 "/paymentResponse5.jsp"
if {[string match $param_1 [HTTP::path]]}{
use pool altaf
}
if {[string match $param_2 [HTTP::path]]}{
use pool barry
}
if {[string match $param_3 [HTTP::path]]}{
use pool doug
}
if {[string match $param_4 [HTTP::path]]}{
use pool engvs109
}
if {[string match $param_5 [HTTP::path]]}{
use pool engvs111
}
}
- Colin_Walker_12Historic F5 AccountSo you're looking at changing your iRule from saying "if URL1, pool 1, if URL2, pool2" etc. to "if URL1, or URL2, or URL3, pool1"? If so, it would look something like this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/paymentResponse1.jsp" - "/paymentResponse2.jsp" - "/paymentResponse3.jsp" - "/paymentResponse4.jsp" - "/paymentResponse5.jsp" { pool paymentresponse_pool } } }
- Born_7758NimbostratusThanks Colin for the response.
- Michael_YatesNimbostratusIf you want the traffic to go to a specific pool member then you can specify the node IP Address and access port.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/paymentResponse1.jsp" - "/paymentResponse2.jsp" { node 10.10.10.10 80 } "/paymentResponse3.jsp" - "/paymentResponse4.jsp" { node 20.20.20.20 80 } "/paymentResponse5.jsp" - "/paymentResponse5.jsp" { pool paymentresponse_pool } } }
- Colin_Walker_12Historic F5 AccountThat's pretty easy as well, actually, as long as you have the IP addresses of the members in question.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/paymentResponse1.jsp" { pool resp_pool member 10.10.10.10 80 } "/paymentResponse2.jsp" { pool resp_pool member 10.10.10.11 80 } "/paymentResponse3.jsp" { pool resp_pool member 10.10.10.12 80 } "/paymentResponse4.jsp" { pool resp_pool member 10.10.10.13 80 } "/paymentResponse5.jsp" { pool resp_pool member 10.10.10.14 80 } } }
- Born_7758NimbostratusThanks guys.
- Born_7758NimbostratusAlso, what should I set as the load balancing method for the "switch" method?
- Colin_Walker_12Historic F5 AccountThe load balancing method that you choose won't affect these particular URLs because the iRule will override that. You can choose any LB method you would normally pick and it'll be fine.
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