mcpField
A
app-platform-networking

app-platform-networking

github.com/digitalocean-labs云与 DevOps3892 次安装3 天前更新
代码仓库

关于 app-platform-networking

用于配置 DigitalOcean App Platform 网络的技能,面向需要设置域名、路由或服务连接的开发者。内容涵盖 CORS、VPC 和出口 IP,并提供配置参考与故障排查指南。

主要功能

  1. 01自定义域名与 DNS 配置
  2. 02路径及子域名路由
  3. 03CORS 配置参考
  4. 04VPC 与可信来源设置
  5. 05专用出口 IP 配置
  6. 06网络问题排查指南

适用场景

  1. 01为多个服务配置同域名路径
  2. 02设置跨子域名 API 请求
  3. 03通过 VPC 安全连接数据库
  4. 04为防火墙配置出口 IP 白名单

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/digitalocean-labs/do-app-platform-skills --skill app-platform-networking

安装后在 Claude Code 中输入/app-platform-networking确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

README.md
reference/
complete-patterns.md
cors-configuration.md
domains-dns.md
ingress-routing.md
static-ips-egress.md
vpc-trusted-sources.md

详细介绍

应用平台网络技能

配置域名、路由、CORS、VPC、静态 IP 和服务间通信。

快速决策

What networking do you need?
├── Custom domain?
│   └── YES → See domains-dns.md
│
├── Multiple services on one domain?
│   ├── Different paths (/api, /app) → Path-based routing
│   └── Different subdomains (api.*, app.*) → Subdomain routing
│
├── Frontend calling API across origins?
│   └── YES → CORS configuration
│
├── Secure database connectivity?
│   └── YES → VPC + trusted sources
│
└── Need static outbound IP?
    └── YES → Dedicated egress

适用场景

场景是否需要此技能
仅使用入门域名否
自定义域名是
多个服务使用不同路径是
多个子域名是
跨子域名 API 调用(CORS)是
通过 VPC 安全访问数据库是
防火墙允许列表(出站 IP)是

快速参考

功能App Spec 字段示例
自定义域名domains[].domainexample.com
通配符domains[].wildcardtrue
路径路由ingress.rules[].match.path.prefix/api
子域名路由ingress.rules[].match.authority.exactapi.example.com
CORSingress.rules[].cors参见参考文档
VPCvpc.idUUID
专用出站 IPegress.typeDEDICATED_IP

基于路径的路由(快速入门)

ingress:
  rules:
    - component: { name: api }
      match: { path: { prefix: /api } }

    - component: { name: frontend }
      match: { path: { prefix: / } }

规则顺序很重要: 将特定规则放在前面。

完整指南:参见 ingress-routing.md


子域名路由(快速入门)

domains:
  - domain: example.com
    type: PRIMARY
    wildcard: true
    zone: example.com

ingress:
  rules:
    - component: { name: api }
      match:
        authority: { exact: api.example.com }
        path: { prefix: / }

    - component: { name: app }
      match:
        authority: { exact: app.example.com }
        path: { prefix: / }

完整指南:参见 domains-dns.md


CORS(快速入门)

ingress:
  rules:
    - component: { name: api }
      match: { path: { prefix: /api } }
      cors:
        allow_origins:
          - exact: https://app.example.com
        allow_methods: [GET, POST, PUT, DELETE, OPTIONS]
        allow_headers: [Content-Type, Authorization]
        allow_credentials: true

注意: 使用 allow_credentials: true 时,仅使用精确来源(不要使用正则表达式)。

完整指南:参见 cors-configuration.md


VPC + 可信来源(快速入门)

vpc:
  id: your-vpc-uuid

VPC CIDR 允许列表(推荐):

doctl vpcs get $VPC_ID --format IPRange  # e.g., 10.126.0.0/20
doctl databases firewalls append $CLUSTER_ID --rule ip_addr:10.126.0.0/20
设置可信来源规则
仅公开访问app:$APP_ID
已启用 VPCip_addr:<vpc-cidr>

重要: 即使使用 VPC,可绑定变量仍会返回公共主机名。请使用私有 URL:

doctl databases connection --private <cluster-id> --format URI

完整指南:参见 vpc-trusted-sources.md


参考文件


常见问题

问题解决方法
域名无法解析检查 DNS 记录,并等待最多 72 小时完成传播
SSL 证书错误添加 letsencrypt.org 和 pki.goog 的 CAA 记录
CORS 预检失败将 OPTIONS 添加到 allow_methods
VPC 连接被拒绝使用 VPC CIDR 允许列表,而不是基于应用的规则
请求被错误组件处理调整规则顺序(特定规则放在前面)

与其他技能集成

  • → designer:向 app spec 添加域名/入口配置
  • → troubleshooting:排查 DNS、CORS、VPC 问题
  • → postgres:为托管数据库配置 VPC 连接
  • → deployment:部署网络配置更改

评论

支持 Markdown