we are planning to implement content-switching and just using one virtual server ip address. This single ip will represent multiple urls with SSL. This is in order for our client to save ip address. Can a single VS handle multiple SSL Certificates and use iRule to determine which one to use? Basically here is the traffic flow
Sample
1. Client → www.test1.com/xxx → vs=1.1.1.1 → iRule1 (policy to check which SSL cert to bind to the URL) → iRule2 (policy to check which pool to send depending on the url or url parameter) → iRule3 (policy to check if the client ip address is allowed to access the pool) → pool_test1
2. Client → www.test1.com/yyy → vs=1.1.1.1 → iRule1 (policy to check which SSL cert to bind to the URL) → iRule2 (policy to check which pool to send depending on the url or url parameter) → iRule3 (policy to check if the client ip address is allowed to access the pool) → pool_test2
3. Client → www.test2.com/xxx → vs=1.1.1.1 → iRule1 (policy to check which SSL cert to bind to the URL) → iRule2 (policy to check which pool to send depending on the url or url parameter) → iRule3 (policy to check if the client ip address is allowed to access the pool) → pool_test3
4. Client → www.test2.com/yyy → vs=1.1.1.1 → iRule1 (policy to check which SSL cert to bind to the URL) → iRule2 (policy to check which pool to send depending on the url or url parameter) → iRule3 (policy to check if the client ip address is allowed to access the pool) → pool_test4
Client is using Citrix and we wanted to replace it with F5.
can you help me how can I include an ip filter that only allows certain ip addresses to access the pool? Should I use matchlass? how to include it in the irule?
can you help me how can I include an ip filter that only allows certain ip addresses to access the pool? Should I use matchlass? how to include it in the irule? you should use “class” command.
e.g.
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
destination 172.28.20.14:443
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
clientssl {
context clientside
}
http { }
tcp { }
}
rules {
myrule
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vlans-disabled
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
when CLIENT_ACCEPTED {
if { not [class match -- [IP::client_addr] equals allow_ip_class] } {
log local0. "[IP::client_addr]:[TCP::client_port] is rejected"
reject
} else {
log local0. "[IP::client_addr]:[TCP::client_port] is accepted"
}
}
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm data-group internal allow_ip_class
ltm data-group internal allow_ip_class {
records {
192.168.206.33/32 { }
}
type ip
}
[root@ve11a:Active:Changes Pending] config tail -f /var/log/ltm
Jan 14 14:24:29 ve11a info tmm[11170]: Rule /Common/myrule : 172.28.19.251:48999 is rejected
Jan 14 14:24:36 ve11a info tmm1[11170]: Rule /Common/myrule : 192.168.206.33:54606 is accepted
Hi Nitass, Thanks for the quick reply. But how can I incorporate that with my previous HTTP iRUle? Basically, after doing a content switching, it will check if the client ip is allowed to access the pool before forewarding it. Else, it will be rejected.
is it possible to do nested IFs? Thanks for the support. just a newbie in iRules.
But how can I incorporate that with my previous HTTP iRUle? Basically, after doing a content switching, it will check if the client ip is allowed to access the pool before forewarding it. Else, it will be rejected. CLIENT_ACCEPTED event is triggered before HTTP_REQUEST event. so, we can reject client ip address in CLIENT_ACCEPTED and select pool based on url in HTTP_REQUEST.
iRules Insight - HTTP Event Order by Jason
e.g.
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
destination 172.28.20.14:443
ip-protocol tcp
mask 255.255.255.255
profiles {
clientssl {
context clientside
}
http { }
tcp { }
}
rules {
myrule
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vlans-disabled
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
when CLIENT_ACCEPTED {
log local0. "-"
if { not [class match -- [IP::client_addr] equals allow_ip_class] } {
log local0. "[IP::client_addr]:[TCP::client_port] is rejected"
reject
} else {
log local0. "[IP::client_addr]:[TCP::client_port] is accepted"
}
}
when HTTP_REQUEST {
log local0. "-"
case insensitive
set uri [string tolower [HTTP::uri]]
switch -glob $uri {
"*opis*" { pool OPIS_POOL }
"*reseller*" { pool RESELLER_POOL }
default {
pool RESELLER_POOL
}
}
}
when SERVER_CONNECTED {
log local0. "-"
log local0. "client [IP::client_addr]:[TCP::client_port] | uri $uri | pool [LB::server pool] | pool member [LB::server addr]:[LB::server port]"
}
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm data-group internal allow_ip_class
ltm data-group internal allow_ip_class {
records {
192.168.206.33/32 { }
}
type ip
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm pool OPIS_POOL
ltm pool OPIS_POOL {
members {
200.200.200.101:80 {
address 200.200.200.101
}
}
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm pool RESELLER_POOL
ltm pool RESELLER_POOL {
members {
200.200.200.111:80 {
address 200.200.200.111
}
}
}
[root@ve11a:Active:Changes Pending] config tail -f /var/log/ltm
Jan 14 14:58:59 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:58:59 ve11a info tmm1[11170]: Rule /Common/myrule : 172.28.19.251:49004 is rejected
Jan 14 14:59:25 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:59:25 ve11a info tmm1[11170]: Rule /Common/myrule : 192.168.206.33:55244 is accepted
Jan 14 14:59:25 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:59:25 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:59:25 ve11a info tmm1[11170]: Rule /Common/myrule : client 192.168.206.33:55244 | uri /opis/something | pool /Common/OPIS_POOL | pool member 200.200.200.101:80
Jan 14 14:59:53 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:59:53 ve11a info tmm1[11170]: Rule /Common/myrule : 192.168.206.33:55246 is accepted
Jan 14 14:59:53 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:59:53 ve11a info tmm1[11170]: Rule /Common/myrule : -
Jan 14 14:59:53 ve11a info tmm1[11170]: Rule /Common/myrule : client 192.168.206.33:55246 | uri /reseller/something | pool /Common/RESELLER_POOL | pool member 200.200.200.111:80
Jan 14 15:00:14 ve11a info tmm[11170]: Rule /Common/myrule : -
Jan 14 15:00:14 ve11a info tmm[11170]: Rule /Common/myrule : 192.168.206.33:55247 is accepted
Jan 14 15:00:14 ve11a info tmm[11170]: Rule /Common/myrule : -
Jan 14 15:00:14 ve11a info tmm[11170]: Rule /Common/myrule : -
Jan 14 15:00:14 ve11a info tmm[11170]: Rule /Common/myrule : client 192.168.206.33:55247 | uri /somethingelse | pool /Common/RESELLER_POOL | pool member 200.200.200.111:80
Seems like we will encounter a problem. IP Filtering will be done on the POOL level and not on the VS.
1. There is a list of ip address that is allowed to access POOL_A and a different set of address for POOL_B and so on. Not limited to just one data group. Example
Data Group: Allowed_Pool_A = ip address A, B and C ---> Allowed to access OPIS POOL but not RESELLER POOL
Allowed_Pool_B = ip address X, Y and Z ---> Allowed to access RESELLER POOL but not OPIS POOL
If the ip is accepted on the first irule, it has no means to check if it is allowed to access the pool .
hi seems everything is working for now. Thanks for that. Is there a need to optimize the rule because it looks like quite slow. I am not sure if it has to do with the nested IFs. What is the purpose of the command RETURN?
Additional requirement
1. Users will just type www.test.com on their browser which will redirect the user to “www.test.com/reseller” BUT the link on the browser will still show www.test.com. User is not aware of redirection
I am not sure if it has to do with the nested IFs.is this article helpful?
Comparing iRule Control Statements by Joe
What is the purpose of the command RETURN? return Wiki
1. Users will just type www.test.com on their browser which will redirect the user to “www.test.com/reseller” BUT the link on the browser will still show www.test.com. User is not aware of redirectionyou can use HTTP::uri command.
1. Users will just type www.test.com on their browser which will redirect the user to “www.test.com/reseller” BUT the link on the browser will still show www.test.com. User is not aware of redirection
when HTTP_REQUEST {
log local0. “in HTTP_REQUEST”
if { [HTTP::uri] equals “/”}{
HTTP::uri “/opis”
}
}
I tried using this but the browser will still show the complete url including the /opis. Is there a way not to show /opis on the browser? only www.test.com.ph
1. Users will just type www.test.com on their browser which will redirect the user to “www.test.com/reseller” BUT the link on the browser will still show www.test.com. User is not aware of redirection
when HTTP_REQUEST {
log local0. “in HTTP_REQUEST”
if { [HTTP::uri] equals “/”}{
HTTP::uri “/reseller”
}
}
I tried using this but the browser will still show the complete url including the /reseller. Is there a way not to show /reseller on the browser? only www.test.com.ph
the user will type in www.test.com.ph/reseller but the browser will just show www.test.com.ph
That isn’t possible really, you can’t control the browser directly.
Regarding the iRule, it should work just fine but you’ll probably find all the links returned by the server don’t include what you want shown. That being the case you’ll probably need to expand the iRule to accomodate all the possible paths that the server might return or use a Stream profile to rewrite the links in the server responses.