How to use Amazon CDN or Cloudfront
Domain registration
-
To do this, first point an A record to your server address in DNS. Suppose you have pointed sub1.domain.com to the IP address of your server.
-
Go to Amazon AWS and search for Cloudfront service.
- Create a destination by clicking create distribution.
- Enter the values in the opened page according to the image below.
All values on this page are default except for the following which should be set as shown in the images.
- At the end, click on
create distribution
to perform the creation operation. - In the next step, go to the location of your DNS records. Assuming that you have registered in Cloudflare, enter the DNS section of your domain and create a cname record. Suppose you create
sub2.domain.com
and set its value equal to the domain created in the previous step in AWS. This value can be seen in thedetails
section underDistribution domain name
.
In fact, this subdomain will be used for our CDN domain.
- Go back to the AWS panel and click on the
edit
option in theGeneral
tab of thesetting
section and click onAdd item
in theAlternate domain name (CNAME) - optional
section that opens. and enter the cname domain from the previous step,sub2.domain.com
.
Getting a certificate
- Enter the
Custom SSL certificate - optional
section and get anssl certificate
for the desired domain. For this, click onRequest certificate
. -
In the newly opened page, continue the process of receiving the certificate and in the
domain name
section and the address field, enter the details of the subdomain registered in the previous step, namelysub2.domain.com
and set the other values as default. and click onRequest
. -
On the certificate list page, you can see that the desired domain status is
pending validation
. Click on the ID and see theDomains
section on the opened page.
- In this section, two values of this section,
Cname name
andCname value
are needed to complete the certificate status. - Go to your DNS records (presumably Cloudflare) and create a
Cname name
record and enter the values you had in the previous step in AWS. In Cloudflare, enterCname name
instead ofname
andCname value
instead ofTarget
. - Now if you go back to AWS and the certificate list page and refresh the page, you will see that the status has changed from
pending
toissues
, which means that our domain has received the certificate correctly. - Now it is back to the
distribution
settings page and the certificate derivation stage, and if you click the refresh button forcustom ssl
, you can see the certificate you received in the previous stage. Select it and leave the other values of this page as default.
[!tip] Note: Be careful not to tick the
Legacy client support
because this option costs $600 per month.
- At the end, click the save changes option to save the changes.
- Now wait until the changes are applied and according to the image below, the state of
Last modified
will change fromDepoloying
to done to the date and time.
-
It usually takes between 2-5 minutes for these changes to be applied, which can be followed by refreshing the screen. Always remember that at any stage you make changes, it should change to this state, which means that the changes are fully applied and usable.
-
Congratulations, the work is done. Amazon Cloudfront CDN is successfully launched. Now just register your CDN domain in your HiFi Manager.