Forum Discussion
JSpartan0901_95
Feb 10, 2012Nimbostratus
Routing traffic to all the pool members except one by keeping the existing load balancing algorithm
Hi all,
I would like to achieve the following in iRules. Appreciate if someone can help me suggest the right way.
Today, we already have a pool configured with Least connections (member) algorithm. Now we are planning to add another member to this pool and route traffic to it based on a value of certain cookie.
One way of doing this would be to create another pool with just the new member and write iRule -
If{ [string match "*[1]" [HTTP::cookie value "testCookie"]]}
{ pool existing_pool }
else
{ pool pool_with_only_one_new_member }
Is there a way I can achieve this by adding the new member to the existing pool?
If{ [string match "*[1]" [HTTP::cookie value "testCookie"]]}
{ pool existing_pool new_member_ip new_member_port }
else
{ pool existing_pool old members 1,2,3 }
Can we do this? If yes, how to ensure it still uses the least connections(member) algorithm?
What will be the correct syntax for mentioning three pool members.
-JS
- nitassEmployeeis it something like this?
[root@ve1023:Active] config b virtual bar list bvirtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve1023:Active] config b pool foo list pool foo { lb method member least conn members { 200.200.200.101:80 {} 200.200.200.102:80 {} 200.200.200.111:80 {} } } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set vs "[IP::local_addr]:[TCP::local_port]" if {[HTTP::cookie value "testCookie"] contains "111"} { pool foo member 200.200.200.111 80 } } when HTTP_RESPONSE { log local0. "[IP::client_addr]:[TCP::client_port] -> $vs -> [IP::remote_addr]:[TCP::remote_port]" } } [root@ve1023:Active] config curl -I http://172.28.19.79 HTTP/1.1 200 OK Date: Sat, 11 Feb 2012 01:02:12 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT ETag: "4183e4-3e-9c564780" Accept-Ranges: bytes Content-Length: 62 Content-Type: text/html; charset=UTF-8 [root@ve1023:Active] config curl -I http://172.28.19.79 -H "Cookie: testCookie=abc111" HTTP/1.1 200 OK Date: Sat, 11 Feb 2012 00:58:25 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Wed, 30 Nov 2011 05:42:33 GMT ETag: "418416-30-33ce6440" Accept-Ranges: bytes Content-Length: 48 Connection: close Content-Type: text/html; charset=UTF-8 [root@ve1023:Active] config cat /var/log/ltm Feb 10 16:55:34 local/tmm info tmm[4822]: Rule myrule : 172.28.19.80:51524 -> 172.28.19.79:80 -> 200.200.200.101:80 Feb 10 16:55:37 local/tmm info tmm[4822]: Rule myrule : 172.28.19.80:51525 -> 172.28.19.79:80 -> 200.200.200.111:80
- JSpartan0901_95NimbostratusThank you!
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects