Cloudflare Docs
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.


​​ Prerequisites

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

​​ Workflow

  1. Log in to the Cloudflare dashboard and select an account and application.

  2. Navigate to Traffic > Load Balancing.

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

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

  5. Click Create Custom Rule.

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

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

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

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

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

  11. (Optional) Click Add another override.

  12. After you create your rule, click Save and Deploy or Save as Draft.

  13. Click Next and review your changes.

  14. Click Save.

​​ Example configuration

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

When incoming requests match:

FieldOperatorValue
URI Pathcontains/content
URI Query Stringcontainswebserver

Then:

ActionOptionsValue
OverridesOrigin poolsServer1