Sign inSign up

maximking19/wasicdn-core

By maximking19

•Updated over 4 years ago

Core Package šŸš€ Blazing Fast S3 Powered CDN ✨ Powered By Fastify, S3 Buckets & Docker! (W.I.P)

Image
1

1.4K

maximking19/wasicdn-core repository overview

ā šŸš€ WasiCDN Core Module (Not Production Ready)

Blazing Fast S3 Powered CDN, Powered By Fastify, S3 Compatible Buckets & Docker!

⁠Running the Core Server

⁠Docker Compose

Create a docker-compose.yml and .env file.

.env:

locations={ "GB": "https://cdn.gb.example.com", "US": "https://cdn.us.example.com", "SG": "https://cdn.sg.example.com", "GE": "https://cdn.ge.example.com", "TW": "https://cdn.tw.example.com" }

docker-compose.yml

version: "3.9"

services:
  core:
    image: maximking19/wasicdn-core
    build: .
    network_mode: host
    env_file: .env # Create a .env file and add Slave Locations.
    environment:
      - name=Core
      - mongodb="mongodb://" # Your MongoDB Connector For The User & Files Database
      - PORT=3001 # The Port For The CDN Service
      - adminPort=3010 # The Admin Port (For Backend Socket.io Use Only)
      - adminPassword="yg6g4byugeuybygbiygyugbyuftuftufvtufvtfytdfcytftufytfc"
      - files="local" # "s3" or "local", Where the CDN files are downloaded from. (Local = Pulls From The Core Server Uploads Folder, S3 = Pulls From The S3 Bucket)
      - defaultServer="DOMAIN_HERE" # The Fallback IP If There Isnt a Close Server
    # s3 Bucket Details (If using s3)
      - s3Provider="" # Amazon AWS S3 "aws", Google Cloud Storage "gcs", Microsoft Azure Blob Storage "azure", DigitalOcean Spaces "digitalocean", Wasabi Object Storage "wasabi" (Custom S3 Bucket use = "s3compatible")
    # - endpoint="" # If using "s3compatible", add endpoint here
    # - region="" # If using "aws" or "digitalocean"
      - accessKeyID=""
      - secretAccessKey=""
      - bucketName=""
    volumes:
      - /usr/lib/cdn-core/uploads:/usr/src/CDN/core/uploads # Where the uploads are stored (/host/path:/container/path)
    ports:
      - "3001:3001" # Change this to PORT Variable
      - "3010:3010" # Change this to adminPort Variable

Slave Service DockerHub: https://hub.docker.com/r/maximking19/wasicdn-slave⁠

⁠Features:

• Fastify Powered Backend
• Built in Load Balancer which directs the connection to the closest server to the user
• Each Slave CDN pulls files from your selected S3 Bucket or local system, each slave location has a copy and distributes them to users.
• Directs users to the closest server by checking the IP Location and sending them to the correct way

⁠CDN Replication

↓    (    Wasabi S3   )     ↓ --> Fetches files from the S3 Bucket
↓            |||            ↓
↓            |||            ↓
↓           /   \           ↓
↓         /       \         ↓
↓       /           \       ↓
↓[ UK Server ][ US Server ] ↓ --> Replicates the files from the S3 Bucket to each server (Replicates at every location) 
↓      \             /      ↓
↓       \           /       ↓
↓        \         /        ↓
———————————————————————————————

⁠How it works

↓     (    Request   )      ↓
↓           | b |           ↓
↓           | d |           ↓
↓   ---------------------   ↓
↓   |  Delivery System  |   ↓ --> Checks the request IP, and forwards there request to the closest server (Checks the IP's location to determine cloest server)
↓   ---------------------   ↓
↓            |||            ↓
↓   ---------------------   ↓
↓   |   Load Balancer   |   ↓ --> Redirects the request to the least stressed server in the location (UK1: 50%, UK2:25% - Would forward to UK2 as lowest System load)
↓   ---------------------   ↓ --> Load Balancer Not Realeased (W.I.P) 
↓            |||            ↓
↓   ---------------------   ↓
↓   |        CDN        |   ↓ --> Serves the requested file on the cloest server to them
↓   ---------------------   ↓
↓            |||            ↓
↓           /   \           ↓
↓         /       \         ↓
↓       /           \       ↓
↓ [  Data  ]     [ File ]   ↓ --> Dispatches both the Data and CDN File to the destination 
↓      \             /      ↓
↓       \           /       ↓
↓        \         /        ↓
↓    -------------------    ↓
↓        Destination        ↓ --> File received! :)
↓    -------------------    ↓

⁠Running the system

⁠Core Module
  1. docker pull maximking19/wasicdn-core
  2. docker run --expose 3001 maximking19/wasicdn-core
⁠Slave Module

Tag summary

Content type

Image

Digest

Size

411.7 MB

Last updated

over 4 years ago

docker pull maximking19/wasicdn-core