- Login to your Cloudflare account at https://dash.cloudflare.com/login
- Click on the domain name you wish to add the tunnel to.
- Click on the "Cloudflare Workers" tab at the top of the screen.
- Click on the "Create a Worker" button.
- Give your worker a name, for example "tunnel.yourdomain.com".
- Paste the following code into the code editor:
const tunnel = new Tunnel()
addEventListener('fetch', event => {
event.respondWith(tunnel.handleRequest(event.request))
})
- Save the worker.
- Click on the "Tunnels" tab at the top of the screen.
- Click on the "Get started" button.
- Click on the "Add a domain" button.
- Enter the domain name you want to use with the tunnel, for example "tunnel.yourdomain.com".
- Click on the "Create demo certificate" button.
- Wait for the certificate to be created.
- Click on the "Install" button next to your domain name.
- Add a CNAME record to your DNS configuration pointing to the provided domain name.
- Wait for the DNS record to propagate.
- Click on the "Verify" button to check if your domain is configured correctly.
- Your domain is now ready to use with Cloudflare Tunnels!