Thay thế ngrok bằng giải pháp Open Source: frp, Cloudflare Tunnel, rathole cho WordPress Lando

CD

Ngrok là công cụ tunnel phổ biến giúp expose local server ra internet, nhưng phiên bản free giới hạn nhiều tính năng (3 tunnels/month, không custom domain, băng thông thấp). Bài này giới thiệu các giải pháp thay thế open source, miễn phí, self-hosted — đặc biệt phù hợp cho WordPress local development với Lando.

Tại sao cần tunnel cho local WordPress?

Khi phát triển WordPress với Lando (hoặc LocalWP, Docker), bạn thường cần expose site ra internet để kiểm tra webhook, demo cho khách hàng, test SSL, tích hợp third-party API, hoặc mobile testing.

So sánh các giải pháp thay thế ngrok

TênStarsHTTP/HTTPSCustom DomainSelf-hostedWordPress Lando
frp108k⭐ Tốt nhất
cloudflared~10k✅ (free)❌ (Cloudflare)⭐ Dễ nhất
rathole9k✅ Tốt
bore9k✅ (TCP)Cơ bản
localtunnel19k✅ Nhanh
zrok~3k✅ Tốt

1. frp — Giải pháp mạnh nhất, self-hosted

frp (108k GitHub stars) viết bằng Go, hoạt động theo mô hình client-server. Cần một VPS có IP public chạy frp server, máy local chạy frp client.

bindPort = 7000
vhostHTTPPort = 8080
auth.token = "your-secret-token"

Trên local, cấu hình frpc.toml:

serverAddr = "your-vps.com"
serverPort = 7000
auth.token = "your-secret-token"

[[proxies]]
name = "lando-wordpress"
type = "http"
localIP = "127.0.0.1"
localPort = 8080
customDomains = ["wp.your-vps.com"]

2. Cloudflare Tunnel — Dễ nhất, miễn phí

cloudflared không cần VPS, không cần mở port — chỉ cần domain dùng Cloudflare DNS.

brew install cloudflared
cloudflared tunnel login
cloudflared tunnel create lando-wp-tunnel

Cấu hình ~/.cloudflared/config.yml:

tunnel: [tunnel-id]
credentials-file: /path/to/file.json
ingress:
  - hostname: wp.yourdomain.com
    service: http://localhost:8080
  - service: http_status:404

Route DNS và chạy: cloudflared tunnel route dns lando-wp-tunnel wp.yourdomain.com && cloudflared tunnel run lando-wp-tunnel. Kết quả: HTTPS miễn phí, không cần mở port.

3. rathole — Hiệu năng cao, bảo mật Noise Protocol

rathole viết bằng Rust, nổi bật với throughput cao hơn frp, memory thấp, và bảo mật tích hợp (không cần tự tạo SSL certificate).

# Server (VPS)
[server]
bind_addr = "0.0.0.0:2333"
[server.services.wordpress]
token = "your-token"
bind_addr = "0.0.0.0:5202"

# Client (local)
[client]
remote_addr = "your-vps.com:2333"
[client.services.wordpress]
token = "your-token"
local_addr = "127.0.0.1:8080"

4. Các giải pháp nhanh khác

localtunnel: npx localtunnel --port 8080 — Node.js, không cần VPS. bore: brew install bore-cli && bore local 8080 --to bore.pub — Rust, đơn giản nhất, chỉ TCP. zrok: zrok share public localhost:8080 — zero-trust, end-to-end encryption.

Lưu ý khi dùng tunnel cho Lando WordPress

  • Site URL: Cập nhật WordPress Address và Site Address thành domain tunnel, nếu không WordPress sẽ redirect về localhost.
  • Mixed content: Nếu dùng HTTPS, chạy search-replace: wp search-replace "http://localhost" "https://your-tunnel.com"
  • Lando proxy: Kiểm tra port với lando info, điều chỉnh config tunnel cho phù hợp.
  • Bảo mật: Luôn dùng token mạnh, HTTPS, xác thực.

Kết luận

Có VPS? Dùng frp. Có Cloudflare? Dùng cloudflared (5 phút setup, HTTPS free). Cần nhanh? localtunnel. Cần hiệu năng cao? rathole.

Bài viết liên quan: Sửa lỗi WPML license key · WordPress SSO plugin · Đổi editor mặc định Ubuntu