Forum Discussion

Mike_Maher's avatar
Mike_Maher
Icon for Nimbostratus rankNimbostratus
Jan 21, 2016

ASM Blocking with multiple formats

I have an application that just a custom HTML response page for all ASM blocks. The application owner is building in new functionality and is asking that for one URL we provide a JSON formatted response if a block happens. I have looked around and I don't seem to see an easy way to do this outside of writing an iRule or sending that traffic to a different policy. I tried turning on AJAX response blocking and I can't even get to the website with that turned for some reason. Anyone had to deal with this and how did you solve the issue?

 

1 Reply

  • We dealt with it in an iRule, and it's pretty simple:

    when ASM_REQUEST_BLOCKING {
        set asm_info [ASM::violation_data]
        if {[string compare -nocase "/web/json-y-page" [HTTP::uri]] == 0} {
           ASM::payload replace 0 [ASM::payload length] "{\"response\":\"1\", \"message\":\"Request Rejected. Support ID: [lindex $asm_info 1]\"}"
           HTTP::header replace Content-Length [ASM::payload length]
        }
    }
    

    This will replace the default response page that would otherwise be sent.