【发布时间】:2021-01-30 02:52:33
【问题描述】:
我读到这篇文章: How to properly configure VPC firewall for App Engine instances? 这对一开始就设置防火墙有很大帮助——所以对于那些发现这个并且正在努力解决这个问题的人——请继续。 https://cloud.google.com/appengine/docs/flexible/python/using-shared-vpc 是一个很好的参考,因为有些帐户需要“添加”权限才能让魔法发生。
我的问题 - 我在 AppEngine 中运行了两个容器化服务,一个是默认(网站),一个是 API。我已将 API 配置为在与默认创建的 VPC/子网分开的 VPC/子网中运行。我没有对直接挂在 App Engine 设置上的防火墙设置进行任何更改,因为这些设置是全局的,并且不允许您针对特定实例 - 并且网站需要保持公开状态,而 API 应该需要白名单访问权限。
dispatch.yaml 用于配置子域映射
dispatch:
- url: "www.example.com/*"
service: default
- url: "api.example.com/*"
service: api
API yaml 设置:
network:
name: projects/mycool-12345-project/global/networks/apis
subnetwork_name: apis
instance_tag: myapi
创建 VPC 网络
name - apis
subnet name - apis
creation mode - automatic
routing mode - regional
dns policy - none
max MTU - 1460
添加防火墙规则
allow 130.211.0.0/22, 35.191.0.0/16 port 10402,8443 tag aef-instance priority 1000
deny 0.0.0.0/0 port 8443 tag myapi priority 900
allow 130.211.0.0/22, 35.191.0.0/16 port 8443 tag myapi priority 800
这可行 - 但我无法指定“白名单 IP”。
如果我执行以下操作并禁用“允许 130 / 35 个网络 8443/800”
allow my.ip.number.ihave port 8443 tag myapi priority 800
它永远不会违反这条规则,它永远不会识别我的 IP。
什么变化/您如何在 VPC 中配置防火墙,以便它接收公共 IP。当我查看日志时,它说它拒绝了我的请求,因为我的 IP 地址是 35.x.x.x。
【问题讨论】:
标签: google-app-engine firewall whitelist vpc