Forum Discussion

Roger_Grannum_7's avatar
Roger_Grannum_7
Icon for Nimbostratus rankNimbostratus
Apr 06, 2006

Newbie Question

First crack at this and I can't seem to get it right. I want to be able to check the URI coming in and based on the variable at the end determine which pool the request goes to.

 

For example:

 

 

I have two pools: member_pool and order_pool

 

 

If a user is not a member and goes to mydomain.com/NewOrder.asp?From=IDGC --> order_pool

 

If a user is a member and goes to mydomain.com/MainPage.asp --> member_pool.

 

 

I tried using:

 

if (http_uri matches_regex "/pages2/english/NewOrder.asp?From=IDGC") {

 

use pool Idg_NewOrder_https

 

}

 

else {

 

use pool idg_443

 

}

 

  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    Roger,

    first of all, it is generally better (read faster) to use the "equals", "starts_with", "contains" and "ends_with" operators instead of "matches_regex" unless you really need the full power of regular expressions. In you particular case I'd suggest to use:

    
    if(http_uri contains "NewOrder") {
      use pool Idg_NewOrder_https
    } else {
      use pool idg_443
    }

    It is impossible to tell what is failing from the data you've provided. I'd guess that your problem is in the matches_regex expression but I can't tell for sure, since you've not provided the URI that you've used to test your rule neither have you descibed what was the observed behavior.

    In order to troubleshoot the problem, you can add log statements to your rule like this:

    
    rule r1 {
      log "uri: " +  http_uri
      if(http_uri contains "NewOrder") {
        use pool Idg_NewOrder_https
        log "using pool Idg_NewOrder_https"
      } else {
        use pool idg_443
        log "using pool idg_443"
      }
    }

    You'll receive following log entries in /var/log/bigip when the rule gets executed:

    
    RULE r1 - uri: NewOrder.asp?From=IDGC
    RULE r1 - using pool Idg_NewOrder_https

  • Thanks for you response.

     

     

    I will try and give more details. There are two piece to this:

     

     

    1) I wanted to test based on the page itself -- NewOrder.asp

     

    2) Also need to be able have traffic move between pools based on the variable at the end --> In this case =IDGC

     

     

    We have two issue. The first is that the login page and the sign up utilize the same pool and the same timeout. I would like to seperate them utilizing Rules. So if the user goes to the login page and beyond they will have a small timeout (120 sec) and when a new customer comes to the site and goes to the order page they can take 600 sec.

     

     

    The second is the variable at the end is utilized for marketing campaigns and I want to be able to utilize the rules to parse the info so that they can be sent to specialize pools on isolated servers that won't impact regular users. So if marketing pushes out a new ad campaign and expect a high volume for 10 days. I can segment the traffic based on the product code to different servers.

     

     

    I changed the Virtual Server to the Rule (using the one you provided) and it still didn't work. When I tried to setup the one with the log info it gave me a syntax error at rule r1 {.

     

     

    Otherwise when I use the one you provided and change the Virtual Server setting I don't get anything when accessing the site. The http pages come up fine but when I go to the order page it just hangs.

     

     

     

    Roger