Forum Discussion
Whitelist a iRule, otherwise redirect
Need some help creating an iRule. The idea is that I have a VS, and I will be associating a iRule to do a redirect, but I dont want to do a redirect if a the IP/Subnet is in the iRule data group. I think I have something close, but would like someones feedback.
when HTTP_REQUEST {
if { ([matchclass [IP::remote_addr] equals $::Whitelist_Sorry]) } {
pass
}
elseif { ([matchclass [IP::remote_addr] equals $::epp-test]) } {
HTTP::redirect http://sorry.********.ca/
}
}
This idea is, if you are in Whitelist_Sorry iRule data group, pass through, otherwise, redirect to a the sorry page. Thoughts?
- smiley_dba_1116NimbostratusSo if you are in the whitelist, allow access to the Virtual server. If you are not in the whitelist, redirect.
- natheCirrocumulussmiley_dba,
- smiley_dba_1116NimbostratusThanks Nathan. Having an issue with the Whitelist_Sorry subnets trying to NOT get the redirect, as they are getting the redirect with everyone else.
- Eric_St__JohnEmployeeWhat does your data group format look like?
- smiley_dba_1116Nimbostratus
class Whitelist_Sorry { { host 10.10.5.139 network 172.16.0.0/16 } }
- natheCirrocumulusTo avoid a problem with context could you try IP::client_addr instead of remote_addr?
- hooleylistCirrostratusIf you're on 9.4.4 or higher make sure to remove the $:: prefix from the data group name. You can add debug logging to figure out why the iRule isn't working. Here's a version 10 or higher example:
when HTTP_REQUEST { if { [class match [IP::client_addr] equals Whitelist_Sorry] } { log local0. "[IP::client_addr]:[TCP::client_port]: Client is in data group so do not redirect. DG: [class get Whitelist_Sorry]" } else { log local0. "[IP::client_addr]:[TCP::client_port]: Client is not in data group so redirect" HTTP::redirect } }
Recent Discussions
Related Content
* 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