Google Cloud App Engine 防火墙:简单地禁止所有并允许一个家庭 IP

Google Cloud App Engine Firewall: simply disallow all and allow a home IP

我已经阅读了很多关于 GCP 防火墙规则的文章,甚至还得到了一位开发运营人员的帮助,他无法理解为什么这些规则会阻止我的 App Engine Standard F1 [=22= 使用家庭 IP ]实例。

Priority T    Action    IP range
2000          Allow     XX.X.XX.XXX
2001          Allow     xxxx:xxxx:xxxx:xxx:xxxx:xxxx:xxxx:xxxx // my V6 IP
default       Deny      *

添加V6 IP时 我被允许访问但有奇怪的错误,例如。刷新页面显示路径错误:但浏览那里(或任何路径)加载正常。

Error: Not Found
The requested URL /feed was not found on this server.

没有 V6 IP(并且只有 V4 IP 允许规则)我无法访问该实例。

如何将自己的 IP 列入白名单以供访问?

正如评论中所述,从我所做的测试中,我可以确认首选通过 IPv6 而不是 IPv4 进行连接。

正如这个answer所指出的:

The first thing that a client determines is which protocols are available. ...It will then do a DNS lookup for both the A (IPv4 address) and AAAA (IPv6 address) records. If only one type is returned then it will use that. If both IPv4 and IPv6 addresses are returned the default behaviour depends a bit on the client software. Usually RFC 3484 is used.

According to the official standards it should prefer IPv6...

您可以通过检查日志中的 IP 地址来确认此行为,该 IP 地址到达您正在测试其防火墙规则的服务(例如 default 服务);服务,using the Logs Viewer.

查找与您提出的请求相匹配的日志条目(例如 / 根目录)。

要显示最新日志,请单击跳转到现在

httpRequest 字段 remoteIp 下,您可以检查您的计算机用于访问 App Engine 的 IP 地址。

为此,请删除您创建的规则并将默认规则更改为 Allow