Enable Remote MySQL Connections in cPanel

Remote MySQL connections are disabled by default in cPanel servers because they are considered a potential security threat. Using the tools in the Web Host Manager (WHM) and the domain-level cPanel interface (usually http://domainname.com/cpanel) remote hosts can be added which the server allows to connect to the MySQL service.

Before using either of the following techniques, you will need to to open up port 3306 in your server’s firewall.

Enabling Remote MySQL in the WHM Interface

Log in to the server’s WHM interface and find the section in the left-side navigation bar labeled SQL Services. You can sort the list by typing ‘sql’ in the search box. Click on the link marked Additional MySQL Access Hosts:

WHM - Remote MySQL List

On the following page, enter one or more hosts or IP addresses in the text box (1) and click the Save button (2). If you wish to activate these settings on all user accounts see (3).

WHM - Remote MySQL page

Now that the remote connection has been activated in the WHM each domain account that wants to use the remote connection will need to activate it in their own cPanel interface.

Enabling Remote MySQL in the Domain cPanel Interface

Log in to the domain’s cPanel interface and find the section on the main page labeled Databases.

In the Databases section find the link/button labeled Remote MySQL and click on it.

cPanel - Remote MySQL list

The following page will appear in your browser. Add a hostname or IP address that you want to grant remote MySQL access to (1) and then click the Save button (2).

If a host or IP address needs to be removed from this list you can click the ‘Delete’ button next to the entry in the list.

cPanel-page-fxt

Once you have made your changes, additions, or removals to the list you can return the main page of the cPanel interface, or log out if you have no other tasks to take care of.

===

Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434
support@liquidweb.com
https://manage.liquidweb.com/

How to Replace PHP GeoIP with MaxMindDB

Depending on the site or application, looking up geographic information related to an IP address can be a pretty common action. When doing IP geolocation in PHP usually the PHP GeoIP extension would be used to facilitate the retrieval of this information. Unfortunately, this particular plugin is no longer actively supported and has not been updated in a number of years.

With the go-to PHP extension of IP geolocation effectively being deprecated, new projects should begin to use the replacement options that are now provided by MaxMind. However, unlike the original GeoIP, which was shipped as a native PHP extension, the new solutions are provided as PHP-based library packages.

Pre-Flight Check

  • Basic familiarity with PHP coding is necessary to utilize Composer packages.
  • Command line access via SSH may be necessary to follow this tutorial.
  • Composer, Curl, funzip must be available on the server.

Step #1: What are my options now?

As mentioned previously, the new options are no longer provided as native PHP extensions, but rather they come as Composer-based PHP packages. The new options provided by MaxMind are either: GeoIP2-php or DB-Reader-php.

Both of the options provide the ability of IP geolocation with subtle differences; in a sense the GeoIP2-php package is an addition built on top of the DB-Reader-php package, it offers all the same features as DB-Reader-php with the addition of API access.

Additionally, it is important to note that only the DB-Reader option is provided without any additional costs. With the new options MaxMind now charges a subscription fee in order to access their APIs.

Generally for most use-cases the necessary features will be provided by the DB-Reader-php package, as such this article will focus on this option.

Step #2: Get started with MaxMind DB-Reader!

As mentioned in the pre-flight check, Composer will be required in order to follow these steps. If you do not have Composer setup on the server please feel free to review our Composer series here: ‘What is Composer?’.

To acquire the necessary DB-Reader package you will want to start by changing directory so that you are in the root folder of your domain (for this example we will just assume this is `public_html`), then you will run the following command:

[public_html] $ composer require maxmind-db/reader:~1.0

Running this command will download the package files into the current folder, as described in our Composer series. This will create a vendor folder if this is the first time using Composer in this site/project.

Next you will require the actual MaxMind database files which contain the geolocation data. To get these files you will execute the following commands:

[public_html] $ funzip <(curl -L http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz) > ./GeoLite2-Country.mmdb
[public_html] $ funzip <(curl -L http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) > ./GeoLite2-City.mmdb

With the above commands executed you should now have the necessary components to do Geolocation using the DB-Reader plugin. All that’s left is to implement it in your code.

Step #3: Looking up your first IP

In order to ensure the geolocation features are working properly you may want to do a quick test. First we’ll confirm you have all the right pieces by running the following command:

$ ls -lah

You should see a file structure similar to this:

-rw-rw-r-- 1 someuser someuser 63 Aug 11 17:03 composer.json
-rw-rw-r-- 1 someuser someuser 2.4K Aug 11 17:03 composer.lock
-rw-rw-r-- 1 someuser someuser 73M Aug 11 17:04 GeoLite2-City.mmdb
-rw-rw-r-- 1 someuser someuser 19M Aug 11 17:04 GeoLite2-Country.mmdb
drwxrwxr-x 4 someuser someuser 4.0K Aug 11 17:03 vendor/

Now you are ready to do a quick test, you can do so by creating an index.php file with the following content:

<?php
require_once 'vendor/autoload.php';

use MaxMind\Db\Reader;
$ipAddress = '8.8.8.8';
$databaseFile = './GeoLite2-City.mmdb';

$reader = new Reader($databaseFile);

print_r($reader->get($ipAddress));

$reader->close();

This index file will simply do a quick test to ensure that the database file is being loaded, an IP can be checked, and the results are being provided. The test will be looking up the geographic information related to Google’s DNS server at 8.8.8.8.

Geo-location results for Google's 8.8.8.8 DNS server via MaxMind
Geo-location results for Google’s 8.8.8.8 DNS server via MaxMind

Having followed the directions correctly you should see output similar to the image above when loading the test index page.

Installing Composer on cPanel servers

Tutorial: How to use Composer
I. Composer 101
II. Installing Composer on cPanel servers
III. Working with Composer & Examples

With a tool like Composer it is generally best to have the ability to run it as any user on the server and from any directory. This is generally referred to as being ‘globally installed’ as any user can access the tool from any location. In this guide we will detail how to install Composer globally on a cPanel based server.

Pre-Flight Check

  • These instructions are intended specifically for installing Composer on a cPanel based server running WHM prior to version 58.
  • We’ll be logging in as root to a Liquid Web Fully Managed cPanel server.
As of WHM version 58 cPanel is now including a version of Composer by default, this can be accessed by simply calling composer from command line.
For more details see: What’s New in WHM 58 & What to Look For

Step #1: Get the installer

Acquire the Composer installer script with the following commands:

$ EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q)
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '$EXPECTED_SIGNATURE') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

