azreyo/carbon

By azreyo

Updated 7 months ago

Lightweight C-based web server with HTTP/2, WebSocket support, and Docker containerization

Image
Networking
Security
Web servers
0

10K+

azreyo/carbon repository overview

Carbon HTTP Server

A high-performance HTTP/HTTPS server written in C with HTTP/2, WebSocket, and modern security features.

Quick Start

docker pull azreyo/carbon:latest
docker run -d -p 8080:8080 --name carbon-server azreyo/carbon:latest

Visit http://localhost:8080 to see your server running.

Features

  • 🚀 HTTP/2 Support - Full HTTP/2 with ALPN negotiation and multiplexing
  • 🔌 WebSocket - RFC 6455 compliant WebSocket support (ws:// and wss://)
  • 🔒 SSL/TLS - HTTPS with modern cipher suites
  • High Performance - Epoll-based I/O, thread pooling, zero-copy transfers
  • 🛡️ Security - Rate limiting, security headers, input sanitization

Usage

Basic HTTP Server
docker run -d \
  -p 8080:8080 \
  --name carbon-server \
  azreyo/carbon:latest
HTTPS Server with Custom Certificates
docker run -d \
  -p 8080:8080 \
  -p 8443:8443 \
  -v ./ssl:/app/ssl:ro \
  -v ./server.conf:/app/server.conf:ro \
  --name carbon-server \
  azreyo/carbon:latest
With Custom Web Content
docker run -d \
  -p 8080:8080 \
  -v ./www:/app/www:ro \
  --name carbon-server \
  azreyo/carbon:latest
Using Docker Compose
version: '3.8'
services:
  carbon-server:
    image: azreyo/carbon:latest
    ports:
      - "8080:8080"
      - "8443:8443"
    volumes:
      - ./www:/app/www:ro
      - ./log:/app/log
      - ./ssl:/app/ssl:ro
      - ./server.conf:/app/server.conf:ro
    restart: unless-stopped

Configuration

Mount a custom server.conf file to configure the server:

# Network
port = 8080
use_https = true

# Protocols
enable_http2 = true
enable_websocket = true

# Performance
max_threads = 8
max_connections = 2000

# Security
verbose = false
Volume Mounts
  • /app/www - Web root directory (default: serves included demo files)
  • /app/log - Log files directory
  • /app/ssl/cert - SSL certificate directory
  • /app/ssl/key - SSL private key directory
  • /app/server.conf - Configuration file

Environment Variables

  • TZ - Timezone (default: UTC)

Exposed Ports

  • 8080 - HTTP port
  • 8443 - HTTPS port

Health Check

The container includes a built-in health check that monitors the HTTP endpoint every 30 seconds.

Examples

Enable HTTP/2
  1. Create server.conf:
port = 8080
use_https = true
enable_http2 = true
ssl_cert_path = ssl/cert/cert.pem
ssl_key_path = ssl/key/key.key
  1. Run with SSL certificates:
docker run -d \
  -p 8443:8443 \
  -v ./ssl:/app/ssl:ro \
  -v ./server.conf:/app/server.conf:ro \
  azreyo/carbon:latest
Enable WebSocket
port = 8080
enable_websocket = true

Test with JavaScript:

const ws = new WebSocket('ws://localhost:8080');
ws.onmessage = (event) => console.log(event.data);
ws.send('Hello Server!');

Security

  • Runs as non-root user (UID 1000)
  • Read-only root filesystem
  • Dropped capabilities except NET_BIND_SERVICE
  • Built-in rate limiting
  • Security headers (CSP, HSTS, X-Frame-Options)

Performance

  • Multi-threaded request handling
  • Epoll-based event loop
  • Memory-mapped file caching
  • Zero-copy file transfers with sendfile()
  • Connection pooling

Building from Source

git clone https://github.com/Azreyo/Carbon.git
cd Carbon
docker build -t carbon-server .

Support

License

MIT License (Modified - Non-Commercial) - See LICENSE


Note: This is a development project. For production use, please conduct thorough security audits and testing.

Tag summary

Content type

Image

Digest

sha256:bcf132d0a

Size

5.9 MB

Last updated

7 months ago

docker pull azreyo/carbon