How to create and configure a function on your Firewall
Functions are functions that run on the edge of the network, close to users. They can help you secure your applications through Firewall.
To use functions in your Firewall, you have to go through two steps:
- Create a function.
- Configure the behaviors on the Firewall page.
Creating a function
- Access Azion Console > Functions.
- Click on + Function.
- Choose a name for your function.
- In the Code tab, write your function code, or simply paste it.
- The function being used on the firewall must contain a finishing event, such as:
addEventListener("firewall", (event) => { event.deny(); });
- Save it.
Now, your function can be used on a firewall configuration.
Configuring your function on the Firewall
After creating a function, you need to configure the firewall to use it.
2.1 Creating a firewall
- Access Azion Console > Firewall.
- Click on + Firewall.
- Choose a name for the firewall.
- Choose the domains you want to associate.
- Enable the use of the Functions module.
- Activate the firewall and save it.
After saving the configuration, on the same page, the tabs Functions Instances and Rules Engine become available.
2.2 Adding a function to the firewall
- Go to the Functions Instances tab.
- Click the + Function Instance button.
- Give a name to your function instance.
- Choose a Function.
- Click the Save button.
- Only functions with the Initiator Type set as Firewall are listed.
- Go to the Rules Engine tab.
- Select + Rules Engine.
- Write a name for the new rule.
- Configure the criteria that will be applied.
- Set the behavior to Run Function and select the function you want to run.
- Click the Save button.