A Redis proxy server designed for multi-tenant environments. This proxy enables secure tenant isolation through key prefixing while providing seamless Redis cluster support.
- Multi-tenant isolation: Automatic key prefixing based on authenticated tenant
- Redis Cluster support: Full support for Redis cluster deployments with automatic redirection handling
- Secure authentication: Bcrypt password hashing with per-tenant credentials
- Connection pooling: Efficient connection management and reuse
- Command routing: Intelligent command routing with MOVED/ASK redirection support
- Docker support: Ready-to-deploy Docker containers
- Basic key operations:
GET,SET,DEL,EXISTS,EXPIRE,TTL,INCR,DECR - Hash operations:
HGET,HSET,HMGET,HMSET,HDEL - List operations:
LPUSH,RPUSH,LPOP,RPOP,LRANGE - Set operations:
SADD,SREM,SMEMBERS - Sorted set operations:
ZADD,ZREM,ZRANGE,ZRANK - Multi-key operations:
MGET,MSET - Utility commands:
PING,INFO
- ❌ NOT PRODUCTION READY: This project is in early development and should not be used in production environments
- ❌ Cross-node operations not implemented: Operations spanning multiple Redis nodes are not yet supported
- 🔄 Planned features:
- Enhanced
MGETandMSEToperations with cross-node support ✅ SCANcommand implementation with tenant-aware key iteration 🚗- Test and Benchmark
- Hot reload of credentials
- Metrics and monitoring endpoints
- Config from ETCD & hot reload
- Command filtering and blacklisting
- Rate limiting per tenant
- API for lower level access to cluster nodes
- Enhanced
Client Applications
↓
Redis Multi-Tenant Proxy (Port 6380)
↓
Redis Cluster (Nodes on Port 6379)
The proxy acts as an intermediary between Redis clients and a Redis cluster, automatically:
- Authenticating clients based on tenant credentials
- Adding tenant-specific prefixes to all keys
- Routing commands to appropriate Redis cluster nodes
- Handling cluster redirections transparently
- Go 1.25.1 or later
- Redis cluster setup (3+ nodes recommended)
# Clone the repository
git clone https://github.com/seabfh/redis-multi-tenant-proxy.git
cd redis-multi-tenant-proxy
# Build the application
make bin
# The binaries will be available in the bin/ directory
./bin/proxy --config config.yaml# Build the Docker image
make image
# Build for compose
docker compose build redis-proxy
# Run with Docker Compose
docker compose up -d
# Restart redis-proxy
docker compose up -d redis-proxy# Proxy server configuration
listen_addr: ":6380"
# Redis Cluster configuration
cluster_nodes:
- "redis-node1:6379"
- "redis-node2:6379"
- "redis-node3:6379"
# Optional cluster authentication (if your Redis Cluster requires it)
cluster_username: ""
cluster_password: ""
# Authentication settings
auth_enabled: true
# Tenant configurations
tenants:
tenant1:
prefix: "tenant1:"
password: "secure_password1"
tenant2:
prefix: "tenant2:"
# Bcrypt hashed password (recommended)
password_hash: "$2a$10$CxOSXe2LKT5g.nvBrno2Guz9R3yP6Z/io0xS5ZfAZjQxULoHDtRvW"
production:
prefix: "prod:"
password_hash: "$2a$10$XQiOPG2Fj6GdJsRQxZJVZerugKxGC9Ky0mXyMsrXtFJLhGT8YKJkW"
rate_limit: 1000
max_connections: 50
# Performance settings
max_connections: 1000
log_level: "info"| Option | Description | Default |
|---|---|---|
listen_addr |
Address and port for the proxy server | :6380 |
cluster_nodes |
List of Redis cluster node addresses | Required |
auth_enabled |
Enable/disable authentication | true |
tenants |
Tenant configuration map | {} |
max_connections |
Maximum concurrent connections | 1000 |
log_level |
Logging level (debug, info, warn, error) | info |
Each tenant can be configured with:
prefix: Key prefix for tenant isolation (e.g., "tenant1:")password: Plain text password (not recommended for production)password_hash: Bcrypt hashed password (recommended)rate_limit: Optional rate limiting (requests per second)max_connections: Optional connection limit per tenant
Use the included utility to generate secure password hashes:
./bin/hashpassword -password=your_password
# Enter your password when prompted
# Copy the generated hash to your config file./bin/proxy --config ./config/config.yaml# Connect using redis-cli
redis-cli -h localhost -p 6380
# Authenticate
AUTH tenant1 secure_password1
# Use Redis commands normally
SET user:1 "John Doe"
GET user:1
HSET user:1:profile name "John Doe" email "john@example.com"
HGET user:1:profile name# launch the proxy and a Redis cluster
docker compose up -d