Cloudflare Docs
Rules
Rules
Visit Rules on GitHub
Set theme to dark (⇧+D)

Request header modification examples

The following examples illustrate how to perform request header modifications with Transform Rules:

​​ Add an HTTP request header with a static value

The following HTTP Request Header Modification Rule adds a header named X-Source with a static value (Cloudflare) to the request:

Text in Expression Editor:

starts_with(http.request.uri.path, "/en/")

Selected operation under Modify request header: Set static

Header name: X-Source

Value: Cloudflare

​​ Add an HTTP request header with the current bot score

The following HTTP Request Header Modification Rule adds a header named X-Bot-Score with the current bot score to the request:

Text in Expression Editor:

starts_with(http.request.uri.path, "/en/")

Selected operation under Modify request header: Set dynamic

Header name: X-Bot-Score

Value: to_string(cf.bot_management.score)

​​ Remove an HTTP request header

The following HTTP Request Header Modification Rule removes the cf-connecting-ip header from the request:

Text in Expression Editor:

starts_with(http.request.uri.path, "/private/")

Selected operation under Modify request header: Remove

Header name: cf-connecting-ip