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.fqdn == "example.com"any(http.request.uri.content_category[*] in {17 85 102})any(identity.groups[*].name in {"Engineering"})net.dst.ip in {10.0.0.0/8}http.request.host == "internal.example.com" and identity.email matches ".*@company.com"次の表は、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 |