This article applies to AWS China Region services. You will learn how to use Amazon CloudFront in the China Region to accelerate and distribute traffic from websites deployed on EC2, and use the China CloudFront SSL Plugin to deploy free SSL certificates to protect your site. The plugin helps you generate, renew, and download free SSL certificates in the AWS China Regions, with Amazon CloudFront integration and automatic certificate renewal. You can also refer to the EC2-CloudFront integration section for configuring CloudFront to distribute EC2 website traffic in AWS Global Regions.
Why Choose Amazon CloudFront?
Amazon CloudFront is a Content Delivery Network (CDN) service provided by AWS. Using a CDN reduces website load times, lowers bounce rates, and increases traffic and revenue, while also reducing the load on origin servers, improving website stability, security, availability, and reliability. Amazon CloudFront securely delivers data, videos, applications, and APIs to customers globally with low latency and high transfer speeds in a developer-friendly environment, and integrates seamlessly with Amazon S3, Elastic Load Balancer, Amazon EC2, and more.
Amazon CloudFront not only accelerates your website and reduces origin server load, but also lowers the data transfer costs for traffic leaving your AWS-hosted website to the internet. For example, compared to EC2’s outbound data transfer costs, using Amazon CloudFront in the AWS China Regions can help you reduce outbound data transfer costs by at least 67%. For specific pricing, refer to the AWS China Region official website EC2 Data Transfer Pricing and CloudFront Data Transfer Pricing.
Considerations for Using CloudFront in China Regions
ICP Filing and Domain Registration: According to relevant laws and regulations, if you need to host a website in mainland China, you must first complete ICP filing. Domains without ICP filing cannot serve web content. Please prepare an ICP-filed domain. Refer to the AWS China ICP Filing Support Documentation for more details on obtaining the required ICP filing for your domain.
CloudFront Provided Domain: CloudFront automatically assigns a
*.cloudfront.cndomain. However, due to ICP filing requirements, you cannot directly use this domain for website services in China. You must add an ICP-filed domain as an alternate domain name (also known as CNAME) to your CloudFront distribution, and then use the alternate domain name to access your website.CloudFront SSL/TLS Certificate Integration: Amazon CloudFront in the China Regions does not currently support Amazon Certificate Manager. If you need to use SSL/TLS certificates with CloudFront, you can obtain them from third-party certificate authorities and import SSL/TLS certificates. You can also use the China CloudFront SSL Plugin to obtain free SSL/TLS certificates, which will be covered in detail in the “Deploy Free Certificates with China CloudFront SSL Plugin” section of this article.
Feature Differences Between China and Global Regions: Amazon CloudFront in the China Regions does not currently support Lambda@Edge, Amazon WAF, and other features. See the documentation for more details.
Prerequisites
To complete all sections of this article and get a consistent experience with AWS services, please ensure you meet the following prerequisites.
- Your AWS China Region account has completed ICP filing, with ports 80/443 open
- You have an ICP-filed domain
- Use Amazon Route 53 as your DNS service. If you haven’t migrated your DNS to Amazon Route 53 yet, see the reference documentation
Integrating EC2 with CloudFront
In the following sections, you will launch an EC2 instance, set up a web server, integrate EC2 with CloudFront, and deploy a free SSL certificate using the China CloudFront SSL Plugin.
You will also learn some tips for using EC2 and CloudFront, such as using Elastic IP to fix your EC2 public DNS hostname for CloudFront origins, or using AWS-managed prefix lists to enhance EC2 security.
The deployment architecture is shown below:

Create EC2 and Install Web Server
In this section, you will create an EC2 instance with a web server, then bind an Elastic IP to fix the EC2 public DNS hostname.
1. Launch EC2 Instance
You can launch an EC2 instance from the EC2 console.

Name your instance, e.g., “web-server”.
You can keep the default AMI and instance type.
- AMI: Amazon Linux 2023
- Instance type: micro

Under “Key pair”, select an existing key pair or create a new one for subsequent system administration.

For network settings, ensure your EC2 instance is deployed in a public subnet, and check “Allow HTTP traffic from the internet” to make port 80 accessible from the internet.

Expand the “Advanced details” section at the bottom:

At the bottom of the page under “User data”, paste the following script to install a web server on first boot. Then click “Launch instance” to start the instance.
| |

2. Create Elastic IP and Associate with EC2
Elastic IP is a static IPv4 address designed for cloud computing. Using an Elastic IP ensures your EC2 instance’s public IP address and public DNS hostname remain unchanged. In this section, you will learn how to associate an Elastic IP with your EC2 instance and access your site using the EC2 instance’s public DNS hostname.
Find Elastic IP under “Network & Security” in the EC2 console left menu.

Click “Allocate Elastic IP address” in the upper right, then click “Allocate” to obtain an Elastic IP.

Select your Elastic IP, click the “Actions” button in the upper right, and choose “Associate Elastic IP address”.

Select your previously created EC2 instance and click “Associate” to ensure the EC2 instance’s public IP address remains stable.

Click the “Instances” menu on the left to return to the instance list, select your instance, and copy the public IPv4 DNS.

Access the public DNS hostname in your browser to verify the web server is installed. You can see the site is currently using port 80 without an SSL/TLS certificate.

