A modern, distributed CDN solution for file storage and delivery.
Optimized for speed, security, and scalability, Distriby seamlessly handles global file distribution with built-in auto-optimization and multi-node synchronization.
- Features
- Getting Started
- API Endpoints
- How It Works
- Architecture Diagram
- Contributing
- License
- Documentation
- 🚀 Global File Distribution: Serve files from the node closest to the user, reducing latency with DNS Anycast (Cloudflare or internal management).
- 🛡️ Security at Its Core:
- Protection against DDoS and unauthorized file access.
- Configurable support for Cloudflare with dynamic activation.
- ⚡ File Auto-Optimization:
- Compression for assets (Brotli, Gzip).
- Image conversion to WebP.
- Optional video/audio transcoding with FFmpeg.
- 🔄 Multi-Node Synchronization:
- Sub-nodes automatically replicate optimized files from the primary node using gRPC.
- Configurable node health monitoring and synchronization.
- 📡 REST API: Upload, delete, retrieve, and monitor files seamlessly.
- 📈 Monitoring: View the status of all nodes, including disk usage, uptime, and traffic.
- 🌐 DNS Anycast: Seamless routing to the closest node, with or without Cloudflare.
- Go (v1.23+)
- FFmpeg (for video/audio transcoding)
- cwebp (for image optimization)
- gzip (for text compression)
- Cloudflare account (optional, for DNS Anycast)
git clone https://github.com/YuketsuSh/distriby.git
cd distribyMake sure Go is installed, then build the project:
go build -o distribyCreate a .env file based on the provided .env.example:
cp .env.example .envSet the following variables:
NODE_ENV=development
PORT=8080
GRPC_PORT=9090
USE_CLOUDFLARE=false
AUTH_SECRET=my_secure_token
DEBUG_MODE=true
NODE_TYPE=primary # "primary" for main node or "secondary" for sub-node
SYNC_ENABLED=true # Enable/disable synchronization for subnodes./distribyDetails about the API, including usage and examples, have been moved to the DOCUMENTATION.md.
-
Primary Node:
- Centralized control for managing files.
- Handles file uploads, deletions, and retrievals.
- Optimizes files automatically before synchronization.
- Monitors and synchronizes active secondary nodes.
-
Secondary Nodes:
- Receive optimized files via gRPC from the primary node.
- Serve files directly to clients based on their proximity.
-
File Optimization:
- Images are converted to WebP using
cwebp - Text file are compressed using
gzip - Videos are transcoded using FFmpeg (H.264/AAC)
- Audio files are transcoded to MP3 format
- Images are converted to WebP using
-
DNS Anycast:
- If Cloudflare is enabled, traffic is routed to the nearest node.
- If Cloudflare is disabled, Distriby uses internal routing based on IP geolocation.
-
Monitoring:
- The primary node tracks the health and status of all sub-nodes.
-
Configuration Persistence:
- The primary node maintains node configurations in a
nodes_config.jsonfile. - This file is created automatically if it doesn't exist.
- The primary node maintains node configurations in a
+---------------------+
| Client/User |
+---------------------+
|
v
+---------------------+
| Cloudflare DNS |
+---------------------+
|
v
+-------------------------------+
| Distriby Primary Node |
| - API for file management |
| - File optimization (Brotli) |
| - Compression (WebP) |
+-------------------------------+
|
v
+-------------------------------+
| Distriby Sub-Nodes (Region X) |
| - File syncing with Rclone |
| - Local file serving |
+-------------------------------+
Although Distriby is a private project for Velyorix, internal contributions are welcome. If you are part of the team and want to improve Distriby:
- Fork the repository.
- Create a new branch (
git checkout -b feature-name). - Commit your changes (
git commit -m "Add new feature"). - Push to your branch (
git push origin feature-name). - Open a Pull Request.
Distriby is a private project for Velyorix. Redistribution is restricted unless authorized.
Full documentation for Distriby, including API details and advanced configurations, can be found in the DOCUMENTATION.md.