This Docker image provides a secure access gateway that integrates both Cloudflare Tunnels and Tailscale for flexible and secure access to your services. You can use either or both technologies simultaneously to create a secure, zero-trust access layer for your applications.
- Cloudflare Tunnel integration for secure public access
- Tailscale VPN integration for private network access
- Support for multiple port forwarding
- Docker-compose ready
- Easy configuration through environment variables
- Automatic service discovery and configuration
Before using this image, you'll need:
- A Cloudflare account (if using Cloudflare Tunnels)
- A Tailscale account (if using Tailscale)
- Docker and Docker Compose installed on your host
- Basic understanding of networking and Docker concepts
# Feature Flags
ENABLE_CLOUDFLARE=true|false
ENABLE_TAILSCALE=true|false
# Cloudflare Configuration
CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
# OR
CLOUDFLARE_TUNNEL_ID=your-tunnel-id
# Tailscale Configuration
TAILSCALE_AUTH_KEY=tskey-auth-xxxxx-xxxxxxxxxxxxx
TAILSCALE_HOSTNAME=your-preferred-hostname
TARGET_PORTS=3000,8080,9000 # Ports to forward via TailscaleTAILSCALE_ACCEPT_DNS=true|false
TAILSCALE_ACCEPT_ROUTES=true|false
TAILSCALE_ADVERTISE_EXIT_NODE=true|false
TAILSCALE_ADVERTISE_ROUTES=
TAILSCALE_SSH=true|falseThis example shows how to expose a simple web application through Cloudflare Tunnel.
services:
secure-proxy:
image: hhftechnology/cloudflare-tailscale-integration:latest
environment:
- ENABLE_CLOUDFLARE=true
- ENABLE_TAILSCALE=false
- CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
volumes:
- ./cloudflared:/etc/cloudflared
restart: unless-stopped
webapp:
image: nginx:alpine
expose:
- "80"This example demonstrates using Tailscale for private access to an internal dashboard.
version: '3'
services:
secure-proxy:
image: hhftechnology/cloudflare-tailscale-integration:latest
cap_add:
- NET_ADMIN
environment:
- ENABLE_CLOUDFLARE=false
- ENABLE_TAILSCALE=true
- TAILSCALE_AUTH_KEY=tskey-auth-xxxxx-xxxxxxxxxxxxx
- TAILSCALE_HOSTNAME=internal-dashboard
- TARGET_PORTS=3000
volumes:
- ./data/tailscale:/var/lib/tailscale
devices:
- /dev/net/tun:/dev/net/tun
dashboard:
image: grafana/grafana
expose:
- "3000"This example shows how to use both Cloudflare and Tailscale to provide different access methods for different components.
services:
secure-proxy:
image: hhftechnology/cloudflare-tailscale-integration:latest
cap_add:
- NET_ADMIN
environment:
- ENABLE_CLOUDFLARE=true
- ENABLE_TAILSCALE=true
- CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
- TAILSCALE_AUTH_KEY=tskey-auth-xxxxx-xxxxxxxxxxxxx
- TAILSCALE_HOSTNAME=admin-portal
- TARGET_PORTS=8080
volumes:
- ./data/tailscale:/var/lib/tailscale
- ./data/cloudflared:/etc/cloudflared
devices:
- /dev/net/tun:/dev/net/tun
website:
image: nginx:alpine
expose:
- "80" # Exposed via Cloudflare
admin:
image: adminer
expose:
- "8080" # Exposed via TailscaleThis example creates a development environment with multiple services accessible through Tailscale.
services:
secure-proxy:
image: hhftechnology/cloudflare-tailscale-integration:latest
cap_add:
- NET_ADMIN
environment:
- ENABLE_CLOUDFLARE=false
- ENABLE_TAILSCALE=true
- TAILSCALE_AUTH_KEY=tskey-auth-xxxxx-xxxxxxxxxxxxx
- TAILSCALE_HOSTNAME=dev-environment
- TARGET_PORTS=3000,8080,5432,6379
volumes:
- ./data/tailscale:/var/lib/tailscale
devices:
- /dev/net/tun:/dev/net/tun
frontend:
image: node:alpine
working_dir: /app
command: npm start
expose:
- "3000"
backend:
image: python:alpine
command: python manage.py runserver 0.0.0.0:8080
expose:
- "8080"
db:
image: postgres:alpine
expose:
- "5432"
redis:
image: redis:alpine
expose:
- "6379"This example demonstrates a hybrid cloud setup where some services are public and others are private.
services:
secure-proxy:
image: hhftechnology/cloudflare-tailscale-integration:latest
cap_add:
- NET_ADMIN
environment:
- ENABLE_CLOUDFLARE=true
- ENABLE_TAILSCALE=true
- CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
- TAILSCALE_AUTH_KEY=tskey-auth-xxxxx-xxxxxxxxxxxxx
- TAILSCALE_HOSTNAME=hybrid-app
- TARGET_PORTS=9000,5432
volumes:
- ./data/tailscale:/var/lib/tailscale
- ./data/cloudflared:/etc/cloudflared
devices:
- /dev/net/tun:/dev/net/tun
api:
image: node:alpine
expose:
- "80" # Public API via Cloudflare
management:
image: portainer/portainer-ce
expose:
- "9000" # Private management via Tailscale
database:
image: postgres:alpine
expose:
- "5432" # Private database access via TailscaleThis example shows a microservices architecture with different access patterns for different services.
version: '3'
services:
secure-proxy:
image: hhftechnology/cloudflare-tailscale-integration:latest
cap_add:
- NET_ADMIN
environment:
- ENABLE_CLOUDFLARE=true
- ENABLE_TAILSCALE=true
- CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
- TAILSCALE_AUTH_KEY=tskey-auth-xxxxx-xxxxxxxxxxxxx
- TAILSCALE_HOSTNAME=microservices
- TARGET_PORTS=8080,9090,3000,5432
volumes:
- ./data/tailscale:/var/lib/tailscale
- ./data/cloudflared:/etc/cloudflared
devices:
- /dev/net/tun:/dev/net/tun
gateway:
image: nginx:alpine
expose:
- "80" # Public API Gateway via Cloudflare
auth-service:
image: node:alpine
expose:
- "8080" # Private auth service via Tailscale
metrics:
image: prom/prometheus
expose:
- "9090" # Private metrics via Tailscale
admin-dashboard:
image: grafana/grafana
expose:
- "3000" # Private dashboard via Tailscale
database:
image: postgres:alpine
expose:
- "5432" # Private database via TailscaleWhen using both Cloudflare Tunnels and Tailscale, the secure-proxy container acts as a gateway:
- Cloudflare Tunnel provides secure public access to services marked for public exposure
- Tailscale provides private, encrypted access to services marked for internal use
- The proxy automatically handles routing and network isolation
- Always use strong authentication keys and tokens
- Regularly rotate your Cloudflare and Tailscale credentials
- Monitor access logs and usage patterns
- Keep the Docker image and all services updated
- Follow the principle of least privilege when exposing services
- Connection Issues:
# Check Tailscale status
docker exec secure-proxy tailscale status
# Check Cloudflare tunnel status
docker exec secure-proxy cloudflared tunnel info
# View logs
docker logs secure-proxy- Port Forwarding Issues:
# Check iptables rules
docker exec secure-proxy iptables -t nat -L PREROUTING
# Verify network interfaces
docker exec secure-proxy ip addr showFor issues, feature requests, or contributions, please visit our GitHub repository: https://github.com/hhftechnology/cloudflare-tailscale-integration
MIT License - See LICENSE file for details