Create Firewall Rules with Rules Engine
Integrate rules in your firewall to set tasks to be executed for specific scenarios without changing your existing code.
Use Rules Engine to define the conditions and behaviors your Firewall executes for each incoming request.
This guide walks you through creating a rule using a practical example: verifying whether a client certificate exists and returning a custom response when it doesn’t. This is useful for enforcing mTLS policies, such as those required for BACEN compliance.
To create a rule:
- Access Azion Console > Firewall.
- Select the firewall in which you want to configure the rule.
- Click the Rules Engine tab.
- Click the + Rule button.
- Give your rule a name and, optionally, a description.
- In the Criteria section, select the
SSL Verification Statusvariable. - As a comparison operator, select
is equal. - As an argument, select
Missing Client Certificate. - In the Behaviors section, select Set Custom Response.
- As arguments:
- On Status Code, add
401. - On Content Type, define the MIME type of the response body. Example:
application/json. - On Content Body, pass the message you want to present to users.
- On Status Code, add
- Click the Save button.
- Run the following
POSTrequest to create a rule, replacing[TOKEN VALUE]with your personal token and the<edge_firewall_id>variable with your firewall id value:
| Key | Description |
|---|---|
name | Name of the rule |
description | Description of the rule |
behaviors | Array that stores objects that define behaviors |
criteria | Array that stores objects that define criteria |
Refer to the Azion API documentation for details on all available criteria and behavior objects.
- You’ll receive the following response:
- Wait a few minutes for the changes to propagate.