Создание кастомных страниц блокировки
Снимок экрана 124 – Правило с особым шаблоном ответа
Далее необходимо на узлах с ролью Анализатор создать файл с данным шаблоном, например,
/etc/ibatyr-nginx/templates/custom_block.response.json со следующим содержимым.
{
«status»: 401,
«headers»: {
«Content-Type»: «application/json»
},
«body»: {
«$apply»: «json_encode», «value»: {
«message»: «transaction blocked», «incident_id»: {
«$apply»: «render», «string»: «{* support_id *}»
}
}
}
}
Для примера и демонстрации возможностей данного функционала ниже приведены еще примеры шаблонов ответа для кастомных страниц с блокировкой.
/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 *}»
}
}
}
}
