DEV Community

MUHAMMAD ARBAB ANJUM
MUHAMMAD ARBAB ANJUM

Posted on

Expose localhost to the network using Cloudflare Tunnel

Install cloudflared

Download from: https://github.com/cloudflare/cloudflared/releases 
Enter fullscreen mode Exit fullscreen mode

Change Dir

cd C:\cloudflared\ 
Enter fullscreen mode Exit fullscreen mode

Login to Cloudflare

cloudflared tunnel login 
Enter fullscreen mode Exit fullscreen mode

Create tunnel

cloudflared tunnel create nextjs-tunnel 
Enter fullscreen mode Exit fullscreen mode

Route DNS

cloudflared tunnel route dns nextjs-tunnel test.myworkly.com 
Enter fullscreen mode Exit fullscreen mode

Create config.yml file in C:\cloudflared\config.yml

tunnel: nextjs-tunnel credentials-file: C:\Users\%USERNAME%\.cloudflared\[your-tunnel-id].json ingress: - hostname: test.domain.com service: http://localhost:3000 - service: http_status:404 
Enter fullscreen mode Exit fullscreen mode

Quick Test

cloudflared tunnel --hostname test.domain.com --url http://localhost:3000 
Enter fullscreen mode Exit fullscreen mode

Run tunnel pointing directly to Next.js

cloudflared tunnel --config config.yml run nextjs-tunnel 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)