Gateway
Reverse proxy routing, SSL, and custom domains
Gateway
The Gateway is Senate's reverse proxy layer, powered by Caddy. It handles routing, automatic HTTPS, load balancing, and custom domains.
Overview
Each machine runs its own Gateway instance that:
- Routes traffic to services on that machine
- Manages SSL certificates automatically
- Provides health checking
- Handles HTTP/2 and WebSocket connections
Architecture
Internet → Gateway (Caddy) → Service Containers
↓
Automatic SSL
Route Matching
Health ChecksViewing Gateway Status
- Go to Machines
- Click on a machine
- Select the Gateway tab
You'll see:
- Gateway running status
- Configured routes
- SSL certificate status
- Upstream health
Routes
Routes define how incoming requests reach your services.
Automatic Routes
When you add a domain to a service, Senate creates a route automatically:
| Domain | Target | SSL |
|---|---|---|
app.example.com | myapp-xxx:3000 | Auto |
Load Balancing
Load Balancing
When a service has multiple instances:
Domain → Gateway → Round Robin → Container 1
→ Container 2
→ Container 3Load Balancing Policies
- Round Robin (default): Even distribution
- Least Connections: Route to least busy (Coming Soon)
- IP Hash: Sticky sessions by client IP (Coming Soon)
Custom Gateway Configuration
Via UI
For advanced routing needs:
- Machine → Gateway tab
- Click Add Route
- Configure custom route
Custom Routes
Add routes not tied to services:
| Use Case | Configuration |
|---|---|
| Static redirect | example.com → www.example.com |
| Path routing | /api/* → backend, /* → frontend |
| External proxy | api.example.com → external-service |
WebSocket Support
Gateway handles WebSocket connections automatically:
- Upgrade HTTP → WebSocket
- Connection persistence
- Proper header forwarding
HTTP/2
Enabled by default:
- Server push support
- Multiplexed connections
- Header compression
Headers
Default Headers
Gateway adds:
X-Forwarded-For: Client IPX-Forwarded-Proto: http/httpsX-Real-IP: Original client IP
Troubleshooting
Route not working
- Check domain DNS points to correct IP
- Verify service is running
- Check container port matches route
- View Gateway logs
502 Bad Gateway
- Service container is not running
- Container port mismatch
- Container health check failing
- Service hasn't started yet
SSL redirect loop
- Check service handles HTTPS or sets proper headers
- Ensure
X-Forwarded-Protois respected - Service should trust proxy headers
Related
- Domains - Domain configuration
- Services - Service management
- Machines - Machine management
- Custom Domain Guide - Setup walkthrough