All Products
Search
Document Center

CDN:Accelerate ECS resources with CDN

Last Updated:Jun 29, 2026

This topic explains how CDN accelerates resources on an ECS instance and describes the implementation procedure.

Benefits

Using an ECS instance as the origin server for CDN combines scalable IaaS computing with accelerated static resource distribution, providing the following benefits:

  • All user requests for website resources are routed through CDN, which reduces the load on the origin server.

  • CDN traffic is charged at a lower rate than the outbound data transfer generated by direct access to an ECS instance.

  • Clients retrieve resources from the nearest CDN node, which reduces network latency and improves static resource delivery.

How it works

When using an ECS instance as an origin server, CDN caches its static resources—such as scripts, images, and audio/video files—on globally distributed acceleration nodes. Users then retrieve these resources from the nearest CDN node. CDN forwards requests for dynamic content, such as web applications and databases, to the ECS instance.

Note

To accelerate dynamic resources on your ECS instance, you can use Alibaba Cloud ESA. For more information, see What is ESA?.

The following figure shows the technical architecture.应用场景

Use case

This topic uses an example website, image.example.com, to demonstrate how to accelerate image resources hosted on an ECS instance.

Parameter

Description

Example

Website domain name

The domain name to accelerate.

image.example.com

Business type

This type depends on your website's content.

For example, if your website consists mainly of images, the business type is Image and Small File.

Image and Small File

Acceleration area

The geographic regions of your website visitors.

Chinese mainland only

Origin domain name

You can use an origin domain name or an IP address.

  • Origin domain name: Enter your origin domain name, which DNS resolves to the public IP address of your ECS instance.

  • IP address: Enter the public IP address of your ECS instance.

ecs.example.com

Note

This example uses an origin domain name.

Other services

Other business requirements.

  • Improve the cache hit ratio (configure cache expiration time).

  • Specify which site on the origin server to retrieve content from (configure an origin host).

  • Improve download efficiency for large files (configure range origin fetch).

  • Improve cache hit ratio and file distribution efficiency (configure parameter filtering).

  • Restrict access to CDN resources and prevent hotlinking from other websites (configure a Referer whitelist/blacklist).

  • Prevent hotlinking and unauthorized traffic consumption (configure URL signing).

Configuration procedure

Based on the use case, this topic outlines the procedure for accelerating resources on an ECS instance with Alibaba Cloud CDN.

加速ECS流程

Manual deployment

Prerequisites

Step 1: Add an accelerated domain name

  1. Log on to the Alibaba Cloud CDN console.

  2. In the left-side navigation pane, choose Domain Names. On the Domain Names page, click Add Domain Name and configure the parameters described in the following table based on the use case.

    Note
    • Domain Name to Accelerate: image.example.com

    • Business Type: Image and Small File

    • Region: Chinese Mainland Only

  3. Click Add Origin Server and configure the origin server.

    For Origin Info, select Origin Domain Name or IP, and enter the origin domain name or the public IP address of the ECS instance. In this example, the origin domain name is ecs.example.com. You can keep the default values for the other parameters.

    Note

    For more information about the parameters, see Configure an origin server.

  4. After you configure the origin server, click Next.

  5. Wait for manual review.

    After the domain name passes the verification, the status of the domain name changes to Enabled. In this case, the domain name is added to CDN.

  6. When the domain name status is Enabled, the CNAME for the accelerated domain name is displayed. In this example, the CNAME is image.example.com.w.kunlunsl.com.

Step 2: Configure the domain name

