Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Pool and path switching by XML content in Request

Hi,

a customer asked for an irule at our F5 bigip (11.5.1) to switch server targets depending on the content of the actual request (POST XML) in the following way:

if in a special key in the XML has value "a" go to pool_a and rewrite URL to "/abc",

if that key is "b" go to pool_b and rewrite URL to "/abc",

else go to pool_a and rewrite URL to "/xyz"

I built something like this, which saves fine but before releasing it, I wanted to ask if this would solve the request/work, is logically correct and if there must be any escaping of the strings.

 when HTTP_REQUEST {
    if { [HTTP::header exists Content-Length] } {
        HTTP::collect [HTTP::header Content-Length]
    }
 }
 when HTTP_REQUEST_DATA {
    if { [HTTP::header exists Content-Length] } {
        if { [HTTP::payload] contains "<ns1:key>a</ns1:key>" } then {
            HTTP::path "/abc"
            pool pool_a
        } elseif { [HTTP::payload] contains "<ns1:key>b</ns1:key>" } then {
            HTTP::path "/abc"
            pool pool_b
        } else {
            HTTP::path "/xyz"
            pool pool_a
        }
    }
 }
0
Rate this Question
Comments on this Question
Comment made 15-Mar-2016 by hfi 1
And of course I would like to ask if this could be optimized? (besides not doing it at all, I'm aware that this is not a recommended scenario for an irule from a performance perspective)
0

Answers to this Question