Cloudflare Tunnel Localhost manual setup

Cloudflare Tunnel Localhost

  1. Visit Cloudflare One
  2. Run the commands
# Login
docker run --mount "type=bind,src=C:\web\dev,target=/home/nonroot/.cloudflared/" cloudflare/cloudflared login
# or windows path
docker run -v "//c/tunnels/cloudflare:/home/nonroot/.cloudflared/:rw" cloudflare/cloudflared login
  1. Create a tunnel
# Create a tunnel
docker run --network host -v "//b/code/docker/cloudflare/cloudflared:/home/nonroot/.cloudflared/:rw" "cloudflare/cloudflared:latest" tunnel create localhost

# (checking) get tokens
docker run --network host -v "//b/code/docker/cloudflare/cloudflared:/home/nonroot/.cloudflared/:rw" "cloudflare/cloudflared:latest" tunnel token <TUNNEL UUID>
  1. Configure Domain
# Configure Domain
docker run -v "//c/tunnels/cloudflare:/home/nonroot/.cloudflared/:ro" cloudflare/cloudflared:latest tunnel route dns <TUNNEL_ID> <DOMAIN_NAME_HERE>

# paste this in a file named config.yml in the configs folder
`
tunnel: d5b6c119-849d-4ad1-83fe-f51038922e36
credentials-file: /home/nonroot/.cloudflared/d5b6c119-849d-4ad1-83fe-f51038922e36.json

ingress:
  - hostname: localhost.yourdomain.eu.org
  # resolve to internal host
    service: http://host.docker.internal:8080
  # return 404 if not matching
  - service: http_status:404
`
  1. Run tunnel
# copy the command from the "configure" tunnel option in networks
# cloudflared.exe service install ...<token...
# use this token as env var
docker run --net="host" -v "//c/tunnels/cloudflare:/home/nonroot/.cloudflared/:rw" cloudflare/cloudflared:latest tunnel run <tunnel id>