1. บทนำ
ในยุคที่การทำงานระยะไกล (Remote Work) เป็นเรื่องปกติ การเข้าถึงบริการภายในองค์กรจากภายนอกจึงเป็นความท้าทายด้านความปลอดภัย Cloudflare Tunnel คือคำตอบที่เปลี่ยนวิธีการเชื่อมต่อแบบเดิมๆ ให้ปลอดภัยยิ่งขึ้น
บทความนี้จะพาคุณเรียนรู้ตั้งแต่พื้นฐานของ Cloudflare Tunnel ไปจนถึงการตั้งค่าขั้นสูง พร้อมตัวอย่างการใช้งานจริงที่สามารถนำไปประยุกต์ใช้ได้ทันที
หมายเหตุ: บทความนี้เขียนขึ้นในเดือนกุมภาพันธ์ 2026 ข้อมูลอาจมีการเปลี่ยนแปลง แนะนำให้ตรวจสอบเอกสารอย่างเป็นทางการของ Cloudflare เป็นบางครั้ง
2. Cloudflare Tunnel คืออะไร
Cloudflare Tunnel (เดิมชื่อ Argo Tunnel) เป็นบริการที่ช่วยให้คุณเปิดเผยบริการที่รันอยู่บนเครือข่ายภายใน (Local Network) หรือ Private Infrastructure สู่อินเทอร์เน็ตได้อย่างปลอดภัย โดยไม่ต้องเปิดพอร์ตบนไฟร์วอลล์หรือ Router
2.1 ข้อดีหลักของ Cloudflare Tunnel
ไม่ต้องเปิดพอร์ต ไม่มี Public IP ที่แฮกเกอร์จะโจมตีได้
ใช้คำสั่งไม่กี่บรรทัดก็เริ่มใช้งานได้
Free Tier ใช้งานได้โดยไม่มีค่าใช้จ่าย
รองรับทั้งโปรเจคเล็กและองค์กรขนาดใหญ่
2.2 ใครที่ควรใช้ Cloudflare Tunnel
- นักพัฒนาที่ต้องการแชร์ Local Development ให้ลูกค้าดู
- ผู้ดูแลระบบที่ต้องการเข้าถึง Home Lab จากที่ไหนก็ได้
- องค์กรที่ต้องการ Zero-Trust Network Access
- ทีม DevOps ที่ต้องการเข้าถึง Internal Tools อย่างปลอดภัย
- คนที่ไม่มี Static Public IP แต่ต้องการเข้าถึงบริการจากภายนอก
3. สถาปัตยกรรม (Architecture)
3.1 วิธีการทำงาน
ลำดับการทำงาน:
- ผู้ใช้เข้าถึง app.example.com ผ่าน Browser
- DNS ชี้ไป Cloudflare Edge Server
- Cloudflare ตรวจสอบ WAF, DDoS Protection, Zero Trust Policy
- Traffic ส่งผ่าน Tunnel แบบเข้ารหัสไปยัง cloudflared daemon
- cloudflared ส่งต่อ ไปยังบริการภายในตาม config
3.2 เปรียบเทียบกับวิธีดั้งเดิม
| คุณสมบัติ | Cloudflare Tunnel | Port Forwarding แบบเดิม |
|---|---|---|
| ความปลอดภัย | ไม่เปิดพอร์ต | เปิดพอร์ต มีความเสี่ยง |
| Public IP | ไม่ต้องการ | ต้องการ Static IP |
| DDoS Protection | มีในตัว | ต้องตั้งค่าเอง |
| WAF | มีในตัว | ไม่มี |
| SSL/TLS | จัดการให้อัตโนมัติ | ต้องตั้งค่าเอง |
| ค่าใช้จ่าย | ฟรีสำหรับพื้นฐาน | ขึ้นกับ ISP |
4. สิ่งที่ต้องเตรียม
Cloudflare Account
- บัญชี Cloudflare (Free Tier ใช้ได้)
- Domain ที่ลงทะเบียนกับ Cloudflare
- เปิดใช้งาน Cloudflare DNS
Server/Computer
- Linux/macOS/Windows
- Internet Connection
- Command Line Access
ความรู้พื้นฐานที่ควรมี
- • การใช้งาน Command Line / Terminal
- • ความเข้าใจพื้นฐานเกี่ยวกับ DNS
- • การใช้งาน SSH (ถ้าติดตั้งบนเซิร์ฟเวอร์ระยะไกล)
- • การแก้ไขไฟล์ Config (YAML)
5. ขั้นตอนการติดตั้ง
สำคัญ: ขั้นตอนนี้แสดง 2 วิธีการติดตั้ง (Package Manager และ Docker) เลือกทำเพียงวิธีใดวิธีหนึ่ง
5.1 ติดตั้ง cloudflared ด้วย Package Manager
Ubuntu/Debian
# เพิ่ม Cloudflare GPG key
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
# เพิ่ม Repository
echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
# ติดตั้ง
sudo apt-get update
sudo apt-get install cloudflared
# ตรวจสอบเวอร์ชัน
cloudflared --version
CentOS/RHEL/Fedora
# เพิ่ม Repository
sudo rpm --import https://pkg.cloudflare.com/cloudflare-main.gpg
# สร้าง repo file
sudo tee /etc/yum.repos.d/cloudflared.repo <
macOS (Homebrew)
# ติดตั้งด้วย Homebrew
brew install cloudflare/cloudflare/cloudflared
# ตรวจสอบเวอร์ชัน
cloudflared --version
5.2 ติดตั้งด้วย Docker (ทางเลือก)
# ดาวน์โหลด image
docker pull cloudflare/cloudflared:latest
# ตรวจสอบเวอร์ชัน
docker run --rm cloudflare/cloudflared:latest --version
6. การตั้งค่าและสร้าง Tunnel
6.1 Login ไปยัง Cloudflare
# Login ด้วย Browser
cloudflared tunnel login
# หรือ Login ด้วย API Token
cloudflared tunnel login --token YOUR_API_TOKEN
ระบบจะเปิด Browser ให้เลือก Domain ที่ต้องการใช้งาน แล้ว Authorize การเข้าถึง
6.2 สร้าง Tunnel ใหม่
# สร้าง tunnel ใหม่
cloudflared tunnel create my-tunnel
# ผลลัพธ์จะแสดง Tunnel ID
# Tunnel credentials written to ~/.cloudflared/.json
6.3 ตั้งค่า DNS Record
# สร้าง CNAME record ชี้ไป tunnel
cloudflared tunnel route dns my-tunnel app.example.com
# หรือใช้ Tunnel ID
cloudflared tunnel route dns app.example.com
6.4 สร้างไฟล์ Config
tunnel:
credentials-file: /root/.cloudflared/.json
ingress:
# กฎที่ 1: app.example.com ไปที่ localhost:3000
- hostname: app.example.com
service: http://localhost:3000
# กฎที่ 2: api.example.com ไปที่ localhost:8080
- hostname: api.example.com
service: http://localhost:8080
# กฎเริ่มต้น: ส่งคืน 404 สำหรับ path อื่นๆ
- service: http_status:404
6.5 รัน Tunnel
# รัน tunnel
cloudflared tunnel run my-tunnel
# หรือระบุ config file
cloudflared tunnel --config ~/.cloudflared/config.yml run
6.6 ตั้งค่าเป็น Systemd Service (Linux)
# ติดตั้งเป็น service
sudo cloudflared service install
# เริ่ม service
sudo systemctl start cloudflared
# เปิดใช้งานตอน boot
sudo systemctl enable cloudflared
# ตรวจสอบสถานะ
sudo systemctl status cloudflared
7. ตัวอย่างการใช้งานจริง
7.1 ตัวอย่างที่ 1: Local Development Server
แชร์เว็บแอพที่กำลังพัฒนาให้ลูกค้าหรือทีมดู
tunnel: 6ff42ae2-765d-4e26-b1f2-cbb23d9ba589
credentials-file: /home/user/.cloudflared/6ff42ae2-765d-4e26-b1f2-cbb23d9ba589.json
ingress:
- hostname: dev.example.com
service: http://localhost:3000
- service: http_status:404
7.2 ตัวอย่างที่ 2: หลายบริการใน Tunnel เดียว
tunnel: 6ff42ae2-765d-4e26-b1f2-cbb23d9ba589
credentials-file: /home/user/.cloudflared/6ff42ae2-765d-4e26-b1f2-cbb23d9ba589.json
ingress:
# Frontend
- hostname: app.example.com
service: http://localhost:3000
# Backend API
- hostname: api.example.com
service: http://localhost:8080
# Admin Dashboard
- hostname: admin.example.com
service: http://localhost:9000
# Database Admin (เช่น Adminer)
- hostname: db.example.com
service: http://localhost:8081
# Path-based routing
- hostname: example.com
path: /api/*
service: http://localhost:8080
- hostname: example.com
path: /admin/*
service: http://localhost:9000
# Default
- service: http_status:404
7.3 ตัวอย่างที่ 3: SSH Access
tunnel: 6ff42ae2-765d-4e26-b1f2-cbb23d9ba589
credentials-file: /home/user/.cloudflared/6ff42ae2-765d-4e26-b1f2-cbb23d9ba589.json
ingress:
- hostname: ssh.example.com
service: ssh://localhost:22
- service: http_status:404
# ติดตั้ง cloudflared บนเครื่อง Client
# แล้วเพิ่ม config ใน ~/.ssh/config
Host ssh.example.com
ProxyCommand cloudflared access ssh --hostname %h
7.4 ตัวอย่างที่ 4: Docker Compose
version: '3.8'
services:
# เว็บแอพ
webapp:
image: node:18-alpine
working_dir: /app
volumes:
- ./app:/app
command: npm start
ports:
- "3000:3000"
# API Server
api:
image: node:18-alpine
working_dir: /api
volumes:
- ./api:/api
command: npm start
ports:
- "8080:8080"
# Cloudflare Tunnel
cloudflared:
image: cloudflare/cloudflared:latest
command: tunnel --config /etc/cloudflared/config.yml run
volumes:
- ./cloudflared/config.yml:/etc/cloudflared/config.yml:ro
- ./cloudflared/credentials.json:/etc/cloudflared/credentials.json:ro
depends_on:
- webapp
- api
restart: always
8. แก้ไขปัญหาที่พบบ่อย
สาเหตุ: บริการที่ระบุใน config ไม่ทำงาน หรือ port ไม่ถูกต้อง
วิธีแก้:
# ตรวจสอบว่า service ทำงานอยู่
curl http://localhost:3000
netstat -tlnp | grep 3000
สาเหตุ: cloudflared ไม่ทำงาน หรือ tunnel ไม่ได้เชื่อมต่อ
วิธีแก้:
# ตรวจสอบสถานะ tunnel
cloudflared tunnel list
cloudflared tunnel info my-tunnel
# รัน tunnel อีกครั้ง
cloudflared tunnel run my-tunnel
สาเหตุ: ยังไม่ได้สร้าง DNS record หรือใช้คำสั่ง route dns
วิธีแก้:
# สร้าง DNS record
cloudflared tunnel route dns my-tunnel app.example.com
# ตรวจสอบ DNS
dig app.example.com
สาเหตุ: ไฟล์ credentials ไม่อยู่ใน path ที่ระบุ
วิธีแก้:
# ตรวจสอบตำแหน่งไฟล์
ls -la ~/.cloudflared/
# แก้ไข config.yml ให้ตรงกับ path จริง
คำสั่งตรวจสอบและ Debug
# ดูรายการ tunnels
cloudflared tunnel list
# ดูข้อมูล tunnel
cloudflared tunnel info my-tunnel
# ดู config ปัจจุบัน
cloudflared tunnel configuration show
# รันแบบ verbose (debug mode)
cloudflared tunnel --config ~/.cloudflared/config.yml --loglevel debug run
# ตรวจสอบ DNS
nslookup app.example.com
dig app.example.com
9. เปรียบเทียบกับทางเลือกอื่น
9.1 Cloudflare Tunnel vs Ngrok
| คุณสมบัติ | Cloudflare Tunnel | Ngrok |
|---|---|---|
| Free Tier | ใช้งานได้ไม่จำกัด | จำกัด 1 session |
| Custom Domain | ใช้ Domain ตัวเองได้ | ต้องจ่ายเงิน |
| WAF | มีในตัว | ไม่มี |
| DDoS Protection | มีในตัว | ไม่มี |
| Zero Trust Access | มีในตัว | ไม่มี |
| ความเหมาะสม | Production, Long-term | Quick testing, Demo |
9.2 Cloudflare Tunnel vs Tailscale
| คุณสมบัติ | Cloudflare Tunnel | Tailscale |
|---|---|---|
| Use Case | Public access, Web apps | Private network, VPN |
| Access Control | Zero Trust Policy | ACL-based |
| Setup Complexity | ง่าย | ง่าย |
| Best For | Web services, APIs | Internal network access |
10. สรุป
ข้อดี
- • ไม่ต้องเปิดพอร์ตบนไฟร์วอลล์
- • มี WAF และ DDoS Protection ในตัว
- • SSL/TLS จัดการให้อัตโนมัติ
- • Free Tier ใช้งานได้จริง
- • รองรับ Zero Trust Access
- • ติดตั้งและใช้งานง่าย
ข้อจำกัด
- • ต้องใช้ Domain กับ Cloudflare
- • ขึ้นอยู่กับ Cloudflare Infrastructure
- • มี Latency เพิ่มเล็กน้อย
- • Free Tier ไม่มี SLA
- • การแก้ไขปัญหาซับซ้อนกว่า
ขั้นตอนถัดไป
1. ลองสร้าง Tunnel แรกของคุณด้วย Local Development Server
2. ตั้งค่า Zero Trust Access เพื่อเพิ่มความปลอดภัย
3. ใช้ Cloudflare Tunnel กับ Home Lab หรือ Internal Tools
4. ศึกษาเพิ่มเติมเกี่ยวกับ Access Policies และ Authentication
11. เทคนิคขั้นสูงสำหรับ Production
หัวข้อนี้เหมาะสำหรับ:
- • Production Environment
- • High Availability Setup
- • Multi-Server Architecture
- • Security-Sensitive Applications
11.1 Load Balancing ด้วย Cloudflare Tunnel
# ตัวอย่างการตั้งค่า Load Balancing
# รัน multiple cloudflared instances บน port ต่างกัน
# Instance 1 (primary)
cloudflared tunnel --config ~/.cloudflared/config-primary.yml run
# Instance 2 (secondary)
cloudflared tunnel --config ~/.cloudflared/config-secondary.yml run
# ใช้ Load Balancer (เช่น Nginx) หน้า cloudflared
tunnel: 6ff42ae2-765d-4e26-b1f2-cbb23d9ba589
credentials-file: /home/user/.cloudflared/6ff42ae2-765d-4e26-b1f2-cbb23d9ba589-primary.json
ingress:
# Primary services (port 3000)
- hostname: app.example.com
service: http://localhost:3000
- service: http_status:404
tunnel: 6ff42ae2-765d-4e26-b1f2-cbb23d9ba589
credentials-file: /home/user/.cloudflared/6ff42ae2-765d-4e26-b1f2-cbb23d9ba589-secondary.json
ingress:
# Secondary services (port 3001)
- hostname: app.example.com
service: http://localhost:3001
- service: http_status:404
11.2 High Availability (HA) Setup
# /etc/systemd/system/cloudflared-ha@.service
[Unit]
Description=Cloudflare Tunnel %I (HA mode)
After=network.target
[Service]
Type=simple
User=cloudflared
Group=cloudflared
ExecStart=/usr/local/bin/cloudflared tunnel --config /etc/cloudflared/config-%i.yml run
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
# Re Load systemd daemon
sudo systemctl daemon-reload
# Start HA services
sudo systemctl start cloudflared-ha@primary
sudo systemctl start cloudflared-ha@secondary
# Enable auto-start
sudo systemctl enable cloudflared-ha@primary
sudo systemctl enable cloudflared-ha@secondary
# Check status
sudo systemctl status cloudflared-ha@primary
sudo systemctl status cloudflared-ha@secondary
Health Check Script
#!/bin/bash
# /usr/local/bin/check-tunnel-ha.sh
TUNNELS=("primary" "secondary")
for tunnel in "${TUNNELS[@]}"; do
if ! pgrep -f "cloudflared.*${tunnel}" > /dev/null; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Tunnel ${tunnel} is DOWN. Restarting..."
systemctl restart cloudflared-ha@${tunnel}
# Send notification (optional)
curl -X POST "https://notify.example.com/tunnel-health" \
-H "Content-Type: application/json" \
-d '{"status": "alert", "tunnel": "'${tunnel}'"}'
fi
done
11.3 Advanced Protocol Support
| Protocol | Supported | Example |
|---|---|---|
| HTTP/HTTPS | service: http://localhost:3000 | |
| SSH | service: ssh://localhost:22 | |
| TCP | service: tcp://localhost:5432 | |
| UDP | service: udp://localhost:53 | |
| PostgreSQL | service: tcp://localhost:5432 | |
| MySQL/MariaDB | service: tcp://localhost:3306 | |
| MongoDB | service: tcp://localhost:27017 | |
| Redis | service: tcp://localhost:6379 | |
| WebSocket | service: ws://localhost:8080/ws | |
| gRPC | service: h2://localhost:50051 |
11.4 Private Network Access (Zero Trust)
tunnel: 6ff42ae2-765d-4e26-b1f2-cbb23d9ba589
credentials-file: /home/user/.cloudflared/6ff42ae2-765d-4e26-b1f2-cbb23d9ba589.json
# Zero Trust Access settings
warp-routing:
enabled: true
ingress:
# Private network service
- hostname: internal.example.com
service: http://192.168.1.100:8080
path: /api/*
# Admin panel with authentication
- hostname: admin.example.com
service: http://localhost:9000
path: /admin/*
# Database access
- hostname: db.example.com
service: tcp://localhost:5432
# Default - allow only from specific IP ranges
- path: /*
auth:
oauth:
provider: google
options:
allowed_domains: your-company.com
allowed_emails:
- user1@your-company.com
- user2@your-company.com
allowed_groups:
- admins
service: http_status:401
Authentication Options
allowed_domains: your-company.com
provider: okta
provider: azure
allowed_ips: ["192.168.1.0/24", "10.0.0.0/8"]
12. Security Best Practices
สำคัญ - อ่านก่อนใช้งาน
Cloudflare Tunnel ช่วยเพิ่มความปลอดภัย แต่การตั้งค่าที่ไม่เหมาะสม bisa เปิดช่องโหว่ได้
คำอธิบาย: อย่ารัน cloudflared ด้วย root user เสมอ
# สร้าง user โดยเฉพาะสำหรับ cloudflared
sudo useradd -r -s /bin/false cloudflared
sudo mkdir -p /etc/cloudflared
sudo chown -R cloudflared:cloudflared /etc/cloudflared
# แก้ไข config และ credentials files
sudo chown cloudflared:cloudflared /etc/cloudflared/config.yml
sudo chown cloudflared:cloudflared /etc/cloudflared/*.json
# แก้ไข systemd service
sudo sed -i 's/User=cloudflared/' /etc/systemd/system/cloudflared.service
คำอธิบาย: คีม credentials.json ต้องได้รับการปกป้อง
# ตั้งค่า permissions อย่างถูกต้อง
chmod 600 /etc/cloudflared/*.json
chmod 644 /etc/cloudflared/config.yml
# อีกวิธี - ใช้ Environment Variables
tunnel: ${TUNNEL_ID}
credentials-file: ${CREDENTIALS_FILE}
# รันด้วย
export TUNNEL_ID=your-tunnel-id
export CREDENTIALS_FILE=/etc/cloudflared/credentials.json
cloudflared tunnel run
คำอธิบาย: ใช้ HTTPS สำหรับ local services เสมอที่ทำได้
# ใช้ Traefik หรือ Caddy สำหรับ automatic TLS
ingress:
- hostname: app.example.com
service: https://localhost:3001
# หรือใช้ nginx reverse proxy พร้อม TLS
ingress:
- hostname: app.example.com
service: http://127.0.0.1:8080
คำอธิบาย: ตั้งค่า Web Application Firewall (WAF) rules
# Rule examples ที่ควรใช้:
# Block suspicious IPs
- ip: 192.168.1.100
action: block
# Block specific URLs
- path: /admin/backup*
action: Block
# Rate limiting
- path: /api/*
action: rate_limit
rate_limit:
requests_per_second: 100
burst_size: 200
# IP restriction
- path: /internal/*
action:whitelist
ip_ranges: ["10.0.0.0/8", "192.168.0.0/16"]
คำอธิบาย: ต้องกำหนด rules ให้ชัดเจน อย่าปล่อย default access
# ❌ ไม่ควรทำแบบนี้ (เปิดกว้างเกินไป)
ingress:
- service: http_status:404
# ✅ ควรทำแบบนี้ (explicit deny)
ingress:
- hostname: app.example.com
service: http://localhost:3000
- path: /api/*
service: http://localhost:8080
# Explicit deny for everything else
- service: http_status:404
คำอธิบาย: ใช้ Access policies แทนการใช้ public IP
# ตัวอย่าง Access Policy ที่ปลอดภัย
ingress:
# Web service - everyone can access
- hostname: www.example.com
service: http://localhost:3000
# Admin panel - only admins
- hostname: admin.example.com
service: http://localhost:9000
path: /admin/*
auth:
oauth:
provider: google
options:
allowed_domains: your-company.com
# Internal API - only specific services
- hostname: api.internal.example.com
service: http://localhost:8080
path: /internal/*
auth:
identity:
providers:
- type: github
options:
clients:
- client_id: ${GITHUB_CLIENT_ID}
client_secret: ${GITHUB_CLIENT_SECRET}
Security Checklist
- ไม่ใช้ root user ในการรัน cloudflared
- ตั้ง permissions ให้ credentials.json เป็น 600
- ใช้ HTTPS/ TLS สำหรับ local services
- ตั้ง WAF rules และ rate limiting
- ไม่เปิด default access แบบไม่จำกัด
- ใช้ Access policies ตาม role/user
- Active log monitoring และ alerting
13. ตัวอย่าง Use Cases จริง
13.1 Local Development Sharing
tunnel: development-tunnel-id
credentials-file: /home/developer/.cloudflared/dev-credentials.json
ingress:
# React app (development)
- hostname: dev-react.example.com
service: http://localhost:3000
# API (development)
- hostname: dev-api.example.com
service: http://localhost:8080
# Database UI (Adminer/PhpMyAdmin)
- hostname: db-admin.example.com
service: http://localhost:8081
# WebSocket for real-time features
- hostname: ws.example.com
service: ws://localhost:8080
# Default
- service: http_status:404
# Run development tunnel
cloudflared tunnel --config ~/.cloudflared/config-development.yml run
# หรือรันด้วย screen/tmux เพื่อให้ทำงานต่อเนื่อง
screen -dmS dev-tunnel cloudflared tunnel --config ~/.cloudflared/config-development.yml run
13.2 Home Lab Access
tunnel: homelab-tunnel-id
credentials-file: /home/homelab/.cloudflared/homelab-credentials.json
ingress:
# Home Assistant
- hostname: hass.example.com
service: http://192.168.1.10:8123
# Pi-hole (Ad blocker)
- hostname: pi.hole.example.com
service: http://192.168.1.20:80
# Jellyfin Media Server
- hostname: media.example.com
service: http://192.168.1.30:8096
# Portainer (Docker management)
- hostname: portainer.example.com
service: http://192.168.1.40:9000
# SSH Access (for maintenance)
- hostname: ssh.homelab.example.com
service: ssh://localhost:22
# Default
- service: http_status:404
13.3 Database Access (Secure)
tunnel: database-tunnel-id
credentials-file: /home/dbadmin/.cloudflared/db-credentials.json
ingress:
# PostgreSQL - with IP restriction
- hostname: db.example.com
service: tcp://localhost:5432
# MySQL - with IP restriction
- hostname: mysql.example.com
service: tcp://localhost:3306
# MongoDB - with authentication
- hostname: mongo.example.com
service: tcp://localhost:27017
# Redis - only from specific IPs
- hostname: redis.example.com
service: tcp://localhost:6379
# Default - deny all
- service: http_status:404
Connect to PostgreSQL via Tunnel
# บนเครื่อง Client
# สร้าง tunnel ไปยัง database server
cloudflared tunnel --config ~/.cloudflared/config-database.yml run
# เชื่อมต่อผ่าน tunnel
psql -h db.example.com -p 5432 -U username -d database
13.4 Multi-Environment Setup
# production/config.yml
tunnel: prod-tunnel-id
credentials-file: /etc/cloudflared/prod-credentials.json
ingress:
- hostname: app.example.com
service: http://localhost:3000
- hostname: api.example.com
service: http://localhost:8080
- hostname: static.example.com
service: http://localhost:3001
- service: http_status:404
# staging/config.yml
tunnel: staging-tunnel-id
credentials-file: /etc/cloudflared/staging-credentials.json
ingress:
- hostname: app.example.com
service: http://localhost:3000
- hostname: api.example.com
service: http://localhost:8080
- service: http_status:404