ALIYUN::OSS::Website

ALIYUN::OSS::Website类型用于将存储空间(Bucket)设置为静态网站托管模式并设置跳转规则(RoutingRule)。

语法

{
  "Type": "ALIYUN::OSS::Website",
  "Properties": {
    "BucketName": String,
    "WebsiteConfiguration": Map
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

BucketName

String

存储空间名称。

WebsiteConfiguration

Map

网站配置。

更多信息,请参见WebsiteConfiguration属性

WebsiteConfiguration语法

"WebsiteConfiguration": {
  "IndexDocument": Map,
  "RoutingRules": List,
  "ErrorDocument": Map
}

WebsiteConfiguration属性

属性名称

类型

必须

允许更新

描述

约束

ErrorDocument

Map

默认错误页面的属性。

更多信息,请参见ErrorDocument属性

IndexDocument

Map

默认主页的属性。

更多信息,请参见IndexDocument属性

RoutingRules

List

路由规则列表,最多20条。

更多信息,请参见RoutingRules属性

IndexDocument语法

"IndexDocument": {
  "Type": String,
  "Suffix": String,
  "SupportSubDir": String
}

IndexDocument属性

属性名称

类型

必须

允许更新

描述

约束

Suffix

String

默认首页。

设置默认首页后,如果您访问以正斜杠(/)结尾的对象,OSS将返回到此默认首页。

SupportSubDir

String

当访问一个子目录时,是否跳转到该子目录下的默认首页。

选项范围如下:

  • true:跳转到子目录下的默认首页。

  • false(默认):不跳转到子目录下的默认首页,而是转向根目录下的默认首页。

    假设默认首页文件名为index.html。若要访问的路径为bucket.oss-cn-hangzhou.aliyuncs.com/subdir/,如果将SupportSubDir设置为false,则会访问bucket.oss-cn-hangzhou.aliyuncs.com/index.html;如果将SupportSubDir设置为true,则会跳转到bucket.oss-cn-hangzhou.aliyuncs.com/subdir/index.html。

Type

String

当访问一个以非正斜杠(/)结尾且不存在的对象时,在设置了默认首页之后的行为如下。

这仅在SupportSubDir设置为true时生效,并且在RoutingRule之后ErrorFile之前生效。 假设默认首页为index.html,尝试访问的文件路径为bucket.oss-cn-hangzhou.aliyuncs.com/abc,而ABC这个对象并不存在。此时,根据Type的不同值,其行为如下:

  • 0(默认):检查abc/index.html是否存在(对象+正斜杠(/)+首页),如果存在,则返回状态码为302的重定向,Location头部信息为/abc/(正斜杠(/)+对象+正斜杠(/))。如果不存在,则返回404错误,并继续检查ErrorFile。

  • 1:直接返回404错误,错误类型为NoSuchKey,然后继续检查ErrorFile。

  • 2:检查abc/index.html是否存在,如果存在则直接返回该对象的内容。如果不存在,则返回404错误,并继续检查ErrorFile。

RoutingRules语法

"RoutingRules": [
  {
    "Condition": Map,
    "RuleNumber": Integer,
    "Redirect": Map
  }
]

RoutingRules属性

属性名称

类型

必须

允许更新

描述

约束

Condition

Map

匹配条件。

此规则仅在满足指定的全部项目时执行。只有当此容器下的每个节点的所有条件都得到满足时,才会被视为匹配成功。更多信息,请参考Condition属性

RuleNumber

Integer

匹配并执行RoutingRule的序列号,OSS将根据此序列号顺序匹配规则。

如果匹配成功,则执行该规则,不再执行后续规则。

Redirect

Map

指定当此规则被匹配时应执行的操作。

更多信息,请参考Redirect属性

Condition语法

"Condition": {
  "IncludeHeaders": List,
  "KeyPrefixEquals": String,
  "HttpErrorCodeReturnedEquals": String,
  "KeySuffixEquals": String
}

Condition属性

属性名称

类型

必须

允许更新

描述

约束

HttpErrorCodeReturnedEquals

String

当访问指定的对象时,为了符合此规则,必须返回此状态。当跳转规则为镜像回源类型时,此字段必须为404。

IncludeHeaders

List

此规则仅当请求中包含指定的头部且其值为指定的值时才会匹配。

最多可设置10个这样的条件。

KeyPrefixEquals

String

要匹配的对象名称的前缀。

KeySuffixEquals

String

要匹配的物体名称的后缀。

IncludeHeaders语法

"IncludeHeaders": [
  {
    "Equals": String,
    "Key": String
  }
]

IncludeHeaders属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

header名称。

Equals

String

header值。

Redirect语法

"Redirect": {
  "MirrorURL": String,
  "ReplaceKeyWith": String,
  "MirrorHeaders": Map,
  "HttpRedirectCode": String,
  "EnableReplacePrefix": Boolean,
  "PassQueryString": Boolean,
  "MirrorFollowRedirect": Boolean,
  "ReplaceKeyPrefixWith": String,
  "RedirectType": String,
  "MirrorPassQueryString": Boolean,
  "MirrorCheckMd5": Boolean,
  "Protocol": String,
  "HostName": String
}

Redirect属性

属性名称

类型

必须

允许更新

描述

约束

RedirectType

String

指定跳转的类型。

可选范围如下:

  • Mirror:回源镜像,即将请求反射回源站。

  • External:外部分支,即OSS会返回一个3xx状态码的请求,指示浏览器或其他客户端去访问另一个地址进行分支。

  • AliCDN:针对阿里云内容分发网络的跳转。与“外部”跳转不同的是,OSS会在此类跳转中添加一个额外的头部信息。阿里云CDN识别到这个特定头部后,会主动跳转到指定的地址,并将获取的数据直接返回给用户,而不是向用户返回3xx的重定向请求。这样可以减少一次客户端的重定向操作,提高访问速度和效率。

EnableReplacePrefix

Boolean

如果将此字段设置为true,对象的前缀将被ReplaceKeyPrefixWith指定的值替换。如果未指定此字段或为空,则表示对象的前缀将被截断。

说明

当ReplaceKeyWith字段不为null时,此字段不能设置为true。

默认值:false

HttpRedirectCode

String

当进行跳转时返回的状态码。

此设置仅在“RedirectType”被设为“External”或“AliCDN”时有效。默认值为302。

可选值:

  • 301

  • 302

  • 307

HostName

String

跳转的域名。

该域名应遵循域名规范。

如果你想访问的文件是test,协议设置为https,主机名设置为example.com,那么Location头信息应该是https://example.com/test

MirrorURL

String

仅当RedirectType设置为Mirror时,此规则才有效。

源URL必须以http://或https://开头,并以正斜杠(/)结尾,OSS将据此后续拼接对象名称来构成返回的URL。

例如,若要访问的对象名为myobject,假如您将其配置为http://example.com/,则返回的源站URL将会是http://example.com/myobject;如果配置为http://example.com/dir1/,则返回的源站URL会是http://example.com/dir1/myobject。这意味着,您指定的源站地址末尾的路径会被保留,并与对象名结合形成完整的回源URL。

MirrorHeaders

Map

指定回传到源端的头部信息。

此设置仅在RedirectType设为Mirror时生效。更多信息,请参考MirrorHeaders属性。

MirrorFollowRedirect

Boolean

当镜像回源后得到的结果是3xx状态码,并且指定了Location时,是否继续跳转到该指定位置以获取数据。

此设置仅在RedirectType配置为Mirror时生效。 例如,当我们镜像请求回到源站时,源站返回了一个302状态码并指定了Location。

  • 如果设置为true,OSS将继续请求该Location指向的地址。

    这个过程最多允许跳转10次,超过10次则镜像回源失败并返回错误。

  • 如果设置为false,OSS将直接返回302状态码并将Location信息透传给客户端,由客户端决定是否继续跳转。

    默认值:true。

MirrorPassQueryString

Boolean

与PassQueryString相同,但优先于PassQueryString。

此设置仅在RedirectType设置为Mirror时有效。

默认值:false

MirrorCheckMd5

Boolean

是否回源检查MD5。

此配置仅在RedirectType设置为Mirror时生效。

当MirrorCheckMd5设置为true时,如果源站返回的响应中包含了Content-Md5头信息,OSS会检查拉取的数据MD5是否与该头信息匹配,如果不匹配,则不会将数据保存到OSS上。

默认值:false。

PassQueryString

Boolean

当执行跳转或回源镜像时,是否携带请求参数。

如果用户以包含请求参数(如 a=b&c=d)的方式请求OSS,并且设置PassQueryString为true,那么如果规则配置的是302跳转,这些请求参数会被添加到跳转的Location头部中。例如,Location变为:example.com?a=b&c=d。如果跳转类型是回源镜像,则在发起回源请求时,这些请求参数也会被一并携带。

有效值:true、false(默认)。

Protocol

String

协议。

当执行跳转操作时,如果RedirectType被设置为External或AliCDN,具体的协议遵循以下规则:

如果需要访问的文件是“test”,并且希望用户被重定向到“example.com”,同时指定协议为HTTPS,那么在HTTP响应中的Location头部字段应被设置为"https://example.com/test"。

这里的“Protocol”参数值可选为:"http" 或 "https",用来指示跳转链接应该使用的网络协议。在上述例子中,选择的是"https",意味着通过安全的HTTPS协议进行跳转。如果选择"http",则Location头部会相应地变为"http://example.com/test",但请注意,这会降低数据传输的安全性,因为HTTP不加密通信内容。

ReplaceKeyWith

String

请求中对象的名称。

使用Redirect规则时,请求中的对象名称将被ReplaceKeyWith指定的值替换,这使得设置变量成为可能。目前支持的变量是${key},它代表请求中对象的名称。

假设要访问一个测试对象,如果将ReplaceKeyWith设置为prefix/{key},那么实际上就是在访问时,对象的路径会被重写为包含前缀“prefix/”。所以,当请求的对象是“test”时,Location头部(即访问的URL)会指向"http://example.com/prefix/test.suffix"。这里的“suffix”是你提及的后缀部分,而“prefix/key,那么实际上就是在访问时,对象的路径会被重写为包含前缀“prefix/”。

ReplaceKeyPrefixWith

String

重定向规则。

如果设置条件为KeyPrefixEquals针对"ABC/",并且ReplaceKeyPrefixWith针对"def/",那么为了访问名为"ABC/test.txt"的对象,根据您的描述,重定向规则将会把对象的前缀"ABC"替换为"def"。

因此,原本的Object路径是"ABC/test.txt",经过重定向规则处理后,将会变为"def/test.txt"。所以,根据这个假设情景,用户尝试访问"http://example.com/ABC/test.txt"会被冲重定向"http://example.com/def/test.txt"。

请注意,这个解释基于您提供的信息和典型的云存储服务中URL重定向规则的工作方式。实际行为可能还需要参考具体实施该重定向策略的系统或服务的文档。

MirrorHeaders语法

"MirrorHeaders": {
  "PassAll": Boolean,
  "Pass": List,
  "Sets": List,
  "Remove": List
}

MirrorHeaders属性

属性名称

类型

必须

允许更新

描述

约束

PassAll

Boolean

是否透传除以下头部之外的其他头部到源站。

此设置仅在RedirectType配置为Mirror时生效。

  • 不透传的内容长度(content-length)、授权信息(authorization、authorization2)、范围请求(range)、日期(date)以及其他头部信息

  • 以oss-、x-oss-或x-drs-开头的头部

默认值:false

Pass

List

将指定的头部信息传递给源。

此操作仅在将RedirectType设置为镜像(Mirror)时有效。

每个头部的长度最多为1,024字节,并且只能包含字符集0-9、a-z、A-Z和破折号(-)。

此字段最多可以指定10个头部信息。

Remove

List

禁用指定头部向源的传递。

这仅在将RedirectType设置为Mirror时有效。

每个头部的长度最多为1,024字节,并且字符集包括0-9、a-z、A-Z和破折号(-)。

此字段最多可以指定10个。

Sets

List

设置一个头部到源服务器,当请求被返回给源服务器时,该头部将被设置,无论指定的头部是否包含在请求中。

此功能仅在将RedirectType设置为Mirror时生效。

此容器最多可以为10个组指定此设置。更多信息,请参考Sets属性。

Sets语法

"Sets": [
  {
    "Value": String,
    "Key": String
  }
]

Sets属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

将Header键的大小限制为最多1024字节,且必须与Pass使用的字符集相同。

此设置仅在RedirectType被设为Mirror时生效。

Value

String

将标头的值设置为最大1024字节,不包括\r\n。

此设置仅在RedirectType被设置为镜像(Mirror)时有效。

ErrorDocument语法

"ErrorDocument": {
  "HttpStatus": String,
  "Key": String
}

ErrorDocument属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

默认的错误页面。

当指定了一个错误页面时,如果访问的对象不存在,将会返回这个错误页面。

HttpStatus

String

错误页面的HTTP状态码。

有效值:

  • 200

  • 404(默认)。

返回值

Fn::GetAtt

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      BucketName:
        Type: String
        Description:
          en: Bucket name.
        Required: true
      WebsiteConfiguration:
        AssociationPropertyMetadata:
          Parameters:
            IndexDocument:
              AssociationPropertyMetadata:
                Parameters:
                  Type:
                    Type: String
                    Description:
                      en: |-
                        Behavior when an Object that ends with a non-forward slash (/) and does not exist is accessed after setting the default home page. It only takes effect when SupportSubDir is set to true, and it takes effect after RoutingRule and before ErrorFile.
                        Assume that the default home page for the index. The HTML, to access the file path for bucket.oss-cn-hangzhou.aliyuncs.com/abc, and ABC this Object does not exist, at this moment, in different values corresponding to the Type of behavior is as follows:
                        - 0 (default) : Check if abc/index.html exists (Object + forward slash (/) + home page) and return 302 with the URL code of /abc/ as Location header (forward slash (/) + Object + forward slash (/)). If it doesn't, it will return 404 and keep checking ErrorFile.
                        - 1: Directly return 404, error NoSuchKey, continue to check ErrorFile.
                        - 2: Check if abc/index.html exists and return the contents of the Object if it does. If it doesn't, it will return 404 and keep checking ErrorFile.
                    AllowedValues:
                      - '0'
                      - '1'
                      - '2'
                    Required: false
                  Suffix:
                    Type: String
                    Description:
                      en: |-
                        Default home page.
                        After setting the default home page, if you visit an Object ending with a forward slash (/), OSS will return to this default home page.
                    Required: true
                  SupportSubDir:
                    Type: String
                    Description:
                      en: |-
                        Whether to jump to the default home page of a subdirectory when accessing it. The range is as follows:
                        - true: Go to the default home page in a subdirectory.
                        - false (default) : Instead of going to the default home page in a subdirectory, go to the default home page in the root directory.
                        Assume that the default home page for the index. The HTML, to access bucket.oss-cn-hangzhou.aliyuncs.com/subdir/, if set SupportSubDir to false, Then go to bucket.oss-cn-hangzhou.aliyuncs.com/index.html; If set SupportSubDir is true, then transferred to the bucket.oss-cn-hangzhou.aliyuncs.com/subdir/index.html.
                    AllowedValues:
                      - 'true'
                      - 'false'
                    Required: false
              Type: Json
              Description:
                en: The properties of default home page.
              Required: false
            RoutingRules:
              AssociationPropertyMetadata:
                Parameter:
                  AssociationPropertyMetadata:
                    Parameters:
                      Condition:
                        AssociationPropertyMetadata:
                          Parameters:
                            IncludeHeaders:
                              AssociationPropertyMetadata:
                                Parameters:
                                  Equals:
                                    Type: String
                                    Description:
                                      en: The value of the header.
                                    Required: false
                                  Key:
                                    Type: String
                                    Description:
                                      en: The name of the header.
                                    Required: true
                              AssociationProperty: List[Parameters]
                              Type: Json
                              Description:
                                en: This rule will only match if the request contains the specified Header and the value is the specified value. Up to 10.
                              Required: false
                              MaxLength: 10
                            KeyPrefixEquals:
                              Type: String
                              Description:
                                en: The prefix of the Object name to be matched.
                              Required: false
                            HttpErrorCodeReturnedEquals:
                              Type: String
                              Description:
                                en: When accessing the specified Object, this status must be returned to match this rule. This field must be 404 when the jump rule is mirror-back to the source type.
                              Required: false
                            KeySuffixEquals:
                              Type: String
                              Description:
                                en: The suffix of the Object name to be matched.
                              Required: false
                        Type: Json
                        Description:
                          en: |-
                            Conditions for matching.
                            This rule is executed if the specified items are all satisfied. A match is only considered if all conditions for each node under this container are met.
                        Required: true
                      RuleNumber:
                        Type: Number
                        Description:
                          en: Match and execute the sequence number of the RoutingRule, OSS will match the rules in turn according to this sequence number. If the match is successful, this rule is executed and no subsequent rules are executed.
                        Required: true
                        MinValue: 1
                        MaxValue: 20
                      Redirect:
                        AssociationPropertyMetadata:
                          Parameters:
                            MirrorURL:
                              Type: String
                              Description:
                                en: |-
                                  Mirror back to the source station address of the source. This only works if RedirectType is set to Mirror.
                                  The origin URL must begin with http:// or https:// and end with a forward slash (/), which OSS will follow with the Object name to form the return URL.
                                  Name to access the Object myobject, for example, if you specify this to http://example.com/, then back to the source URL for http://example.com/myobject, if you specify this to http://example.com/dir1/, Back to the source URL as http://example.com/dir1/myobject.
                              Required: false
                            ReplaceKeyWith:
                              Type: String
                              Description:
                                en: |-
                                  With Redirect, the Object name is replaced with the value specified by ReplaceKeyWith, which allows you to set variables. The currently supported variable is ${key}, which represents the name of the Object in the request.
                                  Suppose to access the Object for the test, if set ReplaceKeyWith to prefix/${key}. The suffix, is the Location head to http://example.com/prefix/test.suffix.
                              Required: false
                            MirrorHeaders:
                              AssociationPropertyMetadata:
                                Parameters:
                                  PassAll:
                                    Type: Boolean
                                    Description:
                                      en: |-
                                        Whether to pass through other headers to the source except the following headers. This only works if RedirectType is set to Mirror.
                                        - content-length, authorization2, authorization, range, date and other headers
                                        - Headers starting with oss-/x-oss-/x-drs-
                                        Default value: false
                                    Required: false
                                  Pass:
                                    AssociationPropertyMetadata:
                                      Parameter:
                                        Type: String
                                        Description:
                                          en: |-
                                            Specifies the Header that is mirrored back to the source. This only works if RedirectType is set to Mirror.
                                            Each Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-).
                                        AllowedPattern: ^[-a-zA-Z0-9]{1,1024}$
                                        Required: false
                                    AssociationProperty: List[Parameter]
                                    Type: Json
                                    Description:
                                      en: |-
                                        Pass through the specified Header to the source. This only works if RedirectType is set to Mirror.
                                        Each Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-).
                                        A maximum of 10 can be specified for this field.
                                    Required: false
                                    MaxLength: 10
                                  Sets:
                                    AssociationPropertyMetadata:
                                      Parameters:
                                        Value:
                                          Type: String
                                          Description:
                                            en: Set the value of the Header to a maximum of 1024 bytes without \r\n. This only works if RedirectType is set to Mirror.
                                          Required: true
                                          MaxLength: 1024
                                        Key:
                                          Type: String
                                          Description:
                                            en: Sets the Header key to a maximum of 1024 bytes in the same character set as Pass. This only works if RedirectType is set to Mirror.
                                          AllowedPattern: ^[-a-zA-Z0-9]{1,1024}$
                                          Required: true
                                    AssociationProperty: List[Parameters]
                                    Type: Json
                                    Description:
                                      en: |-
                                        Set a Header to the origin, and it will be set when the request is sent back to the origin, regardless of whether the specified headers are included in the request. This only works if RedirectType is set to Mirror.
                                        Up to 10 groups can be specified for this container.
                                    Required: false
                                    MaxLength: 10
                                  Remove:
                                    AssociationPropertyMetadata:
                                      Parameter:
                                        Type: String
                                        Description:
                                          en: |-
                                            Disables pass-through of the specified Header to the source. This only works if RedirectType is set to Mirror.
                                            Each Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-).
                                        AllowedPattern: ^[-a-zA-Z0-9]{1,1024}$
                                        Required: false
                                    AssociationProperty: List[Parameter]
                                    Type: Json
                                    Description:
                                      en: |-
                                        Disables pass-through of the specified Header to the source. This only works if RedirectType is set to Mirror.
                                        Each Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-).
                                        A maximum of 10 can be specified for this field.
                                    Required: false
                                    MaxLength: 10
                              Type: Json
                              Description:
                                en: Specifies the Header that is mirrored back to the source. This only works if RedirectType is set to Mirror.
                              Required: false
                            HttpRedirectCode:
                              Type: String
                              Description:
                                en: |-
                                  Status code returned when jumping. Only if RedirectType is set to External or AliCDN.The default value is 302.
                                  Value: 301, 302, 307
                              AllowedValues:
                                - '301'
                                - '302'
                                - '307'
                              Required: false
                            EnableReplacePrefix:
                              Type: Boolean
                              Description:
                                en: |-
                                  If you set this field to true, the prefix of Object is replaced with the value specified by ReplaceKeyPrefixWith. If this field is not specified or is empty, it means that the Object prefix is truncated.
                                  Notes: This field cannot be set to true when the ReplaceKeyWith field is not null.
                                  Default value: false
                              Required: false
                            PassQueryString:
                              Type: Boolean
                              Description:
                                en: |-
                                  Whether to carry request parameters when performing a jump or mirroring back to the source rule.
                                  Does the user request OSS with the request parameters? a=b&c=d, and set PassQueryString to true, if the rule is a 302 jump, then this request parameter is added in the Location header of the jump. For example, Location:example.com?a=b&c=d, the jump type is mirror back to the source, then this request parameter will also be carried in the initiated back to the source request.
                                  Valid values: true, false (default)
                              Required: false
                            MirrorFollowRedirect:
                              Type: Boolean
                              Description:
                                en: |-
                                  If the result obtained by mirriling back to the source is 3xx, whether to continue to jump to the specified Location to obtain data. This only works if RedirectType is set to Mirror.
                                  For example, when we mirror back to the source, the source returns a 302 with Location specified.
                                  - If set to true, OSS will continue to request the Location.
                                  It can jump up to 10 times, and if it jumps more than 10 times, it fails to return the mirror back to the source.
                                  - If set to false, OSS will return 302 and pass through the Location.
                                  Default value: true
                              Required: false
                            ReplaceKeyPrefixWith:
                              Type: String
                              Description:
                                en: |-
                                  This value will be substituted for the prefix of the Object name in Redirect. If the prefix is empty, the string is inserted before the Object name.
                                  Notes: Only ReplaceKeyWith or ReplaceKeyPrefixWith nodes are allowed.
                                  Hypothesis to access the Object for ABC/test. TXT, if set KeyPrefixEquals for ABC /, ReplaceKeyPrefixWith for def /, then the Location head to http://example.com/def/test.txt.
                              Required: false
                            RedirectType:
                              Type: String
                              Description:
                                en: |-
                                  Specifies the type of jump. The range is as follows:
                                  - Mirror: Mirror back to the source.
                                  - External: External branch, i.e. OSS will return a 3xx request specifying the branch to another address.
                                  - AliCDN: Aliyun CDN jump, mainly used for the CDN of Aliyun. Unlike External, OSS adds an additional Header. After identifying this Header, Aliyun CDN will actively jump to the specified address and return the obtained data to the user instead of returning the 3xx jump request to the user.
                              AllowedValues:
                                - Mirror
                                - External
                                - AliCDN
                              Required: true
                            MirrorPassQueryString:
                              Type: Boolean
                              Description:
                                en: |-
                                  Same as PassQueryString, but takes precedence over PassQueryString. This only works if RedirectType is set to Mirror.
                                  Default value: false
                              Required: false
                            MirrorCheckMd5:
                              Type: Boolean
                              Description:
                                en: |-
                                  Whether to check MD5 back to the source body. This only works if RedirectType is set to Mirror.
                                  When MirrorCheckMd5 is set to true, and the response returned by the source contains the Content-Md5 Header, OSS checks whether the pulled data MD5 matches this header, if not, it is not saved on OSS.
                                  Default value: false
                              Required: false
                            Protocol:
                              Type: String
                              Description:
                                en: |-
                                  Protocol when jumping. Only if RedirectType is set to External or AliCDN.
                                  If the file you want to access is test, set to go to example.com, and set Protocol to https, the Location header is https://example.com/test.
                                  Value: http, https
                              AllowedValues:
                                - http
                                - https
                              Required: false
                            HostName:
                              Type: String
                              Description:
                                en: |-
                                  The domain name of the jump, the domain name should conform to the domain name specification.
                                  If the file you want to access is test, the Protocol is set to https, and the Hostname is set to example.com, the Location header is https://example.com/test.
                              Required: false
                        Type: Json
                        Description:
                          en: Specifies the action to be performed when this rule is matched.
                        Required: true
                  Type: Json
                  Description:
                    en: The properties of routing rule.
                  Required: false
              AssociationProperty: List[Parameter]
              Type: Json
              Description:
                en: The list of routing rules, up to 20.
              Required: false
              MaxLength: 20
            ErrorDocument:
              AssociationPropertyMetadata:
                Parameters:
                  HttpStatus:
                    Type: String
                    Description:
                      en: 'The HTTP status code of the error page. Valid values: 200, 404 (default).'
                    AllowedValues:
                      - '200'
                      - '404'
                    Required: false
                  Key:
                    Type: String
                    Description:
                      en: |-
                        The default error page.
                        When an error page is specified, if the accessed Object does not exist, this error page is returned.
                    Required: true
              Type: Json
              Description:
                en: The properties of default error page.
              Required: false
        Type: Json
        Description:
          en: Website configuration.
        Required: false
    Resources:
      Website:
        Type: ALIYUN::OSS::Website
        Properties:
          BucketName:
            Ref: BucketName
          WebsiteConfiguration:
            Ref: WebsiteConfiguration
    
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "BucketName": {
          "Type": "String",
          "Description": {
            "en": "Bucket name."
          },
          "Required": true
        },
        "WebsiteConfiguration": {
          "AssociationPropertyMetadata": {
            "Parameters": {
              "IndexDocument": {
                "AssociationPropertyMetadata": {
                  "Parameters": {
                    "Type": {
                      "Type": "String",
                      "Description": {
                        "en": "Behavior when an Object that ends with a non-forward slash (/) and does not exist is accessed after setting the default home page. It only takes effect when SupportSubDir is set to true, and it takes effect after RoutingRule and before ErrorFile.\nAssume that the default home page for the index. The HTML, to access the file path for bucket.oss-cn-hangzhou.aliyuncs.com/abc, and ABC this Object does not exist, at this moment, in different values corresponding to the Type of behavior is as follows:\n- 0 (default) : Check if abc/index.html exists (Object + forward slash (/) + home page) and return 302 with the URL code of /abc/ as Location header (forward slash (/) + Object + forward slash (/)). If it doesn't, it will return 404 and keep checking ErrorFile.\n- 1: Directly return 404, error NoSuchKey, continue to check ErrorFile.\n- 2: Check if abc/index.html exists and return the contents of the Object if it does. If it doesn't, it will return 404 and keep checking ErrorFile."
                      },
                      "AllowedValues": [
                        "0",
                        "1",
                        "2"
                      ],
                      "Required": false
                    },
                    "Suffix": {
                      "Type": "String",
                      "Description": {
                        "en": "Default home page.\nAfter setting the default home page, if you visit an Object ending with a forward slash (/), OSS will return to this default home page."
                      },
                      "Required": true
                    },
                    "SupportSubDir": {
                      "Type": "String",
                      "Description": {
                        "en": "Whether to jump to the default home page of a subdirectory when accessing it. The range is as follows:\n- true: Go to the default home page in a subdirectory.\n- false (default) : Instead of going to the default home page in a subdirectory, go to the default home page in the root directory.\nAssume that the default home page for the index. The HTML, to access bucket.oss-cn-hangzhou.aliyuncs.com/subdir/, if set SupportSubDir to false, Then go to bucket.oss-cn-hangzhou.aliyuncs.com/index.html; If set SupportSubDir is true, then transferred to the bucket.oss-cn-hangzhou.aliyuncs.com/subdir/index.html."
                      },
                      "AllowedValues": [
                        "true",
                        "false"
                      ],
                      "Required": false
                    }
                  }
                },
                "Type": "Json",
                "Description": {
                  "en": "The properties of default home page."
                },
                "Required": false
              },
              "RoutingRules": {
                "AssociationPropertyMetadata": {
                  "Parameter": {
                    "AssociationPropertyMetadata": {
                      "Parameters": {
                        "Condition": {
                          "AssociationPropertyMetadata": {
                            "Parameters": {
                              "IncludeHeaders": {
                                "AssociationPropertyMetadata": {
                                  "Parameters": {
                                    "Equals": {
                                      "Type": "String",
                                      "Description": {
                                        "en": "The value of the header."
                                      },
                                      "Required": false
                                    },
                                    "Key": {
                                      "Type": "String",
                                      "Description": {
                                        "en": "The name of the header."
                                      },
                                      "Required": true
                                    }
                                  }
                                },
                                "AssociationProperty": "List[Parameters]",
                                "Type": "Json",
                                "Description": {
                                  "en": "This rule will only match if the request contains the specified Header and the value is the specified value. Up to 10."
                                },
                                "Required": false,
                                "MaxLength": 10
                              },
                              "KeyPrefixEquals": {
                                "Type": "String",
                                "Description": {
                                  "en": "The prefix of the Object name to be matched."
                                },
                                "Required": false
                              },
                              "HttpErrorCodeReturnedEquals": {
                                "Type": "String",
                                "Description": {
                                  "en": "When accessing the specified Object, this status must be returned to match this rule. This field must be 404 when the jump rule is mirror-back to the source type."
                                },
                                "Required": false
                              },
                              "KeySuffixEquals": {
                                "Type": "String",
                                "Description": {
                                  "en": "The suffix of the Object name to be matched."
                                },
                                "Required": false
                              }
                            }
                          },
                          "Type": "Json",
                          "Description": {
                            "en": "Conditions for matching.\nThis rule is executed if the specified items are all satisfied. A match is only considered if all conditions for each node under this container are met."
                          },
                          "Required": true
                        },
                        "RuleNumber": {
                          "Type": "Number",
                          "Description": {
                            "en": "Match and execute the sequence number of the RoutingRule, OSS will match the rules in turn according to this sequence number. If the match is successful, this rule is executed and no subsequent rules are executed."
                          },
                          "Required": true,
                          "MinValue": 1,
                          "MaxValue": 20
                        },
                        "Redirect": {
                          "AssociationPropertyMetadata": {
                            "Parameters": {
                              "MirrorURL": {
                                "Type": "String",
                                "Description": {
                                  "en": "Mirror back to the source station address of the source. This only works if RedirectType is set to Mirror.\nThe origin URL must begin with http:// or https:// and end with a forward slash (/), which OSS will follow with the Object name to form the return URL.\nName to access the Object myobject, for example, if you specify this to http://example.com/, then back to the source URL for http://example.com/myobject, if you specify this to http://example.com/dir1/, Back to the source URL as http://example.com/dir1/myobject."
                                },
                                "Required": false
                              },
                              "ReplaceKeyWith": {
                                "Type": "String",
                                "Description": {
                                  "en": "With Redirect, the Object name is replaced with the value specified by ReplaceKeyWith, which allows you to set variables. The currently supported variable is ${key}, which represents the name of the Object in the request.\nSuppose to access the Object for the test, if set ReplaceKeyWith to prefix/${key}. The suffix, is the Location head to http://example.com/prefix/test.suffix."
                                },
                                "Required": false
                              },
                              "MirrorHeaders": {
                                "AssociationPropertyMetadata": {
                                  "Parameters": {
                                    "PassAll": {
                                      "Type": "Boolean",
                                      "Description": {
                                        "en": "Whether to pass through other headers to the source except the following headers. This only works if RedirectType is set to Mirror.\n- content-length, authorization2, authorization, range, date and other headers\n- Headers starting with oss-/x-oss-/x-drs-\nDefault value: false"
                                      },
                                      "Required": false
                                    },
                                    "Pass": {
                                      "AssociationPropertyMetadata": {
                                        "Parameter": {
                                          "Type": "String",
                                          "Description": {
                                            "en": "Specifies the Header that is mirrored back to the source. This only works if RedirectType is set to Mirror.\nEach Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-)."
                                          },
                                          "AllowedPattern": "^[-a-zA-Z0-9]{1,1024}$",
                                          "Required": false
                                        }
                                      },
                                      "AssociationProperty": "List[Parameter]",
                                      "Type": "Json",
                                      "Description": {
                                        "en": "Pass through the specified Header to the source. This only works if RedirectType is set to Mirror.\nEach Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-).\nA maximum of 10 can be specified for this field."
                                      },
                                      "Required": false,
                                      "MaxLength": 10
                                    },
                                    "Sets": {
                                      "AssociationPropertyMetadata": {
                                        "Parameters": {
                                          "Value": {
                                            "Type": "String",
                                            "Description": {
                                              "en": "Set the value of the Header to a maximum of 1024 bytes without \\r\\n. This only works if RedirectType is set to Mirror."
                                            },
                                            "Required": true,
                                            "MaxLength": 1024
                                          },
                                          "Key": {
                                            "Type": "String",
                                            "Description": {
                                              "en": "Sets the Header key to a maximum of 1024 bytes in the same character set as Pass. This only works if RedirectType is set to Mirror."
                                            },
                                            "AllowedPattern": "^[-a-zA-Z0-9]{1,1024}$",
                                            "Required": true
                                          }
                                        }
                                      },
                                      "AssociationProperty": "List[Parameters]",
                                      "Type": "Json",
                                      "Description": {
                                        "en": "Set a Header to the origin, and it will be set when the request is sent back to the origin, regardless of whether the specified headers are included in the request. This only works if RedirectType is set to Mirror.\nUp to 10 groups can be specified for this container."
                                      },
                                      "Required": false,
                                      "MaxLength": 10
                                    },
                                    "Remove": {
                                      "AssociationPropertyMetadata": {
                                        "Parameter": {
                                          "Type": "String",
                                          "Description": {
                                            "en": "Disables pass-through of the specified Header to the source. This only works if RedirectType is set to Mirror.\nEach Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-)."
                                          },
                                          "AllowedPattern": "^[-a-zA-Z0-9]{1,1024}$",
                                          "Required": false
                                        }
                                      },
                                      "AssociationProperty": "List[Parameter]",
                                      "Type": "Json",
                                      "Description": {
                                        "en": "Disables pass-through of the specified Header to the source. This only works if RedirectType is set to Mirror.\nEach Header is at most 1,024 bytes long and has the character sets 0-9, a-z, A-Z, and dash (-).\nA maximum of 10 can be specified for this field."
                                      },
                                      "Required": false,
                                      "MaxLength": 10
                                    }
                                  }
                                },
                                "Type": "Json",
                                "Description": {
                                  "en": "Specifies the Header that is mirrored back to the source. This only works if RedirectType is set to Mirror."
                                },
                                "Required": false
                              },
                              "HttpRedirectCode": {
                                "Type": "String",
                                "Description": {
                                  "en": "Status code returned when jumping. Only if RedirectType is set to External or AliCDN.The default value is 302.\nValue: 301, 302, 307"
                                },
                                "AllowedValues": [
                                  "301",
                                  "302",
                                  "307"
                                ],
                                "Required": false
                              },
                              "EnableReplacePrefix": {
                                "Type": "Boolean",
                                "Description": {
                                  "en": "If you set this field to true, the prefix of Object is replaced with the value specified by ReplaceKeyPrefixWith. If this field is not specified or is empty, it means that the Object prefix is truncated.\nNotes: This field cannot be set to true when the ReplaceKeyWith field is not null.\nDefault value: false"
                                },
                                "Required": false
                              },
                              "PassQueryString": {
                                "Type": "Boolean",
                                "Description": {
                                  "en": "Whether to carry request parameters when performing a jump or mirroring back to the source rule.\nDoes the user request OSS with the request parameters? a=b&c=d, and set PassQueryString to true, if the rule is a 302 jump, then this request parameter is added in the Location header of the jump. For example, Location:example.com?a=b&c=d, the jump type is mirror back to the source, then this request parameter will also be carried in the initiated back to the source request.\nValid values: true, false (default)"
                                },
                                "Required": false
                              },
                              "MirrorFollowRedirect": {
                                "Type": "Boolean",
                                "Description": {
                                  "en": "If the result obtained by mirriling back to the source is 3xx, whether to continue to jump to the specified Location to obtain data. This only works if RedirectType is set to Mirror.\nFor example, when we mirror back to the source, the source returns a 302 with Location specified.\n- If set to true, OSS will continue to request the Location.\nIt can jump up to 10 times, and if it jumps more than 10 times, it fails to return the mirror back to the source.\n- If set to false, OSS will return 302 and pass through the Location.\nDefault value: true"
                                },
                                "Required": false
                              },
                              "ReplaceKeyPrefixWith": {
                                "Type": "String",
                                "Description": {
                                  "en": "This value will be substituted for the prefix of the Object name in Redirect. If the prefix is empty, the string is inserted before the Object name.\nNotes: Only ReplaceKeyWith or ReplaceKeyPrefixWith nodes are allowed.\nHypothesis to access the Object for ABC/test. TXT, if set KeyPrefixEquals for ABC /, ReplaceKeyPrefixWith for def /, then the Location head to http://example.com/def/test.txt."
                                },
                                "Required": false
                              },
                              "RedirectType": {
                                "Type": "String",
                                "Description": {
                                  "en": "Specifies the type of jump. The range is as follows:\n- Mirror: Mirror back to the source.\n- External: External branch, i.e. OSS will return a 3xx request specifying the branch to another address.\n- AliCDN: Aliyun CDN jump, mainly used for the CDN of Aliyun. Unlike External, OSS adds an additional Header. After identifying this Header, Aliyun CDN will actively jump to the specified address and return the obtained data to the user instead of returning the 3xx jump request to the user."
                                },
                                "AllowedValues": [
                                  "Mirror",
                                  "External",
                                  "AliCDN"
                                ],
                                "Required": true
                              },
                              "MirrorPassQueryString": {
                                "Type": "Boolean",
                                "Description": {
                                  "en": "Same as PassQueryString, but takes precedence over PassQueryString. This only works if RedirectType is set to Mirror.\nDefault value: false"
                                },
                                "Required": false
                              },
                              "MirrorCheckMd5": {
                                "Type": "Boolean",
                                "Description": {
                                  "en": "Whether to check MD5 back to the source body. This only works if RedirectType is set to Mirror.\nWhen MirrorCheckMd5 is set to true, and the response returned by the source contains the Content-Md5 Header, OSS checks whether the pulled data MD5 matches this header, if not, it is not saved on OSS.\nDefault value: false"
                                },
                                "Required": false
                              },
                              "Protocol": {
                                "Type": "String",
                                "Description": {
                                  "en": "Protocol when jumping. Only if RedirectType is set to External or AliCDN.\nIf the file you want to access is test, set to go to example.com, and set Protocol to https, the Location header is https://example.com/test.\nValue: http, https"
                                },
                                "AllowedValues": [
                                  "http",
                                  "https"
                                ],
                                "Required": false
                              },
                              "HostName": {
                                "Type": "String",
                                "Description": {
                                  "en": "The domain name of the jump, the domain name should conform to the domain name specification.\nIf the file you want to access is test, the Protocol is set to https, and the Hostname is set to example.com, the Location header is https://example.com/test."
                                },
                                "Required": false
                              }
                            }
                          },
                          "Type": "Json",
                          "Description": {
                            "en": "Specifies the action to be performed when this rule is matched."
                          },
                          "Required": true
                        }
                      }
                    },
                    "Type": "Json",
                    "Description": {
                      "en": "The properties of routing rule."
                    },
                    "Required": false
                  }
                },
                "AssociationProperty": "List[Parameter]",
                "Type": "Json",
                "Description": {
                  "en": "The list of routing rules, up to 20."
                },
                "Required": false,
                "MaxLength": 20
              },
              "ErrorDocument": {
                "AssociationPropertyMetadata": {
                  "Parameters": {
                    "HttpStatus": {
                      "Type": "String",
                      "Description": {
                        "en": "The HTTP status code of the error page. Valid values: 200, 404 (default)."
                      },
                      "AllowedValues": [
                        "200",
                        "404"
                      ],
                      "Required": false
                    },
                    "Key": {
                      "Type": "String",
                      "Description": {
                        "en": "The default error page.\nWhen an error page is specified, if the accessed Object does not exist, this error page is returned."
                      },
                      "Required": true
                    }
                  }
                },
                "Type": "Json",
                "Description": {
                  "en": "The properties of default error page."
                },
                "Required": false
              }
            }
          },
          "Type": "Json",
          "Description": {
            "en": "Website configuration."
          },
          "Required": false
        }
      },
      "Resources": {
        "Website": {
          "Type": "ALIYUN::OSS::Website",
          "Properties": {
            "BucketName": {
              "Ref": "BucketName"
            },
            "WebsiteConfiguration": {
              "Ref": "WebsiteConfiguration"
            }
          }
        }
      }
    }