google-cloud-platform - 带有标签的防火墙规则无法正常工作

标签 google-cloud-platform

我已经创建了下面列出的防火墙规则来将我们的应用程序服务器连接到我们的 Postgres 服务器。但是,它似乎无法正常工作。

规则名称:postgresql

Network default

Source tags

http-server https-server app-server

Allowed protocols and ports

tcp:5432

Target tags

postgres db

仅启用该规则,带有“app-server”标签的服务器无法连接到带有“postgres”标签的 Postgres 服务器

我已确认此规则不起作用,并且问题与 Windows 防火墙或 Postgres 配置无关,因为如果我添加此规则,则应用服务器能够连接到 postgres 服务器。

规则名称:postgres-all

Network default

Source filter

Allow from any source (0.0.0.0/0)

Allowed protocols and ports

tcp:5432

Target tags

postgres

但是,我不想保留该防火墙规则,因为这会向所有内容打开 Postgres。我只想向我们的应用服务器打开 Postgres。

最佳答案

应用服务器使用哪个IP地址连接到数据库? 如果您不使用私有(private) IP(通常在默认网络上为 10.x.x.x),则需要源标记的规则不足以允许连接。

参见 https://cloud.google.com/compute/docs/networking#firewalls :

Note: Source tags cannot be used to allow access to an instance's external IP address. Because tags are associated with an instance, not an IP address, source tags can only be used to control traffic traveling from an instance inside the same network as the firewall.

关于google-cloud-platform - 带有标签的防火墙规则无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36724452/

相关文章:

python - 谷歌云存储python客户端AttributeError : 'ClientOptions' object has no attribute 'scopes' occurs after deployment

docker - Google Compute Engine容器端口已关闭

google-app-engine - Gradle:通过测试配置部署到Appengine的任务?

node.js - 如何使用 kubernetes-client 为 kubernetes 加载配置。谷歌云

docker - 无权推送到 GCR - 但我是该项目的所有者

visual-studio-code - 如何将 VSCode 连接到 GCP 实例

php - 如何使用 PHP 连接 Google Cloud SQL 并检索数据?

wordpress - 在 Google 搜索结果中显示的服务器 IP 地址而不是域

cloud - 将第二个内部/私有(private) IP 地址添加到谷歌云 vm 实例

python - 从谷歌云存储桶访问图像(类似于文件夹)