filtering traffic with irule

Hello, I’m trying to create an irule that will only allow traffic to the VIP if it matches a specific header, all other traffic should be dropped. Is there an easy way to accomplish this?

You can use an Local Traffic policy to do this:

Or a simple iRule:

when HTTP_REQUEST {
    if {!([HTTP::header exists "my-header-name"])} {
        reject
    }
}

Even if you request a Drop, I would suggest to send a 403 response page instead!

Take the lee’s Answer and replace reject with

HTTP::respond 403 content {put here the html content of your blocking page}