为 Google Cloud Endpoints 启用防火墙

问题描述

我有一个 API,它部署在 GKE 中并通过带有 ESPv2 的 Cloud Endpoints 公开。到目前为止,我已经使用 API 密钥保护了 API,并且可以通过互联网获得它。是否有任何可能的方法可以应用某些防火墙规则,即端点只能从特定网络或 IP 范围使用?

解决方法

您需要在 ESPv2 服务前定义一个 ingress with a global HTTPS load balancer

然后,您可以激活 Cloud Armor and set policies to filter the IPs 和您想要的范围