customDomains 字段

参数名必填类型参数描述
domainNameTrueString域名,如果是 auto 取值,系统则会默认分配域名
protocolTrueString协议,取值:HTTP, HTTP,HTTPS
routeConfigsTrueList<Struct>路由
certConfigFalseStruct域名证书
certIdFalseNumber域名证书 ID
tlsConfigFalseStructTLS 协议, 注:目前仅支持配置和修改,不支持删除此配置
wafConfigFalseStructWeb 应用防火墙配置信息

参考案例:

customDomains:
  - domainName: auto
    protocol: HTTP
    wafConfig:
      enableWAF: true
    routeConfigs:
      - path: /*
        serviceName: unit-deploy-service
        functionName: event-function
        qualifier: LATEST
        rewriteConfig:
          equalRules:
            - match: /equalRules
              replacement: /xxxx
          regexRules:
            - match: ^/old/[a-z]+/
              replacement: /xxxx
          wildcardRules:
            - match: /api/*
              replacement: /$1

⚠️ 注意:如果域名配置为auto,系统会默认分配测试域名,该域名仅供测试使用,不对其稳定性等做保证,Serverless Devs FC 组件在日后有权对该域名进行回收等处理,如是线上业务,生产需求业务,强烈建议绑定自己的自定义域名。

certConfig

参数名必填类型参数描述
certNameTrueString证书名称
privateKeyTrueString表示私钥,内容仅支持 PEM 格式
certificateTrueString表示证书,内容仅支持 PEM 格式

通过配置 certId 获取证书内容

当没有配置 certConfig,可以通过 certId 获取配置。当填写 certId 时,会调用阿里云数字证书管理服务的接口获取配置,所以需要有获取证书详情的权限。 参考案例:

customDomains:
    - domainName: test.com
      protocol: HTTP,HTTPS
      certId: 123456
      routeConfigs:
        - path: /*

通过配置 certConfig 获取证书内容

配置 certConfig 时,certificate 和 privateKey 的内容支持多种方式方式获取,参考案例:

直接填写文件内容

customDomains:
  - domainName: test.com
    protocol: HTTP,HTTPS
    routeConfigs:
      - path: /*
    certConfig:
      certName: certName
      certificate: '-----BEGIN CERTIFICATE----\n certificate content \n----END CERTIFICATE-----'
      privateKey: '-----BEGIN RSA PRIVATE KEY----\n privateKey content \n----END RSA PRIVATE KEY-----'

本地文件路径

customDomains:
  - domainName: test.com
    protocol: HTTP,HTTPS
    routeConfigs:
      - path: /*
    certConfig:
      certName: certName
      certificate: ./localpath/certificate.pem
      privateKey: ./localpath/privateKey.pem

能公网直接访问的http 或者 https地址

customDomains:
  - domainName: test.com
    protocol: HTTP,HTTPS
    routeConfigs:
      - path: /*
    certConfig:
      certName: certName
      certificate: https://oss.abc.com/certificate
      privateKey: http://oss.abc.com/privateKey

OSS地址,格式 oss://{region}/{bucketName}/{objectName}, 但是需要子账号获取oss文件的权限

customDomains:
  - domainName: test.com
    protocol: HTTP,HTTPS
    routeConfigs:
      - path: /*
    certConfig:
      certName: certName
      certificate: oss://cn-hangzhou/bucketName/certificate.pem
      privateKey: oss://cn-hangzhou/bucketName/privateKey.pem

tlsConfig

参数名必填类型参数描述
minVersionTrueStringTLS 协议版本,取值:TLSv1.0TLSv1.1TLSv1.2
maxVersionFalseStringTLS 协议版本,取值:TLSv1.0TLSv1.1TLSv1.2
cipherSuitesTrueList<String>加密套件

wafConfig

参数名必填类型参数描述
enableWAFFalseBoolean是否开启 Web 应用防火墙

routeConfigs

参数名必填类型参数描述
pathTrueString路径
serviceNameFalseString服务名
functionNameFalseString函数名
qualifierFalseString服务的版本
rewriteConfigFalseStructURI 重写配置

rewriteConfig

参数名必填类型参数描述
equalRulesFalseList<Struct>完全匹配规则
wildcardRulesFalseList<Struct>通配符匹配规则
regexRulesFalseList<Struct>正则匹配规则
rewriteConfigRules
参数名必填类型参数描述
matchTrueString匹配规则
replacementTrueString替换规则

权限配置相关

子账号需要的权限

最大权限

系统策略:AliyunFCFullAccess

最小权限

服务和函数权限较多的原因:domainNameauto,需要创建 http 函数作为一个辅助函数,使用完之后会进行删除

{
  'Statement':
    [
      {
        'Action': ['fc:DeleteService', 'fc:UpdateService', 'fc:CreateService'],
        'Effect': 'Allow',
        'Resource': 'acs:fc:<region>:<account-id>:services/*',
      },
      {
        'Action': ['fc:DeleteFunction', 'fc:CreateFunction', 'fc:UpdateFunction'],
        'Effect': 'Allow',
        'Resource': 'acs:fc:<region>:<account-id>:services/*/functions/*',
      },
      {
        'Action': ['fc:DeleteTrigger', 'fc:UpdateTrigger', 'fc:CreateTrigger'],
        'Effect': 'Allow',
        'Resource': 'acs:fc:<region>:<account-id>:services/*/functions/*/triggers/*',
      },
      { 'Action': 'ram:PassRole', 'Effect': 'Allow', 'Resource': '*' },
      {
        'Action': ['fc:GetCustomDomain', 'fc:UpdateCustomDomain', 'fc:CreateCustomDomain'],
        'Resource': 'acs:fc:<region>:<account-id>:custom-domains/*',
        'Effect': 'Allow',
      },
    ],
  'Version': '1',
}
在 GitHub 上编辑本页面 更新时间: Sun, Aug 20, 2023