|
| 1 | +# Cloudflared Tunnels |
| 2 | + |
| 3 | +Expose your localhost to the internet using Cloudflare tunnels. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +brew install cloudflared |
| 9 | +``` |
| 10 | + |
| 11 | +## Quick Tunnel (Recommended for Development) |
| 12 | + |
| 13 | +No setup required. Generates a temporary public URL instantly: |
| 14 | + |
| 15 | +```bash |
| 16 | +cloudflared tunnel --url http://localhost:3000 |
| 17 | +``` |
| 18 | + |
| 19 | +Output includes a URL like `https://random-words.trycloudflare.com` that tunnels to your local server. |
| 20 | + |
| 21 | +## Named Tunnel (Persistent, Requires DNS) |
| 22 | + |
| 23 | +For a permanent subdomain on a domain you own: |
| 24 | + |
| 25 | +```bash |
| 26 | +# One-time setup |
| 27 | +cloudflared tunnel login # Authenticate with Cloudflare |
| 28 | +cloudflared tunnel create mytunnel # Create named tunnel |
| 29 | + |
| 30 | +# Route to your domain (requires domain in Cloudflare) |
| 31 | +cloudflared tunnel route dns mytunnel subdomain.yourdomain.com |
| 32 | + |
| 33 | +# Run the tunnel |
| 34 | +cloudflared tunnel run --url http://localhost:3000 mytunnel |
| 35 | +cloudflared tunnel run --url http://localhost:3000 mytunnel |
| 36 | +``` |
| 37 | + |
| 38 | +To delete a named tunnel: |
| 39 | + |
| 40 | +```bash |
| 41 | +cloudflared tunnel delete mytunnel |
| 42 | +``` |
| 43 | + |
| 44 | +## Quick Tunnel vs Named Tunnel |
| 45 | + |
| 46 | +| Feature | Quick Tunnel | Named Tunnel | |
| 47 | +| -------- | ------------------ | ------------------ | |
| 48 | +| Setup | None | Login + DNS config | |
| 49 | +| URL | Random, temporary | Your subdomain | |
| 50 | +| Use case | Local dev, testing | Staging, demos | |
| 51 | + |
| 52 | +**For local development, use quick tunnels.** |
| 53 | + |
| 54 | +## Use Cases |
| 55 | + |
| 56 | +- **Webhook testing** - Receive webhooks from external services (Stripe, GitHub, etc.) |
| 57 | +- **Sharing work** - Share your local development with teammates or clients |
| 58 | +- **Mobile testing** - Test your app on physical devices without deployment |
| 59 | + |
| 60 | +## Stripe Webhook Testing |
| 61 | + |
| 62 | +1. Start the tunnel: |
| 63 | + |
| 64 | + ```bash |
| 65 | + cloudflared tunnel --url http://localhost:3000 |
| 66 | + ``` |
| 67 | + |
| 68 | +2. Copy the generated URL and configure it in Stripe Dashboard: |
| 69 | + - Go to Developers → Webhooks → Add endpoint |
| 70 | + - Enter: `https://your-tunnel-url.trycloudflare.com/webhooks/stripe` |
| 71 | + |
| 72 | +3. Test webhook delivery from the Stripe Dashboard |
0 commit comments