Define a single origin rule using Terraform · Cloudflare Rules docs | Latest TMZ Celebrity News & Gossip | Watch TMZ Live Skip to content
Cloudflare Docs

Define a single origin rule using Terraform

Create an origin rule using Terraform to override the Host header, the resolved hostname, and the destination port of API requests.

The following example defines a single origin rule for a zone using Terraform. The rule overrides the Host header, the resolved hostname, and the destination port of API requests.

# Change origin for API requests
resource "cloudflare_ruleset" "http_origin_example" {
zone_id = "<ZONE_ID>"
name = "Change origin"
description = ""
kind = "zone"
phase = "http_request_origin"
rules {
ref = "change_api_origin"
description = "Change origin of API requests"
expression = "(http.request.uri.path matches \"^/api/\")"
action = "route"
action_parameters {
host_header = "example.net"
origin {
host = "example.net"
port = 8000
}
}
}
}

Use the ref field to get stable rule IDs across updates when using Terraform. Adding this field prevents Terraform from recreating the rule on changes. For more information, refer to Troubleshooting in the Terraform documentation.

Additional resources

For additional guidance on using Terraform with Cloudflare, refer to the following resources:

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.