How to create rules to execute behaviors with Rules Engine for Edge Firewall

Implementing rules in your edge firewall using Rules Engine will allow you to determine the rules it should execute in specific scenarios.

This guide demonstrates the process of creating a rule with a practical example of verifying the existence of a certificate and returning a custom response when there isn’t one. This behavior is useful in scenarios such as adjusting your policies to comply with BACEN requirements.


To create a rule:

  1. Access Azion Console > Edge Firewall.
  2. Select the edge firewall in which you want to configure the rule.
  3. Click the *Rules Engine tab.
  4. Click the New Rule button.
  5. Give your rule a name and, optionally, a description.
  6. In the Criteria section, select the SSL Verification Status variable.
  7. As a comparison operator, select is esqual.
  8. As an argument, select Missing Client Certificate.
  9. In the Behaviors section, select Set Custom Response.
  10. As arguments:
    • On Status Code, add 401.
    • On Content Type, add the content and header description. Example: application/json.
    • On Content Body, pass the message you want to present to users.
  11. Click the Save button.

  1. Run the following POST request to create a rule, replacing [TOKEN VALUE] with with your personal token and the <edge_firewall_id> variable with your edge firewall id value:
Terminal window
curl --location 'https://api.azionapi.net/edge_firewall/<edge_firewall_id>/rules_engine' \
--header 'Accept: application/json; version=3' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{
"name": "SSL Verification",
"is_active": true,
"behaviors": [
{
"name": "set_custom_response",
"status_code": 401,
"content_type": "application/json",
"content_body": "{}"
}
],
"criteria": [
[
{
"variable": "ssl_verification_status",
"operator": "is_equal",
"conditional": "if",
"argument": "MISSING_CLIENT_CERTIFICATE"
}
]
]
}'
KeyDescription
nameName of the rule
descriptionDescription of the rule
behaviorsArray that stores objects that define behaviors
criteriaArray that stores objects that define criteria

See the Azion API documentation to find out more about criteria and behavior objects.

  1. You’ll receive the following response:
{
"results": {
"name": "SSL Verification",
"is_active": true,
"behaviors": [
{
"status_code": 401,
"content_body": "{}",
"name": "set_custom_response",
"content_type": "application/json"
}
],
"criteria": [
[
{
"variable": "ssl_verification_status",
"operator": "is_equal",
"conditional": "if",
"argument": "MISSING_CLIENT_CERTIFICATE"
}
]
],
"last_modified": "2023-11-23T23:54:14.941097Z",
"last_editor": "hannah.kahn+rtm@azion.com",
"id": 28414,
"order": 2
},
"schema_version": 3
}
  1. Wait a few minutes for the changes to propagate.



Contributors