Skip to content
Load Balancing
Visit Load Balancing on GitHub
Set theme to dark (⇧+D)

Create custom rules

Create and manage Load Balancing rules in the Custom Rules page, which is part of the Create/Edit Load Balancer workflow found in Traffic in the dashboard.

Before you begin

  • Understand whether Cloudflare proxies your traffic: Depending on the nature of your traffic, you may have access to more or less fields for your load balancing rules. For more details, see Supported fields and expressions.


1. Create a new Load Balancing rule

  1. Log in to your Cloudflare Account and select a domain.

  2. Select Traffic > Load Balancing.

  3. Edit an existing load balancer or create a new load balancer.

  4. From the Load Balancer workflow, select Custom Rules.

  5. Select Create Custom Rule.

2. Build a Load Balancing expression

This example routes certain content requests from our webserver to a different origin pool.

When incoming requests match:
URI Pathcontains/content
URI Query Stringcontainswebserver
OverridesOrigin poolsServer1

  1. In the Field drop-down list, choose an HTTP property. For more details, see Supported fields.

    Screenshot, Create Custom Rule dialog, choose Field

  2. In the Operator drop-down list, choose an operator. For more details, see Operators.

  3. Enter the value to match. When the field is an ordered list, Value is a drop-down list. Otherwise, Value is a text input.

    Screenshot, Create Custom Rule dialog, choose Value

  4. [Optional] To create a compound expression using logical operators, select And or Or.

    Screenshot, Create Custom Rule dialog, add logical operator

  5. For an action, choose Respond with fixed response or Override and enter additional details. For a full list of actions, see Actions.

    Add an action to complete your load balancing rule

  6. [Optional] Select Add another override.

3. Save a Load Balancing rule and configuration

  1. After you create your rule, select Save and Deploy or Save as Draft.

  2. Select Next and review your changes.

  3. Select Save.