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

  1. Access Azion Console > Edge Functions.

  2. Click on + Edge Function.

  3. Choose a name for your function.

  4. 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();
    });
    
  5. 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

  1. Access Azion Console > Edge Firewall.
  2. Click on + Edge Firewall.
  3. Choose a name for the edge firewall.
  4. Choose the domains you want to associate.
  5. Enable the use of the Edge Functions module.
  6. Activate the edge firewall and save it.

After saving the configuration, on the same page, the tabs Functions Instances and Rules Engine become available.

2.2 Adding an edge function to the edge firewall

  1. Go to the Functions Instances tab.
  2. Click the + Function Instance button.
  3. Give a name to your function instance.
  4. Choose a Edge Function.
  5. Click the Save button.
    • Only functions with the Initiator Type set as Edge Firewall are listed.
  6. Go to the Rules Engine tab.
  7. Select + Rules Engine.
  8. Write a name for the new rule.
  9. Configure the criteria that will be applied.
  10. Set the behavior to Run Function and select the function you want to run.
  11. Click the Save button.

Contributors