-
-
Notifications
You must be signed in to change notification settings - Fork 46
Home
DockFlare automates Cloudflare Tunnel ingress rule management based on Docker container labels, simplifying public exposure of your Dockerized applications. It eliminates manual Cloudflare configuration, acting as a self-hosted ingress controller.
(Note: Ensure the image path is correct or upload the image directly to the wiki)
- Automated Cloudflare Tunnel Management: Creates/uses a specified tunnel, retrieves Tunnel ID & Token.
-
cloudflared
Agent Lifecycle: Deploys & manages thecloudflared
container (using Tunnel Token). -
Dynamic Ingress via Docker Labels:
- Monitors Docker events for containers with labels (prefix:
cloudflare.tunnel.
):enable="true"
,hostname="subdomain.example.com"
,service="http://target:port"
. - Automatically updates Cloudflare Tunnel configuration to match running, labeled containers.
- Monitors Docker events for containers with labels (prefix:
- Multi-Domain Support: Configure multiple domains for a single container using indexed labels, each with its own service target and zone configuration.
- Graceful Deletion: Configurable grace period before removing ingress rules when a container stops.
-
State Persistence: Saves
managed_rules
tostate.json
for restarts. -
Optimized Reconciliation:
- On startup, ensures consistency between Docker containers, saved state, and Cloudflare configuration
- Processes DNS operations in small batches to prevent API rate limiting
- Shows real-time reconciliation progress in the UI
-
Web UI: Status dashboard with:
- Tunnel & agent status.
- Start/Stop agent controls.
- Managed ingress rule list with status, container ID, deletion time, and "Force Delete" option.
- Real-time Log Streaming: View logs in real-time using Server-Sent Events (SSE).
- Content Security Policy (CSP): Ensures secure loading of resources and compatibility with reverse proxies.
This Wiki provides detailed information on getting started, configuration options, usage patterns, and troubleshooting.
- New users: Start with Getting Started.
- Understand the basics: See Core Concepts.
- Configure DockFlare: Check out Configuration.
- Learn how to use labels: Visit the Usage Guide.
---
**3. Create file `Prerequisites.md`**
```markdown
# Prerequisites
Before you begin setting up DockFlare, ensure you have the following prerequisites installed and configured:
* **Docker:** DockFlare runs as a Docker container and interacts with the Docker daemon.
* [Install Docker Engine](https://docs.docker.com/engine/install/)
* **Docker Compose (Recommended):** Simplifies the deployment and management of DockFlare and its potential dependencies.
* [Install Docker Compose](https://docs.docker.com/compose/install/)
* **Cloudflare Account:** You need an active Cloudflare account.
* **Cloudflare API Token:** DockFlare requires an API token to interact with your Cloudflare account.
* **Permissions Required:** The token needs the following permissions:
* `Zone:DNS:Edit`: To create and manage DNS records for your hostnames.
* `Account:Cloudflare Tunnel:Edit`: To create, manage, and configure Cloudflare Tunnels.
* [How to Create a Cloudflare API Token](https://developers.cloudflare.com/api/tokens/create/)
* **Cloudflare Account ID:** Needed to identify your Cloudflare account.
* **How to find it:** Log in to your [Cloudflare Dashboard](https://dash.cloudflare.com), select any domain, and find the **Account ID** listed in the **Overview** section on the right sidebar.
* **Cloudflare Zone ID:** Needed to identify the default domain (zone) you want DockFlare to manage DNS records in. You can override this per-container using labels.
* **How to find it:** Log in to your [Cloudflare Dashboard](https://dash.cloudflare.com), select the specific domain (zone) you want to use, and find the **Zone ID** listed in the **Overview** section on the right sidebar.
4. Create file Quick-Start-Docker-Compose.md
# Quick Start (Using Docker Compose)
This guide provides the quickest way to get DockFlare running using Docker Compose.
### 1. Create `docker-compose.yml`
Create a file named `docker-compose.yml` with the following content. This defines the DockFlare service, its network, and a volume for persistent state.
```yaml
version: '3.8'
services:
dockflare:
image: alplat/dockflare:stable # Use the desired image tag
container_name: dockflare
restart: unless-stopped
ports:
- "5000:5000" # Exposes the Web UI on port 5000
env_file:
- .env # Loads configuration from the .env file
volumes:
# Required to monitor Docker container events
- /var/run/docker.sock:/var/run/docker.sock:ro
# Persistent storage for state.json (managed rules, deletion timers)
- dockflare_data:/app/data
networks:
# Network for communication with the managed cloudflared agent
- cloudflare-net
volumes:
# Define the persistent volume
dockflare_data:
networks:
# Define the network used by DockFlare and its managed agent
cloudflare-net:
Create a file named .env
in the same directory as your docker-compose.yml
. This file stores your sensitive credentials and configuration settings. Replace the placeholder values with your actual Cloudflare details.
# Required Cloudflare credentials
CF_API_TOKEN=your_cloudflare_api_token_here
CF_ACCOUNT_ID=your_cloudflare_account_id_here
CF_ZONE_ID=your_cloudflare_zone_id_here
# Tunnel configuration (Required unless using External Mode)
TUNNEL_NAME=my-dockflare-tunnel # Choose a unique name for the tunnel DockFlare will manage
# Optional: Grace period before deleting rules for stopped containers (Default: 28800 seconds = 8 hours)
# GRACE_PERIOD_SECONDS=28800
# Optional: Prefix for Docker labels (Default: cloudflare.tunnel)
# LABEL_PREFIX=cloudflare.tunnel
# --- Do not uncomment these unless you understand External Mode ---
# Optional: External cloudflared mode (See Advanced Topics)
# USE_EXTERNAL_CLOUDFLARED=true
# EXTERNAL_TUNNEL_ID=your_existing_tunnel_id_if_using_external_mode
Important: Ensure the .env
file is protected and not committed to public repositories.
Navigate to the directory containing your docker-compose.yml
and .env
files in your terminal and run:
docker compose up -d
This command will:
- Pull the
alplat/dockflare:stable
image (if not already present). - Create the
cloudflare-net
network. - Create the
dockflare_data
volume. - Start the
dockflare
container in detached mode (-d
).
DockFlare will now start, connect to Cloudflare, create/verify the specified tunnel (TUNNEL_NAME
), start the associated cloudflared
agent container, and begin listening for Docker events.
- Access the Web UI to monitor DockFlare's status.
- Learn how to Label Your Containers to expose them through the tunnel.
- Home
- Getting Started
- Core Concepts
- Configuration
- Usage Guide
- Advanced Topics
- Troubleshooting
- Contributing
- License