Step-by-Step Guide: Moving a Website Behind Cloudflare

1. Add Your Website to Cloudflare

  • Sign in to Cloudflare.
  • Click Add Site and enter your domain (e.g., example.com).
  • Cloudflare will scan existing DNS records and import them.

2. Review and Update DNS Records

  • Go to the DNS section of your Cloudflare dashboard.
  • Ensure all A, AAAA, and CNAME records that point to your origin IP are marked with the orange cloud icon (Proxied).
☁️ When Proxied (orange cloud): Visitors will see Cloudflare IPs instead of your origin IP.

3. Update Your Registrar’s Nameservers

  • Cloudflare will provide two nameservers (e.g., abby.ns.cloudflare.com, bob.ns.cloudflare.com).
  • Log into your domain registrar and replace your existing nameservers with these.
  • Wait for DNS propagation (usually a few hours).

4. Check DNS Propagation

  • Use tools like dnschecker.org.
  • Or use terminal commands like: dig yourdomain.com or nslookup yourdomain.com.
  • You should see Cloudflare IPs (not your server’s original IP).

⚠️ Important Considerations

Item Description
🔐 Don’t expose your origin IP Remove or secure old subdomains that point directly to your origin (e.g., test.yourdomain.com).
🧱 Firewall your origin Configure your server to accept traffic only from Cloudflare IPs: cloudflare.com/ips.
🌍 Wildcard Domains Cloudflare free plans don’t proxy wildcard * records by default. Add them explicitly if needed.
📜 Update hard-coded IPs If anyone accesses your site by raw IP, ask them to use your domain instead.

🔧 Optional: Lock Down Your Server with Cloudflare IP Ranges

If you’re using a firewall like iptables or UFW, allow only Cloudflare IPs:

# Example for UFW (Ubuntu)
sudo ufw allow from 173.245.48.0/20
sudo ufw allow from 103.21.244.0/22
# (Repeat for all Cloudflare IP ranges)

See full list at: https://www.cloudflare.com/ips/

 

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.