# Automate Behaviors with Rules Engine

import Tabs from '~/components/tabs/Tabs'
import Code from '~/components/Code/Code.astro'


Implementing rules in your application using [Rules Engine](/en/documentation/products/build/applications/rules-engine/) will allow you to determine the tasks it should execute in specific scenarios without modifying your application's code.

This guide demonstrates the process of creating rules with a practical example, but most rules will be unique to each application and its needs. In addition to activating variables such as [device groups](/en/documentation/products/guides/build/create-device-groups/), [cache settings](/en/documentation/products/build/applications/cache-settings/), and [origins](/en/documentation/products/guides/build/work-with-origins/), you can create a wide variety of rules in both the request and response phases.

With this guide, you'll create a rule in the response phase to remove an HTTP header using the **Filter Response Header** behavior.

:::caution[warning]
To unlock the full capabilities of Rules Engine, you should activate the [Application Accelerator](/en/documentation/products/build/applications/application-accelerator/) module. If **Application Accelerator** is activated, data transfer could generate usage-related costs. Check the [pricing page](/en/documentation/products/pricing/) for more information.
:::

---

<Tabs client:visible>
    <Fragment slot="tab.console">Console</Fragment>
    <Fragment slot="tab.api">API</Fragment>

<Fragment slot="panel.console">
To activate the **Application Accelerator** module:

1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Applications**.
2. Click the application you want to configure. 
3. Activate the **Application Accelerator** module.
4. Click the **Save** button.

The `Server` header stores information about the server that generated the response. By removing this header, end-users 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 application and ensure that this action doesn't interfere in any applicable standards and guidelines.
:::

To remove the `Server` header:

1. Navigate to the **Rules Engine** tab.
2. Click the **+ Rule** button.
3. Give your rule a name and, if necessary, a description. 
4. Select **Response Phase**.
5. In the **Criteria** section, select the `${uri}` variable.
6. As a comparison operator, select **starts with**.
7. As an argument, add the value `/`.
8. In the Behaviors section, select **Filter Response Header**.
9. As an argument, add `Server`.
10. Click the **Save** button.
</Fragment>

<Fragment slot="panel.api">
1. Run the following `PATCH` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and the `<application_id>` variable with [your application ID](/en/documentation/products/guides/build/configure-main-settings/) to activate the [Application Accelerator](/en/documentation/products/build/applications/application-accelerator/) module:

<Code lang="bash" code={` 
curl --request PATCH \
  --url https://api.azion.com/v4/edge_application/applications/<application_id> \
  --header 'Accept: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]]' \
  --header 'Content-Type: application/json' \
  --data '{
  "modules": {
    "application_accelerator": {
      "enabled": true
    }
  },
  "active": true,
  "debug": false
}'
`} />


1. You'll receive a response with the updated value.
2. Run the following `POST` request to create a rule in the response phase, replacing `<application_id>` with the `id` value you received in the previous response:

<Code lang="bash" code={` 
curl --request POST \
  --url https://api.azion.com/v4/edge_application/applications/<application_id>/response_rules \
  --header 'Accept: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "FilterRespHeader Server",
    "active": true,
    "criteria": [
      [
        {
          "conditional": "if",
          "variable": "\${uri}",
          "operator": "is_equal",
          "argument": "/"
        }
      ]
    ],
    "behaviors": [
      {
        "type": "filter_response_header",
        "attributes": { "value": "Server" }
      }
    ],
    "description": "Filter Server response header on /"
  }'
`} />

3. Wait a few minutes for the changes to propagate.

:::tip
Check the [Azion API documentation](https://api.azion.com/) and the [OpenAPI specification](https://github.com/aziontech/azionapi-openapi/) to know more about all features available via API.
:::
</Fragment>

</Tabs>