The above commands will: get the installer’s signature, get the installer file, verify the download by checking the signature and finally confirm if the installer is valid, or corrupt. You should see output similar to:

Installer verified

Step #2: Run the installer

To run the installer in a manner that will install composer globally run the following command:
php ./composer-setup.php --install-dir=/usr/local/bin --filename=composer

With this command run as root composer should now be globally installed on the server.

Step #3: Verify the install

In order to verify the composer installation was successfully you will want to do the following to test. First, as root, run the following command:
# composer -V

You should see something similar to:

Composer version 1.2.0 2016-07-19 01:28:52

If that checks out, you will then want to verify Composer works for the users as well. To confirm composer is working for the cPanel accounts SSH into your server as a cPanel user and do the same:

$ composer -V

You should see something similar to:

Composer version 1.2.0 2016-07-19 01:28:52

Enabling Let’s Encrypt for AutoSSL on WHM based Servers

With the recent release of cPanel & WHM version 58 there has been the addition of an AutoSSL feature, this tool can be used to automatically provide Domain Validated SSLs for domains on your WHM & cPanel servers.

Initially this feature was released with support provided for only cPanel (powered by Comodo) based SSL certificates, with the plans to support more providers as things progressed. As of now, cPanel & WHM servers running version 58.0.17, and above, can now also use Let’s Encrypt as an SSL provider. More information on Let’s Encrypt can be found here.

Pre-Flight Check

  • These instructions are intended specifically for a managed Liquid Web server with cPanel.
  • The server should be running cPanel & WHM version 58.0.17, or higher.
  • Command line and root level access via SSH will be necessary to follow this tutorial.

Step #1: Enable Let’s Encrypt Auto SSL provider!

In order to install the Let’s Encrypt AutoSSL provider plugin you will simply log in to the server as the root user via SSH and execute the following command:

# /scripts/install_lets_encrypt_autossl_provider

Running this will add and install the necessary RPM files in order to support Let’s Encrypt as an AutoSSL provider. The command should yield results similar to the following:

Installed the cpanel-letsencrypt RPM! AutoSSL can now use Let’s Encrypt.

Step #2: Verify your work

