PrivateLink
PrivateLink 仅对团队和企业客户可用。如果你想为只读副本创建 PrivateLink 连接,请联系支持。
🌐 PrivateLink is available only to Team and Enterprise customers. Contact support if you would like to create a PrivateLink connection for a read-only replica.
PrivateLink 使用 AWS VPC Lattice 在你的 AWS VPC 和 Supabase 数据库之间提供企业级的私有网络连接。这样可以通过创建一个安全的私有连接来避免暴露在公共互联网中,让你的数据库流量保持在 AWS 网络骨干内。
🌐 PrivateLink provides enterprise-grade private network connectivity between your AWS VPC and your Supabase database using AWS VPC Lattice. This eliminates exposure to the public internet by creating a secure, private connection that keeps your database traffic within the AWS network backbone.
启用 PrivateLink 后,数据库连接永远不会通过公共互联网,这样可以关闭面向公众的连接,同时为敏感工作负载提供额外的安全和合规保护。这种基础设施级别的安全功能帮助组织满足严格的数据治理要求,并减少潜在的攻击途径。
🌐 By enabling PrivateLink, database connections never traverse the public internet, enabling the disablement of public facing connectivity and providing an additional layer of security and compliance for sensitive workloads. This infrastructure-level security feature helps organizations meet strict data governance requirements and reduces potential attack vectors.
PrivateLink 的工作原理 #
🌐 How PrivateLink works
Supabase PrivateLink 是一个组织级别的配置。它的工作原理是将 VPC Lattice 资源配置 分享给你每个 Supabase 项目的任意数量的 AWS 账户。连接可以通过将资源配置关联到 PrivateLink 端点,或者一个 VPC Lattice 服务网络 来实现。这意味着:
🌐 Supabase PrivateLink is an organisation level configuration. It works by sharing a VPC Lattice Resource Configuration to any number of AWS Accounts for each of your Supabase projects. Connectivity can be achieved by either associating the Resource Configuration to a PrivateLink endpoint, or a VPC Lattice Service Network. This means:
- 数据库流量只通过私有 AWS 基础设施
- 网络隔离能增强安全性
- 通过消除公开暴露来最小化攻击面
连接架构从公共互联网路由变成了通过 AWS 安全网络骨干的专用私有通道。
🌐 The connection architecture changes from public internet routing to a dedicated private path through AWS's secure network backbone.
Supabase PrivateLink 支持在端口 5432 上直接连接数据库,以及在端口 6543 上通过 PgBouncer 连接。它不支持其他 Supabase 服务,比如 API、存储、身份验证或实时功能。这些服务将继续通过公共互联网连接运行。
🌐 Supabase PrivateLink supports direct database connections on port 5432 and PgBouncer connections on port 6543. It does not support other Supabase services like API, Storage, Auth, or Realtime. These services will continue to operate over public internet connections.
要求 #
🌐 Requirements
要在你的 Supabase 项目中使用 PrivateLink:
🌐 To use PrivateLink with your Supabase project:
- 团队或企业版 Supabase 订阅
- 与你的 Supabase 项目在同一地区的 AWS VPC
- 接受资源共享以及创建和管理端点的适当权限
入门 #
🌐 Getting started
步骤 1:添加 AWS 账户 #
🌐 Step 1: Add AWS account
进入你项目的集成部分来设置 PrivateLink:
🌐 Navigate to your project's Integrations section to set up PrivateLink:
- 去你的 Supabase 项目仪表板
- 导航到 设置 > 集成
- 找到 AWS PrivateLink 部分
- 点击 添加账户
- 输入你的 AWS 账户 ID
- 为账户提供描述(推荐)
- 点击 添加账户 提交
提交后,Supabase 会为你的项目创建一个 VPC Lattice 资源配置,并向指定的 AWS 账户 ID 发送 AWS 资源共享。这个过程可能需要几分钟。一旦完成,账户会显示“已就绪”状态,表示资源共享已发送到你的 AWS 账户并准备被接受。
🌐 After submission, Supabase creates a VPC Lattice Resource Configuration for your project and sends an AWS Resource Share to the specified AWS Account ID. This process may take a few moments. Once complete, the account will show a "Ready" status, indicating that the resource share has been sent to your AWS account and is ready to be accepted.
步骤 2:接受资源共享 #
🌐 Step 2: Accept resource share
Supabase 会向你发送一个包含你项目的 VPC Lattice 资源配置的 AWS 资源共享。要接受这个共享:
🌐 Supabase will send you an AWS Resource Share containing the VPC Lattice Resource Configurations for your projects. To accept this share:
- 登录你的 AWS 管理控制台,确认你所在的 AWS 区域是你的 Supabase 项目所在的区域
- 进入 AWS 资源访问管理器(RAM)控制台
- 去与我共享 > 资源共享
- 从 Supabase 找到资源共享。
- 资源共享的格式是
sspl-[project_ref]-[random alphanumeric string]
- 资源共享的格式是
- 点击资源共享名称查看详细信息。查看资源共享列表——它应该只包含类型为 vpc-lattice:ResourceConfiguration 的资源。
- 点击 接受资源共享
- 在对话框中确认接受
接受后,你会在 RAM 控制台的 与我共享 > 共享资源 部分以及 VPC 控制台的 PrivateLink 和 Lattice > 资源配置 部分看到资源配置。
🌐 After accepting, you'll see the resource configurations appear in your Shared with me > Shared resources section of the RAM console and the PrivateLink and Lattice > Resource configurations section of the VPC console.
步骤 3:配置安全组 #
🌐 Step 3: Configure security groups
确保你的安全组允许在适当端口上的流量:
🌐 Ensure your security groups allow traffic on the appropriate ports:
- 导航到 VPC 控制台 > 安全组
- 通过点击 创建安全组 为端点或服务网络创建一个新的安全组
- 给你的安全组起个描述性的名字,并选择合适的 VPC
- 为你使用的连接模式添加入站规则:
- 直接连接:Postgres(TCP,端口
5432) - PgBouncer 连接:自定义 TCP(端口
6543) - 如果你同时使用直接连接和 PgBouncer 连接,两个规则都要加上
- 将目标设置为适合你网络的地方(例如,你的 VPC 子网或者你的应用实例的安全组)
- 直接连接:Postgres(TCP,端口
- 点击 创建安全组 来完成安全组的创建
步骤4:建立连接 #
🌐 Step 4: Create connection
在你的 AWS 账户中,你有两种方式可以建立连接:
🌐 In your AWS account, you have two options to establish connectivity:
选项 A:创建 PrivateLink 终端节点 #
🌐 Option A: Create a PrivateLink endpoint
- 在你的 AWS 账户里打开 VPC 控制台
- 在左侧边栏中点击Endpoints
- 点击 创建端点
- 给你的端点起个名字(比如
supabase-privatelink-[project name]) - 在类型下,选择 资源
- 在 资源配置 部分选择合适的资源配置
- 资源配置名称的格式将是
[organisation]-[project-ref]-rc
- 资源配置名称的格式将是
- 从下拉菜单中选择你的 VPC。这应该与你在第 3 步中为安全组选择的 VPC 一致
- 如果你想使用 DNS 记录而不是终端的 IP 地址,请启用 启用 DNS 名称 选项
- 为你的网络选择合适的子网
- AWS会在你选择的每个子网中为你提供一个私有ENI
- IP 地址类型应设置为 IPv4。选择你在第 3.11 步创建的安全组。点击 创建端点。创建后,你将在 端点 部分看到状态为“可用”的端点。关于连接性:
- 终端的 IP 地址会在终端详情的 子网 部分列出
- 如果你在第8步启用了它,DNS记录会出现在端点详情的 关联 部分的 DNS 名称 字段里
选项 B:将资源配置附加到现有的 VPC 网格服务网络 #
🌐 Option B: Attach resource configuration to an existing VPC lattice service network
- 仅当你已有现有的 VPC Lattice 服务网络时才推荐使用此方法
- 在你的 AWS 账户中打开 VPC Lattice 控制台
- 在左侧边栏中进入服务网络,然后选择你的服务网络
- 在服务网络详情中,进入资源配置关联标签
- 点击 创建关联
- 从下拉菜单中选择合适的资源配置
- 点击 保存更改
- 创建后,你会在你的服务网络的资源配置部分看到资源配置,状态为“活动”
- 要连接的话,点击关联详情,域名会显示在 DNS 条目 部分
步骤5:测试连接 #
🌐 Step 5: Test connectivity
确认你的 VPC 私有连接是否正常工作:
🌐 Verify the private connection is working correctly from your VPC:
- 在你的 VPC 中启动一个 EC2 实例或使用已有的实例
- 安装一个 Postgres 客户端(比如
psql) - 使用私有端点测试连接:
1# Direct connection (Postgres)2psql "postgresql://[username]:[password]@[private-endpoint]:5432/postgres"34# PgBouncer connection5psql "postgresql://[username]:[password]@[private-endpoint]:6543/postgres"你应该能看到成功的连接,没有任何公共互联网流量。
🌐 You should see a successful connection without any public internet traffic.
步骤6:更新应用 #
🌐 Step 6: Update applications
配置你的应用以使用私有连接详情:
🌐 Configure your applications to use the private connection details:
- 把你的数据库连接字符串更新成使用私有端点主机名
- 确保你的应用实例在同一个VPC或已连接的VPC里
- 更新任何数据库连接池配置
- 彻底测试应用的连接
示例连接字符串更新:
🌐 Example connection string updates:
1# Direct connection (Postgres)2# Before (public)3postgresql://user:pass@db.[project-ref].supabase.co:5432/postgres45# After (private)6postgresql://user:pass@your-private-endpoint.vpce.amazonaws.com:5432/postgres78# PgBouncer connection9# Before (public)10postgresql://user:pass@db.[project-ref].supabase.co:6543/postgres1112# After (private)13postgresql://user:pass@your-private-endpoint.vpce.amazonaws.com:6543/postgres第7步:限制公共数据库访问(可选) #
🌐 Step 7: Restrict public database access (optional)
为了最大的安全性,你可以在项目设置中限制公共数据库访问:
🌐 For maximum security, you can restrict public database access in your project settings:
- 前往 数据库 > 设置
- 在 网络限制 中,启用 限制所有访问
- 在启用此设置之前,确保所有应用、监控和备份工具都使用私有端点
限制 #
🌐 Limitations
- 只读副本:要通过只读副本建立 PrivateLink,请联系你的客户经理。
- 功能演变:随着我们不断完善产品,设置过程和功能可能会有所变化
兼容性 #
🌐 Compatibility
PrivateLink 终端节点是一个三层解决方案,所以它的行为类似标准的 Postgres 终端节点,允许你通过以下方式连接:
🌐 The PrivateLink endpoint is a layer 3 solution so behaves like a standard Postgres endpoint, allowing you to connect using:
- 使用标准工具直接连接 Postgres
- 第三方数据库工具和ORM(带有合适的路由)
下一步 #
🌐 Next steps
准备好通过 PrivateLink 提升你的数据库安全性了吗?联系我们的企业团队讨论你的需求并开始设置流程。
🌐 Ready to enhance your database security with PrivateLink? Contact our Enterprise team to discuss your requirements and begin the setup process.
我们的支持团队会指导你完成配置,并确保你的私有数据库连接符合你的安全和性能要求。
🌐 Our support team will guide you through the configuration and ensure your private database connectivity meets your security and performance requirements.