Forum Discussion
Robert_Pagano_7
Nimbostratus
Jan 14, 2009conditional redirect based on client's IP address
I need to be able to redirect HTTP connections to a virtual server if the source IP address of the client is not part of a pre-determined group.
If the client is a member of that group, the connection should be processed normally.
I am considering the following...
----- data group list (class) ALLOWED_IP_class -----
host xxx.xxx.xxx.xxx
host xxx.xxx.xxx.xxx
host xxx.xxx.xxx.xxx
----- iRule -----
when HTTP_REQUEST {
Check if the client IP is not part of the "ALLOWED_IP_class"
if { not ([matchclass [IP::client_addr] equals $::ALLOWED_IP_class]) }{
HTTP::redirect "http://someotherdomain.example.com/maintenance.html"
}
}
Questions:
[1] Will the above work correctly?
[2] I will need the same functionality for the related HTTPS virtual server. Is there a comparable event for HTTPS?
Any help will be most appreciated!
Thank you.
- dennypayne
Employee
Your logic looks fine (I'm not near a box to double-check the syntax but it looks good too).
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