Skip to Content
OpenFlare
GuidesDeploymentReferenceArchitectureChangelog

Product Boundaries & Repository Structure

OpenFlare is a distributed reverse proxy, edge security gateway, and intelligent authoritative DNS platform designed for multi-server clusters and single-team operations.

Project Positioning

OpenFlare targets teams operating clusters of OpenFlare Edge proxy nodes and OpenFlare DNS servers that want a self-hosted edge network or an origin shield in front of upstream services:

  • Control and data separation: The Server control plane never SSHs into nodes; edge and DNS nodes pull versioned snapshots via heartbeats and WebSockets.
  • Zero-reload dynamic sync: openflare-edge swaps validated in-memory snapshots atomically without process reloads or dropped connections.
  • Unified security and steering: One control plane coordinates reverse proxying, quality-aware SmartDNS, multi-provider DNS accounts, automated TLS certificates, WAF rules, client PoW challenges, intranet tunnels, and Pages static hosting.
  • Dual deployment modes: Runs as a standalone private edge CDN or behind Cloudflare as an Origin Shield.

Out of scope: Multi-tenant public clouds, Kubernetes Ingress Controllers, service meshes, or general-purpose log aggregation platforms.

Current Capabilities

CapabilitySummaryDesign & Guide
Reverse proxy routingProxy routes (of_proxy_routes) aggregate domains, upstreams, rate limits, and cachingConfigure a reverse proxy
Origin error pagesServes built-in or custom HTML on configured error status codes while preserving the HTTP statusOrigin Error Page Design
Edge cacheNode-local TinyUFO memory/disk cache gated by static extensions and origin response headersEdge Cache Strategy Design
Zones & domainsRegistrable root domains group explicit and wildcard hostnames with route and cert bindingsZone & Domain Resource Design
Multi-provider DNS & SmartDNSManages Cloudflare, Alibaba Cloud DNS, and Tencent Cloud DNSPod accounts, failover groups, and standalone openflare-dns serversMulti-Provider DNS Pointing & Failover Design / SmartDNS System Architecture Design
Network intelligence & qualityCombines multi-source GeoIP/ASN/BGP intelligence, passive TCP_INFO, isolated probes, an adaptive matrix, and a five-tier predictorNetwork Intelligence and Link Quality Architecture
Edge config syncCompiles versioned snapshots on save; nodes validate and swap atomically while keeping the last healthy snapshotOpenFlare Edge Architecture Design
WAF & PoW protectionVisual DAG rules, OWASP CRS inspection, manual/auto/subscription IP groups, GeoIP matching, and browser PoWWAF Orchestration Rule Design / PoW Protection Design
Intranet tunnelsNative Rust relay (openflare-relay) and connector (openflared) with zone-diverse HA and L4/L7 forwardingTunnel & Intranet Penetration Design
Pages static hostingImports prebuilt archives via uploads, Remote URLs, or GitHub Releases and serves them from edge nodesPages Static Hosting Design
Observability & log storageTreats access logs as the single traffic truth and routes telemetry through logstore (PostgreSQL / SQLite / ClickHouse)Edge Observability and Traffic Analytics Architecture / Log Store Decoupling
Runtime i18nConsole supports zh-CN / en / ru (NEXT_LOCALE precedence); operational logs stay in EnglishRuntime Language and Internationalization

Core Product Boundaries & Constraints

Contributors must adhere to these architectural boundaries:

1. Site Routing & Upstream Constraints

  • Single-site policy sharing: One route binds multiple hostnames that share upstream, rate-limit, and cache policies; per-hostname overrides within one route are not supported.
  • Mutually exclusive upstreams: A route targets exactly one upstream mode: direct, tunnel, or pages.
  • Direct upstream restrictions: Direct upstreams accept only http:// or https:// targets; multi-origin entries allow plain scheme://host[:port] values without paths.

2. WAF Security Boundaries

  • Allowlist precedence: Global request allowlists bypass WAF DAG evaluation and body inspection; remaining requests run global rules before ordered route-bound rules.
  • Weak GeoIP dependency: Geographic nodes read local MaxMind MMDB files and evaluate as non-matching if missing or unreadable without interrupting IP filtering or proxying.
  • Control DB decoupling: Edge nodes evaluate compiled in-memory snapshots and never query the control-plane database; IP groups refresh independently by checksum.

