Professional domain setup with Cloudflare protection for home servers
Custom Domain Home Hosting Guide
Overview
This guide walks you through setting up a professional custom domain for your home server using Cloudflare's proxy protection. You'll learn to hide your real IP address, implement enterprise-grade security, and create a robust hosting solution that rivals commercial providers.
Domain Registration & Setup
1.1 Register Your Domain
- Go to Cloudflare Registrar (domains.cloudflare.com)
- Register your-domain.com at wholesale pricing
- Complete the registration process and verify ownership
1.2 Add Domain to Cloudflare
- Create a free Cloudflare account at cloudflare.com
- Click "Add a Site" and enter your domain name
- Select the Free plan
- Cloudflare will scan your existing DNS records
1.3 Update Nameservers
- Cloudflare will provide you with nameservers (e.g., nina.ns.cloudflare.com)
- Go to your domain registrar's control panel
- Replace the default nameservers with Cloudflare's nameservers
- Wait 24-48 hours for DNS propagation (usually much faster)
DNS Configuration
2.1 Create A Record for Root Domain
In your Cloudflare DNS dashboard:
- Type: A
- Name:
@(this represents the root domain) - IPv4 Address:
XXX.XXX.XXX.XXX(your current public IP) - Proxy status: โ๏ธ Proxied (orange cloud)
- TTL: Auto
2.2 Optional: Create Subdomain Records
For services like lab.your-domain.com:
- Type: A
- Name:
lab - IPv4 Address:
XXX.XXX.XXX.XXX - Proxy status: โ๏ธ Proxied (orange cloud)
Server Firewall Configuration
3.1 Block Direct Access
Configure UFW to deny direct access to your server:
3.2 Allow Cloudflare IP Ranges
Only allow Cloudflare's servers to access your web services:
3.3 Create Update Script
Cloudflare IP ranges can change, so create an update script:
SSL/TLS Configuration
4.1 Enable HTTPS in Cloudflare
- Go to SSL/TLS tab in Cloudflare dashboard
- Set encryption mode to Flexible (easiest) or Full
- Enable "Always Use HTTPS" redirect
- Enable "HTTP Strict Transport Security (HSTS)" for extra security
4.2 Option A: Flexible SSL (Easiest)
- Cloudflare handles SSL termination
- Traffic between Cloudflare and your server uses HTTP
- No server-side SSL certificate required
- Good for getting started quickly
4.3 Option B: Full SSL (Recommended)
- Go to SSL/TLS โ Origin Certificates in Cloudflare
- Create a Cloudflare Origin Certificate
- Download the certificate and private key
- Install on your web server (Apache/Nginx)
- Set encryption mode to Full (strict)
SSH Security Hardening
5.1 Review Current UFW Rules
Look for any rules allowing SSH from "Anywhere" - these need to be removed.
5.2 Remove Broad SSH Access
If you see rules like "22/tcp ALLOW IN Anywhere", remove them:
5.3 Allow SSH from Local Network Only
5.4 Verify SSH Security
Ensure SSH (port 22) is only allowed from specific IP ranges, not "Anywhere".
Dynamic IP Management
6.1 Create Cloudflare API Token
- Go to Cloudflare Dashboard โ My Profile โ API Tokens
- Click "Create Token" โ "Custom token"
- Permissions: Zone:Zone:Read, Zone:DNS:Edit
- Zone Resources: Include - Specific zone - your-domain.com
- Save the token securely
6.2 Get Zone and Record IDs
6.3 Create DDNS Update Script
6.4 Setup Automated Updates
Testing & Verification
7.1 Test Domain Resolution
7.2 Verify HTTPS Access
- Visit
https://your-domain.comin a browser - Check that the SSL certificate is valid
- Verify that the site loads correctly
7.3 Confirm IP Masking
7.4 Test Firewall Rules
๐ Congratulations! You've Successfully Completed the Setup
What you've achieved:
- Professional custom domain (
your-domain.com) hosted from home - Enterprise-grade DDoS protection via Cloudflare
- SSL/TLS encryption with valid certificates
- Complete IP masking - your real location is hidden
- Automatic DNS updates for dynamic IP addresses
- Secured SSH access limited to local network only
Advanced Configuration Options
Subdomain Structure Example:
All traffic proxied through Cloudflare for maximum security.
Additional Security Enhancements
- Cloudflare Access: Add zero-trust authentication
- Rate Limiting: Configure request rate limits
- Firewall Rules: Block specific countries or IP ranges
- Bot Protection: Enable advanced bot detection
Performance Optimization
- Caching: Configure page and browser caching rules
- Compression: Enable Brotli and Gzip compression
- Minification: Automatic CSS/JS/HTML minification
- CDN: Leverage Cloudflare's global CDN network
Professional Achievement
You've successfully implemented a professional-grade hosting solution that rivals commercial providers. This setup demonstrates advanced skills in:
- Network Architecture: DNS management, proxy configuration, and traffic routing
- Security Engineering: Firewall configuration, IP masking, and access control
- Systems Administration: Linux server management and service automation
- Cloud Integration: Cloudflare API usage and service orchestration
- DevOps Practices: Infrastructure as code and automated deployments