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 🙂
- CA_ValliJun 26, 2023
MVP
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)
- chris_woodJun 26, 2023
Nimbostratus
Thank you! I will test this afternoon and let you know!
- chris_woodJun 27, 2023
Nimbostratus
Hi!
I tried your script - and looks good in the F5 logs - however the server logs aren't showing showing any connections.
Tried on both http/https - with the http & http-transparent profile. I'm thinking along the lines of SSL/TLS getting in the way - might need to add
Removing the http profile and only using 1 server in the pool worked as expected.
- Jun 27, 2023
Hi chris_wood ,
While assinging my iRule script in your virtual server, did you assign the correct pool in Virtual server resources ?
you sould assign a pool has 2 pool members ( and only replace first "x.x.x.x" by first pool member IP and do the same with the second pool member ip )
Please Take this Packet capture to see the server and client side connections , and see the effect from F5 Bigiptcpdump -nnni 0.0:nnnp -vvv -w /var/tmp/path_test.pcap host x.x.x.x #put Client_ip address instead of "x.x.x.x"
I will be waiting your response
- chris_woodJun 29, 2023
Nimbostratus
Thanks very much for your help! Really appreciated.
I added the web server certificate as a client/server SSL profile, this helped the F5 load balance as expected - however it still wasn't re-writing the URI (this was most likely a config issue on my end)
During out T/Shooting - we decided to go down the web server redirect route as this easy to implement.
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