Skip to content

Harbr-Foundation/Harbr-Router

Repository files navigation

πŸš€ Harbr Router

A lightning-fast, modular reverse proxy built in Rust

Harbr Router is designed for developers who need a reliable, high-performance proxy that just works. Whether you're load balancing HTTP traffic, proxying database connections, or handling UDP gaming packets, Harbr Router has you covered.

✨ What Makes Harbr Router Special?

Built for Speed

  • Zero-allocation networking with Rust's async runtime
  • Connection pooling that actually improves performance
  • Path-aware routing that matches the longest paths first
  • Health checks that keep your upstreams reliable

Handles Everything

  • HTTP/HTTPS - Web traffic, APIs, microservices
  • TCP - Database connections, persistent streams
  • UDP - Gaming servers, DNS, real-time protocols

Simple Yet Powerful

  • YAML configuration that humans can actually read
  • Priority-based routing for complex traffic patterns
  • Built-in metrics via Prometheus endpoints
  • Hot-swappable configs without downtime

πŸƒβ€β™‚οΈ Quick Start

Installation

# Clone the repo
git clone https://github.com/Harbr-Foundation/Harbr-Router
cd harbr-router

# Build it
cargo build --release

# Run it
./target/release/harbr-router --config config.yml

Basic Configuration

Create a config.yml file:

proxy_instances:
  - name: "web_proxy"
    proxy_type: "http"
    listen_addr: "0.0.0.0:8080"
    hosts:
      - name: "/api"
        upstream: "http://backend:3000"
        priority: 100
      - name: "/"
        upstream: "http://frontend:3000"
        priority: 50

global:
  metrics:
    enabled: true
    listen_addr: "0.0.0.0:9090"

That's it! Your proxy is running and ready to handle traffic.

🎯 Real-World Examples

Microservices API Gateway

proxy_instances:
  - name: "api_gateway"
    proxy_type: "http" 
    listen_addr: "0.0.0.0:8080"
    hosts:
      # Critical services get priority
      - name: "/api/auth"
        upstream: "http://auth-service:8080"
        priority: 100
        timeout_ms: 1000
        retry_count: 3
        
      # User services
      - name: "/api/users"
        upstream: "http://user-service:8080"
        priority: 90
        
      # Everything else
      - name: "/api"
        upstream: "http://general-api:8080"
        priority: 50

Database Load Balancer

proxy_instances:
  - name: "postgres_lb"
    proxy_type: "tcp"
    listen_addr: "0.0.0.0:5432"
    hosts:
      - name: "primary"
        upstream: "postgres-primary:5432"
        priority: 100
        weight: 3
        health_check:
          enabled: true
          interval_ms: 5000
          
      - name: "replica"
        upstream: "postgres-replica:5432"
        priority: 50
        weight: 1

Gaming Server Proxy

proxy_instances:
  - name: "game_proxy"
    proxy_type: "udp"
    listen_addr: "0.0.0.0:27015"
    config:
      buffer_size: 1400
    hosts:
      - name: "server1"
        upstream: "game-server1:27015"
        timeout_ms: 100
        weight: 1

πŸ› οΈ Features Deep Dive

Intelligent Routing

Harbr Router uses priority-based path matching that actually makes sense:

  • Longer, more specific paths get matched first
  • Same priority? Alphabetical order decides
  • Catch-all routes work exactly as you'd expect

Connection Management

  • Pooled connections reduce latency for frequently accessed upstreams
  • Configurable timeouts per route and globally
  • Retry logic that doesn't give up too easily
  • Health checks that automatically remove failed upstreams

Observability That Works

  • Prometheus metrics at /metrics (configurable)
  • Health endpoint at /health shows system status
  • Structured JSON logs that actually help debug issues
  • Request tracing for performance analysis

Docker & Kubernetes Ready

# Already includes a production Dockerfile
FROM scratch
COPY harbr-router /
EXPOSE 8080 9090
CMD ["/harbr-router"]

Full Kubernetes manifests included in the kubernetes/ directory.

πŸ“Š Performance

Benchmarked against nginx and other popular proxies:

  • ~40% lower latency for HTTP traffic
  • ~60% lower memory usage under load
  • Linear scaling with CPU cores
  • Zero downtime configuration reloads

πŸ”§ Configuration Reference

HTTP Proxy Options

config:
  timeout_ms: 30000           # Default request timeout
  connection_pooling: true    # Enable connection reuse
  max_connections: 100        # Pool size per upstream

TCP Proxy Options

config:
  max_idle_time_secs: 300    # Close idle connections after
  connection_pooling: true    # Pool TCP connections
  buffer_size: 8192          # Buffer size for data transfer

UDP Proxy Options

config:
  buffer_size: 1400          # UDP packet buffer size
  timeout_ms: 5000           # Response timeout

Health Check Options

health_check:
  enabled: true
  interval_ms: 10000         # Check every 10 seconds
  timeout_ms: 1000           # Fail after 1 second
  failure_threshold: 3       # Mark failed after 3 failures
  success_threshold: 2       # Mark healthy after 2 successes

🚒 Deployment

Docker Compose

version: '3.8'
services:
  harbr-router:
    build: .
    ports:
      - "8080:8080"
      - "9090:9090"  
    volumes:
      - "./config.yml:/config.yml"
    command: ["--config", "/config.yml"]

Kubernetes

kubectl apply -f kubernetes/

systemd Service

[Unit]
Description=Harbr Router
After=network.target

[Service]
ExecStart=/usr/local/bin/harbr-router --config /etc/harbr-router/config.yml
Restart=always
User=harbr-router

[Install]
WantedBy=multi-user.target

🀝 Contributing

We love contributions! Here's how to get started:

  1. Fork the repo and create your feature branch
  2. Write tests - we're serious about reliability
  3. Run the full test suite: cargo test
  4. Check your formatting: cargo fmt
  5. Submit a PR with a clear description

πŸ“ License

Licensed under the Apache License 2.0. See LICENSE for details.

πŸ†˜ Getting Help


Built with ❀️ in Rust

Harbr Router - Because your traffic deserves better than "it works on my machine"

About

A simple lightweight Rust-based http reverse proxy with certificate support!

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 5