iRule to display Error message and close connection

Hi all, I am looking to get an iRule to drop traffic and return with an Error Message when a string in a particular data group list is matched. The URI is under a data group list called commstgtest. I am using the iRule as below which blocks the page but what I want is to display a an Error Message ‘Resource Unavailable’ and close the connection.

when HTTP_REQUEST { if {[class match [string tolower [HTTP::uri]] ends_with commstgtest]} { HTTP::close } }

Is this possible to do this?

Hi

Before your HTTP::close command, insert a HTTP::respond command then you can send whatever HTTP status code and payload and you need

Something like this?

when HTTP_REQUEST {   
    if {[class match [string tolower [HTTP::uri]] ends_with commstgtest]} {  
      HTTP::respond 200 content { ErrorError page }
    }  
  }

You could use an iRule like this to respond with the message then drop if you want to close the connection

when HTTP_REQUEST {
    if {[class match [string tolower [HTTP::uri]] ends_with commstgtest]} { 
        HTTP::respond 403 content "Resource Unavailable"
        drop
    }
}