Creating Load Balancing rules
Overview
Create and manage Load Balancing rules in the Custom Rules page, which is part of the Create/Edit Load Balancer workflow in the Traffic app.
Create a Load Balancing rule in the Cloudflare dashboard via the following:
Create a new Load Balancing rule
Log in to your Cloudflare Account and click the site to manage.
In the Cloudflare dashboard, click the Traffic app, then select the Load Balancing tab.
To add a rule to an existing load balancer, click the Edit link associated with that specific load balancer. Otherwise, click Create Load Balancer and follow the workflow in Create a load balancer in the Cloudflare dashboard.
The Edit Load Balancer page displays:
In the breadcrumb links for the Edit Load Balancer workflow, click Custom Rules.
Click Create Custom Rule.
In the Create Custom Rule dialog that appears, supply a descriptive name via the Rule name input. The example below uses "Select pool by URI path and query."
After creating a rule, build a Load Balancing expression that defines when the rule triggers.
Build a Load Balancing expression
In the Create Custom Rule Expression builder, under When incoming requests match…, use the Field drop-down list to choose an HTTP property. This example uses URI path. For more details, see Supported fields and operators.
To select a comparison operator, use the Operator drop-down list. This example uses the
contains
operator.Enter the value to match. When the field represents an enumeration, Value is a drop-down list. Otherwise, Value is a text input. The example below matches requests where the URI path contains
/content
:[Optional] To create a compound expression using logical operators, click the And or Or button.
A new expression displays. Edit the expression. The below example uses the
and
operator and adds the requirement that the URI query string containwebserver
:Continue editing the expression as necessary.
Choose a Load Balancing action of either Respond with fixed response or Override a current Load Balancer setting when the rule matches.
[Optional] Click Add another action.
After configuring a Load Balancing action, save the Load Balancing rule and configuration.
Save a Load Balancing rule and configuration
In the Create Custom Rule dialog, click Deploy. If unready to deploy your rule, click Save as draft.
The Custom Rules card displays, and your new rule is listed:
Click Next and review your changes:
Click Save.
When the save completes, the Load Balancing page displays.