To double check that this has been successful you can simply pull up WHM and load the ‘Manage AutoSSL’ page. Upon loading this page you should see a list similar to the following screenshot.

WHM AutoSSL w/ Let's Encrypt
If your server’s ‘Manage AutoSSL’ page shows the same options as above you have successfully enabled Let’s Encrypt for AutoSSL.

One thing to keep in mind is that there are some domain and subdomain limits that are enforced by Let’s Encrypt. More details on that can be found in cPanel documentation here: Manage AutoSSL – Domain and rate limits.

How to Disable MySQL Strict Mode

MySQL’s, and MariaDB’s, strict mode controls how invalid or missing values in data changing queries are handled; this includes INSERT, UPDATE, and CREATE TABLE statements. With MySQL strict mode enabled, which is the default state, invalid or missing data may cause warnings or errors when attempting to process the query.

When strict mode is disabled the same query would have its invalid, or missing, values adjusted and would produce a simple warning. This may seem like the preferred result, however with strict mode disabled certain actions may cause unexpected results; for instance, when the value being inserted exceeds the maximum character limit it will be truncated to fit the limit.

There are various reasons why MySQL’s strict mode may need to be disabled, however the most common is when a server is running WHMCS — this is a requirement of that tool.

Pre-Flight Check

  • These instructions are intended specifically for disabling MySQL strict mode on a managed Liquid Web server with cPanel.
  • The server should be running either MySQL 5.6/5.7 or MariaDB 10.x
  • Command line and root level access via SSH will be necessary to follow this tutorial.

Step #1: Make Backups, Always!

Whenever modifying files on a server it’s always best practice to take some form of a backup beforehand. This ensures you have a way to revert changes if something goes awry; it’s also beneficial because it helps track when and what changes were made.

While logged into SSH with the root user, do the following:

cp -a /usr/my.cnf{,.strict.bak}
cp -a /etc/my.cnf{,.strict.bak}

The above command uses ‘BASH brace expansion’ in order to make a backup copy of the file in its original directory.

Step #2: Disable MySQL Strict Mode

Depending on the server and the current configurations you may need to edit one, or both, of the following files on the server. Generally, the relevant configuration lines are only in one of them, however, it could be in either one without causing issues; so generally it’s best to check both.

To edit the files, you will open the file with your favorite command line editor. In this example, we use ‘vim’.

vim /usr/my.cnf
vim /etc/my.cnf

In vim, you can press “a” or “i” to enter text insertion mode; pressing the escape key (Esc) on your keyboard returns you to command mode. For a refresher on editing files with vim, see our New User Tutorial: Overview of the Vim Text Editor.

Within each file above you will be looking for a line with the following content:

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

If you find a line similar to the above that is setting the `sql_mode` variable then you will need to replace it with the following line to disable MySQL strict mode.

sql_mode=""

Once this adjustment has been made, or you’ve confirmed the file does not need to be adjusted you will then save and close the file.

Step #3: Restart the MySQL Service

Finally, to make these changes effective you will need to restart the MySQL service as it will only read the configuration files when it initially loads up. In order to force MySQL to use the new configuration files you will do the following:

For CentOS 7 servers:
systemctl restart mysql

For CentOS 6 and prior:
/etc/init.d/mysql restart

After issuing this command on the server the MySQL service will be restarted and will load the changes made. If all the directions were followed and completed, then MySQL strict mode should now be disabled.

To verify that the process was completed properly you can run the following:

mysql -e "SELECT @@sql_mode;"

The output may look similar to the following:

+--------------------------------------------+
| @@sql_mode
+--------------------------------------------+
| NO_AUTO_CREATE_USER
+--------------------------------------------+

If you have any questions or are not comfortable making these changes yourself, please feel free to contact Heroic Support®.

Exploring the CloudFlare Dashboard

Getting Started With CloudFlare™

Pre-Flight Check

Accessing the CloudFlare Dashboard

After logging into your Manage interface, click on Domains in the left menu and select the CloudFlare tab.

Each domain you’ve added to your CloudFlare account is listed here.

CloudFlare Dashboard Overview

Menu Bar

The menu bar at the top allows you to add new sites to CloudFlare by clicking on the blue Add Website button, or quickly narrow the number of domains displayed through the Search field. The Website column header also can be sorted alphabetically by clicking on its icon.

