Forum Discussion
Redirect traffic to specific nodes based on URI with non-standard port
We are trying to send all traffic containing a two specific URIs to two specific nodes (with non-default port numbers) in a single pool, while all other requests are directed to two other nodes in the same pool (on port 80). I've tried different combinations of redirections and iRules to accomplish this but have had no luck thus far. I've managed to get the redirection to work with a separate pool, but the webserver does not return the expected results.
There are two separate services running on a single server (80 and 8080). SSL is offloaded on the VIP and back-end traffic is unencrypted. I've tried different combinations of iRules, creating separate pools, and even separate VIPs, but have had no success.
My thought was to combine the nodes into the same pool and create an iRule that selectively load-balances the traffic to specific pool members based on the incomming URI.
From an iRule standpoint I'm assuming this would be a good start, but I'm not sure where to go from here. Forgive my syntax errors. I have never constructed iRules this complex before:
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { ((($uri starts_with "/X") or ($uri starts_with "/Y"))
HTTP::redirect http://[getfield [HTTP::host]":" 1]:8080[@uri])
}
{
node 10.x.x.x:8080
node 10.X.X.X:8080
}
else .... send to other nodes on 80
}
The process looks something like this:
1.) If the incomming URI starts with "/X" or "/Y"
a. Make sure to include ":8080" after the FQDN while maintaining the original URI
b. Forward the traffic to two specific pool members
2.) Otherwise...
a. Forward all other requests to the other two separate pool members
b. Don't worry about :8080
Any ideas?
I usaully use a URI forwarding policy to direct traffic based off URI. You can setup a different pool, with whatever port you want, for each special URI and use the virtual server's default pool for all other traffic
Local Traffic >> Policy Rule X: HTTP URI path starts with /X Forward traffic to pool testsite.uri.X Rule Y: HTTP URI path starts with /Y Forward traffic to pool testsite.uri.X
- JoelS_272975
Nimbostratus
Thanks Jason. That does seem more efficient. I haven't ever messed with policies to be honest. However, I'm guess the configuration would look something like this (we are running 11.6 code):
Policy Strategy: First-Match Requires: http Controls: forwarding Rules Conditions. operand: http-uri event: request* selector: path condition: equal (or contains) */X */Y Actions Target: Forward Event: Request Action: select Parameter: pool (POOL-ABC)
Does that look correct based on your experience?
Thanks in advance!
- Jason0
Nimbostratus
That's how I've configued my URI policies. One piece of advice, don't put a / as the first character of your rule name. 11.6 processes rules with this syntax but 12.1.2 cannot.
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