Treat the CloudFront domain as a first-party domain for your website.
To treat the CloudFront domain as a first-party domain for your website, you’ll need to configure CloudFront to serve content using a custom domain (CNAME) that is a subdomain of your main domain. Here’s a step-by-step guide:
- Generate an SSL certificate: First, you need to generate an SSL certificate for your custom subdomain (e.g.,
cdn.farukgaric.com). You can use AWS Certificate Manager (ACM) to create a free SSL certificate or obtain one from a third-party Certificate Authority (CA).
- Create a CloudFront distribution: Go to the AWS Management Console, and under the “Services” menu, select “CloudFront.” Click on “Create Distribution,” and then “Web.” Fill in the “Origin Settings” to point to the origin of your website’s content (e.g., an S3 bucket or an HTTP server).
- Add CNAME to CloudFront distribution: In the “Distribution Settings” section, under “Alternate Domain Names (CNAMEs),” enter your custom subdomain (e.g.,
- Select SSL certificate: Under “SSL Certificate,” choose “Custom SSL Certificate,” and select the SSL certificate you generated in Step 1.
- Finish creating the distribution: Complete the rest of the form with your desired settings, and click “Create Distribution.” It may take some time for your new distribution to deploy.
- Update your DNS records: Add a CNAME record to your domain’s DNS settings, pointing your custom subdomain (e.g.,
cdn.) to the CloudFront distribution domain name (e.g.,
- Update your website’s code: Modify the URLs of your CSS files and other resources in your website’s HTML to point to your custom subdomain (e.g.,
Once these steps are completed, your custom subdomain will be a first-party domain for your website’s resources. It may take some time for DNS changes to propagate, so be patient while the new settings take effect.
Keep in mind that these instructions are for AWS CloudFront. The process might be slightly different if you’re using a different CDN.