Forum Discussion

Born_7758's avatar
Born_7758
Icon for Nimbostratus rankNimbostratus
Jun 23, 2011

Directing traffic to a specific pool member

Hello,

 

 

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

 

}

 

}

 

 

 

 

7 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    So 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
        }
      }
    }
    

    Let me know if you're looking to achieve something else.

    Colin
  • Thanks Colin for the response.

     

     

    What I am trying to do is "if URL1, member1...if URL2, member 2, etc."
  • If you want the traffic to go to a specific pool member then you can specify the node IP Address and access port.

    The alternative would be to create additional pools so that you don't tie your traffic to a specific IP Address (you could then add and remove nodes from the pool without having to modify your iRule).

    
    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_12's avatar
    Colin_Walker_12
    Historic F5 Account
    That's pretty easy as well, actually, as long as you have the IP addresses of the members in question.

    So if member 1 is 10.10.10.10, and member 5 is 10.10.10.14:

    
    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
        }
      }
    }
    

    And if you have many more you could use a data group and the class command to simplify the long switch case.

    Colin
  • Thanks guys.

     

     

    Can you please give an example if I were to use a datagroup?
  • Also, what should I set as the load balancing method for the "switch" method?
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The 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.

     

     

    Colin