Forum Discussion
iRule for load balancing to different virtual server depending on the URI path
Hi Guys,
I have three Virtual Server to be configured on our LTM's which are running on the version 15.1.7. One virtual server is facing to client (let say VS-A) and contains two virtual server (let say VS-B and VS-C) that should be load balance.
VS-B and VS-C need to load balance on the VS-A but the incoming traffic should be clasify use the uri /path.
The conditions like this:
if the uri contains /aa, /bb, /cc will be forward and load balance to VS-B and VS-VS-C.
I tried to make irules like this:
when HTTP_REQUEST {
if { [HTTP::uri] contains "/aa,/bb,/cc" } {
virtual VS_B
} else {
virtual VS_C
}
}
But the results is traffic from the client always going to the VS-B, so the load balancing doesn't have running.
I don't know it can be configured with the iRules or not, since I am not an expert in writing the iRules can anyone suggest me with the iRules that helps working the VIP as mentioned above.
Appreciate any kind your insight.
Thanks
- wibowoNimbostratus
Similler case, need the irules for this one anyone
Your description is hard to follow. Can you please provide a flow chart for how you want the different URIs to map to what paths / locations / IPs? Or perhaps a better flow to facilitate understanding of the issue.
- BobowCirrus
Bobow This might work but what you are attempting to do seems a whole lot more complicated this way and can most likely be done cleanly by only matching the URI path to a specific destination VS rather than letting load balancing occur and then changing the HOST and URI path after the fact.
when LB_SELECTED priority 500 { set SELECTED_POOL_MEMBER[LB::server addr] } when HTTP_REQUEST_SEND priority 500 { if { ${SELECTED_POOL_MEMBER} == vs_b_ip } { HTTP::uri [string map {"/aa" "/"}[HTTP::uri]] HTTP::host [string map {"test.com" "test1.com"}[HTTP::host]] } elseif { ${SELECTED_POOL_MEMBER} == vs_c_ip } { HTTP::uri [string map {"/aa" "/"}[HTTP::uri]] HTTP::host [string map {"test.com" "test1.com"}[HTTP::host]] } }
As many have said before "Just because it can be done with an iRule doesn't mean you should." so you might want to look at alternatives that work a bit better. For instance you might consider allowing the servers to listen for the orignal host and uri rather than mapping strings to assist in resolving the issue.
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