How To Install Cloudflare CDN For Magento 2

by admin

First, we will briefly introduce you about CDN and its benefit. CDN is the acronym for Content Delivery Network, which is a global server system. CDN saves the content in a website and then distributes those content to other servers. Those servers will transfer data to users when they access the website.

Here, we will walk you through step by step to install Cloudflare CDN for your Magento 2.

1. Sign up for Cloudflare and add your domain name

Add your domain name to Cloudflare:

Add domain name cloudflare cdn magento 2

After adding your domain, please follow the Cloudflare’s guide to start configuration.

cloudflare cdn magento 2 guide

2. Change your domain name servers to Cloudflare

Access the domain management page and point the domain’s DNS to Cloudflare according to the instruction. In our example, the 2 DNS need to be pointed to:

  • elinore.ns.cloudflare.com
  • jonah.ns.cloudflare.com

3. Configure CloudFlare to server

In CloudFlare, access the CND tab:

CND tab cloudflare cdn magento 2

Fill the DNS Records needed pointing to the server’s IP.

Note:

  • First, you must enable Cloudflare (the yellow cloud icon) in order to use CDN of CloudFlare
  • Secondly, if the SSL of the server is turned on, you can not use CDN from Cloudflare because the IP will be changed when turning on CDN, then the website will display an error notification.

Solution: Use Cloudflare’s SSL at Crypto tab:

crypto tab cloudflare cdn magento 2

4. Set up Cloudflare module for Magento 2

You need to order Module on Marketplace, and then set up Module via Composer:

Path of the Module on Marketplace is: cloudflare/cloudflare-magento

Access the SSH and find root folder of Magento

Type this command: composer require cloudflare/cloudflare-magento:1.1.3

Note: When ordering Module on Marketplace, there will be an edition, replace the 1.1.3 with the version you ordered.

SSH cloudflare cdn magento 2

After installation, access the Admin:

backend cloudflare cdn magento 2

Log in to Cloudflare at Module’s Config

log in cloudflare cdn magento 2

After that, get API Key like the picture below:

API key cloudflare cdn magento 2

So we have finished setting up and configuring Cloudflare for Magento 2. You should purchase the Pro version from Cloudflare to be supported with more advanced features.

You might also want to know: How to configure Amazon CDN (CloudFront) for Magento 2

Next Reading Suggestions