All Collections
Getting Started
Domain
Configure Cloudflare for Templ using your own Cloudflare account
Configure Cloudflare for Templ using your own Cloudflare account

How to install Cloudflare for your Templ hosted WordPress site, using your own Cloudflare account.

Karl avatar
Written by Karl
Updated over a week ago

Note: Templ has partnered up with Cloudflare, allowing you to access Cloudflare's features directly through Templ. Learn how you can start enjoying the benefits of Cloudflare through Templ right now.

If, for some reason, you prefer to use your own Cloudflare account, you can follow the guide in this article.

Introduction to Cloudflare

Cloudflare is a website security company that offers a range of services including Content Delivery Network (CDN) and DDoS mitigation, among others.

Cloudflare's services act as a reverse proxy, sitting between a website’s visitors and the Cloudflare user’s hosting provider, such as Templ. This setup makes it easier to speed up your WordPress site and enhance its security.

Setting up Cloudflare

This guide assumes you have a Cloudflare account. If not, sign up for a free account at the Cloudflare website.

Step 1: Add your site to Cloudflare

  1. Login to the Cloudflare dashboard and click on + Add Site.

  2. Input your WordPress site’s domain (omit "www" and "http/https") and click Add site.

  3. Choose a plan. The free plan is suitable for most needs. Click Confirm plan.

  4. Wait for Cloudflare to scan your domain's DNS settings and add them automatically.


​Step 2: Verify DNS Settings

  • Cloudflare provides two options. You can opt for their CDN and protection services, which accelerates and protects your sites, or you can choose to use just their DNS. Most customers will want the first option, as it leverages the full range of benefits Cloudflare offers. To make sure your domains are enabled, check that the cloud icon is colored orange.

  • If you have additional records, such as email (MX records), ensure these are excluded from Cloudflare (grey cloud icon).

  • Confirm your settings and click Continue. You can always modify your records later on, if needed.

Step 3 - Change to Cloudflare's nameservers

Change the nameservers of your domain to point to Cloudflare. You need to use the nameservers provide by Cloudflare.

Cloudflare operates as a full proxy service. This means that you point your domain to Cloudflare, and Cloudflare then points your domain (website) to Templ using an A-Record. Updating your nameservers to point to Cloudflare does not result in any downtime.

Here’s what Cloudflare’s nameservers typically look like:

Please note that your nameservers will be different.


Below are links to popular domain registrars along with their guides on how to update nameservers. Make sure to select "Custom DNS".

Allow up to 24 hours for the nameserver change to complete. As soon as the nameservers are updated, you will receive an email from Cloudflare with confirmation.

Step 4: Point your website to Templ

If your website wasn't already pointing to Templ, now is the time to do so.

  1. Ensure your domain is added and assigned to your website in the Templ Panel.

  2. In Cloudflare, update the A-Record to point to your website's IP address, found in the Templ Panel on the website's overview page.

  3. In Cloudflare, ensure there’s a CNAME record for "www" pointing to your domain, like in the example below.

That's all. Your site is now setup with Cloudflare!


​Common issues and solutions

Error "ERR_TOO_MANY_REDIRECTS"

This is the most common issue you might come across when you install Cloudflare.

  • Cause: This occurs when SSL is set to 'Flexible' mode in Cloudflare while SSL is already configured on the server.

  • Solution: In the Cloudflare dashboard, navigate to SSL/TLS settings and change the Encryption mode to 'Full'.

Managing Cloudflare Cache

There are two ways to clear the Cloudflare cache:

  • Via Cloudflare Dashboard: Clear the entire cache (Purge Everything) or perform a custom purge.

  • Using WordPress Plugin: Install the Cloudflare plugin for WordPress to manage cache and settings directly from WP Admin.

Optional: Install the Cloudflare WordPress plugin

  1. Installation: Go to WP Admin - Plugins - Add New, search for Cloudflare, and install.

  2. Configuration: Enter your Cloudflare email and Global API Key in the plugin settings. You can grab your API key under profile/api-token in the Cloudflare dashboard. Copy the one that says “Global API Key.” Click on Save API Credentials.

Some benefits of installing the Cloudflare plugin includes:

  • Boost the performance of your WordPress site in one click

  • Automatic cache purge

  • Change Cloudflare settings from within the plugin itself without needing to navigate to the Cloudflare dashboard.

  • View analytics such as total visitors, bandwidth saved, and threats blocked

  • Support for HTTP2/Server Push

Access Plugin Settings

  • Navigate to Settings - Cloudflare in WP Admin to manage cache, view analytics, and more.

Did this answer your question?