Domains List

  • The Status column shows at a glance whether CloudFlare is active on any listed domain, and can be clicked to quickly expand the domain’s dashboard.
  • A Quick Settings Menu, labeled , is located to the far right of the domain name. Clicking on it will allow you to pause CloudFlare, purge cached files, and perform other tasks without having to expand the domain’s dashboard.

    More button

  • To expand a domain’s full CloudFlare dashboard, you can either select “CloudFlare Dashboard” from the Quick Settings Menu () or click the [+] button to the left of the domain name.

CloudFlare Dashboard

Primary CloudFlare Dashboard

Once expanded, a domain’s CloudFlare Dashboard allows you to manage CloudFlare settings for the domain:

  • The Enable Development Mode link in the top-right corner will temporarily pause edge caching and minification so that changes made on your site can be seen more quickly.
  • The Pause CloudFlare link temporarily disables all CloudFlare services for the site.
  • Site Statistics are available in the top left corner, allowing you to see the number of cached and uncached requests processed through CloudFlare, and the amount of data included in those requests.
  • Clicking on the Caching Level setting allows you to choose between three levels:
    • No Query String, which only serves files from the cache when there is no query string (example.com/photo1.jpg).
    • Ignore Query String, which delivers the same resource to everyone, regardless of the query string (example.com/photo1.jpg?w=200&h=200).
    • Standard, which delivers a different resource each time the query string changes. This is the level recommended by CloudFlare.
  • The Purge Cached Files button clears any cached content from CloudFlare.
  • Clicking on the Auto Minify setting allows you to choose whether to removes unnecessary characters from your source code (like whitespace, comments, etc.) to reduce file sizes and lower the amount of data, which helps to reduce page load times. You can enable Auto Minify for CSS, javascript, and HTML files.
  • SSL Setup, available on paid plans, allows you to configure SSL settings on the domain.
  • The Security Level setting allows you to choose between four levels of protection:
    • Essentially Off: Provides a challenge to only the most grievous offenders.
    • Low: Challenges only the most threatening visitors.
    • Medium: Challenges both moderate threat visitors and the most threatening visitors.
    • High: Challenges all visitors that have exhibited threatening behavior within the last 14 days.
    • I’m Under Attack! Should only be used if your website is under a DDoS attack. Visitors will receive an interstitial page while CloudFlare analyzes the traffic and behavior to make sure they are a legitimate human visitor trying to access your website. This setting can be enabled quickly by clicking on the I’m Under Attack! button directly underneath the Security Level setting.
  • Clicking on your current Plan allows you to change the level of your CloudFlare service, from free to paid and basic to advanced. Premium features, including the CloudFlare firewall, are managed via the interface at CloudFlare’s website.
  • The DNS Settings link allows you to view and modify settings for the domain.

DNS Settings

Clicking on the DNS Settings link in a domain’s CloudFlare Dashboard brings up the current settings for the domain.

CNS settings in the CloudFlare dashboard

The Report DNS Changes button will allow you to add new subdomains to the domain, such as “blog.yourdomainname.com” or “shop.yourdomainname.com”. The DNS record values needed to configure your domain name for CloudFlare also are listed on this page for your reference.
 

How To Configure Your Server to Log Real Visitor IPs

Getting Started With CloudFlare™

 
Because CloudFlare acts as a proxy, all visits to your website and web applications will, by default, be logged as originating from a CloudFlare IP address — not the visitor’s actual IP address. However, the Apache module mod_cloudflare can be used to ensure that visitors’ actual IP addresses are logged and displayed.

We recommend that you activate mod_cloudflare as outlined in this article to accurately log website visitor IP addresses and prevent unwanted behavior. Without this step, your server’s firewall could block CloudFlare’s IP addresses, making your site inaccessible. If you need to check whether the module is already enabled or need assistance installing it, please open a ticket and Heroic Support® will be happy to help.

Pre-Flight Check

  • This article assumes that you have already set up CloudFlare and added your domain.
  • We’ll be installing the mod_cloudflare module for Apache, and you’ll need root-level SSH access to proceed.
  • If you’re using a web server other than Apache, you’ll need to enable the appropriate module for your web server. For Nginx, you can use the ng_http_realip_module, and an HTTP Module for IIS also is available.

Installing mod_cloudflare on CentOS 6 and CentOS 7 Servers with cPanel

