An RFC 9458 compliant Oblivious HTTP gateway implementation in Rust.
## Overview
This gateway implements the Oblivious HTTP protocol as defined in [RFC 9458](https://datatracker.ietf.org/doc/rfc9458/), providing a privacy-preserving HTTP proxy that prevents servers from linking requests to individual clients. The gateway acts as the decryption endpoint in the OHTTP architecture, receiving encrypted requests from relays and forwarding them to target servers.
OHTTP enables clients to make HTTP requests without revealing their identity to the target server by routing requests through a trusted relay that forwards encrypted messages to this gateway. The gateway decrypts the requests using HPKE (Hybrid Public Key Encryption), forwards them to the target server, and returns encrypted responses back through the relay.
## Architecture
Client -> Relay -> Gateway -> Target Server
| |
| v
| [Decrypt Request]
| [Forward to Target]
| [Encrypt Response]
| |
<--------+
This implementation serves as the Gateway component, handling:
- HPKE-encrypted request decapsulation
- Request validation and origin policy enforcement
- Target server communication
- Response encryption and encapsulation
- Key management and rotation
## Features
- **RFC 9458 Compliance**: Full implementation of the OHTTP specification
- **HPKE Encryption**: Uses the `ohttp` crate with HPKE for secure request/response handling
Configure `ALLOWED_TARGET_ORIGINS` to restrict which domains the gateway can reach. Without this, the gateway may be used to proxy requests to unintended targets.
### Rate Limiting
Enable rate limiting to prevent abuse:
```bash
RATE_LIMIT_RPS=50
RATE_LIMIT_BURST=100
RATE_LIMIT_BY_IP=true
```
### Key Management
- Keys rotate automatically based on `KEY_ROTATION_INTERVAL`
- Old keys are retained for `KEY_RETENTION_PERIOD` to handle delayed requests
- Use `SEED_SECRET_KEY` for deterministic key generation in clustered deployments
### Request Validation
The gateway validates:
- Request size limits
- Binary HTTP message format
- Target origin allowlists
- Path traversal attempts
## Monitoring
### Metrics
Prometheus metrics are available at `/metrics`:
-`ohttp_requests_total` - Total requests processed
-`ohttp_request_duration_seconds` - Request processing time