Disable all policies after iRule execution - Multiple redirect/respond invocations not allowed

Hi, I would like to prepare sorry page in iRule. I want to display sorry page only for IP address from internet. Below you can find iRule prepared so far:

when HTTP_REQUEST {
    if { not ([class match [IP::client_addr] equals LOCAL_NET]) } {
       HTTP::respond 200 content { 
         Service is not working.
       } Cache-Control No-Cache Pragma No-Cache
  }
}

Problem is that in polices I got some redirect statements, and when IP address is not in IP data group I’m receiving “Multiple redirect/respond invocations not allowed”.

Is there some kind of possibility to stop processing Polices after condition from iRule?

I believe policies happen before iRules, so the easiest solution would probably be to put everything in an iRule and not use the policies.

when HTTP_REQUEST {
    if { not ( [class match [IP::client_addr] equals LOCAL_NET] ) } {
        HTTP::respond 200 content "Service is not working'" Cache-Control "No-Cache" Pragma "No-Cache"
    } else {
        if { [string tolower [HTTP::uri]] equals "/foo" } {
            HTTP::redirect "/bar"
        }
    }
}

Aren’t you looking for the ‘event’ command?

You can use this to prevent next iRules from executing:

event disable all

Reference here: DevCentral - An F5 Technical Community

You could try adding a policy on top to redirect the external users to a local page implemented using iFiles. It seems like a good option, I’ve done this in past for a customer who was trying to implement error messages using complex HTML pages with images and css files. Reference: DevCentral - An F5 Technical Community

Another option to consider is to add an exception condition in your redirect policies for the external users, leaving then the respond event free to be thrown by iRule.