Insert Pool Name into serverside HTTP Header
Hello,
We currently use an irule to direct API calls to either a SOAP pool or REST pool based on URI Path. The Virtual Server has no Default pool configured. The way our current irule is configured is in the if statement where we are evaluating the path to determine what pool to send the api calls to, we are inserting the pool name to the header "manually." We are not sure if this is the best way to do this or if there is an irule that can do this for us and can be attached to any Virtual Server where we want the pool name inserted in the HTTP path.
Example:
...
when HTTP_Request {
if [string tolower [HTTP::path]] starts_with "/xyz/1234"} {
HTTP::header insert "X-Pool" "REST_Pool"
pool REST_Pool
} elseif [string tolower [HTTP::path]] starts_with "/abc/5678"} {
HTTP::header insert "X-Pool" "SOAP_Pool"
pool SOAP_Pool
} else {
HTTP::header insert "X-Pool" "Default_Pool"
pool Default_Pool
}
}
...
I have been reading about the "HTTP_Request_Send" functionality and we tested this in our Dev environment at the end of our irule by adding the following after the when HTTP_Request.. removing the "HTTP::header insert "X-Pool" "Pool Name" command before the "pool Pool Name".
when HTTP_Request_Send {
HTTP::header insert [LB::server pool]
}
This caused calls to fail so we reverted.
Basically we are wanting to create an irule that can be applied to any of our Virtual Servers where we control what pool the traffic is sent to using an irule to insert the pool name into the header without having to add the "HTTP::header insert "X-Pool" "REST_Pool" command multiple times.
Thanks in advance!