Skip to content

非公式 / UnofficialCloudflare, Inc. 非提携。アカウント情報は入力しないでください。Not affiliated with Cloudflare, Inc. Do not enter Cloudflare credentials here.Official docsこのサイトについてプライバシー

Gateway ポリシー式

最終更新 Markdown で表示Agent セットアップ

Gateway ポリシーは、wirefilter ベースの式言語を使って、セレクター(条件)に対してトラフィックを照合します。この構文は、WAF、Rules、その他の Cloudflare 製品が使う Rules language に似ていますが、同じではありません。違いの詳細は Gateway と Ruleset Engine を参照してください。

式の構文

Gateway の式は、次のパターンに従います。

<field> <operator> <value>

例:

dns.fqdn == "example.com"
http.request.host == "api.example.com"
identity.email == "[email protected]"

演算子

Gateway は次の演算子に対応しています。

Operator Name Example
== 等しい dns.fqdn == "example.com"
!= 等しくない http.request.host != "blocked.com"
in 値が集合に含まれる net.dst.port in {80 443}
matches 正規表現に一致 http.request.host matches ".*\\.example\\.com"
> より大きい http.upload.file.size > 10
>= 以上 http.download.file.size >= 100
< より小さい http.upload.file.size < 50
<= 以下 http.download.file.size <= 200

論理演算子

複数の条件を論理演算子で組み合わせます。

Operator Name Example
and 論理積(AND) dns.fqdn == "example.com" and identity.email == "[email protected]"
or 論理和(OR) net.dst.port == 80 or net.dst.port == 443
not 論理否定(NOT) not(identity.email == "[email protected]")

配列の扱い

一部の Gateway フィールドは配列(複数の値)を返します。配列のいずれかの要素が条件を満たすときに一致させるには、any() 関数を使います。

any(http.request.uri.content_category[*] in {17 85 102})
any(identity.groups[*].name in {"Engineering" "Security"})
any(http.request.domains[*] == "example.com")

[*] 記法は、関数が配列のすべての要素を評価することを示します。

リストの扱い

式では、リストの UUID を使って リスト を参照できます。

http.request.host in $<LIST_UUID>
any(http.request.domains[*] in $<LIST_UUID>)

リストの UUID を確認するには、Zero Trust で My Team > Lists を開き、リストを選びます。UUID はブラウザーの URL に表示されます。

よく使うフィールドのパターン

Gateway の各ポリシータイプには、利用できるフィールドのセットがあります。次の表は、各ポリシータイプが使うフィールド接頭辞です。

Policy type Field prefix Example fields
DNS dns. dns.fqdn、dns.content_category、dns.src_ip
HTTP http. http.request.host、http.request.uri、http.request.domains
Network net. net.dst.ip、net.dst.port、net.src.ip
Identity identity. identity.email、identity.groups、identity.name
Device posture device_posture. device_posture.checks.passed

各ポリシータイプで利用できるフィールドの完全な一覧は、このページ先頭のセレクタードキュメントを参照してください。

式の例

DNS ポリシーでドメインをブロックする

dns.fqdn == "example.com"

HTTP ポリシーで複数のコンテンツカテゴリをブロックする

any(http.request.uri.content_category[*] in {17 85 102})

特定のユーザーグループからのトラフィックを許可する

any(identity.groups[*].name in {"Engineering"})

Network ポリシーで宛先 IP 範囲へのトラフィックをブロックする

net.dst.ip in {10.0.0.0/8}

アイデンティティ条件とトラフィック条件を組み合わせる

http.request.host == "internal.example.com" and identity.email matches ".*@company.com"

Gateway と Ruleset Engine

次の表は、Ruleset Engine がサポートする Rules language と Gateway ポリシー式の主な違いをまとめたものです。

Ruleset Engine Gateway
製品 WAF、Transform Rules、Cache Rules、Configuration Rules DNS、HTTP、Network、Egress、Resolver ポリシー
フィールドの例 http.request.uri.path、cf.bot_management.score、ip.src dns.fqdn、http.request.host、identity.email
アイデンティティフィールド 利用不可 利用可能(例: identity.email、identity.groups)
DNS フィールド 利用不可 利用可能(例: dns.fqdn、dns.content_category)
ドキュメント Rules language Traffic policies

関連リソース

役に立ちましたか?