3. Tunnel Boundaries

  • Dual L4 & L7 protocols: L7 HTTP/WebSocket traffic routes from OpenFlare Edge to Relay Gateways; L4 TCP/UDP ports listen directly on relays and forward over embedded rathole tunnels.
  • Domain and auth isolation: Relay pools, relays, tunnels, connectors, and L4 services reside under /tunnels, authenticate via oftok1_ bootstrap tokens, X-Relay-Token, and X-Tunnel-Token, and release on tunnel-v*.
  • Origin SSRF guard: openflared validates resolved target IPs against allow/block CIDRs before connecting (blocking 169.254.169.254/32 by default).

4. Pages Static Hosting Boundaries

  • Prebuilt artifact ingestion: Accepts manual uploads or a Remote URL / public GitHub Release source. Editing or removing a source leaves immutable deployments and active releases intact.
  • Archive & size limits: Supports zip, tar.gz/tgz, tar.xz/txz, tar.bz2/tbz2, tar, and 7z. Archive size is capped by pages_max_package_size_mb (default 100 MiB, range 1–2048); extracted file/total limits are 4x the archive limit (minimum 100 MiB) across up to 1,000 regular files.
  • No remote source builds: OpenFlare does not clone Git repositories or run build commands; edge nodes consume validated artifacts only.

5. System & Infrastructure Boundaries

  • Shared site snapshot: All edge nodes synchronize the same site snapshot and operate under their assigned performance policy.
  • Single-tenant model: Built for single-team operations without multi-tenant resource isolation or RBAC roles.
  • External dependencies: Server requires Redis (or Valkey) for Asynq queues and cache invalidation; primary storage uses PostgreSQL (or SQLite when database.enabled=false); ClickHouse is optional (see Log Store Decoupling).

Repository Structure

OpenFlare uses a single monorepo (Go control-plane module github.com/Rain-kl/OpenFlare at the repository root, with standalone runtime components consolidated under components/):

PathResponsibility
cmd/server/, cmd/openflare/Control-plane Server entrypoint (main.go + cli/) and openflare operations CLI
components/edge/Rust OpenFlare Edge gateway source and smoke tests
components/compute/Rust OpenFlare Compute runtime and embedded deployment agent
components/dns/Rust OpenFlare DNS authoritative server source
components/tunnel/Rust native tunnel workspace (common/, relay/, flared/)
components/shared/Shared component crates (compute-call/, probe/, rathole-client/) and static templates (edgeassets/)
internal/Control-plane business domains, repositories, and shared wire packages
frontend/Next.js admin console embedded into the Go Server binary
pkg/Cross-cutting libraries (cache/, cap/, geoip/, httppool/, i18n/, logger/, mail/, netintel/, push/, trace/, util/)
scripts/Public host install, update, uninstall, and database fetch scripts
tools/Swagger generation, linting, and internal packaging tools
docs/Fumadocs documentation site and design specs
docker/Component Dockerfiles and container entrypoints
tests/integration/Cross-module integration tests

Server Control Plane Layering (cmd/server/ + internal/)

DirectoryResponsibility
internal/platform/Cross-module wiring and lifecycle (bootstrap/, buildinfo/, lifecycle/)
internal/router/HTTP routes and middleware (v1/openflare_*.go)
internal/apps/openflare/OpenFlare domains (agent/, cloudflare/, dnsaccount/, netintel/, netquality/, node/, observability/, pages/, pow/, proxy_route/, smartdns/, tunnel/, waf/, zone/, etc.)
internal/openflare/Shared OpenFlare packages: dnsprovider/, edgeconfig/, pagesarchive/, protocol/, routeidentity/
internal/model/GORM entities, config key constants, and pure no-IO rules
internal/infra/persistence/migrator/goose/Goose SQL migrations for PostgreSQL, SQLite, and ClickHouse
internal/repository/Exclusive persistence boundary (CRUD, cache, and logstore backends)
internal/infra/task/, internal/infra/config/Asynq task definitions and Viper config loader
internal/shared/API response envelopes (response/) and HTTP binding helpers (httpx/)

API Route Prefixes:

PrefixPurposeAuthentication
/api/v1/d/*OpenFlare console APIsSession Cookie + optional X-Access-Token
/api/v1/agent/*OpenFlare Edge protocolX-Agent-Token
/api/v1/dns-agent/*OpenFlare DNS protocolX-DNS-Discovery-Token / X-DNS-Token
/api/v1/relay/*Relay protocolX-Relay-Bootstrap-Token / X-Relay-Token
/api/v1/tunnel/*OpenFlared connector protocolX-Tunnel-Token
/api/v1/admin/*Platform admin APIsAdmin Session

On this page