大网数据广告活动
服务器运维问答

Adding Google Cloud Platform firewall rule for Vercel service

· 52CE 我爱测

I'm currently hosting my database on a Google Cloud Platform VM and the serverless API which connects to it is hosted on Vercel. I've managed to allow my IP in the GCP firewall but I'm having difficulties in allowing connections …

问题原文

原帖链接 · Leonardo Petrucci · CC BY-SA 4.0

I'm currently hosting my database on a Google Cloud Platform VM and the serverless API which connects to it is hosted on Vercel.

I've managed to allow my IP in the GCP firewall but I'm having difficulties in allowing connections to the the database form the API.

The GCP firewall doesn't accept any non-IP values for the firewall, so I can't simply add my hostname.

I own the domain the API is using, but the IP is obviously controlled by Vercel. I've tried pinging my domain to find out Vercel's IP (76.76.21.21) and added that to my firewall as an IP Range 76.76.21.21/32, but my API still times out while trying to connect.

I've allowed all connections from Postgres so I know it can't be that.

Any idea on how I can allow my API through the firewall?

已采纳解答

原帖链接 · Octavio Alamilla Galicia · CC BY-SA 4.0

I would recommend you to enable for a couple of hours the VPC and firewall logging in order to confirm the IP from Vercel API and then you can whitelist it, however I've found that Vercel deployments use dynamic IP addresses due to the dynamic nature of the platform, so, the IP will be changing all time.

You will must permit an open range in the GCP firewall rules 0.0.0.0/0 over the TCP/UDP ports you are using to consult your database in GCP, and to properly secure your database, they recommend using a randomly generated password, stored as an environment variable, at least 32 characters in length, and to rotate this password on a regular basis.

Please check the following links for further references.

[1]. https://vercel.com/knowledge/how-to-allowlist-deployment-ip-address [2]. https://cloud.google.com/vpc/docs/using-flow-logs#console [3]. https://cloud.google.com/vpc/docs/using-firewall-rules-logging#gcloud

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-01-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。