CSS to F5 iRule redirect to pool question.

have a CSS that we are moving away from and going to F5 v9.4.7

The CSS has two VIPs same IP and port one is a default url “*” goes to server A and the other is url “/battery/*” goes to service B

I am thinking that I create a standard port 80 VIP with default pool A and attach irule that sends /battery/ request to pool B

when HTTP_REQUEST {

if {[HTTP::uri] contains {/battery/}}

{pool B}

}

}

is there a better way to right this or will this even work?

Thanks in advance.

here is sample from CSS:

content blah-80

vip address 1.1.1.1

add service serverA

protocol tcp

port 80

url “/*”

active

content blah-battery-80

vip address 1.1.1.1

add service serverB

protocol tcp

port 80

url “/battery/*”

active

That should work fine, with a slight adjustment for correct syntax and a bit of string normalization:

when HTTP_REQUEST {  
    if { [string tolower [HTTP::uri]] contains "battery"} {  
     pool apache_pool  
     }  
 }

There’s a bit more elaboration on the ‘contains’ bit here:

http://devcentral.f5.com/Wiki/default.aspx/iRules.contains

will give this a try. The string tolower.. is tolower just part of string rule? not familiar with that term.

‘string’ is a TCL command, and there are bunch of interesting things you can do with it. There’s a great rundown of some of them here:

http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=338

In the rule above, we just want to cover the possibility that someone will be looking for /BATTERY/ and get them to the right place.

“/battery/*” would match a path starting with /battery/, so you could use [HTTP::path] starts_with “/battery/” for the same functionality. If the web app is not case sensitive, you could set the path to lowercase before checking that it starts with /battery/ as jquinby suggested.

If you’re on 9.4.0 or higher, you could also use an HTTP class instead of an iRule to filter requests based on URI to a specific pool.

Aaron

Thanks for all the info..

I used the:

when HTTP_REQUEST {

if { [string tolower [HTTP::uri]] contains “battery”} {

pool battery_pool

}

}

which worked.

9.4.7 is the code running on the BigIP

I like the idea of HTTPClass profile for this instance, however I had tried HTTPClass profile on a previous conversion. It was using a header list and didn’t work, dropped in iRule for the header and it worked. So…not so sure about the HTTPClass, but I won’t give up on it yet.

Thanks for all your input. Glad this site exists and you all are very responsive!!