Configuring Drupal 8 in cPanel to Use Cloudflare Services

Configuring Drupal 8 in cPanel to Use Cloudflare Services

Cloudflare is a popular CND service provider. CDN stands for Content Delivery Network and is used for caching websites and web pages. It significantly speeds up the website loading time. Caching also reduces load on the server.

Many web hosting companies include basic Cloudflare CDN in their Linux hosting plans. If you have cPanel, you can set up Cloudflare by configuring Drupal 8. In this guide, find the exact process you need to follow for that purpose.

Step-by-Step Process

Below are the steps you need to follow. These steps are meant for Drupal 8. Other versions of Drupal will have similar, if not exact, steps.
  • Enable Cloudflare in cPanel
To start using Cloudflare CDN services, you need to first enable it. For this, you need to log into your cPanel account. Then follow theps:
  • Once inside cPanel, click on the Cloudflare icon
  • Navigate into administration section where it lists all the domains
  • Locate the domain for which you want to use CDN. Then enable Cloudflare on it
Now Cloudflare CDN is enabled for that domain.

Click on “Settings” besides the domain. You’ll see a list of settings options you can tweak. All of these are subjective and depends on your preference. But here are some settings options we recommend you select:
  • Cloudflare Caching Level: Basic
  • Web Application Firewall: On
  • Cloudflare Security Settings: Medium
  • SSL Support: Full
  • Image Optimization: Basic
You’ll be prompted to get a paid account. But if you don’t need advanced options, you can stay with the free plan.
  • Install Supporting Modules
Before you can start using the Cloudflare module, you must install the supporting modules on your Drupal 8 website, which are:
  • Chaos Tools
  • Purge
  • URLS Queuer
  • Cloudflare PHP SDK
After downloading the modules, you need to install the files at “admin/modules/install”. You can also use FTP or Drush for this purpose.

The Cloudflare PHP SDK needs Composer as a prerequisite. So execute this command:
composerrequired8-contrib-modules/cloudflarephpsdk "1.0.0-alpha1"
Once you’ve downloaded all the modules including Cloudflare, you’d have to configure them. Here are our recommended settings to apply:

Cloudflare Module

Enable these options:
  • CloudFlare - CloudFlare CDN integration
  • CloudFlare Form Tester - It adds the replacement services that can test CloudFlare forms
Purge Module

Enable these options:
  • Purge
  • Purge Drush
  • Purge Tokens
  • Purge UI
  • Cron processor
  • Late runtime processor
  • Core tags queuer
  • URLs queuer
  • CloudFlare Purger
After installing and enabling the Purge module suite options, you’d have to navigate into the administrative panel and enable CloudFlare settings. Please note that you’d have to install the CloudFlare PHP SDK first using Composer first before you can install CloudFlare. The SDK works as a dependency.

To manage the cache performance, you can make changes at “admin/config/development/performance/purge” and use the Adv Agg module.
  • Enable Path-based Caching
If you’re using the CloudFlare free plan, you must enable Path-based caching. There’s also the Tag-based caching, but it’s available to the Plus plan users.

If you haven’t already, you must first install Drush on your web server. Then, open Drush and execute the following commands:
  • admin/config/development/performance/purge (to uninstall purge_queuer_coretags)
  • drush en purge_queuer_url (to install purge_queuer_url)
  • drush ev "deletefrom queue wherename = 'purge'"(to clear stale tag clear requests)
  • drush cset system.performance (to clear stale tag clear requests)
  • drush cache-rebuild (to empty page cache)
  • Configure CSS, JS, and HTML Minification
Open the Cloudflare administrative panel and turn on the settings for CSS, JavaScript, and HTML minification. It can significantly improve the performance. To manage them, you can use Adv Agg.

First, you have to download the Advanced CSS and JavaScript Aggregation (Adv Agg). Once installed, navigate into admin/config/development/performance to configure the settings.

Here’s what you need to enable from the Bandwidth Optimization settings panel:
  • Aggregate CSS files
  • Aggregate JavaScript files
  • Minified Source HTML
There’s also the advanced configuration options. Go through the options and select the ones that matter to you. Otherwise, leave them as they are.
  • Define Page Rules for Admin & Anon Users
In the final step, you need to define the page rules. This is necessary to customize your website for publishing use with caching services and speed up your website.

Here are the steps to follow:
  • Inside the cPanel Cloudflare panel, locate and select the domain
  • Click on the link that reads “Page Rules
  • Click on “Create Page Rule” for building new filter system
  • Enter the base URL
  • Click on “Add a Setting
  • Select the new rule you just created to activate it
  • Save the changes made and exit
With Page Rules, admins will find it easier to filter out required sections of the website from Cloudflare CDN. It’s important for pages like the administration page since they can interfere with functions.

So that’s how you configure your Drupal 8 website in cPanel to start using Cloudflare CDN. After successful installation, you’ll notice an improvement in the page loading speed. For further assistance, get in touch with the customer support team.
First release
Last update
0.00 star(s) 0 ratings

More resources from kumkumsharma