cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

iRule/policy for round robin traffic

Sulabh_Srivasta
Altostratus
Altostratus

Hi All,

 

I need help in setting up iRule/policy to loadbalance Round Robin traffic to two nodes listening on multiple ports.

 

Node - X.X.X.X listening on port 1001,1002,1003

Node - Y.Y.Y.Y listening on port 1001,1002,1003

 

 

Example : Client put in browser : https://www.abc.com/core/services,  LTM should send round robin traffic to :

 

https://X.X.X.X:1001/core/services/instance_1

https://X.X.X.X:1002/core/services/instance_2

https://X.X.X.X:1003/core/services/instance_3

 

https://Y.Y.Y.Y:1001/core/services/instance_4

https://Y.Y.Y.Y:1002/core/services/instance_5

https://Y.Y.Y.Y:1003/core/services/instance_6

 

 

Please let me know if this is possible with iRule, can this be done in same pool ??

 

Any help will be greatly appreciated.

 

Thank you.

4 REPLIES 4

Why don't you just add everything to a single pool as the F5 has no issues if the IP addresses of the pool members are the same ?

 

From what I see you also need to rewrite the host and URI and maybe for this an irule will be needed (you can also use the "switch" way and not the "if" condition and you will need to add many elseif to match the other conditions):

 

when LB_SELECTED {

if {[LB::server addr] equals X.X.X.X && [LB::server port] equals 1001} {

HTTP::header replace Host "X.X.X.X:1001"

HTTP::uri "/core/services/instance_1"

}

}

 

 

https://clouddocs.f5.com/api/irules/LB__server.html

 

 

https://devcentral.f5.com/s/articles/irules-101-02-if-and-expressions

 

https://clouddocs.f5.com/api/irules/switch.html

Thanks Nik, I added all in same pool and it is working.

Also you haven't explained well what you want to do. For example if you want when the first request is send to X.X.X.X and you want the other requests from the same client to also be send to X.X.X.X but maybe on different port (round robin) look at the destination address persistance:

 

 

https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-profiles-reference-12-1-0/4.html

 

 

 

If you want that the requests after the first one to also be send to same ip address but also the same port then maybe Cookie or Universal or source persistance can be used.

 

 

 

 

Also in my first reply I forgot to mention that if you also need to rewrite URL in the HTML payload not only the HTTP headers you will need to review the stream profile:

 

 

https://support.f5.com/csp/article/K39394712

 

https://support.f5.com/csp/article/K7027

crodriguez
F5 Employee
F5 Employee

As Nikoolayy1 indicated, BIG-IP LTM does allow pool members in a single pool to be configured with different IP addresses and/or different ports. The only reason you would need an iRule (or local traffic policy) is if you wanted to conditionally select the pool member to load balance to based on some part of the payload or if you want to modify the payload for the server-side request or client-side response in some way. For example, if you wanted to conditionally select the pool or pool member to load balance to based on the HTTP host name or parts of the HTTP URI, you will need to use an iRule or local traffic policy to set up the appropriate conditions and actions.

 

You do not have to make any modifications to the HTTP host header unless the application server requires it. Otherwise, the host header will be passed unchanged from the client-side request to the server-side request by the BIG-IP system. In most cases, this is sufficient.

 

Other considerations, such as persistence, are not reflected in your original question, so it is up to you to determine whether or not you need it (or other profiles) on the virtual server and in what form. Certainly, if you want to modify the HTTP payload in any way - request or response - you will need an HTTP-type profile on the virtual server.