Forum Discussion
gpoverland
Nimbostratus
Jul 08, 2008IRule that rewrites URI based on Pool or PoolMember Selected
I am trying to create an Irule that selects to rewrite a URI based on which pool member is chosen. Why you ask, well this is to accomodate the slow migration from an older application to a newer appli...
hoolio
Cirrostratus
Jul 08, 2008You're on track. The issue is that HTTP_REQUEST is triggered when the HTTP request headers are parsed. The headers are parsed and then a pool member is selected by the LB_SELECTED event. For details on events, you can check the wiki page (Click here) and for an example of the order (Click here).
You can modify the URI in the HTTP_REQUEST_SEND event using the clientside command. The clientside command is necessary to change the context from the server side to client side.
I'm not sure what you're doing with the pool commands though, so I've left that part out. If you do really want to reselect a different pool once you determine the IP address of the server LTM picked the first time around, could you add some background?
when HTTP_REQUEST_SEND {
Save the URI to avoid running this command multiple times.
set uri [clientside {HTTP::uri}]
log local0. "[IP::client_addr]:[TCP::client_port]: \$uri: $uri"
log local0. "[IP::client_addr]:[TCP::client_port]: selected server details: [LB::server]"
Check if the selected servfer is .3 or .4
if {[IP::addr [LB::server addr] equals 172.29.58.3] or [IP::addr [LB::server addr] equals 172.29.58.4]} {
log local0. "[IP::client_addr]:[TCP::client_port]: matched server check for .3 or .4"
Check if the URI contains the first string
if {$uri contains "/GSFO/GSFOPub"} {
Update the URI
clientside {HTTP::uri "/Async/CMReceive.ashx"}
log local0. "[IP::client_addr]:[TCP::client_port]: updated URI to /Async/CMReceive.ashx"
Check if the URI contains the second URI
} elseif {$uri contains "/ERA/ERAPub" }{
Update the URI
clientside {HTTP::uri "/Async/ERAReceive.ashx"}
log local0. "[IP::client_addr]:[TCP::client_port]: updated URI to /Async/ERAReceive.ashx"
} else {
Take some default action?
log local0. "[IP::client_addr]:[TCP::client_port]: didn't match URI checks"
}
}
}
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