コンテンツにスキップ

Terraformを使用して単一のオリジンルールを定義する

Terraformを使用して、`Host`ヘッダー、解決されたホスト名、およびAPIリクエストの宛先ポートを上書きするオリジンルールを作成します。

以下の例は、Terraformを使用してゾーンの単一のオリジンルールを定義します。このルールは、Hostヘッダー、解決されたホスト名、およびAPIリクエストの宛先ポートを上書きします。

# APIリクエストのオリジンを変更する
resource "cloudflare_ruleset" "http_origin_example" {
zone_id = "<ZONE_ID>"
name = "オリジンを変更"
description = ""
kind = "zone"
phase = "http_request_origin"
rules {
action = "route"
action_parameters {
host_header = "example.net"
origin {
host = "example.net"
port = 8000
}
}
expression = "(http.request.uri.path matches \"^/api/\")"
description = "APIリクエストのオリジンを変更"
enabled = true
}
}

Additional resources

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