Creating Request and Response rules using Rules Engine for Edge Application

Rules Engine is an Edge Application capability that allows you to create no-code solutions that follow the business rules of your edge application.

With Azion Edge Application’s reverse-proxy architecture, the rules you create will be executed between either the Request phase, which contains data that a client sends to an origin server, or Response phase, which contains data from the origin that is sent to the client.

Learn more about Rules Engine

Creating a request rule: Rewrite Request

Section titled Creating a request rule: Rewrite Request

Rules created in the Request phase will be executed before the request to the origin servers is completed. For instance, using the Rewrite Request behavior, you can create a rule to deliver content to a user from a specific URI without requiring that they use the exact path value from the origin in the request.

For the purposes of this guide, assume that your goal is to deliver the contents of the page /content/page.html when a client makes a request for https://www.domain.com/page. To create a rule that will rewrite this request:

  1. Access Azion Console.

  2. On the upper-left corner of the page, go to Products menu > Edge Application.

  3. Select the edge application for which you want to create the rule.

  4. In the Main Settings tab, enable the Application Accelerator module.

  5. Select the Rules Engine tab.

  6. Click the Add Rule button.

  7. On the dropdown menu, select Request Phase.

  8. Give your rule a name and, if necessary, a description.

  9. In the Criteria section, configure your criteria as follows:

    If ${uri} is equal to /page

    This criteria will identify the URL of the request by the URI trailing slash /.

  10. In the Behaviors section, add the behavior you want your application to execute. In this case, Rewrite Request.

  11. The behavior selected takes an argument; to redirect the request to the page:

${uri}content/page.html

This argument concatenates the ${uri} variable, whose value is /, to the page’s path.

  1. Click the Save button to save your rule.

Now, when a request is made to the URL https://www.domain.com/page, users should see the contents from the /content/page.html page without having to specify the entire address in their browser.


Creating a response rule: Filter Response Header

Section titled Creating a response rule: Filter Response Header

Rules created in the Response phase will be executed before the response is delivered to the client. For example, you can create a rule that’ll remove an HTTP header from the response using the Filter Response Header behavior.

The Server header stores information about the server that generated the response. By removing this header, clients won’t receive information about the infrastructure of your application, enhancing your security by reducing the information available to potential attackers.

Note: exercise caution when removing any headers from your edge application and ensure that this action doesn’t interfere in any applicable standards and guidelines.

To filter the Server header from the response:

  1. Access Azion Console.

  2. On the upper-left corner of the page, go to Products menu > Edge Application.

  3. Select the edge application for which you want to create the rule.

  4. In the Main Settings tab, enable the Application Accelerator module.

  5. Select the Rules Engine tab.

  6. Click the Add Rule button.

  7. On the dropdown menu, select Response Phase.

  8. Give your rule a name and, if necessary, a description.

  9. In the Criteria section, configure your criteria as follows:

    If ${uri} starts with /

    This criteria will execute the rule for the entire application.

  10. In the Behaviors section, add the behaviors you want to be executed. In this case, Filter Response Header.

  11. The behavior selected takes an argument, which should be Server.

This argument will remove every instance of the Server header from all responses.

  1. Click the Save button to save your rule.

Now, when a request is made to your application, the Server header will be removed from the response.


Contributors