Forum Discussion
Looking to pick node members based on URI and rewrite that uri.
So basically, we are trying to allow out users to have a short website to put into their browser based on the branch location. So app.test.com/NewYork or app.test.com/NewJersey or app.test.com/Newark Based on that we need to pick a pool and rewrite the URI, the issue is the server on the other side will not understand the "Branch" part of the URI, so we cannot pass that to the webserver. Following that we have two possible URI they want to be able to automatically direct the user to an maybe hide. So app.test.com/NewYork -> pool.server1.com:8080/OldVersion/A app.test.com/NewJersey -> pool.server1.com:8081/OldVersion/G app.test.com/Newark -> pool.server1.com:8081/NewVersion/A
The users browser of course would need to keep at least the https://app.test.com/"Branch"/*
I have attempted to tackle this using the host name instead, NewYork-app.test.com / NewJersey-app.test.com as well, so here is what I was thinking on that. It doesn't hide the Applications URI like we want but at least provides the users a nicer address and lets us hide which webserver they are running on. This is all to prevent the regularly occurring trouble calls where the users at a site are supposed to be hitting the 8081 server and not the 8080 server.
when HTTP_REQUEST {
log local0. "Requested hostname: [HTTP::host] from IP: [IP::local_addr] and URI: [HTTP::uri]"
switch -glob [string tolower [HTTP::host]] {
"newyork-app.test.com" {
log local0. "Server-Selected:[LB::server]"
if { [HTTP::uri] equals "/" }{
HTTP::uri /OldVersion/A
}
pool pool_pool.server1.com-8081
}
"newjersey-app.test.com" {
log local0. "Server-Selected:[LB::server]"
if { [HTTP::uri] equals "/" }{
HTTP::uri /OldVersion/G
}
pool pool_pool.server1.com-8081
}
"newark-app.test.com" {
log local0. "Server-Selected:[LB::server]"
if { [HTTP::uri] equals "/" }{
HTTP::uri /NewVersion/A
}
pool pool_pool.server1.com-8081
}
default {
log local0. "Server-Selected:[LB::server]"
if { [HTTP::uri] equals "/" }{
HTTP::uri /OldVersion/A
}
pool pool_pool.server1.com-8080
}
}
}
Being able to do the same thing with a URI would be better, but I have gotten the applications guys to agree that the HTTP::host method might work as well.
2 Replies
- Kevin_Stewart
Employee
You're getting into the realm of the old proxypass iRule, but this should all be possible now with an LTM rewrite profile (11.4+).
The issue is that you have to rewrite the URI in both directions. Request traffic for /newyork/* has to be rewritten to /oldversion/a/, and then any URLs in the response have to be rewritten from /oldversion/a/ to /newyork/*.
If you have a recent version of BIG-IP take a look at the rewrite profile, otherwise search for the ProxyPass iRule.
- Michael_Jenkins
Cirrostratus
Have you seen the ProxyPass iRule? It's a little complex (though there is a simpler version of it I think too), but it may do what you're looking for.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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