mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-06-03 20:12:58 +00:00
3.1 KiB
3.1 KiB
Cloudflare Tunnel Setup
This guide explains how to set up Cloudflare tunnel for Containr, allowing you to expose your services without configuring a domain.
Prerequisites
- A Cloudflare account
- A domain (any domain, even a free one)
Setup Steps
1. Create a Cloudflare Tunnel
- Log in to your Cloudflare Dashboard
- Go to Zero Trust → Networks → Tunnels
- Click Create tunnel
- Choose Cloudflared and click Next
- Give your tunnel a name (e.g., "containr-tunnel")
- Click Save tunnel
2. Get Your Tunnel Token
After creating the tunnel, Cloudflare will show you a command like:
cloudflared tunnel run <tunnel-id>
Copy the token from the .cloudflared/config.yml file or use the token provided by Cloudflare.
3. Configure Containr
-
Copy
.env.exampleto.envif you haven't already:cp .env.example .env -
Edit
.envand add your Cloudflare tunnel token:CLOUDFLARED_TOKEN=your_copied_tunnel_token_here
4. Start Services with Cloudflare Tunnel
# Start all services including cloudflared
make cloudflared-up
# Or start manually
docker-compose --profile cloudflared up -d
5. Configure Tunnel Routes
In your Cloudflare dashboard:
- Go to your tunnel settings
- Add the following public hostnames:
your-domain.com→http://traefik:80(for frontend)api.your-domain.com→http://traefik:80(for backend)traefik.your-domain.com→http://traefik:80(for dashboard)
6. Access Your Services
Once configured, you can access:
- Frontend:
https://your-domain.com - API:
https://api.your-domain.com - Traefik Dashboard:
https://traefik.your-domain.com
Management Commands
# Start with Cloudflare tunnel
make cloudflared-up
# Stop Cloudflare tunnel
make cloudflared-down
# View logs
docker-compose logs -f cloudflared
# Check status
docker-compose ps
Benefits
- No domain configuration required in
.env - Automatic SSL through Cloudflare
- DDoS protection and security features
- Easy setup - just need a tunnel token
- Works anywhere - no port forwarding needed
Troubleshooting
Tunnel Not Connecting
- Verify your
CLOUDFLARED_TOKENis correct - Check cloudflared logs:
docker-compose logs cloudflared - Ensure your tunnel is active in Cloudflare dashboard
Services Not Accessible
- Verify you've configured the public hostnames in Cloudflare
- Check that all services are running:
docker-compose ps - Ensure the tunnel routes point to
http://traefik:80
Token Issues
- Regenerate your tunnel token in Cloudflare dashboard
- Make sure there are no extra spaces or newlines in the token
Alternative: Domain Mode
If you prefer traditional domain setup instead of Cloudflare tunnel:
-
Configure your domain in
.env:DOMAIN=yourdomain.com ACME_EMAIL=admin@yourdomain.com -
Use regular commands:
make prod
This will use Let's Encrypt certificates instead of Cloudflare tunnel.