Skip to content

[Rules] Add Rules documentation updates - #31670

Merged
ngayerie merged 4 commits into
productionfrom
ngayerie/DEE-3644
Jun 26, 2026
Merged

[Rules] Add Rules documentation updates#31670
ngayerie merged 4 commits into
productionfrom
ngayerie/DEE-3644

Conversation

@ngayerie

@ngayerie ngayerie commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Documentation updates covering undocumented behaviors, configuration guidance, and execution order details across Rules, ruleset engine, custom errors, and bulk redirects.

Changes

Topic File Change
http.host always raw src/content/fields/index.yaml Clarifies that Origin Rules host overrides are not reflected in http.host seen by other rule phases or Workers
Custom Errors vs default WAF block page rules/custom-errors/index.mdx Explicit clarification that Custom Error Rules don't override the default WAF block page (legacy Custom Pages system)
Custom error asset size limit rules/custom-errors/index.mdx Documents ~1.5 MB limit after inlining (base64 for binary resources; plain text for CSS/JS)
Bulk Redirects and WAF rules/url-forwarding/bulk-redirects/index.mdx Bulk Redirects run after WAF — firewall events still log even when request is later redirected
X-Real-IP workaround rules/transform/request-header-modification/index.mdx Use Snippets or Workers with a fetch() subrequest; value must be a valid IP; cross-zone subrequests are hard-overridden
x-forwarded-for re-added by proxy rules/transform/request-header-modification/index.mdx Cloudflare's backend proxy re-adds x-forwarded-for after all rule phases (not the cache service)
64 regex per rule limit ruleset-engine/rules-language/expressions/index.mdx New section documenting the maximum number of regular expressions per rule expression
Preserve query string rules/url-forwarding/bulk-redirects/reference/parameters.mdx Caution that enabling unconditionally drops the target URL's query string

Resolves DEE-3644

Document undocumented behaviors and configuration guidance across
Rules, ruleset engine, custom errors, and bulk redirects:

1. http.host always raw, even with Origin Rules host override
3. Custom Error Rules vs default WAF block page distinction
4. Custom error asset size limit (1.5 MB after base64 inlining)
5. Bulk Redirects execution order relative to WAF
6. X-Real-IP and other protected headers via Snippets/Workers subrequest
7. x-forwarded-for re-added by Cloudflare backend proxy after rule phases
11. Maximum 64 regular expressions per rule expression
12. Preserve query string overwrites target URL query string

Resolves DEE-3644
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/.github/CODEOWNERS @cloudflare/product-owners, @cloudflare/content-engineering, @kodster28
/src/content/docs/rules/ @pedrosousa, @cloudflare/appsec-reviewers, @elithrar, @smarsh-cf, @maurizioabba, @cloudflare/product-owners
/src/content/docs/ruleset-engine/ @pedrosousa, @cloudflare/appsec-reviewers, @elithrar, @maurizioabba, @cloudflare/product-owners
* @cloudflare/product-owners

@ask-bonk

ask-bonk Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review for PR #31670

Summary

This PR adds accurate, tightly-scoped documentation updates across 6 files (+32/-5) in the Rules, ruleset engine, and fields reference areas. The changes address previously undocumented limits, execution-order edge cases, and configuration guidance sourced from an internal wiki review.

Automated checks

✅ pnpm run check        — 0 errors
✅ pnpm run format:core:check — All files formatted correctly
✅ pnpm run lint         — No issues

Suggested labels

docs, rules, ruleset-engine


Inline review comments

1. src/content/fields/index.yaml — imprecise request.cf reference

Line 18 (new description):

"...this change is not reflected in the http.host value seen by other rule phases ..., [Cloudflare Workers], or the request.cf object."

Issue: request.cf is an object that holds Cloudflare-specific metadata (e.g. colo, country, tlsClientAuth). It does not directly expose an http.host property. Workers read the Host header via request.headers.get("host") or from the request URL. Referencing request.cf as something that "sees" http.host could confuse readers.

Suggestion: Consider tightening the wording. For example:

If you have configured [Origin Rules](/rules/origin-rules/) that change the hostname, this change is not reflected in the `http.host` value seen by other rule phases (such as custom rules, cache rules, or transform rules) or [Cloudflare Workers](/workers/). All rule phases and Workers evaluate against the original, unmodified host.

Alternatively, if the intent is to mention request.cf properties that are host-derived, make that explicit:

