zunohan/zunik

By zunohan

•Updated about 1 month ago

⚔ High-performance reverse proxy with Auto-SSL, HTTP/2, and 6 LB algorithms. Built with Rust.

Image
Networking
Developer tools
Operating systems
0

10K+

zunohan/zunik repository overview

⁠Zunik - High-Performance Reverse Proxy

Zunik⁠ is a lightweight, high-performance reverse proxy & load balancer written in Rust. Drop-in replacement for nginx/traefik with Auto-SSL and zero downtime reload.

Key Features:

  • HTTP/1.1 + HTTP/2 auto-detection
  • Auto-SSL via Let's Encrypt (ACME protocol)
  • 6 Load Balancing algorithms (Round Robin, Weighted, Random, IP Hash, Least Connections, Least Response Time)
  • Zero-downtime config reload (lock-free atomic swap)
  • Health Checks (TCP/HTTP with configurable thresholds)
  • Middleware pipeline (CORS, Headers, Auth, Compression, Rate Limit, Path Rewrite)
  • Admin Dashboard with REST API
  • Multi-file config support (include + --config-dir)
  • Smart config auto-detect (config.toml → config/ dir → crash)
  • ~5MB memory, ~15MB Docker image

⁠Quick Start

Create config.toml:

[server]
http_listen = "0.0.0.0:80"

[dashboard]
enabled = true
listen = "0.0.0.0:8080"

[routes.app]
enabled = true

[routes.app.match_rule]
path_prefix = "/"

[[routes.app.backends]]
url = "http://your-backend:3000"

Run with Docker:

Single config file:

docker run -d --name zunik \
  -p 80:80 -p 8080:8080 \
  -v $(pwd)/config.toml:/app/config.toml:ro \
  zunohan/zunik:latest

Config directory:

docker run -d --name zunik \
  -p 80:80 -p 8080:8080 \
  -v $(pwd)/config/:/app/config/:ro \
  zunohan/zunik:latest

šŸ’” Smart config: Zunik auto-detects config.toml or config/ dir. No flags needed.

Access the Dashboard at http://localhost:8080

⁠Auto-SSL (Let's Encrypt)

[server]
http_listen = "0.0.0.0:80"
https_listen = "0.0.0.0:443"

[server.auto_ssl]
domains = ["example.com"]
email = "[email protected]"
docker run -d --name zunik \
  -p 80:80 -p 443:443 \
  -v $(pwd)/config.toml:/app/config.toml:ro \
  -v zunik-certs:/app/certs \
  zunohan/zunik:latest

⁠Docker Compose

services:
  zunik:
    image: zunohan/zunik:latest
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    volumes:
      - ./config.toml:/app/config.toml:ro
      - zunik-certs:/app/certs
    restart: unless-stopped

  backend:
    image: your-app:latest
    expose:
      - 3000

volumes:
  zunik-certs:

⁠Load Balancing

[routes.api]
load_balancing = "least_connections"

[routes.api.match_rule]
path_prefix = "/api"

[[routes.api.backends]]
url = "http://api-1:3000"
weight = 3

[[routes.api.backends]]
url = "http://api-2:3000"
weight = 1

[routes.api.health_check]
interval_secs = 10
path = "/health"
timeout_secs = 5

Supported algorithms: round_robin, weighted_round_robin, random, ip_hash, least_connections, least_response_time

⁠Multi-Domain Routing

[routes.web]
[routes.web.match_rule]
host = "myapp.com"
[[routes.web.backends]]
url = "http://frontend:3000"

[routes.api]
priority = 10
[routes.api.match_rule]
host = "api.myapp.com"
[[routes.api.backends]]
url = "http://api:3000"

⁠Multi-file Config (Microservices)

Split configs per service, similar to nginx sites-enabled/:

zunik --config-dir ./config/
config/
ā”œā”€ā”€ 00-server.toml
ā”œā”€ā”€ 01-users.toml
ā”œā”€ā”€ 02-orders.toml
└── 03-products.toml

With Docker:

services:
  zunik:
    image: zunohan/zunik:latest
    command: ["--config-dir", "/app/config/"]
    volumes:
      - ./config/:/app/config/:ro

Files are loaded in alphabetical order — use prefixes 00-, 01-... to control order.

⁠Docker Swarm

services:
  zunik:
    image: zunohan/zunik:latest
    command: ["--config-dir", "/app/config/"]
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    volumes:
      - /path/to/config/:/app/config/:ro
      - zunik-certs:/app/certs
    deploy:
      mode: global
    networks:
      - proxy

networks:
  proxy:
    driver: overlay
    attachable: true

volumes:
  zunik-certs:

⁠Middlewares

# CORS
[[routes.api.middlewares]]
type = "cors"
allowed_origins = ["*"]
allowed_methods = ["GET", "POST", "PUT", "DELETE"]

# Compression
[[routes.api.middlewares]]
type = "compress"

# Basic Auth
[[routes.api.middlewares]]
type = "basic_auth"
[routes.api.middlewares.users]
admin = "password123"

# HTTPS Redirect
[[routes.api.middlewares]]
type = "redirect_https"

# Strip Prefix
[[routes.api.middlewares]]
type = "strip_prefix"
prefix = "/api"

Available: add_headers, cors, strip_prefix, add_prefix, basic_auth, compress, redirect_https, rewrite_path

⁠Volumes

PathDescription
/app/config.tomlConfiguration file
/app/config/Config directory (multi-file)
/app/certs/SSL certificates

⁠Ports

PortDescription
80HTTP
443HTTPS
8080Admin Dashboard & API

⁠Dashboard API

EndpointDescription
GET /Web Dashboard
GET /api/metricsRequest metrics
GET /api/configCurrent config
GET /api/healthBackend health status

⁠Environment Variables

docker run -e RUST_LOG=zunik=debug zunohan/zunik:latest

⁠Documentation

Full documentation and source code: https://github.com/zuno90/zunik⁠

⁠Support

If you find Zunik useful, consider buying me a coffee!

Buy Me A Coffee

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:5989bce0e…

Size

37 MB

Last updated

about 1 month ago

docker pull zunohan/zunik