Forum Discussion
Big-IP LTM - load balancing incoming request to 2 different 'paths' on Member Pool
Ok chris_wood ,
This Irule Code should meet your need :
when LB_SELECTED {
if { [IP::addr [LB::server addr] equals x.x.x.x] } {
log local0. " Server 1 selected , Change path to ( http://example/folder/folder/server1 ) "
HTTP::uri "http://[HTTP::host]/folder/folder/server1"
} elseif { [IP::addr [LB::server addr] equals x.x.x.x] } {
log local0. " Server 2 selected , Change path to ( http://example/folder/folder/server2 ) "
HTTP::uri "http://[HTTP::host]/folder/folder/server2"
}
}
#Replace "x.x.x.x" Ips by your servers/poolmembers IPs.
#First "x.x.x.x" server1 and second "x.x.x.x" server2
>> I have tested it and it works as expected , after capturing the traffic in both sides , I observerd the chaning in URI paths according to selected pool member inside the pool.
<< Why I used this method >> ?
Because you need to use round Robin loadbalance technique and modify the request to servers at the same time.
try it and let me know.
Goodluck 🙂
This works, I was wondering if there was a way to make it dynamic so it was scalable ..
I've looked into [LB::server] instruction and tested it, but it only returns server IP and pool name.
chris_wood if you have control on the server environment and it's possible to edit the URLs, you might want to set it up this way:
- assign any IP address you want
- if possible, try configuring server hostname to match the last octect ex. apache30 for IP 10.10.10.30 or apache12 for 10.10.10.12
- if possible, configure server URL to match the hostname, ex. /path/to/apache15
This way, iRule might support service scalability as server farm grows,
when LB_SELECTED {
set selected [getfield [LB::server addr] "." 4]
set server "apache$selected"
# log local0. "server $server"
set path "/path/to/$server" ; set host "$server.local.domain"
HTTP::host $host
HTTP::path $path
}
This will rewrite http(s)://<virtual server url> to http(s)://apacheXX.local.domain/path/to/apacheXX for any given XX , without redirects (client transparent)
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