Forum Discussion
Michael_Yates
Nimbostratus
Jan 22, 2008HTTP Request rewrite before sending to specified node
I'm trying to make an iRule that will enable website testing on different specified nodes. Because most of the website that need to be testing in this way are URL dependent I wanted to do the testing...
hoolio
Cirrostratus
Jan 22, 2008If 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects