Alibaba Cloud Content Delivery Network (CDN) provides the URL signing feature to protect origin servers from unauthorized downloads and access. Hotlink protection provides a referer blacklist and a referer whitelist that can address some hotlink issues. However, the referer header can be forged. Origin servers require protection features that are more optimized than hotlink protection. In this case, you can enable the URL signing feature to protect your origin server.

Background information

URL signing works with both origin servers and CDN nodes to protect origin servers from hotlink issues.
  • URLs can be signed by CDN nodes. Signed URLs carry signature information that can be used for permission verification.
  • Users send signed URLs to CDN nodes.
  • CDN nodes authenticate the signatures of the URLs. If a URL passes the authentication, a response is returned. If a URL fails the authentication, the request is rejected.

For more information about sample URL signing code in Python, see URL signing examples.

Notice After a request passes the authentication, the special characters such as = and + in the URL are escaped.

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 target domain name and click Manage.
  4. In the left-side navigation pane of the specified domain, click Access Control.
  5. Click the URL Signing tab.
  6. In the URL Signing section, click Modify.
  7. In the Set URL Signing dialog box, turn on the URL Signing switch and set the parameters.
    URL signing
    Parameter Description
    Type
    Alibaba Cloud CDN supports three signing types. You can select a signing type based on your business requirements to protect resources on your origin server. Supported signing types are:
    Note If a URL signing error occurs, a 403 error is returned.
    • MD5 calculation errors

      Example: X-Tengine-Error:denied by req auth: invalid md5hash=de7bfdc915ced05e17380a149bd760be

    • Time-related errors

      Example: X-Tengine-Error:denied by req auth: expired timestamp=1439469547

    Primary Key Specify the primary key for the selected signing type.
    Secondary Key Specify the secondary key for the selected signing type.
  8. Click OK.

What to do next

To generate a signed URL, perform the following steps:
  1. In the Generate Signed URL section, enter the Original URL and signing information.
    Parameter Description
    Original URL Enter a complete URL, for example, https://www.aliyun.com.
    Type
    Select a signing type based on your business requirements.
    Cryptographic Key Set the cryptographic key. The Cryptographic Key is the Primary Key or Secondary Key specified in the URL Signing settings.
    Validity Period Set the validity period for the signed URL based on your business requirements. Unit: seconds. Example: 1800.
    Note The default validity period is 30 minutes. If you want to set a validity period of less than 30 minutes, set Validity Period to a negative value. For example, if you want to set the validity period to 10 seconds, set Validity Period to -1790.
    Generate a signed URL
  2. Click Generate.
    A Signed URL and a Timestamp are generated.URL signing