hfi_254510
Mar 15, 2016Nimbostratus
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 "a" } then {
HTTP::path "/abc"
pool pool_a
} elseif { [HTTP::payload] contains "b" } then {
HTTP::path "/abc"
pool pool_b
} else {
HTTP::path "/xyz"
pool pool_a
}
}
}