Alibaba Cloud CDN allows you to rewrite HTTP headers in back-to-origin requests. You can manage HTTP headers for back-to-origin requests based on your business requirements.

Background information

HTTP request headers are a component of the header section in request messages transmitted over HTTP. HTTP request headers bring specific parameters to servers.

If the requested resource is not cached on Alibaba Cloud CDN edge nodes, the request is redirected to the origin server. The information carried by the request headers is passed on to the origin server. Alibaba Cloud CDN allows you to rewrite HTTP request headers in back-to-origin requests so that your origin server can identify user information more easily. For example, you can configure the X-Forwarded-For (XFF) header to pass client IP addresses to your origin server.

HTTP request headers
Note HTTP request header management is optimized. You can replace, modify, and delete headers in back-to-origin requests, specify whether duplicate headers are allowed, and enable cross-origin request authentication. For more information, see Rewrite HTTP headers in back-to-origin requests (upgraded feature).

Procedure

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.
  4. In the left-side management pane of the domain name, click Back-to-origin.
  5. Click the Custom Request Header tab.
  6. Click Customize.
  7. In the Customize Back-to-origin Request Header dialog box, select Custom Origin Header from the Parameter drop-down list, and set Custom Parameters and Value.
    Notice
    • When you set parameters in the Customize Back-to-origin Request Header dialog box, we recommend that you set Parameter to Custom Origin Header and select a header based on your business requirements.
    • After you set the Customize Back-to-origin Request Header parameter, the strings are converted to camel case during back-to-origin routing, as shown in the following examples:
      • Example 1: ALI-CDN is converted to Ali-Cdn.
      • Example 2: ALICDN is converted to Alicdn.

      If you want to disable automatic letter case conversion, add the following header to Customize Back-to-origin Request:

      • Parameter: Ali-Swift-Header-Capitalize
      • Value: off
    Customize an HTTP header

    If you want to modify or delete an HTTP header, click Modify or Delete in the Actions column.

  8. Click OK.

What to do next

In the Customize Back-to-origin Request Header dialog box, if you set Parameter to Custom Origin Header, the following error message may be returned. The error message is returned because the specified header is reserved. Reserved headers cannot be configured in the console. In this case, specify another header.

Configuration examples

Sample scenario: Enable the origin server to compress files before they are returned to the edge nodes to reduce data transfer.

Configuration: The following figure shows the configuration. Configurations

Expected result: The files returned from the origin server are compressed.