Manage custom response page with Irules

Hello,

I’m trying to manage custom response page following http response code and violations.

I’m using irule in Normal mode for each policy

I don’t know why but my rule don’t catch anything, I used the example given by F5

First example for http 500 blocked

when ASM_REQUEST_BLOCKING {
         set asm_support_id [ASM::support_id]
         set client_ip [IP::client_addr]
    if {[ASM::violation names] contains “VIOL_HTTP_RESPONSE_STATUS” and {[HTTP::status] == 500 }}
    {
        log local0. “VIOLATION_500 detected”
        set response “<html>
        <head>
            <title>Request rejected by the server</title>
        </head>
        <body>
            Internal error.Please contact your administrator<br><br>
            Your support ID : $asm_support_id
            Your ip : $client_ip
        </body>
    </html>”
        ASM::payload replace 0 [ASM::payload length] “”
        ASM::payload replace 0 0 $response
    }
}

Is there something that miss

Thanks

Hi,

You need to follow the next steps:

  1. Make sure that “Trigger ASM iRule Events” option is enabled in the policy properties.
    1. Navigate to Security  ››  Application Security : Policy : Policy Properties.
    2. Change to the correct “Current edited security policy”

You can review my original post too for more info.

https://community.f5.com/discussions/technicalforum/asm-custom-response-page-add-additional-information/292637/replies/292641

Hello thanks for reply

As i said i’ve already set Trigger ASM iRule Events to Normal in my policy. Do you see a syntax error maybe ?