I have to be missing something simple here… setting up a new irule to do a simple whitelist. Here’s the whole thing (stolen shamelessly from somewhere else on DevCentral):
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals trusted_ips] } {
log local0. "[IP::client_addr]:[TCP::client_port]: Client is in data group so do not redirect. DG: [class get trusted_ips]"
} else {
log local0. "[IP::client_addr]:[TCP::client_port]: Client is not in data group bail"
reject
}
}
The “trusted_ips” datagroup has a single dummy entry, 1.2.3.4, not my requesting IP. When I try to hit the vip this irule is attached to, I get the destination page (a simple static page on an apache server), and the log entry:
Sun Dec 29 13:09:26 PST 2013 info slot1/DCA2400VPRA tmm1[9649] Rule /Common/trusted_ips_only : 162.195.xxx.xxx:53465: Client is not in data group bail
So - the irule is executing, but the “reject” isn’t seemingly rejecting. I tried “discard” and “drop”, same behavior. (and HTTP::respond gave me back an error about HTTP or ICAP profiles that I can’t seem to find any docs on). What I’d really like is a 404 error, frankly.
I’ve been using irules in 10.2.4 for years - but this is on new iron, a Viprion running 11.4, and either something changed or I’m missing something simple somewhere, not for the first time.
Are you using any proxy between your client and your BIG-IP ?
And last thing, maybe you can try to this iRule to send a 404 response :
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals trusted_ips] } {
log local0. "[IP::client_addr]:[TCP::client_port]: Client is in data group so do not redirect. DG: [class get trusted_ips]"
} else {
log local0. "[IP::client_addr]:[TCP::client_port]: Client is not in data group bail"
HTTP::respond 404
}
}
Are you using any proxy between your client and your BIG-IP ?
And last thing, maybe you can try to this iRule to send a 404 response :
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals trusted_ips] } {
log local0. "[IP::client_addr]:[TCP::client_port]: Client is in data group so do not redirect. DG: [class get trusted_ips]"
} else {
log local0. "[IP::client_addr]:[TCP::client_port]: Client is not in data group bail"
HTTP::respond 404
}
}
No, no cache, no proxies - I can reproduce this with curl on the command line. Changing “reject” to “HTTP::respond 404” causes this error on trying to save the iRule: 01070394:3: HTTP::respond in rule (/Common/trusted_ips_only) requires an associated HTTP or ICAP profile on the virtual server (/Common/test). Interestingly - this is the error I’ve seen before, I thought at runtime. The profile associated with thisw VIP is the default you get when you select http and port 80 - “Performance (HTTP)” with “fasthttp” listed as the profile (the only choice there).
No, no cache, no proxies - I can reproduce this with curl on the command line. Changing “reject” to “HTTP::respond 404” causes this error on trying to save the iRule: 01070394:3: HTTP::respond in rule (/Common/trusted_ips_only) requires an associated HTTP or ICAP profile on the virtual server (/Common/test). Interestingly - this is the error I’ve seen before, I thought at runtime. The profile associated with thisw VIP is the default you get when you select http and port 80 - “Performance (HTTP)” with “fasthttp” listed as the profile (the only choice there).
CLIENT_ACCEPTED has the same behavior - it logs that the connection is denied, but I still get back the content to the client. The virtual server profile is “fasthttp” - the only one visible in the dropdown. Here’s the actual config (slightly censored): ltm virtual /Common/test { description “test for bortels” destination /Common/63.xx.xx.xx:80 ip-protocol tcp mask 255.255.255.255 pool /Common/testweb profiles { /Common/fasthttp { } } rules { /Common/trusted_ips_only } source 0.0.0.0/0 translate-address enabled translate-port enabled }
CLIENT_ACCEPTED has the same behavior - it logs that the connection is denied, but I still get back the content to the client. The virtual server profile is “fasthttp” - the only one visible in the dropdown. Here’s the actual config (slightly censored): ltm virtual /Common/test { description “test for bortels” destination /Common/63.xx.xx.xx:80 ip-protocol tcp mask 255.255.255.255 pool /Common/testweb profiles { /Common/fasthttp { } } rules { /Common/trusted_ips_only } source 0.0.0.0/0 translate-address enabled translate-port enabled }
Interestingly - if I change the type to “Standard” rather than “Performance (HTTP)” - this workd (in that I get rejected now, which was the expected behavior).
I guess this modifies the question a bit - why would choosing the Performance/fasthttp profile allow irule execution - but not honor the reject (silently!)?
The ugly continues - having seen it block, I add my IP into the datagroup - and it posts the “do not redirect” log line in the original script… but on the client… it just hangs until timeout. Very, very odd - never had these issues in 10.2.4; there’s got to be something fundamental I’m missing…