The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

4 Steps To Setup Cloudflare CDN In Magento 2

Content Delivery Network (CDN) is a global server system which serves content to the users via a global network of data centers. Cloudflare CDN is one of the largest CDN providers in the world. With the support of Cloudflare CDN, the distance between the content and users is minimized. As a result, Cloudflare CDN helps businesses reach global audiences more cost-effectively.

Configure Content Delivery Network (CDN) in Magento 2

Table of Contents:

Benefits of Using Cloudflare for Magento 2

Magento de­mands many resources, espe­cially for speed, performance­, managing visitor numbers, and safety. These­ are key in the rival-fille­d online shopping world.

Cloudflare provide­s tools to tackle problems and ease­ difficulties in operating your business smoothly. Ke­y features compleme­nt hosting infrastructure to enable progre­ss.

Cloudflare boasts ove­r 360 data centers globally. By caching static website­ content like images across this vast infrastructure­, traffic loads balance seamlessly. Rathe­r than solely relying on a main host, files are now store­ redundantly worldwide.

There are a few advantages of using Cloudflare for Magento 2.

Optimized Performance

Cloudflare store­s static content, like images and vide­os, to accelerate spe­ed. It minimizes HTML, JavaScript, and CSS code, conde­nsing source size. These­ enhancements optimize­ the browser cache to rapidly load conte­nt.

Improved Security

Cloudflare’s se­curity arsenal shields website­s using tools like DDoS shields, SSL/TLS encryption, and malware­ cleaners.

One prime­ defense is the­ir web application firewall. It blocks threats including malicious traffic, PCI compliance­ problems, injection attacks, brute force­ assaults, and bots aiming for checkout fraud.

DNS Load Balancing

Cloudflare’s DNS se­rvice helps balance traffic across se­rvers and data centers for Mage­nto sites. This even distribution lighte­ns loads. Additionally, Cloudflare uses technology to stop DNS Spoofing and attacks happe­ning between syste­ms.

Requirements for Cloudflare and Magento 2

To configure Cloudflare for Magento 2, you must initially establish the following:

  • Cloudflare Account
  • Authorized Domain
  • Magento Store

For Cloudflare usage, ownership of a domain (e.g., example.com) is essential. If you don’t already own a domain and intend to leverage Cloudflare for authoritative DNS, I strongly advise acquiring your domain through Domain Register.

Alternatively, utilizing Cloudflare Registrar streamlines the setup process by automatically employing Cloudflare for authoritative DNS.

Configure Cloudflare

Source: Cloudflare

4 Steps to setup Cloudflare CDN in Magento 2

Step 1: Create A Cloudflare Account And Add Your Domain Name

Access to here, and then click to the Sign Up button to create a Cloudflare account.

Setup CloudFlare CDN in Magento 2

Enter your email and password into the Email and Password field, then click to the Create Account button

Setup CloudFlare CDN in Magento 2 image 2

After creating your CloudFlare CDN account successfully, enter your domain name on the site field and click to the Add site button.

Setup CloudFlare CDN in Magento 2 image 4

Then, please follow Cloudflare’s instruction to begin the configuration process.

Step 2: Point Your Domain Nameservers To Cloudflare

Access the domain management page and change your nameservers (DNS) to Cloudflare following the instruction. In our example, the 2 DNS need to be pointed to:

  • kiki.ns.cloudflare.com
  • oswald.ns.cloudflare.com

Step 3: Configure CloudFlare to server

  • In CloudFlare, access the CND tab
  • Fill the DNS Records needed pointing to the server’s IP Note:

  • Firstly, you must enable Cloudflare (the yellow cloud icon) to use CDN of CloudFlare.
  • Secondly, when CDN is turned on, the IP will be changed. Hence, in case that the SSL of the server is turned on, it is unable for you to use CDN from Cloudflare, and the website will show an error notification.

To solve this problem, you can use the Cloudflare’s SSL at Crypto tab:

Setup CloudFlare CDN in Magento 2 image 5

Step 4: Install the Cloudflare module for Magento 2

  • You need to buy a Cloudflare module on the Marketplace and then set up the 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: Replacing 1.1.3 with the version of Magento which you offered from Marketplace.

  • After setting up Cloudflare successfully, access the Admin panel:

Setup CloudFlare CDN in Magento 2 image 6

Login to Cloudflare at Module’s Config, click to the View button to get API Key.

Setup CloudFlare CDN in Magento 2 image 7

Alright, we have completed the installation and configuration process of Cloudflare in Magento 2. To be supported with more advanced functions, you should buy the Pro version from Cloudflare.

Test Cloudflare and Magento 2 integration

Follow these steps to verify that Cloudflare CDN is functioning correctly on your Magento 2 store:

  1. Open your Magento 2 site on a web browser.
  2. Right-click on the site and select Inspect.
  3. Navigate to the Network tab in the Inspector console.
  4. Choose any JS or CSS file from the left corner.
  5. If your cf-cache-status displays HIT, it indicates that your CDN is operating effectively.

Test Cloudflare

Conclusions

This is the instructions to setup Cloudflare in Magento 2. In case you have questions on any steps, don’t hesitate to ask us. Implementing CloudFlare CDN is the smartest way to enhance your website performance and speed. You can also take a look at the Amazon Cloudfront CDN configuration guides. Furthermore, with over four years of experience in developing Magento extensions, we are here to facilitate more advanced features for your store. Let Mageplaza help you to grow your store right now!

Explore Magento 2 extensions now!

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service
x

    Explore Our Products:

    People also searched for

    Subscribe

    Stay in the know

    Get special offers on the latest news from Mageplaza.

    Earn $10 in reward now!

    Earn $10 in reward now!

    comment
    iphone
    go up