To install mod_cloudflare on a cPanel server running CentOS 6 or CentOS 7, simply yum install our mod_cloudflare package:

yum install lw-mod_cloudflare-cpanel

We built the RPM in a way that does not require you to run EasyApache, because Heroic Support® is what we do 🙂

To confirm that the module has been added to Apache, run this command:

httpd -M | grep -i cloud

Installing mod_cloudflare on Core-Managed CentOS 6 and CentOS 7

To install mod_cloudflare on a core managed (non-cPanel) server running CentOS 6 or 7, simply yum install our mod_cloudflare package!

yum install lw-mod_cloudflare

To confirm that the module has been added to Apache, run this command:

httpd -M | grep -i cloud

Installing mod_cloudflare on Ubuntu/Debian Core-Managed Servers

To install mod_cloudflare on Ubuntu/Debian Core Managed, simply apt-get install our mod_cloudflare package:

apt-get install lw-mod_cloudflare

To confirm that the module has been added to Apache, run this command:

httpd -M | grep -i cloud

Next Step: Get to Know CloudFlare

Now that you’ve got everything configured, it’s time to Explore the CloudFlare dashboard.
 

How to Configure Your DNS for CloudFlare

Getting Started With CloudFlare™

Pre-Flight Check

  • This article assumes that you have already set up CloudFlare and added your domain.
  • We’ll be adding DNS records in Liquid Web’s Manage dashboard. If your site isn’t using Liquid Web’s nameservers, you’ll need to make changes at your registrar or DNS provider.
  • We’ll be using cPanel to set up an .htaccess redirect. If you don’t have access to cPanel, you will need to edit your .htaccess file directly; if you’re using a web server other than Apache (such as Nginx or IIS), you’ll need to set up the redirect manually. You can find tips for doing so in the bonus content section of this article.
Note: If your site’s DNS records are managed by CloudFlare or any other external source, our Heroic Support® team can provide the records you will need to add there to configure CloudFlare, but we will not be able to access your DNS records themselves.

Step #1: Get Your CloudFlare DNS Settings

  • Once your site has been added to CloudFlare via Manage, select Domains from the left menu, click on the CloudFlare tab and click the [+] button next to your domain name to expand the CloudFlare dashboard.
  • Now click on the DNS Settings link near the bottom-right corner to view your settings.

    View DNS Settings in the CloudFlare dashboard

  • The popup window will show you the specific changes you’ll need to make for your site:

    CloudFlare DNS settings popup

    Specifically, you’ll need to:

    • Add an .htaccess redirect to ensure all traffic to your site uses the “www” subdomain.
    • Add a CNAME record for the subdomain “cf-landing.yourdomainname.com”.
    • Change your CNAME record for the “www” subdomain to point to “www.yourdomain.com.cdn.cloudflare.net”.

Step #2: Redirect Traffic to Your ‘www’ Subdomain

If you have access to cPanel, setting up the redirect is a simple process using the method detailed below. If you don’t have access to cPanel, though, you’ll need to set up the redirect manually. You can find tips for doing so in the bonus content section of this article.

  • Log into your site’s cPanel and click on the Redirects icon.

    cPanel redirect

  • You’ll set up the redirect on this page:
    • Set the Type of redirect to “Permanent (301)”.
    • Select your domain name from the http:// dropdown menu.
    • Leave the / field blank.
    • In the Redirects to field, enter the full URL to which you want to direct traffic. As shown below, it must include both the protocol and “www” subdomain. In this case, we want to redirect traffic for “http://example.com” to “http://www.example.com”, so we’ve put “example.com” in the http:// field and “http://www.example.com” in the Redirects to field.

      13cpanelredirect2

  • Once done, click the Add button at the bottom to put the redirect in place and move on to the next step.

Step #3: Add the CloudFlare Landing Page Record

  • In your Manage dashboard, select Domains from the left menu, then click on the DNS tab to see a list of your domains.
  • Now click the [+] to the left of your domain name to display all of its DNS records.

    Manage dashboard domain DNS

  • Click the Add New Record button in the bottom right to add the new record.

    Add DNS record in Manage

  • We want to add a CNAME record for the CloudFlare landing subdomain, so enter “cf-landing” into the NAME field, select “CNAME” for the TYPE field, and set the TTL field to a reasonable value. TTL, or Time To Live, tells DNS servers how frequently to look for changes to the record. The value is listed in seconds, 3600 (one hour) is typically sufficient. Once done, click the green checkmark button to add the record.

    Add a CNAME DNS record for CloudFlare

  • Review the record details in the popup window to make sure they match the values provided by CloudFlare, and click the Confirm button to add the record.

    Confirm the addition of a CloudFlare DNS record

