Forum Discussion
SSHSSH_97332
Nimbostratus
Jan 26, 2012Multiple IRules to same VS
i will do an Irule mentioned at the below link :
but at the same time i want to forward to specific Pool based on src ip of client , will i do 2 Irules & then apply to the VS ? or it should only be one combined IRules containing all ?
13 Replies
- SSHSSH_97332
Nimbostratus
i will do an Irule mentioned at the below link :
http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/2160986/showtab/groupforums/Default.aspx
but at the same time i want to forward to specific Pool based on src ip of client , will i do 2 Irules & then apply to the VS ? or it should only be one combined IRules containing all ? - nathe
Cirrocumulus
SSHSSH
I'd use 1 iRule - would this work? Oh and I've found a neat src ip irule example from hoolio. I take it you'll be forwarded a specific src ip to a different pool altogether? If so try this.
when CLIENT_ACCEPTED {
Save VS default pool name
set default_pool [LB::server pool]
Check if client IP is 1.1.1.1
if {[IP::addr [IP::client_addr] equals 1.1.1.1]}{
Select the second pool
pool second_pool
}
}
when HTTP_REQUEST {
switch [string tolower [URI::host [HTTP::uri]]] {
youtube.com -
www.youtube.com -
4shared.com -
www.4shared.com -
rapidshare.com -
www.rapidshare.com {
pool cache_pool
}
default {
pool $default_pool
}
}
}
N - hoolio
Cirrostratus
Do you want requests from the specific client IP to still get checked for the requested host header? If not, you could disable the HTTP_REQUEST event:when CLIENT_ACCEPTED { Save VS default pool name set default_pool [LB::server pool] Check if client IP is 1.1.1.1 select second pool and skip the host header check in HTTP_REQUEST if {[IP::addr [IP::client_addr] equals 1.1.1.1]}{ Select the second pool pool second_pool event HTTP_REQUEST disable } } when HTTP_REQUEST { switch [string tolower [URI::host [HTTP::uri]]] { youtube.com - www.youtube.com - 4shared.com - www.4shared.com - rapidshare.com - www.rapidshare.com { pool cache_pool } default { pool $default_pool } } }
Aaron - SSHSSH_97332
Nimbostratus
Thanks All , but my target exactly is :
i have 2 pools ( each one has 2 proxies ) at my vs=0.0.0.0/80
if the requesting client source ip x.x.x.0 or y.y.y.0& at the same time requesing one of the above sites >>>>>> forward to pool one ( sothat the proxy group1 can serve the request )
if the requesting client source ip x1.x1.x1.0 or y1.y1.y1.0 & at the same time requesing one of the above sites >>>>>> forward to pool two ( sothat the proxy group2 can serve the request )
if not of the above , i don't need to forward to proxies at all , i need to forward to my GW router to the internet directly - SSHSSH_97332
Nimbostratus
So what would be final IRules ? - SSHSSH_97332
Nimbostratus
i need it with if else not with switch (if possible ) - SSHSSH_97332
Nimbostratus
......... - nitass
Employee
can you try this?when HTTP_REQUEST { switch [string tolower [HTTP::host]] { youtube.com - www.youtube.com - 4shared.com - www.4shared.com - rapidshare.com - www.rapidshare.com { set flag 1 } default { set flag 0 } } if {[class match -- [IP::client_addr] equals group1] and $flag} { pool proxy1 } elseif {[class match -- [IP::client_addr] equals group2] and $flag} { pool proxy2 } else { forward pool gateway } } - SSHSSH_97332
Nimbostratus
Thanks alot nitass , but how can i use if/else instead of switch sothat all the IRule depends on if/else - nitass
Employee
do you mean something like this? anyway, i do not get the point. why do you need if/else instead of switch??when HTTP_REQUEST { if {[class match -- [string tolower [HTTP::host]] equals domain_list]} { set flag 1 } else { set flag 0 } if {[class match -- [IP::client_addr] equals group1] and $flag} { pool proxy1 } elseif {[class match -- [IP::client_addr] equals group2] and $flag} { pool proxy2 } else { forward pool gateway } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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