Share your DDEV sites publicly using Cloudflare Tunnel (free alternative to ddev share)
](https://github.com/ddev/ddev-addon-registry)
This DDEV addon provides a simple command to share your local DDEV sites publicly using Cloudflare Tunnel. It works similarly to ddev share (which uses ngrok) but with Cloudflare’s free tunnel service.
ddev share-cf and get a public URLcloudflared binary installed on your host machineImportant for Windows users: This addon requires WSL2. You must install and run DDEV in WSL2, not natively on Windows. See the WSL2 section below for details.
First, install cloudflared on your host machine:
macOS (Homebrew):
brew install cloudflared
Debian/Ubuntu:
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb
RHEL/CentOS/Fedora:
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.rpm -o cloudflared.rpm
sudo rpm -i cloudflared.rpm
Windows with WSL2:
Important: This addon requires WSL2. WSL2 is your “host” environment where both DDEV and cloudflared must be installed.
If you’re using DDEV with WSL2 (the recommended approach for Windows), follow the Linux instructions above inside your WSL2 terminal. For example, if using Ubuntu in WSL2:
# Run this inside your WSL2 terminal (not PowerShell or CMD)
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb
Do NOT install cloudflared on Windows itself - it needs to be installed in WSL2 where DDEV runs.
For other installation methods, see the Cloudflare documentation.
ddev add-on get davo20019/ddev-share-cf
From your DDEV project directory, simply run:
ddev share-cf
This will:
cloudflared is installed (shows installation instructions if not)https://randomly-generated.trycloudflare.com)Press Ctrl+C to stop the tunnel when you’re done.
When you run ddev share-cf, the addon:
cloudflared is installed on your host machineThe tunnel URL changes each time you run the command (similar to ddev share).
ddev share| Feature | ddev share (ngrok) |
ddev share-cf (Cloudflare) |
|---|---|---|
| Free tier | 40 connections/min | Unlimited |
| Speed | Good | Excellent (Cloudflare CDN) |
| Account required | Yes | No |
| Setup | Configure token | Zero config |
| URL persistence | Changes each time | Changes each time (or stable with named tunnels) |
By default, ddev share-cf creates a temporary quick tunnel with a random URL that changes each time. If you need a stable, persistent URL on your own domain, you can use named tunnels.
cloudflared tunnel login command asks you to select a zone (domain) from your account. If you don’t have any domains in Cloudflare, you won’t be able to complete the authentication step and cannot use named tunnels. You can add a domain to Cloudflare for free.Don’t have a domain in Cloudflare? No problem — quick tunnels (
ddev share-cfwith no flags) work without any account or domain. Named tunnels are only needed if you want a stable URL on your own domain.
ddev share-cf --login
This opens your browser to authorize cloudflared with your Cloudflare account. A certificate is saved to ~/.cloudflared/cert.pem.
ddev share-cf --create-tunnel my-project --hostname dev.example.com
This creates a named tunnel and adds a CNAME record on your Cloudflare domain pointing to the tunnel. DNS propagation may take a few minutes.
You can also create the tunnel without a hostname and add DNS later:
ddev share-cf --create-tunnel my-project
Once set up, start the tunnel with:
ddev share-cf --tunnel my-project
Your site will be available at https://dev.example.com (or whatever hostname you configured) every time.
To delete a named tunnel:
ddev share-cf --delete-tunnel my-project
Note: This deletes the tunnel from Cloudflare but does not remove the DNS record. You can remove CNAME records from the Cloudflare dashboard.
| Quick tunnel | Named tunnel | |
|---|---|---|
| URL | Random *.trycloudflare.com |
Your own domain |
| Persistence | Changes each time | Stable across sessions |
| Account | Not required | Cloudflare account + domain |
| Setup | None | One-time login + create |
| Best for | Quick demos, testing | Webhooks, client previews, CI |
Perfect for:
If you’re using Windows with WSL2 and getting a “cloudflared not found” error:
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb
ddev and ddev share-cf must be run from your WSL2 terminalCommon mistake: Installing cloudflared on Windows (via winget or PowerShell) instead of in WSL2. Remember: WSL2 is your “host” environment, not Windows.
If you get an error that cloudflared is not installed, the command will automatically detect your operating system and show you the appropriate installation instructions.
You can also manually install cloudflared by following the instructions in the Installation section above.
Make sure the addon is properly installed:
ddev add-on get davo20019/ddev-share-cf
The script should be executable, but if you encounter issues:
chmod +x .ddev/commands/host/share-cf
Make sure your DDEV project is running before starting the tunnel:
ddev start
ddev share-cf
The addon automatically detects Drupal multisite setups by checking for sites/sites.php. When detected, it adjusts the tunnel configuration to properly support multisite routing.
To use with Drupal multisite:
ddev share-cf - it will detect multisite and display: ℹ️ Drupal multisite detectedhttps://random-name.trycloudflare.com)web/sites/sites.php:<?php
// Map the Cloudflare tunnel URL to your subsite
$sites['random-name.trycloudflare.com'] = 'stage'; // Replace 'stage' with your subsite directory name
Note: The tunnel URL changes each time you run the command, so you’ll need to update sites.php with the new URL for each session.
The addon automatically detects WordPress installations. WordPress stores absolute URLs throughout the database (options, post content, meta fields, serialized data, etc.), which causes redirects, broken media, and broken links when accessing the site through a tunnel URL.
When WordPress is detected, the addon will display instructions. To fix this, use wp search-replace to replace URLs across all tables (including serialized data):
ddev share-cf and note the generated URL (e.g., https://random-name.trycloudflare.com)# Replace local URL with tunnel URL (handles serialized data correctly)
ddev wp search-replace 'https://yoursite.ddev.site' 'https://random-name.trycloudflare.com' --all-tables
# Revert to local domain
ddev wp search-replace 'https://random-name.trycloudflare.com' 'https://yoursite.ddev.site' --all-tables
Note: The tunnel URL changes each time you run the command, so you’ll need to repeat this for each session.
The addon automatically detects Magento installations. Like WordPress, Magento stores base URLs in the database (core_config_data table), which causes redirects (like admin login) to redirect back to your local domain.
When Magento is detected, the addon will display instructions. To fix redirects:
ddev share-cf and note the generated URL (e.g., https://random-name.trycloudflare.com)# Update to tunnel URL (include trailing slash)
ddev exec bin/magento config:set web/unsecure/base_url 'https://random-name.trycloudflare.com/'
ddev exec bin/magento config:set web/secure/base_url 'https://random-name.trycloudflare.com/'
ddev exec bin/magento cache:flush
# Revert to local domain
ddev exec bin/magento config:set web/unsecure/base_url 'https://yoursite.ddev.site/'
ddev exec bin/magento config:set web/secure/base_url 'https://yoursite.ddev.site/'
ddev exec bin/magento cache:flush
Note: The tunnel URL changes each time you run the command, so you’ll need to update the base URLs for each session.
Contributions, issues, and feature requests are welcome!
Apache License 2.0 - see LICENSE file for details.
David Loor
ddev share command