Forum Discussion
What_Lies_Bene1
Mar 26, 2013Cirrostratus
It's not ideal but if you configure multiple Pools accordingly, with the Pool name ending in the port number it supports then the following pretty short rule should work as long as a four digit port number is always used. It is probably worth adding in some checks to ensure you have a valid value before rewriting the URI and Host and specifying the Pool.
when HTTP_REQUEST {
Find the first / in the URI, skip 4 characters and match the rest of the string, set this as variable newuri
set newuri [findstr [HTTP::uri] "/" "4"]
Find the first / in the URI, skip 0 characters and match until the next /, this this as variable newport
set newport [findstr [HTTP::uri] "/" "0" "/"]
Change the URI before we send this request to a real server
HTTP::uri "$newuri"
Change the HTTP Host header
HTTP::header replace Host "[HTTP::host]:$newport"
Use the relevant Pool
pool pool_$newport
}