...or host-derived properties in the [`request.cf`](/workers/runtime-apis/request/#incomingrequestcfproperties) object.

2. src/content/docs/rules/custom-errors/index.mdx — section hierarchy

Line 92 (new heading):

## Size limits

Issue: The size limit applies only to custom error assets, not to Error Pages or inline custom error rule responses. As an H2, it sits at the same level as ## Custom Error Assets, ## Custom Error Rules, and ## Error Pages, which makes it look like a peer topic.

Suggestion: Consider nesting it as an H3 under ## Custom Error Assets:

### Size limits

This keeps the page structure accurate (the limit is asset-specific) while still surfacing it in the table of contents. Not a blocker.


3. src/content/docs/rules/custom-errors/index.mdx — minor style inconsistency

Line 43 (updated note):

"...A custom WAF response configured directly in a WAF rule action takes precedence over both an Error Page and a Custom Error Rule."

Observation: The original text used singular "custom error rules" (lowercase) at the end; the update uses "Custom Error Rule" (title case). Elsewhere on the page the feature is referred to as "Custom Error Rules" (title case, plural) and "custom error rule" (sentence case, singular). This single instance of singular title case is slightly inconsistent but acceptable.


What changed (file-by-file)

File Change
src/content/fields/index.yaml Expands http.host description to clarify that Origin Rules overrides are invisible to other phases, Workers, and request.cf.
src/content/docs/rules/custom-errors/index.mdx Clarifies that Custom Error Rules do not override the default WAF block page; adds new Size limits section documenting the ~1.5 MB asset limit.
src/content/docs/rules/url-forwarding/bulk-redirects/index.mdx New section explaining that Bulk Redirects run after WAF, so firewall events are still logged even for redirected requests.
src/content/docs/rules/transform/request-header-modification/index.mdx Adds workaround for setting protected headers (e.g. x-real-ip) via Snippets or Workers subrequests; corrects x-forwarded-for re-addition behavior from "cache service" to "backend proxy".
src/content/docs/ruleset-engine/rules-language/expressions/index.mdx New section documenting the 64-regular-expression limit per rule expression.
src/content/docs/rules/url-forwarding/bulk-redirects/reference/parameters.mdx Adds :::caution admonition that Preserve query string overwrites any query string present in the target URL.

Verdict

Approve with minor suggestions. The content is technically accurate, follows the style guide, and all CI checks pass. The request.cf wording in index.yaml is the only item that should be tightened before merge.

github run

- http.host: drop misleading request.cf reference (it holds metadata
  like colo/country, not the host header)
- custom-errors: nest 'Size limits' as H3 under 'Custom Error Assets'
  (the limit is asset-specific, not page-wide)
- custom-errors: align casing ('custom error rule' lowercase to match
  the rest of the page)
@ngayerie
ngayerie marked this pull request as ready for review June 25, 2026 20:53
@ngayerie
ngayerie requested review from a team and elithrar as code owners June 25, 2026 20:53
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review

✅ No issues found in commit 6c88c63.

Code Review

This code review is in beta and may not always be helpful — use your judgment.

✅ No code review issues found.

Style Guide Review

✅ No style-guide issues found.

Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.

mabba verified all 8 claims against fl2, rulesets-control-plane,
custom-pages, nginx-ssl, pingora-origin, and pingora-backend-router.
Items 1, 5, 6b, 7, and 11 are verified accurate. Three items needed
rewording:

- #4 base64 inlining: only images and binary resources (including
  those referenced from CSS via url()) are base64-encoded. CSS and
  JavaScript files are inlined as plain text inside <style>/<script>
  tags. Verified at custom-pages/collapsify/src/flattener.rs.

- #6 x-real-ip workaround: the protected-header restriction is enforced
  by an unconditional rewrite in fl2/lib/module-header-upstreaming.
  Workers and Snippets can influence the value via a fetch() subrequest,
  but the value must be a syntactically valid IP address, and cross-zone
  subrequests are hard-overridden to an internal Cloudflare address to
  prevent IP spoofing. Verified at fl2/bin/fl2/src/visitor.rs:140-145.

- #12 Preserve query string: the target's query string is *always*
  dropped when Preserve query string is enabled — unconditionally,
  even when the request has no query string. Verified at
  fl2/bin/fl2/src/rulesets/actions/redirect.rs:263-271.
@ngayerie ngayerie changed the title Add Rules documentation updates [Rules] Add Rules documentation updates Jun 26, 2026
Add Sam Marsh and Maurizio Abba as code owners for /src/content/docs/rules/.
Add Maurizio Abba as code owner for /src/content/docs/ruleset-engine/.
@ngayerie
ngayerie requested review from a team and kodster28 as code owners June 26, 2026 13:54
@ngayerie
ngayerie merged commit 20dc671 into production Jun 26, 2026
16 checks passed
@ngayerie
ngayerie deleted the ngayerie/DEE-3644 branch June 26, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants