Forum Discussion
Jim_Carlberg_98
Nimbostratus
Nov 08, 2012Command is not valid in current event context
I have an IP subnet in meeting_redirect-ip. If the users subnet is equat to that subnet, I want to redirect them to meet.contractor.com. If the IP address does not match, I want the request to forward to the pool members.
I keep getting command is vaid in current event context.
when CLIENT_ACCEPTED {
if { ![class match [IP::client_addr] equals meetingplace_redirect_ip] }{
HTTP::redirect "https://meet.contractor.com" }
}
Jim
4 Replies
- nathe
Cirrocumulus
Jim
See https://devcentral.f5.com/wiki/iRules.http__redirect.ashx for a list of events that supports http::redirect. You'll have to use http_request, for example.
Hope this helps,
N - What_Lies_Bene1
Cirrostratus
Also worth mentioning that an IP address won't match an IP subnet. - hoolio
Cirrostratus
The HTTP filter haven't been hit in CLIENT_ACCEPTED so you won't be able to use HTTP commands there. You can do a check of the client IP once per connection in CLIENT_ACCEPTED and send a redirect in HTTP_REQUEST. Or you could just move the code to HTTP_REQUEST.
If you've defined the subnets in an address type data group, a bitwise comparison is done using class match.when HTTP_REQUEST { if { not [class match [IP::client_addr] equals meetingplace_redirect_ip] }{ HTTP::redirect "https://meet.contractor.com" } }
Aaron - What_Lies_Bene1
Cirrostratus
Just to clarify Aaron, are you saying that you can match an IP address to a Data Group subnet?
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
