Skip to content

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

よく使うポリシー

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

次のポリシーは、ネットワークトラフィックを保護するためによく使われます。ネットワークポリシーは上から下の順で評価され、最初に一致したポリシーが適用されます。より具体的な Allow ポリシーを、広い Block ポリシーより上に置きます。

推奨ポリシーのベースラインは、インターネットトラフィックと SaaS アプリを保護する を参照してください。

ほかのセレクター、演算子、アクションの一覧は、ネットワークポリシーのページ を参照してください。

未承認のアプリケーションをブロックする

シャドーIT のリスクを抑えるため、一部の組織はユーザーが使えるウェブツールやアプリケーションを制限します。たとえば、次のポリシーは既知の AI ツールをブロックします。

セレクター 演算子 値 アクション
Application in Artificial Intelligence Block

次の API 例では、filters: ["l4"] はこのポリシーがネットワーク(レイヤー 4)ポリシーであることを示します。

Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Block unauthorized applications",
		"description": "Block access to unauthorized AI applications",
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "any(app.type.ids[*] in {25})",
		"identity": "",
		"device_posture": ""
	}'

ユーザー ID を確認する

ポリシーに ID ベースの条件 を追加して、ユーザーまたはグループ単位でアクセスを設定します。

セレクター 演算子 値 論理 アクション
Application in Salesforce And Block
User Group Names in Contractors
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Check user identity",
		"description": "Block access to Salesforce by temporary employees and contractors",
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "any(app.ids[*] in {606})",
		"identity": "any(identity.groups.name[*] in {\"Contractors\"})",
		"device_posture": ""
	}'

デバイスポスチャを強制する

特定のソフトウェアがインストールされていることや、その他の構成属性をデバイスに求めます。デバイスポスチャチェックを有効にする手順は、デバイスポスチャのセクション を参照してください。たとえば、デバイスのシリアル番号 のリストを使い、会社のデバイスから Cloudflare One Client で接続した場合だけアプリケーションへアクセスできるようにできます。

次の例では、デバイスのシリアル番号 のリストを使い、会社のデバイスから Cloudflare One Client で接続している場合にだけアプリケーションへアクセスできるようにできます。

セレクター 演算子 値 論理 アクション
SNI Domain is internalapp.com And Block
Passed Device Posture Checks not in Device serial numbers
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "All-NET-ApplicationAccess-Allow",
		"description": "Ensure access to the application comes from authorized WARP clients",
		"precedence": 70,
		"enabled": false,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "any(net.sni.domains[*] == \"internalapp.com\")",
		"device_posture": "not(any(device_posture.checks.passed[*] in {\"<DEVICE_SERIAL_NUMBERS_LIST_UUID>\"}))"
	}'

デバイスポスチャチェックの UUID を取得するには、List device posture rules エンドポイントを使います。

resource "cloudflare_zero_trust_gateway_policy" "all_net_applicationaccess_allow" {
  account_id  = var.cloudflare_account_id
  name        = "All-NET-ApplicationAccess-Allow"
  description = "Ensure access to the application comes from authorized WARP clients"
  precedence  = 70
  enabled     = false
  action      = "block"
  filters     = ["l4"]
  traffic     = "any(net.sni.domains[*] == \"internalapp.com\")"
	posture			=	"not(any(device_posture.checks.passed[*] in {\"${"$"}${cloudflare_zero_trust_list.allowed_devices_sn_list.id}\"}))"
}

セッション期間を強制する

一定時間が経過したあとに再認証を求めるには、Cloudflare One Client のセッション を設定します。

承認したトラフィックだけを許可する

ユーザーのアクセスを、HTTP ポリシー で構成した特定のサイトまたはアプリケーションだけに制限します。このパターンでは 2 つのポリシーを使います。HTTP/HTTPS トラフィックを許可する Allow ポリシーのあとに、それ以外を拒否する Block ポリシーを置きます。Allow ポリシーを Block ポリシーより上に置き、一致するトラフィックが包括的なブロックより先に許可されるようにします。

1. HTTP および HTTPS トラフィックを許可する

セレクター 演算子 値 論理 アクション
Detected Protocol is TLS And Allow
Destination Port in 80, 443
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow HTTP and HTTPS traffic",
		"description": "Restrict traffic to HTTP and HTTPS traffic",
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.detected_protocol == \"tls\" and net.dst.port in {80 443}",
		"identity": "",
		"device_posture": ""
	}'

2. その他のトラフィックをすべてブロックする

セレクター 演算子 値 アクション
Protocol in TCP, UDP Block
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Block all other traffic",
		"description": "Block all other traffic that is not HTTP or HTTPS",
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "net.protocol in {\"tcp\" \"udp\"}",
		"identity": "",
		"device_posture": ""
	}'

すべてのポートを検査するときに HTTPS トラフィックをフィルタリングする

組織がネットワークポリシーでデフォルトでトラフィックをブロックしており、すべてのポートで HTTP トラフィックを検査する 場合は、フィルタリングするために HTTP および TLS トラフィックを明示的に許可する必要があります。

セレクター 演算子 値 論理 アクション
Detected Protocol is TLS Or Allow
Detected Protocol is HTTP
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow on inspect all ports",
		"description": "Filter HTTPS traffic when using inspect all ports",
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.detected_protocol == \"tls\" or net.detected_protocol == \"http\"",
		"identity": "",
		"device_posture": ""
	}'