Step #4: Change the Data Field Value for Your ‘www’ Subdomain

  • Locate the entry for your “www” subdomain and click the Edit button to change its value.

    Edit WWW record

  • In the DATA field, change the current value from your domain name to the value provided by CloudFlare. In this case, we’re replacing “example.com” with “www.example.com.cdn.cloudflare.net”. Because this is an existing record, DNS will abide by the record’s current TTL value; lowering it at this point likely will not speed up propagation, but you may want to check that it has a reasonable value.

    Change the value of your WWW record for CloudFlare

    Once you’ve entered the correct value, click the green checkmark button.

  • Finally, review the values presented on the popup window, and then click the Confirm button to add the record.

    Confirm www CNAME change

  • Once CloudFlare sees the DNS changes you’ve made, web traffic to your site will be routed through its servers. Note that it can take up to 24-48 hours for the DNS changes you made to fully propagate across the Internet, but in many cases you will see the changes take effect much more quickly.

Next Step: Configure Visitor Logging

Because CloudFlare acts as a proxy, sitting between your website and the rest of the Internet, your server will, by default, log all visits to your site as having originated from CloudFlare. Fortunately it is a simple matter to configure your web server so that site visitors’ actual IP addresses will be logged. Proceed to Part Three to get started.
 

Bonus: Domain Redirects for Sites Without cPanel

If you don’t have access to cPanel or are using a web server other than Apache, you’ll need to set up the “www” redirect manually. These instructions cover the general steps for popular web servers:

Apache

Apache redirects are accomplished via .htaccess files. The one you’ll need to edit will be located in your web site’s root directory, but you may need to check a box in your FTP client to show hidden files in order to see it. If you don’t already have a file named “.htaccess” in your site’s main directory, you’ll need to create one.

To redirect your non-www domain to www, simply add these lines at the beginning of your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301]

IIS

The non-www to www redirect can be made in IIS by adding the following redirect to the site’s web.config file:

<rule name="WWW Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www.(.+)$" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>

Nginx

Nginx redirects may be configured in the site’s virtual host (.vhost) file or main configuration file, depending on the server version and operating system. Since Nginx is not supported by Liquid Web, we’re assuming that you already know how to edit the virtual host configuration.

To redirect your non-www domain to www, you’ll need to ensure that the primary server is configured to use only the “www” subdomain for its server name.

First, back up the configuration file and then locate the server block for your domain. If both the www and non-www versions of your domain name are listed in the same server block, remove the non-www reference to your site from that server name line. Then create a separate server block for the main, non-www, domain, similar to this one:

server {
listen 80;
server_name yourdomainname.com;
return 301 http://www.yourdomainname.com$request_uri;
}

This will direct all traffic directed at your site’s main domain to the www version of your domain name. Once you’ve finished, restart nginx for the change to take effect.
 

How To Add CloudFlare to Your Website

Getting Started With CloudFlare™

Pre-Flight Check

  • This article covers adding CloudFlare through your Liquid Web account and enabling it for a site you host here.
  • In this example, we’ll be setting up a new CloudFlare account for an existing domain that will continue to use its current nameservers.
  • Please note that to accurately log website visitor IP addresses and prevent unwanted behavior, we recommend that you activate the mod_cloudflare module on your server as detailed in Part III: How To Configure Your Server to Log Real Visitor IPs. Without this, your server’s firewall may block CloudFlare’s IP addresses, making your site inaccessible. If you need to check whether the module is already enabled or need assistance installing it, please open a ticket and Heroic Support® will be happy to help.

