This topic provides a quick start for Alibaba Cloud CDN, including adding a domain name, configuring an origin, creating a CNAME record, and applying recommended performance and security settings.
The examples in this topic use www.example.com as the domain name and 10.10.10.1 as the origin server IP.
How Alibaba Cloud CDN accelerates content delivery
If you are already familiar with how a CDN works, you can skip this section and proceed to the configuration.
Quick access to Alibaba Cloud CDN
Complete the following configuration to enable content acceleration. If you prefer a video tutorial, you can also watch our Quick Start.
Before using Alibaba Cloud CDN, complete the following prerequisites:
-
You need to complete real-name verification for your Alibaba Cloud account. If you do not have an account, you can create one on the account registration page.
Add domain name and origin server
-
Configure domain name
To enable acceleration for your domain name, add it to Alibaba Cloud CDN as an Domain Name to Accelerate. This allows Alibaba Cloud CDN to identify and accelerate requests for the domain.
-
Q: Considerations for a unified accelerated domain name
When you configure a unified accelerated domain name, consider the following:
-
Business type selection: Select 'Image and Small File' to optimize for static resource acceleration.
-
Shared cache: If multiple accelerated domain names serve identical content from the origin server, enable shared cache to improve the cache hit ratio.
-
HTTPS support: To support HTTPS access, you must configure a separate SSL certificate for each accelerated domain name.
-
Origin host header settings: Set the origin host header to the origin's actual domain name to prevent host header mismatches.
-
Domain name addition rules: Add each domain name as a separate accelerated domain name in Alibaba Cloud CDN. For example,
www.example.comandexample.comare two different domain names and must be added as accelerated domain names and configured with CNAME records separately in the CDN console.
-
-
Verify domain ownership
Alibaba Cloud CDN requires domain ownership verification to confirm that you own the domain name. You can skip this step if you have already verified the domain or if no verification prompt appears.
-
Configure origin server information
An origin server is a web server that hosts your application content. When a cache miss occurs, a CDN node retrieves the requested resource from the origin server.
-
Verify accelerated domain name
After you add the accelerated domain name, we recommend that you test it on a local machine first. This allows you to switch DNS records without impacting production traffic. After you verify that the accelerated domain name is working correctly, point its DNS record to the CNAME address.
NoteSimulated access incurs standard CDN charges. For more information, see Billing components.
Recommended Configurations
After you configure the domain name and origin server, click Next to go to the Recommended Configurations page.
The Recommended Configurations section provides four configurations, Improve cache hit ratio, Improve access performance, Cost control, and Improve access security, to quickly improve the cache hit ratio, access performance, and security of your CDN.
You can configure features based on your business needs or skip this step. You can access this page again later by clicking Quick Configuration in the Action column on the Domain Names page.
Improve cache hit ratio
Cache Expiration
Configure cache rules to reduce origin fetch requests. Rules are matched in order, and the first matched rule takes effect. Based on your resource characteristics, set a suitable cache expiration time. The following table shows recommended configurations for rules based on file extensions.
|
File type |
File extension |
Expiration time |
Description |
|
Images/Audio/Video |
|
30 days |
Resource content does not change often. |
|
Static scripts |
|
1 hour |
May change frequently with version releases. |
|
Website homepage |
|
Do not cache (0 seconds) |
Ensures that users always get the latest page structure. |
Ignore Parameters
When you enable the ignore URL parameters feature, CDN points of presence (POPs) remove the parameters that follow the question mark (?) in a URL when generating a cache key. This allows requests for the same resource that have different parameters to hit the same cache. This improves the cache hit rate and reduces origin fetch traffic.
In the Ignore URL Parameters dialog box, set Mode to Keep Specified Parameters or Delete Specified Parameters. Set Ignore URL Parameters to Yes. In the Keep Specified Parameters field, enter the parameters that you want to keep. You can enter up to 10 parameters, separated by commas. If you enable Keep Origin Fetch Parameters, all parameters are kept for origin fetch requests. If this feature is disabled, the parameters for origin fetch requests are the same as the parameters in the cache key. Click OK to save the configuration.
Improve access performance
Range Origin Fetch
Range origin fetch retrieves only the uncached byte ranges of large files from the origin server. This prevents the re-transmission of entire files.
If the client has configured range origin fetch parameters, select Match Client. Use 512 KB chunks for images. For videos or large files, use 1 MB, 2 MB, or 4 MB chunks based on file size.
If the accelerated resources are videos or large files, select Enable Range Origin Fetch (Recommended for Large File Delivery). Select 1 MB, 2 MB, or 4 MB chunks based on file size. All origin fetch requests from CDN nodes will then use the specified chunk size.
Gzip Compression
Use Gzip compression for accelerated files between 1 KB and 10 MB to reduce the amount of data transferred.
This feature does not compress files smaller than 1 KB or larger than 10 MB. Common image and video file types are already compressed, so enabling Gzip for them has no effect. Before you enable this feature, read the precautions in Gzip compression.
Turn on the Gzip compression switch. Do not enable this feature if your origin server files have their own MD5 verification mechanism.
Cost control
To prevent high bills from sudden bandwidth spikes caused by attacks or unauthorized usage, configure a usage cap to control the maximum bandwidth, traffic, and number of HTTPS requests for your domain name. For more information, see Configure a usage cap.
-
When a capping rule is triggered, the accelerated domain name is temporarily taken offline and becomes inaccessible. If you only want to receive an alert when usage exceeds the threshold, set traffic monitoring alerts.
-
Set the threshold based on your website's historical traffic, bandwidth, and number of HTTPS requests. If you are unsure about this data, skip this configuration for now. After your system is stable, use the CDN Usage Query feature to view usage information for the accelerated domain name, and then configure the usage cap.
Traffic Cap
If your billing method is the default Pay-by-traffic, configure this feature. Set the threshold based on historical traffic. The system calculates the total traffic for the domain name over a specified period. When the cumulative traffic exceeds the threshold you set, the capping rule is triggered, and the domain name is taken offline. The accelerated domain name is brought back online at the specified unblocking time.
Bandwidth Cap
If your billing method is Pay-by-peak-bandwidth, configure this feature to effectively control the upper limit of your billable bandwidth. When the real-time bandwidth exceeds the threshold you set, the capping rule is triggered, and the domain name is taken offline. The accelerated domain name is brought back online at the specified unblocking time.
HTTPS Requests Cap
If your accelerated domain name requires HTTPS access and you need to control the budget for HTTPS requests, configure this feature. When the cumulative number of requests exceeds the threshold you set, the capping rule is triggered, and the domain name is taken offline. The accelerated domain name is brought back online at the specified unblocking time.
Enhance access security
HTTPS Certificate
If your domain name requires HTTPS access, configure a certificate. Otherwise, HTTPS is unavailable.
Skip this step if HTTPS is not required.
Enabling HTTPS generates static HTTPS requests. The first 5 million static HTTPS requests per month are free. You are charged for requests that exceed this limit. Charges for HTTPS requests cannot be offset by a CDN data plan. Ensure that your account has a sufficient balance or purchase an HTTPS request package to prevent your CDN service from being suspended due to overdue payments. For more information, see Static HTTPS requests.
-
If you purchased a certificate from Alibaba Cloud Certificate Management Service, select SSL Certificates Service and select your certificate from the Certificate Name list. If you cannot select your certificate, check that the domain name bound to the certificate is the same as the accelerated domain name.
-
If you use a certificate from a third-party provider, select Custom Certificate (Certificate+Private Key). Set a Certificate Name, and then upload the Certificate (Public Key) and Private Key. The certificate is saved in Alibaba Cloud Certificate Management Service. You can view it in My Certificates.
Referer Black/Whitelist
A Referer blocklist/allowlist controls access based on the Referer field in HTTP request headers to prevent resource hotlinking. You can configure a blocklist or an allowlist. The two lists are mutually exclusive. For more information, see Configure a Referer blocklist/allowlist.
You can enable the Customize and subscribe to operations reports feature in advance. Operations reports collect and display user access data, such as PV/UV, Regions and ISPs, Domain Name Ranking, popular referers, Popular URLs, Popular Origin URLs, and Top Client IPs. Then, use the popular referers data to configure the Referer Black/Whitelist.
Q: Hotlink protection and bandwidth limiting for CDN-to-OSS
When your CDN fetches images from OSS, use the following quick configuration settings to enable hotlink protection and control bandwidth costs:
-
Hotlink protection: In the 'Improve Access Security' section of quick configuration, set up Referer-based hotlink protection with a whitelist of your allowed domain names. Alternatively, use an IP blacklist to block malicious IPs. This prevents unauthorized use of your resources.
-
Bandwidth limiting: In the 'Prevent Excessive Costs' section of quick configuration, set a bandwidth threshold. If this threshold is exceeded, a capping rule is triggered that takes the accelerated domain name offline to control traffic and costs. The domain automatically comes back online after the unblocking period ends.
3. Configure CNAME
Configure a CNAME record to point your domain name to the nearest CDN point of presence (POP) to route user requests through Alibaba Cloud CDN for acceleration.
A CNAME record is a type of DNS record that maps one domain name to another. For more information, see Introduction to CNAME records.
Resource prefetch
After you add a domain name to CDN, you can prefetch popular static resources to CDN POPs. This provides faster access for first-time visitors by serving content directly from the cache.
-
Log on to the CDN console.
-
In the navigation pane on the left, click Purge and Prefetch.
-
On the Purge/Prefetch tab, set the operation type to Prefetch.
-
In the input box, enter the full URL of each file to prefetch. Enter one URL per line. Prefetching directories is not supported. For example:
https://www.example.com/install/package.zip. -
Click Submit.
-
On the operation records tab, view the details and progress of your purge or prefetch tasks. A task is complete when its progress reaches 100%.
-
Submitted purge or prefetch tasks cannot be canceled.
-
The completion time for a prefetch task depends on the file size, number of files, and origin server performance. A task typically takes 5 to 30 minutes.
Step 5: Verify Alibaba Cloud CDN caching
If you still cannot access your site or you encounter errors after completing these steps, see Troubleshoot access issues.
After completing these steps, you have configured Alibaba Cloud CDN to accelerate your website.