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