I want to create a tunnel between my custom domain (e.g., backend.dinhanhthi.com) and my locally hosted server (e.g., http://localhost:3000). For this, I'll use Cloudflare's Zero Trust, which is free.

You can access Zero Trust from the Cloudflare dashboard or via this link.

Follow these steps: Create a tunnel → Choose Cloudflared → Give it a name → Save tunnel → (install cloudflared following the docs) and then:

  1. Either activate it once for the current session using cloudflared tunnel run...
  2. Or install it permanently on your machine to run automatically at startup by using sudo cloudflared service install ...

Next, click "Next" and configure Public hostnames:

Then click "Complete setup."

You can now check the result based on the option you chose earlier (cloudflared tunnel run or sudo cloudflared service install...).

Remarks:

If you don't have a custom domain and need a simpler solution, consider using ngrok instead.