To improve acceleration performance and access security, you can configure the following features based on your business requirements.

  1. In the Alibaba Cloud CDN console, go to the Domain Names page. Find the domain name that you want to manage and click Manage in the Actions column.

  2. Configure the features in the following table based on your business needs.

    Use case

    Description

    Configuration

    Improve the cache hit ratio

    Set a reasonable cache expiration time to improve the cache hit ratio:

    • For static files that are infrequently updated, such as images and application installation packages, we recommend that you set the expiration time to one month or longer.

    • For static files that are frequently updated, such as JavaScript and CSS files, set the expiration time based on your business requirements.

    • For dynamic files, such as PHP, JSP, and ASP files, we recommend that you set the expiration time to 0s to disable caching.

    Configure CDN cache expiration

    Specify the site for origin fetch requests from CDN nodes

    If your origin server hosts multiple sites, and the site that CDN needs to access is different from the accelerated domain name, you must configure the origin host. Alibaba Cloud CDN uses the host information to retrieve resources from the correct site during origin fetch.

    Configure a default origin host

    Improve the efficiency of file downloads from the origin

    When you enable range origin fetch, CDN nodes can request large files from your ECS origin server in chunks. The instance then responds with only the requested range of content.

    Note

    This feature is suitable for distributing large files, such as audio and video. You do not need to configure this feature for image and small file acceleration.

    Configure range origin fetch

    • Improve the cache hit ratio

    • Improve file distribution efficiency

    When parameter filtering is enabled, CDN nodes remove the parameters that follow the ? in a URL when generating a cache hash key. This allows requests for the same resource file with different parameters to hit the same cached file, which improves the cache hit ratio and reduces traffic to the origin server.

    Filter parameters

    Restrict users who can access CDN resources and prevent hotlinking

    By configuring a Referer whitelist or blacklist, you control access based on the Referer header of the request. CDN either allows or denies the request based on your rules. If allowed, CDN serves the resource. If denied, CDN returns a 403 status code.

    Configure a Referer blacklist or whitelist

    Prevent hotlinking and unauthorized traffic consumption

    URL signing requires coordination with your origin server. The server needs to generate signed URLs according to the authentication algorithm specified in the URL signing configuration on CDN. Once enabled, CDN serves requests only from clients with valid signed URLs, thus preventing unauthorized access.

    Configure URL signing

Nginx configuration for static and dynamic content

If your origin server uses Nginx, you can improve acceleration performance by separating static and dynamic content and applying different CDN caching policies to each.

Static resource cache configuration

For static resource paths, such as /css, /js, and /images:

  • Cache expiration time: We recommend that you set the cache expiration time to 30 days (2,592,000 seconds). Static resources like CSS, JS, and images are updated infrequently. A longer cache time can significantly improve the cache hit ratio.

  • Ignore Parameters: We recommend that you enable this feature to prevent multiple cached copies from being generated when URLs contain different query parameters.

  • Range origin fetch: We recommend that you enable this feature. For large JS/CSS bundle files, CDN nodes can retrieve content in chunks based on the specified range, which reduces origin fetch traffic and response time.

Dynamic resource cache configuration

For dynamic request paths, such as /api or .php files:

  • Cache expiration time: We recommend that you set the cache expiration time to 0 seconds (no caching) to ensure that each request retrieves the latest data from the origin server.

Origin host configuration

  • Origin host: Set this to the domain name configured on your Nginx server, such as the domain name ecs.example.com that is bound to the ECS instance, not the accelerated domain name.

  • Reason: Nginx uses the server_name directive to differentiate between virtual hosts. If the origin host sent by CDN does not match a configured server_name, Nginx may route the request to a default site or return an error, preventing CDN from retrieving the correct resources.

Step 3: Configure a CNAME record

You must add a CNAME record at your DNS provider to point your accelerated domain name to the CNAME address provided by CDN. This routes user requests through the CDN network for acceleration.

The following steps show how to add a CNAME record if your DNS provider is Alibaba Cloud DNS.

Note

For more information, see Configure a CNAME record.

  1. Log on to the Alibaba Cloud DNS console by using the account that owns the domain and go to the Public DNS page.

  2. On the Authoritative Domains page, find the root domain (example.com) of the accelerated domain name, and click DNS Settings in the Actions column.

  3. Click Add Record to add a CNAME record.

    • Type: CNAME

    • Host Record: image

    • Record Value: Enter the CNAME that you obtained from the Domain Names page, which is image.example.com.w.kunlunsl.com in this example.

    • Keep the default values for the other parameters.

  4. Verify the CNAME record.

    • Method 1: Check the status in the Alibaba Cloud CDN console

      1. Go to the Domain Names page in the Alibaba Cloud CDN console.

      2. Find the target domain name and check the CNAME Status column. The status shows Configured once the CNAME record is in effect.

        Note

        A new CNAME record in Alibaba Cloud DNS takes effect immediately. An updated record takes effect after its TTL expires (the default is 10 minutes). During this propagation time, the status may appear as Pending Configuration.

    • Method 2: Use the nslookup command

      1. Open the command-line interface on your computer.

      2. Run nslookup -type=CNAME accelerated domain name. If the returned CNAME record matches the CNAME value for the accelerated domain name in the CDN console, this indicates that CDN acceleration has taken effect. For example:

        nslookup -type=CNAME image.example.com
        Last login: xxx
        xxx ~ % nslookup -type=CNAME image.example.com
        Server:
        Address:	 xxx
        Non-authoritative answer:
        image.example.com	canonical name = image.example.com.w.kunlunsl.com.
        Authoritative answers can be found from: