Routing traffic by URI using iRule
The DevCentral team recently developed a solution for routing traffic to a specific server based on the URI path. A BIG-IP Local Traffic Manager (LTM) sits between the client and two servers to load...
Published May 01, 2013
Version 1.0ltwagnon
Ret. Employee
Joined May 15, 2019
ltwagnon
Ret. Employee
Joined May 15, 2019
lkchen
Jun 13, 2013Nimbostratus
Hmmm, a couple years ago I was faced with a similar need -- content was developed using capabilities not present on the main production website, but is then unexpectedly announced to the world as a URI on the main site - and it wasn't a one off occurrence. Historically two competing web units...the older basic web running the main website (www.example.com), and the newer applications unit doing dynamic web development (app.example.com). But, recently (at the time) combined ... they had presented an idea that they would put a reverse proxy in front of the main site so that some URI's would direct to the dynamic web servers, which hasn't happened yet.
So back then, I was rushed to come up with a solution, and I came up with my own 'proxy' iRule....
when HTTP_REQUEST priority 500 {
switch -glob [HTTP::uri] {
"/path1" -
"/path1/*" {
if { $usessl == 1 } {
set usepool pool1_ssl
} else {
set usepool pool1
}
}
"/path2" -
"/path2/*" {
...
}
}
Where there are another iRule with when HTTP_REQUEST with priorities before (set usessl and set usepool to [LB::server pool]), and after (check if [active_members $usepool] < 1) - display apology page, else pool $usepool).
Problem...you use string tolower on URI, but URI is case sensitive. (generally people are told to keep with lower case, but not everybody does, plus others with spaces.... Also some people do it intentionally, some with the intent that to hide/obscure private/internal only content (and getting the URI with case into robots.txt)....
Wonder if I need to worry about persistence or use catch, etc. since the temporary irule is starting to get old.... ;)