プロキシエンドポイントユーザーのプライベートネットワークアクセスを制限する

プロキシエンドポイントを使う場合、デフォルトではプロキシエンドポイントに追加したすべてのデバイスが、Cloudflare Tunnel 経由で接続した内部アプリケーションとサービスにアクセスできます。アクセスを制限してセキュリティを追加するには、次のポリシーを作成します。

送信元 IP プロキシエンドポイント

送信元 IP プロキシエンドポイント を使う場合、特定の送信元 IP からプロキシエンドポイント経由で接続するユーザーだけにアクセスを制限します。

1. 特定の送信元 IP からのプロキシエンドポイントトラフィックを許可する

セレクター 演算子 値 論理 アクション
Proxy Endpoint in Proxy Endpoint And Allow
Source IP in 203.0.113.0/24 And
Destination IP in 10.0.0.0/8
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow proxy endpoint traffic from specific source IPs",
		"description": "Allow traffic from proxy endpoint users with specific source IPs to reach private network",
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.proxy_endpoint.ids[*] in {\"<PROXY_ENDPOINT_ID>\"} and net.src.ip in {203.0.113.0/24} and net.dst.ip in {10.0.0.0/8}",
		"identity": "",
		"device_posture": ""
	}'

<PROXY_ENDPOINT_ID> を、プロキシエンドポイント ID に置き換えます。

2. プライベートネットワーク宛てのその他のプロキシエンドポイントトラフィックをブロックする

セレクター 演算子 値 論理 アクション
Proxy Endpoint in Proxy Endpoint And Block
Destination IP in 10.0.0.0/8
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Block all other proxy endpoint traffic",
		"description": "Block any other proxy endpoint traffic from accessing the private network",
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "net.proxy_endpoint.ids[*] in {\"<PROXY_ENDPOINT_ID>\"} and net.dst.ip in {10.0.0.0/8}",
		"identity": "",
		"device_posture": ""
	}'

<PROXY_ENDPOINT_ID> を、プロキシエンドポイント ID に置き換えます。

認可プロキシエンドポイント

認可プロキシエンドポイント を使う場合、特定の送信元 IP から接続するユーザーだけにアクセスを制限して、セキュリティを追加します。ユーザー認証情報が漏洩しても、不正アクセスを防げます。

1. 特定の送信元 IP からのプロキシエンドポイントトラフィックを許可する

セレクター 演算子 値 論理 アクション
Proxy Endpoint in Proxy Endpoint And Allow
Source IP in 203.0.113.0/24 And
Destination IP in 10.0.0.0/8
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow authorized proxy endpoint traffic from specific source IPs",
		"description": "Allow traffic from authorization proxy endpoint users with specific source IPs to reach private network",
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.proxy_endpoint.ids[*] in {\"<PROXY_ENDPOINT_ID>\"} and net.src.ip in {203.0.113.0/24} and net.dst.ip in {10.0.0.0/8}",
		"identity": "",
		"device_posture": ""
	}'

<PROXY_ENDPOINT_ID> を、プロキシエンドポイント ID に置き換えます。

2. プライベートネットワーク宛てのその他のプロキシエンドポイントトラフィックをブロックする

セレクター 演算子 値 論理 アクション
Proxy Endpoint in Proxy Endpoint And Block
Destination IP in 10.0.0.0/8
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Block all other authorized proxy endpoint traffic",
		"description": "Block any other authorization proxy endpoint traffic from accessing the private network",
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "net.proxy_endpoint.ids[*] in {\"<PROXY_ENDPOINT_ID>\"} and net.dst.ip in {10.0.0.0/8}",
		"identity": "",
		"device_posture": ""
	}'

<PROXY_ENDPOINT_ID> を、プロキシエンドポイント ID に置き換えます。

プライベートネットワークへのアクセスを制限する

Cloudflare Tunnel 経由で接続したリソースへのアクセスを制限します。

次の例は 2 つのポリシーで構成されます。1 つ目は特定のユーザーにアプリケーションへの到達を許可し、2 つ目はその他のトラフィックをすべてブロックします。

1. 従業員を許可する

セレクター 演算子 値 論理演算 アクション
Destination IP in 10.0.0.0/8 And Allow
User Email matches regex .*@example.com
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow company employees",
		"description": "Allow any users with an organization email to reach the application",
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in {10.0.0.0/8}",
		"identity": "identity.email matches \".*@example.com\"",
		"device_posture": ""
	}'

2. その他のユーザーをブロックする

セレクター 演算子 値 アクション
Destination IP in 10.0.0.0/8 Block
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Block everyone else",
		"description": "Block any other users from accessing the application",
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in {10.0.0.0/8}",
		"identity": "",
		"device_posture": ""
	}'

IP アドレスを上書きする

特定の IP アドレス宛てのトラフィックを、別の IP アドレスで上書きします。

セレクター 演算子 値 論理 アクション
Destination IP in 203.0.113.17 And Network Override
Destination Port is 80
Override IP Override Port
1.1.1.1 80
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Override example.com with 1.1.1.1",
		"description": "Override a site'\''s IP address with another IP",
		"enabled": true,
		"action": "l4_override",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in {203.0.113.17} and net.dst.port == 80",
		"identity": "",
		"device_posture": "",
		"rule_settings": {
				"l4override": {
						"ip": "1.1.1.1",
						"port": 80
				},
				"override_host": "",
				"override_ips": null
		}
	}'

役に立ちましたか?