This topic describes how to configure mirroring-based back-to-origin rules in several example scenarios.
Example 1
- When a requester requests an object that does not exist in the examplefolder directory of examplebucketA, the request is redirected to
https://example.com
to access the required object in the destfolder directory. - The origin site contains objects whose names start with forward slashes (/). These objects must be obtained and then stored in examplebucketA.
- The MD5 hashes of the objects in the origin must be checked. If the MD5 hashes of the objects in the origin do not match the MD5 hashes calculated by Object Storage Service (OSS), these objects are not stored in examplebucketA.
To meet the preceding requirements, use the following steps to configure a mirroring-based back-to-origin rule:
Example 2
https://example.com
) and Origin B (https://example.org
). The two origins have the same directories. Customer B wants OSS to meet the following
requirements:
- When a requester requests an object that does not exist in the A/example directory, OSS searches the example directory of
https://example.com
for the object. - When a requester requests an object that does not exist in the B/example directory, OSS searches the example directory of
https://example.org
for the object. - Determine whether to request objects from the specified address based on whether the redirection policy is configured for Origin A and Origin B.
To meet the preceding requirements, refer to the steps presented in Example 1 to configure two mirroring-based back-to-origin rules that have the parameter settings described in the following tables.
- Parameter settings for Rule 1
Parameter Description Mode Select Mirroring. Prerequisite Select File Name Prefix and set File Name Prefix to A/example/. Replace or Delete File Prefix Select Replace or Delete File Prefix and set Replace or Delete File Prefix to example/. Note This parameter is displayed only when you configure the File Name Prefix parameter.Origin URL Select https in the first text box, enter example.com in the second text box, and leave the third text box empty. 3xx Response Select Follow Origin to Redirect Request. Note If Follow Origin to Redirect Request is not selected, OSS directly returns the URL specified in the redirection rule to the requester. - Parameter settings for Rule 2
Parameter Description Mode Select Mirroring. Prerequisite Select File Name Prefix and set File Name Prefix to B/example/. Replace or Delete File Prefix Select Replace or Delete File Prefix and set Replace or Delete File Prefix to example/. Note This parameter is displayed only when you configure the File Name Prefix parameter.Origin URL Select https in the first text box, enter example.org in the second text box, and leave the third text box empty. 3xx Response Select Follow Origin to Redirect Request.
The following content shows the access process after the preceding back-to-origin rules are configured:
- A requester requests
https://examplebucketB.oss-cn-beijing.aliyuncs.com/A/example/example.txt
for the first time. - If the A/example/example.txt object does not exist in examplebucketB, OSS redirects the request to
https://example.com/example/example.txt
to obtain the object. - The response to the request varies based on whether a redirection rule is set for
the origin.
- If a redirection rule is specified for the example/example.txt directory of Origin A, OSS sends a new request to the URL specified in the redirection rule for Origin A, stores the object named A/example/example.txt in examplebucketB, and returns the object to the requester.
- If no redirection rule is specified for the example/example.txt directory of Origin A, OSS stores the object named A/example/example.txt in examplebucketB and returns the object to the requester.
If a requester requests https://examplebucketB.oss-cn-beijing.aliyuncs.com/B/example/example.txt
that does not exist in the B/example directory, the object obtained by using the
back-to-origin rule is stored in the B/example directory of examplebucketB.
Example 3
- When a requester requests an object that does not exist in the examplefolder directory of the root directory of examplebucketC, OSS searches the examplefolder directory of examplebucketD for the object.
- Allow the query string included in the request URL for an object to be transferred to the origin.
- Allow the
header1
,header2
, andheader3
HTTP headers included in the request URL for an object to be transferred to the origin.
To meet the preceding requirements, refer to the steps presented in Example 1 and configure a mirroring-based back-to-origin rule that has the following parameter settings.
Parameter | Description |
---|---|
Mode | Select Mirroring. |
Prerequisite | Select File Name Prefix and set File Name Prefix to examplefolder/. |
Type of Source | Select OSS Private Bucket and select examplebucketD from the Source Bucket drop-down list.
Note When you configure Type of Source, OSS generates the
AliyunOSSMirrorDefaultRole role and grants the role the read-only permission (AliyunOSSReadOnlyAccess) on all
your buckets.
|
Origin URL | Select https in the first text box and leave the other text boxes empty. |
Other Parameter | Select Transfer queryString.
OSS transfers the query string included in the URL of the required object to the origin. |
Set Transmission Rule of HTTP Header | For Allow, select Transmit Specified HTTP Header Parameters and add the header1, header2, and header3 headers.
Back-to-origin rules do not support some HTTP headers such as |
- A requester requests
https://examplebucketC.oss-cn-shanghai.aliyuncs.com/examplefolder/example.png?caller=lucas&production=oss
for the first time. - If the examplefolder/example.png object does not exist in examplebucketC, OSS sends a request to
https://examplebucketD.oss-cn-shanghai.aliyuncs.com/examplefolder/example.png?caller=lucas&production=oss
to obtain the object. - examplebucketD collects access statistics based on the
?caller=lucas&production=oss
parameter passed to the origin and returns example.png to OSS. - OSS stores the object with a name of examplefolder/example.png in examplebucketC.
If the request includes the header1, header2, and header3 HTTP headers, these headers are also transferred to examplebucketD.