Step #1: Add CloudFlare to Your Account

  • In your Manage interface, click on Domains in the left menu and select the CloudFlare tab.

    CloudFlare panel in Manage->Domains

  • Enter the email address you want to associate with your account in the Email field and click the Let’s Get Started button to continue.
  • Within a few moments, you’ll receive an email from CloudFlare acknowledging that you’ve created the account.
    • The email will come from no-reply@cloudflare.com.
    • Its subject will be “Welcome to CloudFlare, in partnership with Liquid Web”.
    • The email will include your CloudFlare username, a link to set your password, and a brief description of the service.
  • In the email, click the Claim your CloudFlare password at: link to set your password at CloudFlare’s website.

    Set password link in CloudFlare email

    Note: You’ll notice that the confirmation window at CloudFlare prompts you to “Reset Your Password”. Despite appearances, that does not indicate that you previously had set up a CloudFlare account using that email address; it simply uses the same language as the “forgot password” process on their site.
  • Enter your password twice to confirm it and then click the Reset Password button. Be sure to record your CloudFlare username and password in a safe location. It is separate from your Liquid Web account and not stored in our system. As such, we do not have the ability to provide it to you should it be lost. We can, however, assist with resetting it should that be necessary.

    CloudFlare password set

    Note: You’ll also receive an email confirmation from CloudFlare with the subject “Your CloudFlare password has been changed”. Once again, the word “changed” is due to the use of their password reset process to set your password, and — in this one specific instance — does not indicate that an existing password has been overwritten or that anyone besides you has made changes to your account.

Step #2: Add a Site to CloudFlare

  • Return to the CloudFlare tab in the Domains Dashboard of your Manage interface, and you will be able to add a new site to your CloudFlare account. To get started, click the green Add a Site button.

    Add a site to CloudFlare

    Note: You’ll only see the green Add a Site button when adding your first website to CloudFlare. Once a site has been added to your CloudFlare account, you’ll see a blue Add Website button which you’ll use to add additional sites.
  • Once you click the Add a Site (or Add Website) button, you’ll be presented with a popup window where you’ll enter the site’s details.

    Add CloudFlare site popup

    • Domain Name is the domain you’re adding. In this case, we’re using “example.com”. Don’t enter the protocol (http://), and don’t include the “www”. Once you’ve entered the domain name, simply hit the tab key on your keyboard or click out of the field.
    • DNS Configuration lets you decide whether you will continue to use a site’s existing nameservers or CloudFlare’s. If you choose to use CloudFlare’s, you will need to manage your DNS records through your account there. As noted in the instructions for creating a CloudFlare account, we do not have access to your credentials there, and can not log in on your behalf to provide direct assistance setting up DNS records there if you need it. In this article, we will be using the site’s existing DNS provider (which is Liquid Web).
      • Subdomain lists the subdomain CloudFlare is protecting. In this case, because we’re setting up the main domain, it lists “www”.
      • Source Domain tells CloudFlare where to look for the source files for the domain name. This is the CloudFlare landing DNS record you’ll set up in Part 2.
      • Use the Add Another Subdomain button to add any other subdomains you’re currently using such as “shop.yourdomainname.com” or “blog.yourdomainname.com”. If you want to set up the main domain name now and return to this step, you can do so from the DNS Settings link in your CloudFlare dashboard by clicking the Report DNS Changes button.
    • CloudFlare Plan. This section lists the available service levels you can choose from, ranging from Free to Premium. All packages include CloudFlare’s global CDN, web optimization and security features, and unlimited bandwidth. The various paid packages include support for SSL certificates, Google’s SPDY protocol, mobile optimization, a web application firewall, and advanced DDoS mitigation.
    • Once you’ve chosen your desired level of service, click the Activate Service button under the name of the plan to add the site.

      Site is being added to CloudFlare

  • After a few moments you’ll see a “ready” message, indicating that the site has been added, and you’ll receive a welcome email confirming that the domain name has been added to your account. Click the “go to dashboard” link at the bottom and proceed to Part Two to configure the DNS settings for your domain and activate CloudFlare.

    Site successfully added to CloudFlare

    Note: At this point, you’ve added the site to CloudFlare, but you must complete the DNS setup to activate CloudFlare for the site.

 

How to Access cPanel File Manager

 
This tutorial assumes you’ve already logged in to cPanel.

  1. Scroll down a little to find the File Manager link. Now click on File Manager.

    filemgr-cpanel-1-access-scene3_1

    Notice that File Manager has been opened in a new tab of your browser.
    You’re now in the File Manager area.

  2. To log out of the File Manager, just close the tab.

    filemgr-cpanel-1-access-scene4_1

    Now you can log out of cPanel. Click the log out button at the top of the screen.

    filemgr-cpanel-1-access-scene6_1

  3. Click on Logout to log out of cPanel.