Updated on 2024-05-31 GMT+08:00

Configuring a Back-to-Source Rule

Scenarios

See Back to Source.

You can create back-to-source rules or replicate existing back-to-source rules from another bucket.

Constraints

See Back to Source.

Creating a Mirroring Back-to-Source Rule

  1. In the navigation pane of OBS Console, choose Object Storage.
  2. In the bucket list, click the bucket you want to operate to go to the Objects page.
  3. In the navigation pane, choose Back to Source. The back-to-source rule list is displayed.
  4. Click Create.

    Figure 1 Creating a mirroring back-to-source rule

  5. Configure a mirroring back-to-source rule by referring to the parameters listed in Table 1.

    Table 1 Parameters in a mirroring back-to-source rule

    Parameter

    Description

    Resource Type

    Type of the resources at the source site (origin server).

    • Public: The origin server data comes from public object storage.
    • Private: The origin server data comes from private object storage of some cloud vendors.

    Back-to-Source Condition

    Conditions that trigger the back-to-source rule.

    A mirroring back-to-source rule is triggered when the following conditions are met: The requested object starts with the specified file name prefix, and an HTTP status code 404 is returned because the object is not found in the bucket.

    The specified file name prefix:

    • Cannot exceed 1,023 characters.
    • Cannot contain or overlap with any other file name prefix specified for an existing rule.
    • Can be left blank, which means that the rule applies to all files that do not meet the conditions of other back-to-source rules configured for the bucket. A bucket can have only one back-to-source rule that does not have a file name prefix specified.

    For example, if the file name prefix is set to 123/, the rule is triggered when the 123/456.txt file is requested but not available in the bucket.

    Add Prefix or Suffix

    When OBS requests data from the source site, the prefix or suffix is added in front of or after the name of the requested object. However, the object returned to OBS and the client keeps its original name without the added prefix or suffix.

    Example: A client requests abc.txt from OBS, which triggers the back-to-source rule. If the specified prefix is 123, OBS then retrieves 123abc.txt from the source site. However, the object is still downloaded as abc.txt to OBS and then returned to the client.

    Replace Prefix With

    OBS uses the specified prefix to replace the file name prefix set in the back-to-source condition when it requests data from the source site. However, the object returned to the client keeps the original prefix in its name.

    Example: The file name prefix is set to 123 as the back-to-source condition and the replacement prefix is set to abc. When the client requests 123456.txt, the back-to-source rule is triggered. Then OBS requests abc456.txt from the source site. However, the obtained object is still saved as 123456.txt in OBS and returned to the client.

    Source URL

    Source site address. You can set active sites and standby sites.

    The active site address is preferentially used during the back-to-source process. If multiple active site addresses are configured, all active sites are accessed in polling mode. If two or more active site addresses are configured, when the first request to an active address fails and the retry conditions are met, the request will retry another active site address. Configure at least one active site. Up to five active sites are supported. If you fail to retrieve content from all active sites, the request will try standby sites.

    Format: http(https)://source domain name/static path

    • The source domain name is the domain name of the source site.
      • If the source site is a bucket that can be accessed over HTTP, the address is the bucket domain name.
      • If the source site is a private bucket provided by other cloud vendors, the address is the region domain name. At present, only private buckets of some cloud vendors are supported.
    • The static path indicates the directory that stores the target file. For example, if the static path is 123/, the target file is in the 123/ directory.

    Retry Condition

    Condition when a retry is triggered.

    4XX and a specific error code starting with 4 cannot be configured together. This rule works the same for 5XX and an error code starting with 5. A maximum of 20 error codes can be configured.

    Carry Request String

    When this function is enabled, query parameters in the request URL are passed to the source site.

    Redirect Request

    When this function is enabled, the request will follow the 3xx redirection response, if redirection is configured for the source site, to fetch the requested resource and save the resource to OBS. A request can follow a maximum of 10 redirections.

    Redirect without Referer

    With this function enabled, if redirection has been configured for the origin server, the Referer header in the request will be filtered out during redirecting.

    HTTP Header Pass Rule

    You can specify the HTTP header parameters that can be passed to the source site when a request sent to OBS triggers the mirroring back-to-source rule. References provides a configuration example and lists the HTTP headers that are not supported.

    • Pass all parameters/Pass specified parameters: Set the HTTP header parameters that can be passed.
    • Do not pass specified parameters: Set the HTTP header parameters that cannot be passed. In this case, OBS does not pass the specified headers to the source site. If a header is specified for both the pass and do-not-pass categories, it is deemed as a do-not-pass parameter.
    • Configure custom parameters: You can set a custom value for a specified header. If a client request carries this header, OBS changes the header value to the custom value before passing it to the source site.

    IAM Agency

    An IAM agency is required to delegate OBS to obtain data from the source site. The agency must grant OBS the Tenant Administrator permission, with an unlimited validity period. If no appropriate IAM agency is available, create one by referring to Creating an IAM Agency.

  6. Click OK.

Replicating Mirroring Back-to-Source Rules

  1. In the navigation pane of OBS Console, choose Object Storage.
  2. In the bucket list, click the bucket you want to operate to go to the Objects page.
  3. In the navigation pane, choose Back to Source. The back-to-source rule list is displayed.
  4. Click Replicate.
  5. Select a replication source, which is bucket whose back-to-source rules you want to replicate.

    • The back-to-source rules replicated from a source bucket will not overwrite existing rules in the destination bucket, and any that conflict with the existing ones will not be replicated.
    • The version of both source and destination buckets must be 3.0.
    • Before replicating the back-to-source rules, you can change their source URL. For details about the source URL configuration, see Table 1.
    • You can remove the rules that you do not want to replicate.
    • There can be five back-to-source rules at most in a bucket. If the number of rules you will replicate plus the number of existing rules in the destination bucket exceeds five, the replication will fail. Before replicating the rules, delete some if necessary.
    Figure 2 Replicating back-to-source rules

  6. Click OK to replicate the rules to the destination bucket.

References

Example for configuring an HTTP header pass rule:

Assume that the parameters are set as shown in Figure 3.

Figure 3 Configuring an HTTP header pass rule

Based on the preceding configuration, if the header of the request sent to OBS is as follows:

GET /ObjectName HTTP/1.1 
Host: bucketname.obs.region.myhuaweicloud.com
aaa:aaa
bbb:bbb
ccc:ccc

OBS sends the following request to the source site when the back-to-source rule is triggered:

GET /ObjectName HTTP/1.1 
Host: source.com 
aaa:aaa
ccc:111

Notes for passing HTTP headers during back to source

  • HTTP headers that can be passed from a source site to a client:
    • Content-Type
    • Content-Language
    • Content-Encoding
    • Content-Disposition
    • Cache-Control
    • Expires
  • HTTP headers that cannot be passed from a client to a source site:
    1. HTTP headers starting with the prefix below:

      x-obs-

    2. All standard HTTP headers, including:
      • Content-Length
      • Authorization2
      • Authorization
      • Range
      • Date