How to setup Cloudflare easily for eCommerce websites like Opencart?

In this tutorial, we set up Cloudflare CDN for eCommerce websites like Opencart, three steps are: first create a Cloudflare account, add a website domain in the Cloudflare dashboard, and change the DNS records of your domain. We show you how to fix the SSL issues that we face in Cloudflare, how to connect FTP after Cloudflare is set up, and finally how to log the real visitors’ IP than the Cloudflare IP.

Let’s take an example of https://dpsignadvertising.com where we install Opencart, register this domain at onlydomains.com, and delegate to name servers:

Delegate to your name servers

It is similar in your DNS settings also, mostly we point to servers ns1 and ns2.

Let’s create a Cloudflare account

Cloudflare email to setup

Now time to add a domain to Cloudflare

If you were following the steps while registering an account then it will directly take you to add the site.

  • Log in to your Cloudflare account.
  • Click on Add Site from the top navigation bar.
    Add new site in cloudflare
  • Enter your website URL and then click “Add Site”.
  • Then you need to select the plan as per your need, we are using a free plan, select the free plan and click “Confirm plan”
    Cloudflare free plan
  • Now Cloudflare attempts to automatically identify your DNS records and shows lists of DNS results, for dpsignadvertising.com it is showing as in the image:
    DNS record cloudflare
    Be careful and check for missing DNS records, mostly MX records if you have setup. Then, click Continue.
  • Now you will see like NS records of Cloudflare:
  • Now login to the domain registrar, in our case is onlydomains.com and we change the NS1 and NS2, now it looks like in the image below:
    NS changed as cloudflare
  • Once you click “Delegate to your Name Servers”, sometimes it takes up to 24hrs to 48hrs, in our case, it was done within 10mins and we receive an email like below:
    Setup complete cloudflare Opencart
  • Once you got an email your Cloudflare is active and you can see the active status in the Cloudflare admin. Similarly, you can see the analytics that it is serving.
    Cloudflare analytics in dashboard

How to solve the SSL issue of Cloudflare?

Go to Cloudflare Dashboard >> Click SSL/TLS >> Edge Certificates >> Then toggle to ON for “Always Use HTTPS”

SSL issue fix in Cloudflare

Then the SSL issues are resolved.

Cloudflare FTP issues?

The solution to FTP Cloudflare issues: With Cloudflare set up, you will not be able to connect to your FTP with the domain name so you need to use the IP of your server. You can find the Cloudflare Dashboard >> DNS >> Then find the FTP IP or your website URL IP.

Solution to FTP cloudflare issues

Get the actual visitors’ IP address than the Cloudflare IP address in Opencart

If you are using Google Analytics then you may see the same Cloudflare IP address that the visitor’s IP address as all IPs are proxied by Cloudflare. Sometimes, the Payment gateway may block all the payments as well as it will see the same IP ordering the products which may create suspicious activities, so to fix that you need to add the following code at top of index.php

if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
  $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}

Cloudflare can be used on any website so it does not stick to Opencart, with the above you can enable Cloudflare on any website. It is the same case for the Opencart, we also installed Cloudflare in our webocreation.com blog and see a good improvement in site speed. You can hire us directly or can hire the top 3% of Freelance Cloudflare Experts.

We hope this helps someone to set up Cloudflare properly and easily in Opencart. Please don’t forget to post your questions or comments so that we can add extra topics. You can follow us at our Twitter account @rupaknpl and subscribe to our YouTube channel for opencart tutorials.

Previous articleFull webpage screenshot chrome with two commands – easiest way
Next articleOpencart user, permissions, user group management, and API users

LEAVE A REPLY

Please enter your comment!
Please enter your name here