Forum Discussion

Fotios_30046's avatar
Fotios_30046
Icon for Nimbostratus rankNimbostratus
Nov 18, 2009

Send Request To Pool If Certain HTTP_URI

I have a virtual server setup with a default pool. We have a third party appliance we want to use if anyone hits a certain subfolder of our site, www.site.com/products. There will probably be something after the products, so I need to rule to look for products and possibly anything after then send it to a different pool.

 

 

Here's what I have so far.

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with "/products" } {

 

pool Appliance.

 

}

 

}

 

 

I don't need to make any changes to the virtual server except for adding this iRule, right?

6 Replies

  • Hi Fotios,

    You could write up in the following manner using the switch command.

     
     when HTTP_REQUEST { 
        switch -glob [HTTP::uri] { 
         "/products" { pool appliance } 
         "/products/something" {pool something } 
         "/products/something/andsomething" { pool andsomething } 
        } 
     } 
     

    If you need more info then do a search on this site for "SWITCH"

    I hope this helps
  • I don't need anything that advanced. Basically, we have a search appliance that we're adding to our site under /products. The only question I had was, what if the uri is longer than just /products, it will still be picked up by this iRule, right?
  • By making a small alteration in the irule you could

    I.E.

     
     when HTTP_REQUEST { 
        switch -glob [HTTP::uri] { 
          "/products*" { pool appliance } 
        } 
     } 
     

    Bhattman

  • One small wrinkle I found. If you're hitting the site under the /products* and you want to go back to the main site under the other pool, it doesn't seem to use that but rather stick to the appliance pool. Should I set the default pool, then change it based on the uri? Or could I reset the connection somehow?
  • You should either explicitly set a pool for every case in the iRule if you're selecting a pool for any case, or add a OneConnect profile. See this post for details/testing examples:

     

     

    iRule Editor can't find default_pool

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=3392157229

     

     

    Aaron