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.

  1. On Azion Console, on the upper-left corner, select Edge Functions in the Edge Libraries section.

  2. Click on Add a Function.

  3. Choose a name for your function.

  4. Write your Edge Function code, or simply paste it.

    Note: 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

Section titled Configuring your edge function on the Edge Firewall

After creating an edge function, you need to configure the edge firewall to use it.

  1. On Azion Console, on the upper-left corner, select Edge Firewall in the Secure section.
  2. Click on Add a Rule Set.
  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 and Rules Engine become available.

2.2 Adding an edge function to the edge firewall

Section titled 2.2 Adding an edge function to the edge firewall
  1. Go to the Functions tab.

  2. Choose an Instance Name.

  3. Select Add Function.

  4. Choose a function.

  5. Click the Save button.

    Note: only functions with the Initiator Type set as Edge Firewall are listed.

  6. Go to the Rules Engine tab.

  7. Select New Rule.

  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.

Note: it might take a while for your changes to propagate.


Contributors