Run Cloudflare Tunnel for Lando service container

Run Cloudflare Tunnel for Lando service container
·
Roman Zipp

This post will guide you through creating a Cloudflare Tunnel for a local Lando service container.

Create Tunnel

  1. Create a new directory .cloudflare
  2. Authorize Argo Tunnel for Domain
    • Select the Domain
    • A file cert.pem will be starting to download
  3. Store cert.pem in .cloudflare/cert.pm
  4. Run cloudflared tunnel --config=.cloudflare/config.yml --origincert=./.cloudflare/cert.pem create "Test"
  5. Set tunnel id to tunnel value in .cloudflare/config.yml
  6. Create DNS CNAME Entry with <TUNNEL ID>.cfargotunnel.com
  7. Start Tunnel via the script below

Start Tunnel

In my case I want to expose the appserver_nginx Lando service to the tunnel.

cloudflared tunnel \
  --config=.cloudflare/config.yml \
  --origincert=./.cloudflare/cert.pem \
  run \
  --url=$(lando info --filter "service=appserver_nginx" --format json | jq '.[0].urls[1]' | sed 's/\"//g')

You can debug all requests using the --loglevel debug flag.