# Milestone 02: Hosting Gateway

> HTTP gateway server for serving hosted web applications

## Status: Complete

## Tasks

- [x] Create HostingGateway server with Axum
- [x] Implement request handler with host-based routing
- [x] Implement content fetching from Synor Storage
- [x] Add content type detection (20+ MIME types)
- [x] Implement RateLimiter with token bucket algorithm
- [x] Add CacheControl middleware for immutable assets
- [x] Create SSL configuration structure
- [x] Create hosting-gateway binary
- [x] Create Docker configuration (Dockerfile + Caddy)
- [x] Create docker-compose.hosting.yml
- [x] Add comprehensive test coverage (37 tests total)

## Files

```
crates/synor-hosting/src/
├── server/
│   ├── mod.rs      # HostingGateway, GatewayConfig
│   ├── handler.rs  # Request routing, content fetching
│   ├── middleware.rs # RateLimiter, CacheControl
│   └── ssl.rs      # SSL configuration
├── bin/
│   └── hosting-gateway.rs

docker/hosting-gateway/
├── Dockerfile      # Multi-stage Rust build
└── Caddyfile       # Wildcard HTTPS for *.synor.cc

docker-compose.hosting.yml
```

## Key Components

- `HostingGateway`: Main HTTP server using Axum
- `GatewayConfig`: Configuration (listen addr, domain, storage URL, rate limit)
- `RateLimiter`: Token bucket rate limiting per client IP
- `CacheControl`: Immutable asset detection for optimal caching
- Caddy reverse proxy with automatic Let's Encrypt HTTPS

## Architecture

```
Internet → Caddy (HTTPS) → HostingGateway → Storage Gateway → Storage Nodes
                ↓
         *.synor.cc wildcard cert
```

## Validation Commands

```bash
cargo test -p synor-hosting
cargo build -p synor-hosting --features server
docker-compose -f docker-compose.hosting.yml build
```

---

*Completed: January 2026*
