Creating custom blocking pages

When a transaction is blocked by a rule, you can set a custom page with blocking. To do this, in the action of the desired rule, you need to check the “Use a special response template” option and enter an arbitrary file name in the field, for example, as shown in screenshot 124.

image115

Screenshot 124 – Rule with custom response pattern

Next, you need to create a file with this template on nodes with the Analyzer role, for example,

/etc/ibatyr-nginx/templates/custom_block.response.json with the following content.

{

“status”: 401,

“headers”: {

“Content-Type”: “application/json”

},

“body”: {

“$apply”: “json_encode”, “value”: {

“message”: “transaction blocked”, “incident_id”: {

“$apply”: “render”, “string”: “{* support_id *}”

}

}

}

}

As an example and to demonstrate the capabilities of this functionality, below are more examples of response templates for custom pages with blocking.

  • /etc/ibatyr-nginx/templates/default.response.json:

{

“status”: {

“$apply”: “render”,

“string”: “{* BLOCKED_STATUS_CODE or 403 *}”

},

“headers”: {

“Content-Type”: {

“$apply”: “render”,

“string”: “{* BLOCKED_CONTENT_TYPE or ‘text/html’ *}”

}

},

“body”: {

“$apply”: “render”, “file”: {

“$apply”: “render”,

“string”: “{* BLOCKED_TEMPLATE or ‘blocked.html’ *}”

}

}

}

  • /etc/ibatyr-nginx/templates/example.response.json:

{

“status”: 403,

“headers”: {

“Content-Type”: “application/json”,

“X-Multiple-Headers”: [“one”, “two”, “three”], “X-The-Answer”: {

“$apply”: “render”,

“string”: “{* number + 1 *} is the answer”, “context”: {

“number”: 41

}

}

},

“body”: {

“$apply”: “json_encode”, “value”: {

“message”: “You have been blocked.”, “code”: 1001,

“incident_id”: { “$apply”: “render”,

“string”: “{* support_id *}”

},

“time”: {

“$apply”: “render”,

“string”: “{* time_iso8601 *}”

},

“client_ip”: { “$apply”: “render”,

“string”: “{* remote_addr *}”

}

}

}

}