Cloudflare is a content delivery network (CDN) and security provider that helps optimize website performance and protect against DDoS attacks. With Cloudflare’s global network, websites can deliver content faster by caching resources close to visitors.
Adding a domain to Cloudflare is straightforward whether registering a new domain or using an existing one. Once added, there are various configuration settings to optimize performance and security.
Table of Contents
Prerequisites
Before adding a domain to Cloudflare, ensure you meet these requirements:
- Domain name registered – If registering a new domain, choose your registrar. If using an existing domain, ensure you have access to update the nameservers.
- Website hosted – Your site needs to be hosted somewhere for Cloudflare to point to. This could be on a server you manage, a hosting provider, or a platform like WordPress.com.
- Cloudflare account – Sign up for a free Cloudflare account if you don’t already have one. Paid plans provide additional configuration options.
Adding a Domain
Follow these steps to add a new or existing domain to Cloudflare:
New Domain
If registering a new domain name:
- When checking out, select Cloudflare as your DNS provider.
- Cloudflare will automatically be configured when the domain registration is complete.
Existing Domain
If using an existing domain name:
- Log in to your Cloudflare account and click Add Site.
- Enter your root domain name, like
example.com
. - Select the free or paid plan you wish to use.
- Click Continue.
- Verify domain ownership through TXT record verification.
- Update your domain’s nameservers to use Cloudflare’s.
- Wait up to 24 hours for the changes to fully propagate.
Once added, Cloudflare will begin acting as a reverse proxy, managing traffic to your origin server.
Configuration Settings
Cloudflare provides many configuration settings to control performance, security, and functionality. Here are some key options to review:
1. Crypto
Enabling HTTP/2 and TLS encryption provides performance and security benefits:
- HTTP/2 – Improves page load speed through compressed headers and multiplexing.
- TLS – Encrypts traffic between Cloudflare and your origin for security.
2. Caching
Cloudflare caches static resources like images, CSS, and JS files globally. Adjust caching rules for optimal performance:
- TTL – Set duration files stay cached from 10 minutes to 1 year.
- Respect Origin Headers – Bypass cache if origin specifies not to cache.
- Cache Level – Determine what can be cached based on file type, request headers, etc.
3. Speed
Enable speed optimizations like compression and minification to improve performance:
- Auto Minify – Automatically minify CSS, JS, and HTML files.
- Brotli Compression – More efficient compression method than Gzip.
- Rocket Loader – Deferred loading of JS files.
4. Security
Cloudflare provides robust security tools including:
- Web application firewall – Block attacks like SQL injection and cross-site scripting.
- Rate limiting – Slow down traffic during DDoS attacks.
- IP Access Rules – Allow/block visitors by IP address range.
5. Content
Use page rules to customize content delivery per URL:
- Edge Cache TTL – Override default cache duration for specific pages.
- Security Level – Set higher security level for sensitive pages.
- Country Access – Block visitors from specific countries.
Checking Status
Review Cloudflare’s dashboard to understand how your site is performing and optimize where needed. Key metrics include:
- Total visitors – Number of unique visitors.
- Bandwidth – Total data transferred from Cloudflare’s CDN.
- Threats stopped – Count of cyber attacks blocked.
- Cache ratio – Percentage of requests served from cache.
- Data center connectivity – Connection quality scores to Cloudflare data centers.
The analytics provide visibility into performance which can help guide configuration improvements.
Summary
Adding a domain and configuring Cloudflare provides immediate benefits in site speed, security, and functionality. Tuning the performance and caching settings are key to ensuring a positive experience for visitors.