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 |
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 site URLs in the database, which can cause redirects (like after login) to redirect back to your local domain instead of staying on the tunnel URL.
When WordPress 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
ddev wp option update home 'https://random-name.trycloudflare.com'
ddev wp option update siteurl 'https://random-name.trycloudflare.com'
# Revert to local domain
ddev wp option update home 'https://yoursite.ddev.site'
ddev wp option update siteurl 'https://yoursite.ddev.site'
Note: The tunnel URL changes each time you run the command, so you’ll need to update the URLs for each session. Alternatively, consider using the Relative URL plugin for easier multi-domain support.
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