Sebelum memulakan lab ini, pastikan anda sudah:
- ✅ Selesai Lab 23 (DNS record sudah setup dengan DNS only mode)
- ✅ Domain anda sudah boleh diakses dari browser
- ✅ EC2 instance masih running dengan Nginx
Dalam lab ini, anda akan belajar:
- Perbezaan antara DNS only (gray cloud) vs Proxied (orange cloud)
- Enable Cloudflare proxy untuk domain anda
- Verify perubahan IP address
- Lihat benefits dari Cloudflare proxy
- Troubleshoot issues jika ada
Status sekarang: Dari Lab 23, DNS record anda dalam mode DNS only
Cara kerja:
User Browser → (DNS lookup) → Cloudflare DNS → Return real IP
User Browser → (Direct connection) → Your AWS Server
Ciri-ciri:
- Traffic direct ke server anda
- Real IP address visible kepada public
- Tiada CDN caching
- Tiada extra security layer
- Simple setup
Mode yang akan kita enable: Proxied through Cloudflare
Cara kerja:
User Browser → (DNS lookup) → Cloudflare DNS → Return Cloudflare IP
User Browser → Cloudflare Edge Server → Your AWS Server
Ciri-ciri:
- Traffic melalui Cloudflare network
- Real IP hidden (hanya Cloudflare IP visible)
- CDN caching enabled
- Extra security (DDoS protection, WAF)
- Free SSL certificate
- Slightly more complex setup
Buka terminal dan check IP address yang DNS return:
# Check IP untuk domain anda
dig +short example.comExpected output (DNS only mode):
54.123.45.67
Ini adalah real IP dari EC2 instance anda
- Buka browser
- Pergi ke: https://www.whatsmydns.net/
- Masukkan domain anda:
example.com - Click Search
- Perhatikan pada IP yang dipaparkan - ini adalah real server IP anda
# Check HTTP headers
curl -I http://example.comExpected output:
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Mon, 10 Nov 2025 10:00:00 GMT
Content-Type: text/html
Note: Nampak server details (nginx version)
- Pergi ke https://dash.cloudflare.com
- Login dan pilih domain anda
- Click DNS tab
- Cari A record untuk root domain (
example.comatau@) - Anda akan nampak icon gray cloud 🔴 (DNS only)
- Click pada gray cloud icon
- Icon akan bertukar ke orange cloud ☁️ (Proxied)
- Record akan automatically save
Before:
Type: A
Name: @
Content: 54.123.45.67
Proxy status: 🔴 DNS only
After:
Type: A
Name: @
Content: 54.123.45.67
Proxy status: ☁️ Proxied
- Cari record untuk
wwwsubdomain - Click gray cloud icon
- Icon bertukar ke orange cloud
- Save
Tunggu beberapa saat (30 saat - 2 minit), kemudian:
# Check IP address
dig +short example.comExpected output (Proxied mode):
104.21.45.123
172.67.89.234
Ini adalah Cloudflare IP addresses (bukan real server IP anda!)
Nota: Anda akan dapat 2 IP addresses - ini adalah Cloudflare edge servers yang akan proxy request ke server anda.
Langkah 2: Verify Real IP Hidden
- Pergi ke: https://www.whatsmydns.net/
- Masukkan domain:
example.com - Click Search
- IP address sekarang adalah Cloudflare IP (104.x.x.x atau 172.x.x.x)
# Check HTTP headers dengan proxy enabled
curl -I http://example.comExpected output:
HTTP/1.1 200 OK
Date: Mon, 10 Nov 2025 10:05:00 GMT
Content-Type: text/html
Server: cloudflare
CF-RAY: 8b1234567890abcd-KUL
CF-Cache-Status: DYNAMIC
Perhatikan perubahan:
- ✅
Server: cloudflare(bukan nginx lagi) - ✅ Ada
CF-RAYheader (Cloudflare tracking ID) - ✅ Ada
CF-Cache-Statusheader - ✅ Nginx version tidak visible (more secure)
| Feature | DNS Only (Gray Cloud) | Proxied (Orange Cloud) |
|---|---|---|
| IP Visible | Real server IP | Cloudflare IP sahaja |
| DNS Response | 1 IP (server anda) | 2 IPs (Cloudflare edges) |
| Traffic Route | Direct ke server | Melalui Cloudflare |
| CDN Caching | ❌ Tidak | ✅ Ya |
| DDoS Protection | ❌ Basic AWS only | ✅ Yes (Cloudflare) |
| SSL Certificate | ❌ Perlu setup manual | ✅ Free automatic |
| Server Header | Visible (nginx/1.18.0) | Hidden (cloudflare) |
| Response Time | Direct connection | Potentially faster (CDN) |
| Security | Basic | Enhanced (WAF, bot protection) |
| Analytics | ❌ Limited | ✅ Detailed di Cloudflare |
Before (DNS only):
# Test response time
time curl -I http://example.comAfter (Proxied):
# Test response time with Cloudflare
time curl -I http://example.comHasil mungkin berbeza bergantung lokasi anda dan Cloudflare edge server terdekat
Cloudflare mempunyai 300+ data centers di seluruh dunia:
- Asia: Singapore, Kuala Lumpur, Bangkok, Jakarta, etc.
- Europe: London, Frankfurt, Paris, Amsterdam, etc.
- Americas: New York, Los Angeles, São Paulo, etc.
- Oceania: Sydney, Auckland, etc.
Bila enable proxy, request akan route ke edge server terdekat.
Bila proxied, Cloudflare add extra headers:
CF-RAY: 8b1234567890abcd-KUL
→ Unique request ID + edge location (KUL = Kuala Lumpur)
CF-Cache-Status: HIT | MISS | DYNAMIC | BYPASS
→ HIT = Served from cache
→ MISS = Not in cache, fetched from origin
→ DYNAMIC = Dynamic content, not cacheable
→ BYPASS = Cache bypassed
CF-Connecting-IP: 1.2.3.4
→ Real visitor IP (use this for logging!)
CF-Visitor: {"scheme":"https"}
→ Original protocol used by visitor