DevOps

Cloudflare Tunnels from Local

How to expose a local service using Cloudflare Tunnels

This page is a short version of:

https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/create-local-tunnel/

You need to install:

https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/

download the deb package if ubuntu

  sudo dpkg -i .deb
cloudflared login

login and select a domain name

then do

cloudflared tunnel create dev_n73

Tunnel credentials written to /home/agust/.cloudflared/62c0d82d-2b85-43c2-a54f-e2b40b4823b8.json. cloudflared chose this file based on where your origin certificate was found. Keep this file secret. To revoke these credentials, delete the tunnel.

Created tunnel dev_n73 with id 62c0d82d-2b85-43c2-a54f-e2b40b4823b8

Now create a cloudflare.yaml file for the config

url: http://localhost:8081
tunnel: 62c0d82d-2b85-43c2-a54f-e2b40b4823b8
creditals-file: /home/agust/.cloudflared/62c0d82d-2b85-43c2-a54f-e2b40b4823b8.json

Now add a CNAME in the selected domain to CNAME: name: tunnel target: 62c0d82d-2b85-43c2-a54f-e2b40b4823b8.cfargotunnel.com

for example, if i have selected the agustfricke.com domain i will use the tunnel.agustfricke.com hostname

after that run

cloudflared tunnel --config cloudflare.yml run dev_n73

Done.