Nexcess Logo

How to set up the Cloudflare CDN for Magento 2

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
November 07, 2023

This article describes how to set up a Content Delivery Network (CDN) for a Magento 2 website hosted at Nexcess using various methods in conjunction with the highly acclaimed Cloudflare CDN provider.

The benefits of using the Cloudflare CDN are also documented. In addition, the sections below briefly explain the Performance Shield add-on feature offered by Nexcess.

Overview of the Cloudflare CDN for Magento 2 configuration

With a distributed network of servers spread over the globe, Cloudflare offers a robust CDN for Magento 2 stores. It intelligently routes requests for content using the most efficient network pathways. Such a platform provides your valued visitors access to website-cached static content based on their location — for faster page loading.

The CDN for Magento 2 also serves as a proxy server; your IP will be hidden when you enable Cloudflare. The only people who will know the IP address of your server are you and your server administrator due to this masking. The server IP won't change when Cloudflare is enabled; instead, it will be hidden.

As soon as Cloudflare is established for your domain, the CDN and site optimization will begin. Additionally, as a Nexcess customer, leveraging the Nexcess Edge CDN powered by Cloudflare is among the easiest methods for configuring your domain's CDN.

The benefits of the Cloudflare CDN for Magento 2

  • Performance. Enhance efficiency on an ultra-private network by adding more edge caching and Brotli compression.
  • Image enhancement. Allow on-the-fly edge image conversion for next-generation picture formats is one of its key features.
  • Enhanced protection for websites. Websites can be shielded from various threats by using Cloudflare's security capabilities, such as SQL injection, DDoS, and cross-site scripting attacks.
  • Limit the bandwidth over usage. Perform automatic content caching and sending it to the user from the server that is nearest to them.
  • Minification of code. By reducing the number of characters in CSS and JavaScript files and eliminating superfluous ones, minification enhances the speed of websites.
  • Load balancing. Offers high availability and enhanced performance in addition to load balancing, achieved by dividing incoming traffic among several servers or data centers.
  • Enhanced SEO. Your website's search engine ranking can be greatly improved by faster loading times.

Multiple ways to set up CDN for Magento 2


Method #1: Using the Performance Shield add-on from Nexcess with Magento 2

Nexcess is thrilled to present the Performance Shield feature set to its clients in collaboration with Cloudflare. For Cloudflare integration with your Nexcess account, these combined functionalities are available with the enterprise performance and enhanced security protection add-on, known as Performance Shield from Nexcess and powered by Cloudflare.

The product name is shorthand for the Nexcess Enterprise Performance and Protect add-on. This premium set of bundled features guards the performance integrity of your website by anticipating the newest security risks. Cloudflare's WAF, DDoS protection, CDN for Magento 2, and continuous network prioritization are included in all our Performance Shield plans that can be bought per website. Now, for optimal performance protection, you can upgrade one or multiple websites on your hosting plan with Nexcess.

Step #1a

Click on the Performance option from the Magneto plan list:

Click on the Performance option from the Magneto plan list.


Step #1b

You must point your domain to Nexcess nameservers to enable Performance Shield. Once this is done, please select the Activate Performance Shield button:

You must point your domain to Nexcess nameservers to enable Performance Shield. Once this is done, please select the Activate Performance Shield button.


Step #1c

There are three types of Performance Shield plans that may be purchased, and the cost is per website per month:

  • Small plan at a cost of $5 per website per month
  • Medium plan at a cost of $10 per website per month
  • Large plan at a cost of $10 per website per month

Please select the desired plan and then select the Add Performance Shield Plan button. Please note that the Performance Shield features will take some time to take effect as they are rolled out to worldwide caching servers:

Please select the desired plan and then select the Add Performance Shield Plan button. Please note that the Performance Shield features will take some time to take effect as they are rolled out to worldwide caching servers.


It is advisable to activate during a non-peak hour for your website. Please give Cloudflare up to 24 hours to cache your content and provide top-notch performance no matter the website visitor's global location.

Also, the site admin should know that the CDN for Magento 2 details will disappear from the Nexcess Client Portal once the Performance Shield functionality has been activated:

Also, the site admin should know that the CDN for Magento 2 details will disappear from the Nexcess Client Portal once the Performance Shield functionality has been activated.


Method #2: Using the Nexcess Edge CDN with Magento 2

You can use the corresponding Magneto Command Line Interface (CLI) command to set up the Nexcess Edge CDN in a standalone fashion if you're not interested in the premium service facilitated by the Performance Shield add-on and plans.

Step #2a

Deactivate the Performance Shield add-on if the domain has a premium Performance Shield plan currently configured.

Step #2b

Navigate to the Nexcess CDN details, which are found by going to the portal's Content Delivery tab:

Navigate to the Nexcess CDN details, which are found by going to the portal's Content Delivery tab.


Step #2c

Run the following Magento CLI commands to configure the Nexcess Edge CDN:

[ae631018@cloudhost-7138473 791e7fa4ae.nxcli.io]$ php bin/magento config:set web/secure/base_static_url https://eadn-wc01-11015885.nxedge.io/cdn/static/

