Custom Share Providers¶
You can customize the built-in providers or create your own share providers in .ddev/share-providers/.
Customizing Built-in Providers¶
Take Ownership of a Built-in Provider¶
- Edit the provider script (e.g.,
.ddev/share-providers/ngrok.sh) - Remove the
#ddev-generatedline at the top - Make your changes
- DDEV will never overwrite this file again
Create a Custom Variant¶
# Copy built-in provider
cp .ddev/share-providers/ngrok.sh .ddev/share-providers/my-ngrok.sh
# Edit my-ngrok.sh:
# - Remove '#ddev-generated' line
# - Customize as needed
# Use your variant
ddev share --provider=my-ngrok
Creating a New Provider¶
Create a new executable script in .ddev/share-providers/:
#!/usr/bin/env bash
set -euo pipefail
# Start your tunnel tool
mytunnel http "$DDEV_LOCAL_URL" &
TUNNEL_PID=$!
trap "kill $TUNNEL_PID 2>/dev/null || true" EXIT
# Capture public URL (however your tool exposes it)
URL=$(get-tunnel-url)
# Output URL to stdout (CRITICAL: first line only)
echo "$URL"
# Wait for tunnel to exit
wait $TUNNEL_PID
Provider Script Contract¶
Every share provider must follow this contract:
Input (Environment Variables)¶
| Variable | Description |
|---|---|
DDEV_LOCAL_URL | Local URL to tunnel (e.g., http://127.0.0.1:8080) |
DDEV_SHARE_ARGS | Provider-specific arguments (optional) |
All standard DDEV environment variables are also available.
Output¶
stdout: Public URL (first line only - captured by DDEV)stderr: Logs, status messages (passed through to user)
Lifecycle¶
- Validate tool is installed
- Validate required environment variables
- Start tunnel process in background
- Capture public URL (via API, stdout, file, etc.)
- Output URL to stdout
- Wait for tunnel process to exit
Signal Handling¶
Providers must handle SIGINT (Ctrl+C) and SIGTERM gracefully. Use trap to cleanup background processes:
Hooks Integration¶
After the tunnel URL is captured, DDEV sets the DDEV_SHARE_URL environment variable and runs pre-share hooks. This allows you to alter projects as needed (like WordPress ddev wp search-replace, for example).
Example .ddev/config.share.yaml:
hooks:
pre-share:
- exec: |
echo "Tunnel URL: ${DDEV_SHARE_URL}"
wp search-replace ${DDEV_PRIMARY_URL} ${DDEV_SHARE_URL}
Troubleshooting Custom Providers¶
Provider not found:
Check that .ddev/share-providers/foo.sh exists and is executable:
Provider outputs no URL:
Common causes: tool not installed, authentication required, no internet. Debug by running the provider directly: