Jul 12, 2012
cPanel Access Level
Root Administrator
To start off I can say that my domains nameservers is pointed to Clouudflare and the DNS is controlled by Cloudflare as well. Then I point my domain to the IP Address of my WHM / cPanel installation. This setup is only for a single domain just because I wanted the extra privacy with a VPS for web hosting.

When you type the domain my site works perfectly (With SSL) but you can connect directly to the server with the direct IP which I want to be hidden from the public to remove the possibility of any kinds of attacks.

How do I disable connecting through the browser with the IP of my WHM / cPanel Server and enforce my domain to connect to it with my cloudflare setup?

Another question for me lies how should my Cloudflare propagation look for my private vps cpanel hosted site? (eg. DomainRegistor > Cloudflare > cPanel server or DomainRegistor > cPanel > Cloudflare? I have always beliewed that Cloudflare should be in front of my web server but this limits WHM & cPanels functions.

Any ideas and comments would be greatly appreciated.

Regards, Jake


Well-Known Member
Apr 17, 2013
cPanel Access Level
Root Administrator

If you have a domain coming through CloudFlare, and when you access cPanel through such domain, you might experience some cPanel layout issues in the panel..

You can use the CloudFlare to protect your domain from attack, but if you want to protect your server from this, you will have to get a hardware firewall for your server, so it will be protected..


Staff member
Apr 11, 2011

You can follow the steps referenced below (partly taken from our SSL FAQ document) to prevent access to your domain name over it's IP address.

1. Navigate to WHM's Include Editor interface (WHM Home >> Service Configuration >> Apache Configuration >> Include Editor).

2. Select the Pre Virtual Host Include option.

3. Select the Apache version from the menu. We recommend that you select All Versions.

4. Enter the following text in the available text box:

<VirtualHost IPADDRESS:80>
  ServerName HOSTNAME
  DocumentRoot /usr/local/apache/htdocs
  ServerAdmin EMAIL
  <IfModule mod_suphp.c>
    suPHP_UserGroup nobody nobody

<VirtualHost IPADDRESS:443>
  ServerName HOSTNAME
  DocumentRoot /usr/local/apache/htdocs
  ServerAdmin EMAIL
  <IfModule mod_suphp.c>
    suPHP_UserGroup nobody nobody
    SSLEngine on

This example uses the following values:
  • IPADDRESS represents your IP address.
  • HOSTNAME represents your server's hostname.
  • EMAIL represents your contact email address.
  • SSLCERTIFICATEFILE represents the full file path to your SSL certificate.
  • SSLCERTIFICATEKEYFILE represents the full file path to your SSL certificate's key.
5. Click Proceed
6. Click Update.

Additionally, note that you'd need to update the DocumentRoot values to reflect a directory with an index file or .htaccess file that denys access.

As far as your second question, CloudFlare should come before the cPanel server. See this page on their documentation:

My cPanel won't load or keeps logging me out after enabling Cloudflare

Thank you.