L7 load balancing by content

We are migrating from cisco ACE. In Ace we specify class-map to use L7 load balancing as follow: class-map type http loadbalance match-all L7- 2 match http url /XDSOAPRouter/is/* class-map type http loadbalance match-any L7- 2 match http url /XDSOAPRouter/cx/.* Each content ‘is’ & ‘cx’ gow to a different pool. How can we achive that on F5?

Hello Krys,

You can write an iRule that depending on the uri there is a different pool selected :

https://devcentral.f5.com/questions/pool-selection-based-on-uri-string

Hi Janek, I implemented following iRule but all HTTP requests are going to the default pool SYSLOG3_pool which is set under Virtual Services Resources. How to make sure that iRule has a priority over the default pool?

when HTTP_REQUEST {

if { [HTTP::path] starts_with “/XDSOAPRouter/8t" } { pool SYSLOG_pool } if { [HTTP::path] starts_with "/XDSOAPRouter/cx” } { pool SYSLOG1_pool } if { [HTTP::path] starts_with “/XDSOAPRouter/is*” } { pool SYSLOG3_pool } }

thanks for this!

Hi Krys

From 5000 feet, it looks like you’re missing “elseif” and “else” expressions. Have you tried it with those in place?

Bernie

Hi Bernie, I tried “esleif”, still is not working. I can’t have “else” pointing to the default pool. In my case each request must be forwarded to the right pool. All my requests are going to SYSLOG1_pool which is a default pool under virtual servers.

when HTTP_REQUEST {

if {[HTTP::path] starts_with "/XDSOAPRouter/8t" } { pool SYSLOG_pool

} elseif {[HTTP::path] starts_with "/XDSOAPRouter/cx" } { pool SYSLOG1_pool } elseif {[HTTP::path] starts_with “/XDSOAPRouter/is*” } { pool SYSLOG3_pool } }

Hmm. Could you try; } then { instead of } {

Is this correct? Because I’m getting error. if {[HTTP::path] starts_with "/XDSOAPRouter/8t" }then{ pool SYSLOG_pool

} elseif {[HTTP::path] starts_with "/XDSOAPRouter/cx" }then{ pool SYSLOG1_pool } elseif {[HTTP::path] starts_with “/XDSOAPRouter/is*” }then{ pool SYSLOG3_pool } }

01070151:3: Rule [/Common/L7-test] error: /Common/L7-test:2: error: [parse error: extra characters after close-brace][then{ pool SYSLOG_pool } elseif {[HTTP::path] starts_with “/XDSOAPRouter/cx" }then{ pool SYSLOG1_pool } elseif {[HTTP::path] starts_with "/XDSOAPRouter/is” }then{ pool SYSLOG3_pool }] /Common/L7-test:4: error: [parse error: extra characters after close-brace][then{ pool SYSLOG1_pool } elseif {[HTTP::path] starts_with “/XDSOAPRouter/is*” }then{ pool SYSLOG3_pool }] /Common/L7-test:6: error: [parse error: extra characters after close-brace][then{ pool SYSLOG3_pool }]

Yeah that’s wrong then :frowning: The previous one looked better. I’ll see if I can try it out real fast tomorrow

Now is working:)

when HTTP_REQUEST {

if { [HTTP::path] starts_with “/XDSOAPRouter/8t” } { pool SYSLOG_pool } if { [HTTP::path] starts_with “/XDSOAPRouter/cx” } { pool SYSLOG1_pool } if { [HTTP::path] starts_with “/XDSOAPRouter/is” } { pool SYSLOG3_pool } }

Cheers! Bonus wildcard in the first one? I’m not sure I’d have thought of that

It could be the wildcard, I will teset later and let you know my findings. Thanks for help.