Expose your local services to the internet using your domain names via Cloudflare's tunneling technology. With cfex, you can create instant HTTPS endpoints for any local service without port forwarding or static IPs.
cfex (Cloudflare Exposer CLI) simplifies creating secure tunnels between your local development environment and the internet. It leverages Cloudflare’s tunnel technology to:
- Expose local services via HTTPS endpoints.
- Use custom domain names for development and testing.
- Access your services behind firewalls or NAT.
- Test webhooks and APIs locally without additional setup.
When developing web applications, cfex is useful for:
- Sharing local development servers: Share your work with clients or team members.
- Webhook testing: Test external integrations directly from your local environment.
- Accessing local services on mobile: Use your app on other devices.
- Demoing features: Quickly share links for feedback without deploying.
With cfex, you can:
# Share your React app
cfex dev.yourdomain.com:3000 # https://dev.yourdomain.com
# Expose your API
cfex api.yourdomain.com:8080 # https://api.yourdomain.com
# Test webhooks
cfex webhook.yourdomain.com:4000 # https://webhook.yourdomain.com- Cloudflare Account with Registered Domain: Sign up for free.
- cloudflared Installed: Install cloudflared.
- jq Installed:
- macOS:
brew install jq - Ubuntu/Debian:
sudo apt install jq
- macOS:
- Cloudflare API Token: Create API Token with:
- Permissions:
Zone-DNS EditandZone-Read - Zone: Include the domain you want to use.
- Permissions:
# Install cfex
curl -sSL https://raw.githubusercontent.com/muthuishere/cfex-cli/main/install.sh | bashcloudflared tunnel loginThis command:
- Opens Cloudflare's login page.
- Creates a certificate at
~/.cloudflared/cert.pem.
export CLOUDFLARE_API_KEY='your-api-token'For persistence:
echo 'export CLOUDFLARE_API_KEY="your-api-token"' >> ~/.bashrc # or ~/.zshrc
source ~/.bashrc # or ~/.zshrc# React/Vue/Angular dev server
cfex dev.yourdomain.com:3000
# Local API server
cfex api.yourdomain.com:8080
# Webhook testing
cfex webhook.yourdomain.com:4000# List tunnels
cfex list
# Delete tunnel(s)
cfex delete domain.com
# Show help
cfex --help-
Installation Issues:
- Verify
cloudflaredandjqare installed. - Check permissions for installation directories.
- Verify
-
Authentication Issues:
- Ensure the API token is set and valid.
- Re-run
cloudflared tunnel loginif needed.
-
DNS Issues:
- Allow time for DNS propagation.
- Verify domain ownership and permissions.
-
Connection Issues:
- Ensure the service is running on the specified port.
- Check for port conflicts or firewall settings.
- Linux
- macOS
- Windows (via WSL):
- Install WSL:
wsl --installin PowerShell (Admin). - Restart your computer.
- Follow Linux setup instructions.
- Install WSL:
- ngrok: Subscription required for custom domains.
- LocalTunnel: Free, but lacks features like DNS management.
- cloudflared: The native client that cfex simplifies.
cfex provides a streamlined solution for exposing your local services using Cloudflare, making it ideal for developers working with custom domains and secure tunnels.