Create custom rules

Last updated Apr 16, 2026 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 proxy status of your traffic, you may have access to different fields for your load balancing rules. For more details, refer to Supported fields and expressions.

Example Workflow

  1. In the Cloudflare dashboard, go to the Load Balancing page. Go to Load Balancing ↗
  2. Edit an existing load balancer or create a new load balancer.
  3. From the Load Balancer workflow, select Custom Rules.
  4. Select Create Custom Rule.
  5. In the Field drop-down list, choose an HTTP property. For more details, refer to Supported fields.
  6. In the Operator drop-down list, choose an operator. For more details, refer to Operators.
  7. Enter the value to match. When the field is an ordered list, Value is a drop-down list. Otherwise, Value is a text input.
  8. (Optional) To create a compound expression using logical operators, select And or Or.
  9. For an action, choose Respond with fixed response or Override and enter additional details. For a full list of actions, refer to Actions.
  10. (Optional) Select Add another override.
  11. After you create your rule, select Save and Deploy or Save as Draft.
  12. Select Next and review your changes.
  13. Select Save to confirm.

Warning

To save a new load balancer rule, make sure to save both the rule and the overall load balancer configuration.

Note

In general, for non-terminating actions, the last change made by rules within the same phase will win (later rules can overwrite changes made by previous ones). However, for terminating actions, such as Block, Redirect, or any of the challenge actions, rule evaluation will stop and the action is executed immediately.

Load Balancer Custom Rules override the default Load Balancer settings, including pool and origin selection. These are non-terminating actions, so the last rule applied will override any prior rules.

Example use case

URL-based routing

If you want to host example.com/blog separately from your main website, for example, use the following custom rule.

When incoming requests match:

Field Operator Value
URI Path contains /blog

Then:

Action Options Value
Overrides Pools <BLOG_SERVER>

Was this helpful?

YesNo

On this page

Create custom rules - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/load-balancing/additional-options/load-balancing-rules/create-rules/#page","headline":"Create custom rules","description":"Create custom rules for load balancing behavior.","url":"https://developers.cloudflare.com/load-balancing/additional-options/load-balancing-rules/create-rules/","inLanguage":"en","image":"https://developers.cloudflare.com/load-balancing/additional-options/load-balancing-rules/create-rules/og.png?v=1bf93ed1b7d4080e","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Expression syntax for custom load balancing rules. title: Expressions image: https://developers.cloudflare.com/load-balancing/additional-options/load-balancing-rules/expressions/og.png?v=ca0dd2d29828ca32


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/load-balancing/llms.txt
Use this file to discover all available pages before exploring further.