In the following sections, you will use this hostname as the CloudFront origin to divert website traffic from EC2 to Amazon CloudFront.
Create CloudFront Distribution
In this section, you will create a CloudFront distribution and associate it with the previously deployed EC2 instance, routing traffic through CloudFront to accelerate content delivery.
1. Create CloudFront Distribution and Associate EC2
Next, you will quickly set up a CloudFront distribution. Go to the CloudFront console and create a distribution:

On the CloudFront configuration page, you will see the basic configuration elements that a CloudFront distribution requires:
- Origin – The origin server, supporting multiple AWS services including but not limited to S3, EC2, ELB, API Gateway, as well as third-party origins
- Cache Behavior – Define caching behavior through path matching, enable transfer compression, allowed request methods, access control, etc.
- Settings – Alternate domain names (CNAME), SSL certificate, default root object, logging, etc.
For the origin, use the EC2 public DNS (with Elastic IP) as the origin domain. Ensure the origin protocol is HTTP.

For the default cache behavior, you can keep the default settings:

Note: Due to compliance requirements, the default CloudFront distribution domain in the Beijing/Ningxia regions cannot be accessed directly. You must complete domain ICP filing and set up CNAME DNS resolution before access is possible.
In the settings section, enter your ICP-filed domain as the alternate domain name (CNAME):

After creation, wait for deployment to complete. Once deployed, check your alternate domain name — if the domain has passed ICP filing, you should see a “green checkmark”.

After deployment, go to Route 53 (or your DNS provider) to update the DNS configuration. Using Route 53 as an example, enter the corresponding domain’s hosted zone and create a new record.

Fill in the DNS record:

After completing the DNS update, open your browser and access the ICP-filed domain:

Note: If you encounter a 502 error, check whether EC2 has an SSL certificate installed or whether the origin port is correct. See the documentation. If you encounter a 403 error, ensure you are accessing via the ICP-filed domain.
2. Enhance EC2 and Website Security
In this section, you will use AWS-managed prefix lists to enhance EC2 security. You can use the Amazon CloudFront managed prefix list to restrict inbound HTTP/HTTPS traffic to only the IP addresses of CloudFront origin-facing servers.
Select your instance, go to the EC2 security group, and edit the inbound rules: add an HTTP rule, enter “cloudfront” in the source field, select the com.amazonaws.global.cloudfront.origin-facing prefix list, and remove the existing 0.0.0.0/0 rule.

You can also associate SSL/TLS certificates with CloudFront to enhance website security. In the following section, you will deploy free SSL certificates using the China CloudFront SSL Plugin.
Deploy Free Certificates with China CloudFront SSL Plugin
Before starting, please confirm once again that you are using Amazon Route 53 for DNS resolution. This section covers the deployment process only. For more details, see the China CloudFront SSL Plugin.
1. Initialize Deployment
Deploy via CloudFormation. Click the link to launch the stack in the CloudFormation console.

2. Enter Deployment Parameters
Specify stack details with the following parameters:
- Stack Name: Name your stack
- Email: Enter your email for SNS email notifications (only one email supported)
- Domain Name: Enter the domain names for the SSL certificate. Supports wildcard domains and multiple domains (comma-separated)
- SSL Renew Interval Days: Enter the certificate renewal interval. Let’s Encrypt certificates are valid for 90 days; enter a number between 1 and 89. Recommended default: 80 days.

3. Confirm Deployment
Review the deployment details on the current page, check the “I acknowledge” box at the bottom, and click Submit.

After submission, you will see resources being created in the stack events tab. Wait approximately 3 minutes.
4. Subscribe to SNS Notifications Promptly
During the stack deployment process, check your email promptly. You will receive an SNS subscription confirmation request from no-reply@sns.amazonaws.com. Please click the confirmation link as soon as possible.

Successful subscription confirmation:

5. Check Stack Deployment Progress
When the stack status changes to green CREATE_COMPLETE, the deployment is finished.
Check the “Outputs” tab for quick links:
- CloudfrontConsole: Access the CloudFront console to quickly bind the issued certificate
- ManagementWebURL: Access SwaggerUI to view or delete existing SSL certificates in IAM
- S3BucketURL: Access the S3 console to download the issued SSL certificates

6. Bind SSL Certificate in the Amazon CloudFront Console
After stack deployment is complete, an SSL certificate will be automatically requested for your domain. If you have subscribed to the SNS topic, you will receive an email notification confirming the certificate has been issued. The certificate name consists of the stack name and expiry time, e.g., Certbot-2023-11-14-1540.

Open the CloudFront console, select your distribution, and find the option to edit alternate domain names and SSL certificate.

Select the corresponding SSL certificate from the custom SSL certificate dropdown, then save changes.

After deployment, you can access your CloudFront-accelerated site via HTTPS in the browser and verify the SSL certificate issued by Let’s Encrypt, valid for 90 days.

For more information on using the China CloudFront SSL Plugin, see the plugin documentation.
Summary
Through this article, you have learned the basics of Amazon CloudFront and how to divert website traffic deployed on EC2 to CloudFront for acceleration and cost savings. You have also learned to use AWS-managed prefix lists in EC2 security groups to ensure your EC2 only accepts traffic originating from CloudFront, and to deploy free SSL certificates using the China CloudFront SSL Plugin to protect your site with HTTPS.
References
- China CloudFront SSL Plugin
- Amazon CloudFront Introduction
- Amazon CloudFront China Region Differences
- Network Acceleration with Amazon CloudFront in China
Original Post: Amazon CloudFront Deployment Mini-Guide (Part 8) - Deploy Free Certificates with China CloudFront and CloudFront SSL Plugin