Forum Discussion

Jim_Carlberg_98's avatar
Jim_Carlberg_98
Icon for Nimbostratus rankNimbostratus
Nov 08, 2012

Command 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's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    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
  • 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
  • Just to clarify Aaron, are you saying that you can match an IP address to a Data Group subnet?