跳转到内容
搜索文档

更新日志

Cloudflare 的最新更新与改进。

Back to all posts

使用 Gateway 策略过滤 Workers 的公共互联网流量

使用 VPC 网络(VPC Network) 绑定(binding)与 network_id: "cf1:network" 的 Workers 现在可以通过 Cloudflare Gateway 出口到公共互联网目标。这意味着您现有的 Zero Trust 流量策略 —— DNS、HTTP、网络和出口(egress)—— 将延伸到源自您的 Workers 的流量,就像今天对 WARP 用户所做的那样。

  1. Calls env.EGRESS.fetch()

  2. VPC binding
  3. Public Internet

    Any public hostname or IP

Gateway logsDNSHTTPNetwork

您默认获得的内容:

  • 可见性。 Worker 出口流量与您的其他流量一起显示在 Gateway DNSHTTP网络 日志中,以便您可以审计您的 Workers 在何时调用了什么。
  • 强制执行。 任何其选择器与 Worker 请求相匹配的现有 Gateway 策略都将适用 —— 包括允许/阻止列表、DNS 类别过滤和 HTTP 目标规则。如果您已经为您的员工屏蔽了某个类别,您的 Workers 将继承该屏蔽。
{
	"vpc_networks": [
		{
			"binding": "EGRESS",
			"network_id": "cf1:network",
			"remote": true,
		},
	],
}
[[vpc_networks]]
binding = "EGRESS"
network_id = "cf1:network"
remote = true
// Egress to a public destination — subject to your Gateway policies and logged
const response = await env.EGRESS.fetch("https://api.example.com/data");
// Egress to a public destination — subject to your Gateway policies and logged
const response = await env.EGRESS.fetch("https://api.example.com/data");

有关配置选项,请参阅 VPC 网络(VPC Networks)。有关策略编写,请参阅 Cloudflare Gateway 流量策略