[ae631018@cloudhost-7138473 791e7fa4ae.nxcli.io]$ php bin/magento config:set web/unsecure/base_static_url https://eadn-wc01-11015885.nxedge.io/cdn/static/



[ae631018@cloudhost-7138473 791e7fa4ae.nxcli.io]$ php bin/magento config:set web/secure/base_media_url https://eadn-wc01-11015885.nxedge.io/cdn/media/

[ae631018@cloudhost-7138473 791e7fa4ae.nxcli.io]$ php bin/magento config:set web/unsecure/base_media_url https://eadn-wc01-11015885.nxedge.io/cdn/media/ 


Note that if your Magento 2 store is installed using pub directory, then you must use the following syntax instead:

https://eadn-wc01-11015885.nxedge.io/cdn/pub/static/
https://eadn-wc01-11015885.nxedge.io/cdn/pub/media/


Method #3: Using your own Cloudflare account with Magento 2

Alternatively, you can use your own Cloudflare account to set up a CDN for the Magento 2 store domain you host with us. To do so, you can follow guidance covered in this article:

How to use Cloudflare CDN

Beware that if you calculate the total costs, leveraging the Cloudflare options offered exclusively to Nexcess account holders are more economical due than using your own Cloudflare account to our partnership with Cloudflare.

Method #4: Use your own account with a third-party CDN provider in conjunction with Magento 2

You can also configure CDN using third-party providers like BunnyCDN, Fastly, Sucuri, CDN77, KeyCDN, or Cloud CDN by Google.

To complete your CDN for Magento 2 setup using a third-party CDN provider, refer that company's documentation along with the various guides found in our knowledge base. Feel free to contact our support team if you require more assistance during the process.

CDN for Magento 2 — frequently asked setup questions


How can you check if the Cloudflare CDN for Magento 2 is enabled?


Method #1

Check the A record for the domain. If the Cloudflare Performance Shield is active and the A record points to a Cloudflare IP address, then it uses the Cloudflare CDN as expected:

Root@viproot-Vostro-15-3568:~# dig +short techworkq.com 

104.16.81.94 
104.16.82.94


Method #2

Once you use curl command with the domain name, it will show the server's name as cloudflare if configured properly.

root@viproot-Vostro-15-3568:~# curl -IL techworkq.com
x-host: techworkq.com
x-varnish: 2490836 2490808
x-cache: HIT x-varnish-age: 84 pragma: no-cache expires: -1
BYPASS cf-cache-status: DYNAMIC 
server: cloudflare  


Method #3

Load the domain in the CDN Finder website to check the status of your CDN for Magento 2 configuration:

Load the domain in the CDN Finder website to check the status of your CDN for Magento 2 configuration.


Is it necessary to set up the Nexcess Edge CDN separately if the Performance Shield add-on is turned on?

Yes, using the Performance Shieid add-on does not automatically configure the prerequisite CDN by Nexcess in the Magento administration area. The primary Nexcess Edge CDN integration must be set up for a site if you want to have site assets served by our CDN for Magento 2.

The Performance Shield add-on augments the Nexcess Edge CDN platform with many security features and two performance features in it. For setting up a Performance Shield plan, please configure the Nexcess CDN first and then activate the Performance Shield add-on per website you wish to use it on. Remember that the monthly fees are assessed on a per website basis.

How better will page loading performance be over just using the Nexcess Edge CDN?

The Performance Shield add-on is 100% of the time used together with the Nexcess Edge CDN. Features included with Performance Shield are mostly related to security enhancements, such as WAF, DDoS protection, and bot protection. At-the-edge image conversion along with CSS and JS edge minification are the performance features that come with the add-on.

To be transparent, implementing the Performance Shield add-on might not demonstrate any faster page loading speeds than utilizing the Nexcess Edge CDN by itself, even with the slight improvements in auto-minification (CSS and JS) and image conversion at the edge. You can expect a slight improvement in front-end performance, though.

For secondary sites on Magento plan, is it possible to enable Performance Shield?

It is not feasible at this time. It’s a technical limitation; that feature is on our roadmap for the future, but we do not have an ETA.

Which websites can utilize Performance Shield?

Performance Shield can be added to managed hosting for any PHP-based application hosted at Nexcess, including WordPress, WooCommerce, and Magento — as well as for any application found on a Flexible Cloud Plan with us.

Conclusion regarding the Cloudflare CDN for Magento 2

The purpose of this article was to provide you with further insight into the different ways we can set up a CDN for your Magento 2 online store hosted on Nexcess servers.

Let our Performance Shield add-on protect your Magento 2 site


Extend security. Enhance performance.

Fight common application vulnerabilities and protect performance integrity for only $5/month per site with Nexcess Performance Shield.

By reading this post, we hope you have a better understanding of the entire process, and you can easily configure a CDN for Magento 2 without any confusion. We suggest you buy a Performance Shield plan for your domain if site speed is your objective.

Sundeep Soman
We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.