Skip to main content

Your first tunnel in four steps

1

Authenticate

Log in to Cloudflare and set your API token.

moley config set --cloudflare.token="your-api-token"
Getting an API token

Go to Cloudflare → API Tokens and create a token with:

  • Zone > Zone > Read — resolve your zone and account ID
  • Zone > DNS > Edit — create and delete CNAME records
  • Account > Cloudflare Tunnel > Edit — create, configure, and delete tunnels
  • Account > Zero Trust > Edit — only when using access: blocks (Access Applications, Policies, Identity Providers)
2

Initialize

Generate a tunnel configuration file.

moley tunnel init

This creates a moley.yml with a generated tunnel name and an example app config.

3

Configure apps

Edit moley.yml to match your local services.

moley.yml
tunnel:
name: "my-project"
persistent: false # delete tunnel on stop

ingress:
zone: "yourdomain.com"
mode: subdomain # or "wildcard"
apps:
- target:
port: 8080
hostname: "localhost"
protocol: http
expose:
subdomain: "api" # api.yourdomain.com

- target:
port: 3000
hostname: "localhost"
protocol: http
expose:
subdomain: "web" # web.yourdomain.com
4

Run

moley tunnel run

Your apps are now live. Stop with moley tunnel stop — tunnels, DNS records, and Access Applications are cleaned up automatically.