---
title: "Configure Application Rules"
sidebar_label: "Configure Application Rules"
description: "How to manage traffic using Application Rules"
sidebar_position: 8
---

import Formbricks from '@theme/MDXComponents/Formbricks'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import EditIcon from '@selectel/docux/icons/edit'
import {TabItemLabel} from '@selectel/docux/components'

# Configure Application Rules

Application Rules is a way to manage traffic based on specific requests. You can create advanced load balancing rules that cannot be configured via [Application Profiles](/public-cloud/manage-load-balancer/configure-application-profile/) or using other services on the Edge router.

## Create a rule \{#create-rule}

1. From the [control panel](https://my.selectel.ru/vmware/), open the Cloud Director panel: in the top menu, click **Products** → **VMware-based cloud** → section **Cloud Director**.

2. Open your virtual data center page.

3. Go to the **Networking** → **Edges**.

4. Open the page of the required Edge.

5. Click **SERVICES**.

6. Open the **Load Balancer** → **Application Rules**.

7. Click **+**.

8. Enter a rule name.

9. Paste the script that will determine the load balancing:

   <Tabs queryString="where">
     <TabItem value="other-pool" default>
       <TabItemLabel>
         To another pool
       </TabItemLabel>

       If the primary pool is not working, traffic can be redirected to another load balancing pool. For the rule to work, several pools must be configured on the load balancer. All members of the primary pool must be in the `down` state. Script format:

       ```bash
       acl pool_down nbsrv(<primary_pool_name>) eq 0
       use_backend <secondary_pool_name> if <primary_pool_name>
       ```

       Specify:

       * `<primary_pool_name>` — the name of the primary pool;
       * `<secondary_pool_name>` — the name of the pool to which traffic will be redirected.
     </TabItem>

     <TabItem value="external-resource">
       <TabItemLabel>
         To an external resource
       </TabItemLabel>

       If all members of the primary pool are in the `down` state, traffic can be redirected to an external website using a script:

       ```bash
       acl pool_down nbsrv(<pool_name>) eq 0
       redirect location <url> if pool_down
       ```

       Specify:

       * `<pool_name>` — the name of the primary pool; ;
       * `<url>` — the website URL.
     </TabItem>
   </Tabs>

10. Click **KEEP**.

## Add a rule to a virtual server \{#add-rule-to-virtual-server}

1. From the [control panel](https://my.selectel.ru/vmware/), open the Cloud Director panel: in the top menu, click **Products** → **VMware-based cloud** → section **Cloud Director**.
2. Open your virtual data center page.
3. Go to the **Networking** → **Edges**.
4. Open the page of the required Edge.
5. Click **SERVICES**.
6. Open the **Load Balancer** → **Virtual Servers**.
7. Select a [virtual server](/public-cloud/manage-load-balancer/add-virtual-server/).
8. Click .<EditIcon />
9. Open the **Advanced** tab.
10. Click **+**.
11. Add a [rule](#create-rule).

<Formbricks />
