ALIYUN::OSS::Website is used to configure static website hosting and redirection rules for an Object Storage Service (OSS) bucket.
Syntax
{
"Type": "ALIYUN::OSS::Website",
"Properties": {
"BucketName": String,
"WebsiteConfiguration": Map
}
}
Properties
Property | Type | Required | Editable | Description | Constraint |
BucketName | String | Yes | No | The bucket name. | None. |
WebsiteConfiguration | Map | No | No | The website configurations. | For more information, see WebsiteConfiguration properties. |
WebsiteConfiguration syntax
"WebsiteConfiguration": {
"IndexDocument": Map,
"RoutingRules": List,
"ErrorDocument": Map
}
WebsiteConfiguration properties
Property | Type | Required | Editable | Description | Constraint |
ErrorDocument | Map | No | No | The properties of the default error page. | For more information, see ErrorDocument properties. |
IndexDocument | Map | No | No | The properties of the default homepage. | For more information, see IndexDocument properties. |
RoutingRules | List | No | No | The redirection rules. You can specify up to 20 redirection rules. | For more information, see RoutingRules properties. |
IndexDocument syntax
"IndexDocument": {
"Type": String,
"Suffix": String,
"SupportSubDir": String
}
IndexDocument properties
Property | Type | Required | Editable | Description | Constraint |
Suffix | String | Yes | No | The default homepage. | After the default homepage is specified, OSS returns the default homepage if you access an object whose name ends with a forward slash (/). |
SupportSubDir | String | No | No | Specifies whether to redirect the access to the default homepage in the subdirectory when the subdirectory is accessed. | Valid values:
|
Type | String | No | No | The type of operations for the system to perform when the default homepage is specified, the name of the accessed object does not end with a forward slash (/), and the object does not exist. | This property takes effect only when SupportSubDir is set to true and applies after RoutingRule and before ErrorFile. For example, the default homepage is index.html, the path of the abc object that you want to access is bucket.oss-cn-hangzhou.aliyuncs.com/abc, and the abc object does not exist. Valid values:
|
RoutingRules syntax
"RoutingRules": [
{
"Condition": Map,
"RuleNumber": Integer,
"Redirect": Map
}
]
RoutingRules properties
Property | Type | Required | Editable | Description | Constraint |
Condition | Map | Yes | No | The matching conditions. | The rule is executed only when all specified conditions are met. A rule is matched only when the rule meets all the conditions that are specified by nodes in the Condition container. For more information, see Condition properties. |
RuleNumber | Integer | Yes | No | The sequence number of the redirection rule. OSS matches and executes the redirection rule based on the specified sequence number. | If the rule is matched, OSS executes the rule and do not execute subsequent rules. |
Redirect | Map | Yes | No | The operations for the system to perform when the rule is matched. | For more information, see Redirect properties. |
Condition syntax
"Condition": {
"IncludeHeaders": List,
"KeyPrefixEquals": String,
"HttpErrorCodeReturnedEquals": String,
"KeySuffixEquals": String
}
Condition properties
Property | Type | Required | Editable | Description | Constraint |
HttpErrorCodeReturnedEquals | String | No | No | The HTTP status code. The rule is matched only when the specified object is accessed and the specified HTTP status code is returned. When RedirectType is set to Mirror, you must set HttpErrorCodeReturnedEquals to 404. | None. |
IncludeHeaders | List | No | No | The headers that you want to include in the request. The rule is matched only when the request contains the specified headers and header values. | You can specify up to 10 headers for this property. |
KeyPrefixEquals | String | No | No | The prefix of the object name that you want to match. | None. |
KeySuffixEquals | String | No | No | The suffix of the object name that you want to match. | None. |
IncludeHeaders syntax
"IncludeHeaders": [
{
"Equals": String,
"Key": String
}
]
IncludeHeaders properties
Property | Type | Required | Editable | Description | Constraint |
Key | String | Yes | No | The header name. | None. |
Equals | String | No | No | The header value. | None. |
Redirect syntax
"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 properties
Property | Type | Required | Editable | Description | Constraint |
RedirectType | String | Yes | No | The redirection type. | Valid values:
|
EnableReplacePrefix | Boolean | No | No | Specifies whether to replace the prefix of the object name with the value of ReplaceKeyPrefixWith. If you set this property true, the prefix of the object name is replaced with the value of ReplaceKeyPrefixWith. If you leave this property empty or set this property to null, the prefix of the object name is truncated. | Note You can set this property to true only when ReplaceKeyWith is set to null. Default value: false. |
HttpRedirectCode | String | No | No | The HTTP redirection code in the response. | This property takes effect only when RedirectType is set to External or AliCDN. Default value: 302. Valid values:
|
HostName | String | No | No | The domain name for redirection. | The domain name must comply with the domain name conventions. For example, if the name of the object that you want to access is test, Protocol is set to |
MirrorURL | String | No | No | The origin URL for mirroring-based back-to-origin. This property takes effect only when RedirectType is set to Mirror. | The origin URL must start with http:// or https:// and end with a forward slash (/). OSS appends an object name to the end of the URL to generate a back-to-origin URL. For example, the name of the object that you want to access is myobject. If MirrorURL is set to |
MirrorHeaders | Map | No | No | The headers that are returned to the origin when you use mirroring-based back-to-origin. | This property takes effect only when RedirectType is set to Mirror. For more information, see the "MirrorHeaders properties" section of this topic. |
MirrorFollowRedirect | Boolean | No | No | Specifies whether to redirect the access to the address specified by Location to query data if the origin returns a 3xx status code. | This property takes effect only when RedirectType is set to Mirror. For example, when a mirroring-based back-to-origin request is sent to the origin and Location is specified, the origin returns the 302 status code. Valid values:
|
MirrorPassQueryString | Boolean | No | No | This property has the same effect as PassQueryString and takes precedence over PassQueryString. | This property takes effect only when RedirectType is set to Mirror. Default value: false. |
MirrorCheckMd5 | Boolean | No | No | Specifies whether to check the MD5 hash of the body of the response returned by the origin. | This property takes effect only when RedirectType is set to Mirror. When MirrorCheckMd5 is set to true and the response returned by the origin includes the Content-Md5 header, OSS checks whether the MD5 hash of the obtained data matches the header value. If the MD5 hash of the obtained data does not match the header value, OSS does not store the data. Default value: false. |
PassQueryString | Boolean | No | No | Specifies whether to include parameters of the original request in the redirection request when the system performs redirection or mirroring-based back-to-origin. | For example, PassQueryString is set to true, and the a=b&c=d parameter settings are included in a request sent to OSS. If the redirection code specified in the rule is 302, the parameter settings are added to the Location header value for redirection. In this example, the Location header value is changed to Default value: false. Valid values: true and false. |
Protocol | String | No | No | The protocol. | When the system performs a redirection operation and RedirectType is set to External or AliCDN, the protocol complies with the following rules: For example, the name of the object that you want to access is test and HostName is set to Valid values of Protocol: http and https. In the preceding example, the redirection operation is performed based on HTTPS that is safer than HTTP. If Protocol is set to http, the Location header value is changed to |
ReplaceKeyWith | String | No | No | The value that is used to replace the requested object name when the request is redirected. | You can specify a variable for ReplaceKeyWith. The ${key} variable is supported. For example, the name of the object that you want to access is test. If ReplaceKeyWith is set to prefix/{key}, the object name prefix specified by prefix/ is also included in the object address in the actual access scenario. In this example, the object address specified by the Location header is |
ReplaceKeyPrefixWith | String | No | No | The value that is used to replace the prefix of the object name during redirection. | For example, if KeyPrefixEquals is set to ABC/ and ReplaceKeyPrefixWith is set to def/ when you access an object named ABC/test.txt, OSS replaces ABC with def. The original object path is ABC/test.txt. After the redirection rule is applied, the object path is changed to def/test.txt. In this example, you are redirected to This example is illustrated based on the information you provide and the typical mechanism of URL redirection rules in OSS. To obtain more information about the actual result, you may need to refer to the documentation of the relevant system or service that implements the redirection rule. |
MirrorHeaders syntax
"MirrorHeaders": {
"PassAll": Boolean,
"Pass": List,
"Sets": List,
"Remove": List
}
MirrorHeaders properties
Property | Type | Required | Editable | Description | Constraint |
PassAll | Boolean | No | No | Specifies whether to pass through request headers except for the excluded headers to the origin. | This property takes effect only when RedirectType is set to Mirror. The following headers are excluded:
Default value: false. |
Pass | List | No | No | The headers that you want to pass through to the origin. | This property takes effect only when RedirectType is set to Mirror. Each header can be up to 1,024 bytes in length, and can contain only digits, letters, and en dashes (‒). You can specify up to 10 headers for this property. |
Remove | List | No | No | The headers that you do not want to pass through to the origin. | This property takes effect only when RedirectType is set to Mirror. Each header can be up to 1,024 bytes in length, and can contain digits, letters, and en dashes (‒). You can specify up to 10 headers for this property. |
Sets | List | No | No | The headers that are sent to the origin. The headers are configured in the data returned by the origin regardless of whether the headers are included in the request. | This property takes effect only when RedirectType is set to Mirror. You can specify up to 10 headers for this property. For more information, see the "Sets properties" section of this topic. |
Sets syntax
"Sets": [
{
"Value": String,
"Key": String
}
]
Sets properties
Property | Type | Required | Editable | Description | Constraint |
Key | String | Yes | No | The header key. The header key can be up to 1024 bytes in length. The character set of this property is the same as the character set of Pass. | This property takes effect only when RedirectType is set to Mirror. |
Value | String | Yes | No | The header value. The header value can be up to 1,024 bytes in length, and cannot contain \r\n. | This property takes effect only when RedirectType is set to Mirror. |
ErrorDocument syntax
"ErrorDocument": {
"HttpStatus": String,
"Key": String
}
ErrorDocument properties
Property | Type | Required | Editable | Description | Constraint |
Key | String | Yes | No | The default error page. | After an error page is specified, the error page is returned if the object that you access does not exist. |
HttpStatus | String | No | No | The HTTP status code returned with the error page. | Valid values:
|
Return values
Fn::GetAtt
None.