Forum Discussion
hooleylist
Jan 22, 2008Cirrostratus
If this is the method you want to try, below is a rule which should do it.
I assume that requests the client sends will start with /node and then have the actual path the application expects following that node prefix. If the real path was /path/to/index.html, and you wanted to specify node1 received the request, you would make a request to /node1/path/to/index.html. The method below wouldn't work if you requested /node1path/to/index.html because the /node1 portion would be removed and the resulting URI wouldn't start with a leading forward slash.
when HTTP_REQUEST {
switch -glob [HTTP::path] {
/node1/* {
Remove the /node1 prefix from the path
HTTP::path [string map {/node1 ""} [HTTP::path]]
Set the node
node 192.168.1.1 8080
}
/node2/* {
Remove the /node1/ prefix from the path
HTTP::path [string map {/node2 ""} [HTTP::path]]
Set the node
node 192.168.1.2 8080
}
default {
Take some default action?
pool http_pool
}
}
}
The iRule wiki and TCL man pages have details on the various commands:
switch (Click here)
HTTP::path (Click here)
node (Click here)
string map (Click here)
Aaron