Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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?

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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.

0