如何阻止 GCP 中负载均衡器旁边的虚拟机的流量

发布于 2025-01-20 17:39:47 字数 196 浏览 6 评论 0 原文

我在 GCP 中的虚拟机上遇到来自中国和美洲的流量问题,我已经设置了 GCP Cloud Armor 以阻止来自智利以外的任何流量。但这只是通过网站 url 输入的流量,但如果您输入 ip,您仍然可以输入。这推高了云费用。

如何将虚拟机设置为仅接受来自负载均衡器的流量? 谢谢 !

编辑: 我正在使用非托管实例组。

I'm having problems with traffic from China and Americas hitting my VM's in GCP, I already setup GCP Cloud Armor to block any traffic from outside Chile. But this is only the traffic than enter vía the site url, but if you type the ip u can enter anyways. This is driving up the cloud bill.

How I setup my vm's to only accept the traffic from the load balancer ?
Thanks !

EDIT:
I'm using unmanaged instance group.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻想少年梦 2025-01-27 17:39:47

Google Cloud Armour安全策略具有拒绝规则,该规则阻止了IP地址和特定区域的流量。

您可以使用Google Cloud Console,Google Cloud CLI或REST API来配置Google Cloud Armor安全策略,规则和表达式。当您使用GCLOUD CLI创建安全策略时,请使用-Type标志来指定安全策略是后端安全策略还是边缘安全策略。

以下命令添加了一个规则,以阻止中国和美国指定IP范围内的请求:

gcloud compute security-policies rules create 1000 \
 --security-policy my-policy \
 --expression ("origin.region_code == 'CN' || 'US') &&  inIpRange(origin.ip, '1.2.3.0/24')" \
 --action "deny-403" \
 --description "country and IP block"

请参阅此文档有关使用Google Cloud Cloud Armor阻止特定区域的流量的更多信息,并参考此文档对于区域代码。

The Google Cloud Armor security policy has a deny rule that blocks traffic from the IP address and from the particular regions.

You can configure Google Cloud Armor security policies, rules, and expressions by using the Google Cloud Console, the Google Cloud CLI, or the REST API. When you use the gcloud CLI to create security policies, use the --type flag to specify whether the security policy is a backend security policy or an edge security policy.

The following command adds a rule to block requests from the region China and America that are in the specified IP range:

gcloud compute security-policies rules create 1000 \
 --security-policy my-policy \
 --expression ("origin.region_code == 'CN' || 'US') &&  inIpRange(origin.ip, '1.2.3.0/24')" \
 --action "deny-403" \
 --description "country and IP block"

Refer this documentation for more information on blocking traffic from specific regions using Google Cloud Armor and refer to this documentation for region codes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文