Computer Security, Sucuri, Technology, Tutorials, Web Security, WordPress

How To Setup Cloudflare CDN And Sucuri WAF To Protect Origin Server

April 9, 2017

One method I adopt to protect my server infrastructure/hide origin server IP is using both Cloudflare and Sucuri. Cloudflare as a speedy CDN while Sucuri for the Web Application Firewall and Protection. An advantage of this setup is that the site enjoys the benefits of a swift Content Delivery Network, strong Web Application protection, and DDoS scrubbing capabilities. Also by switching providers whether from previous utilizations as a CDN/reverse proxy creates confusion among the less competent actors aka script kiddies. For maximum effectiveness, switch to a new server origin IP prior to using this setup.

How to do it: Essentially, I have Cloudflare pointing to the Sucuri firewall’s IP Address with A Records in Cloudflare’s DNS management.

  1. Login to Cloudflare.
  2. Click on the DNS area of Cloudflare.
  3. Add a new A record, type in ‘’ in the Name field, and the assigned Sucuri firewall IP address in the Value field.
  4. Add another new A record, type in ‘www’ in the Name field, and the same assigned Sucuri firewall IP address in the Value field.
  5. Make sure the orange cloud is enabled for both of the new A records. Orange cloud means Cloudflare is active.

An example of my current Cloudflare CDN setup which points to Sucuri firewall IP address for enhanced protection and benefits.

By not pointing the A records directly to your server’s origin IP address in Cloudflare’s dashboard, you are minimizing the potential for exposure of the origin IP. We point the Sucuri Firewall (CloudProxy) to your hosting provider’s IP in the following section which creates a ‘double layer’ chain. Cloudflare travels to Sucuri before reaching the origin server. Logically, two layers are better than one.

For Sucuri:

  1. Login to Sucuri’s Firewall Dashboard.
  2. Click on ‘General‘ section.
  3. Click on ‘CDN Support‘ section.
  4. Choose Cloudflare from the box. Then click Proceed.

An illustration of how to enable the External CDN support on Sucuri’s Firewall Dashboard.


  1. Click on ‘Hosting IP Address‘ section of Sucuri’s Firewall Dashboard.
  2. Type your server’s origin IP address in the ‘Add new address…‘ box and click on ‘Add Address’

An illustration of the Hosting IP Address section of Sucuri’s Firewall Dashboard.

Now the Sucuri Firewall is pointing to your hosting provider.


  1. Go back to Cloudflare’s dashboard.
  2. Click on ‘Network‘ section and confirm that IPv6 is ‘Off‘ and NOT ENABLED.

An illustration of IPv6 Compatability disabled for Cloudflare to ensure a conflict-free experience with Sucuri.


Those are the steps required to fully enable the use of Cloudflare’s CDN with Sucuri’s WAF (CloudProxy) on your site.

Of course, you probably have already used Cloudflare’s nameservers in your Domain Provider settings. If not, just add them in. Plain and simple.

There is another important thing you should do. Modify your .htaccess file to prevent Sucuri’s Firewall from being bypassed in the event that a clever malicious actor manages to grab hold of your origin server IP.

For Sucuri’s .htaccess:

  1. Go back to Sucuri’s Firewall Dashboard.
  2. Click on ‘Security‘ section and scroll all the way down until you see the ‘Preventing Firewall Bypass‘ section of the page.
  3. You will see codes for Apache 2.4, Apache 2.2, and Nginx. Pick one that corresponds to your server and version.
  4. Copy and paste the code into the root .htaccess of your site. You may log in using SFTP to edit the .htaccess file. Important: You should make a backup of the original, unaltered .htaccess prior to modification.
  5. Save your changes, upload the modified .htaccess file back to your server. Changes should take effect immediately without needing to clear any CDN/browser caches.

An illustration of the various server codes offered by Sucuri’s Firewall Dashboard used to prevent CloudProxy Firewall bypass.

You should also incorporate the IP addresses provided by Cloudflare here into the .htaccess file. Mixing both Sucuri and Cloudflare IP addresses into one single .htaccess is fine (.htaccess in root). Just add all the CloudFlare IP addresses right before ‘</FilesMatch>’.

For Cloudflare’s .htaccess:

The Apache .htaccess is below:

Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from
Allow from 2400:cb00::/32
Allow from 2405:8100::/32
Allow from 2405:b500::/32
Allow from 2606:4700::/32
Allow from 2803:f800::/32
Allow from 2c0f:f248::/32
Allow from 2a06:98c0::/29


By allowing only Sucuri and Cloudflare access to the origin server, the security of your origin server increases dramatically. A person that tries to directly access your server via the origin IP using HTTP 80 will be denied, preventing successful bypass of Sucuri’s CloudProxy Firewall. This will hinder the actor from attacking the server’s web application directly. However, this does not stop the actor from directly launching DDoS attacks against the origin IP. The DDoS attacks would not be effectively mitigated by the CDN or WAF since the actor knows the origin IP. Only server-side protections could help in this situation, but if the DDoS is large, it would be a good idea to change your server’s origin IP.

An illustration of a 403 error served to me when I attempt to access my site’s server via the origin IP address. This indicates effective use of the .htaccess file located in the root directory.

For more information, check out another article I’ve written to prevent Cloud WAF Bypass here that also has the above code with the exception that the code indicated in this article has been specifically tailored for use with Sucuri.

Also, when Cloudflare asks whether you want to use their SSL certificate, you agree even though you might choose to use a third-party SSL or Sucuri’s SSL. The reason is that Cloudflare will create confusion by generating these certificates which can be looked up using tools like Censys. With the increase of SSL certificates showing up in the Censys lookup, it takes longer to look through the records and can easily cause confusion.

Evidently, a disadvantage is that speed will be impacted by this overall setup since visitors who access the site will be proxied through both Cloudflare and Sucuri before their request reaches my server. Hence, it adds a bit of time to the site’s load speed. Nevertheless, I perceive the added benefits provided by CloudFlare and Sucuri as worth the mere load time. After all, these companies provide some worthwhile services.

Nonetheless, one of the many benefits enjoyed by this setup is the concealment and creation of confusion pertaining the direct-to-connect IP address in lookups by CrimeFlareViewDNS, and other methods such as those described here.

An illustrating of one of the many lookups I used from CrimeFlare to test my domain for potential exposure of my server’s origin IP address.

As you can see, it shows a direct-connect-IP address for my site’s domain. However, it shows that it points to Sucuri’s firewall server. Of course, the potential malicious actor might be excited to see this, thinking that he actually found my server’s origin IP address. But an IP address lookup of the direct-connect IP refers to it belonging to Sucuri. In fact, clicking on the direct-connect IP below the page indicates several sites protected by Sucuri, one of the domains is shown to belong to me. Any DDoS attacks (layers 3, 4, or 7 ) launched against the listed IP is mitigated by Sucuri’s scrubbing capabilities and anti-DDoS techniques, protecting my server from taking any direct hits.

As you can see, this historical lookup pulls two IP addresses, one belonging to Cloudflare and Sucuri. Sucuri was initially used then I used Cloudflare as a CDN while still retaining Sucuri’s protective services. For someone less competent, he will be confused by the mixed results of this lookup. Nowhere is the origin server IP seen in the above images. Ultimately, this setup is beneficial since cyberattacks are becoming increasingly sophisticated and dangerous.

You Might Also Like

Back to top
%d bloggers like this: