Open WebUI Stack
Docker Compose stack for Open WebUI with LiteLLM proxy, observability, and security best practices.
Architecture
graph TB
classDef internet fill:#f9f9f9,stroke:#333,stroke-width:2px,color:#333,stroke-dasharray: 5 5;
classDef proxy fill:#f39c12,stroke:#e67e22,stroke-width:2px,color:#fff;
classDef app fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff;
classDef db fill:#2ecc71,stroke:#27ae60,stroke-width:2px,color:#fff;
classDef obs fill:#9b59b6,stroke:#8e44ad,stroke-width:2px,color:#fff;
Internet((Internet)):::internet
subgraph Ingress [Ingress / Proxy]
Traefik[Traefik<br/>Reverse Proxy]:::proxy
end
subgraph Core [Core Applications]
OpenWebUI[Open WebUI]:::app
LiteLLM[LiteLLM<br/>Proxy]:::app
end
subgraph Data [Data & Storage]
Qdrant[(Qdrant<br/>Vector DB)]:::db
Valkey[(Valkey<br/>Cache)]:::db
PostgreSQL[(PostgreSQL<br/>Database)]:::db
end
subgraph Observability [Observability Stack]
LGTM[LGTM Stack<br/>Grafana/Loki/Tempo/Mimir]:::obs
OTEL[OTEL Collector]:::obs
Exporters[Metrics Exporters]:::obs
end
%% Traffic flow
Internet -->|HTTPS| Traefik
Traefik -->|HTTP| OpenWebUI
Traefik -->|HTTP| LiteLLM
Traefik -->|HTTP| LGTM
OpenWebUI -->|API| Qdrant
OpenWebUI -->|RESP| Valkey
OpenWebUI -->|SQL| PostgreSQL
OpenWebUI -->|API| LiteLLM
LiteLLM -->|RESP| Valkey
LiteLLM -->|SQL| PostgreSQL
%% Exporters querying targets
Exporters -.->|Scrape| PostgreSQL
%% Telemetry flow (dashed)
LiteLLM -.->|OTLP| LGTM
OpenWebUI -.->|OTLP| LGTM
Exporters -.->|Metrics| OTEL
OTEL -.->|Push| LGTM
Features
- Traefik Reverse Proxy: Automatic HTTPS with self-signed certificates generated by Traefik, HTTP to HTTPS redirect
- LiteLLM Proxy: Unified gateway for multiple LLM providers (OpenAI, Anthropic, Gemini, Ollama)
- LGTM Observability Stack: Grafana, Loki, Tempo, Mimir for logs, traces, and metrics
- Qdrant Vector Database: Production-ready vector search for RAG
- PostgreSQL: Shared database for Open WebUI and LiteLLM
- OpenTelemetry: Full observability with distributed tracing
- Security: Network isolation, secure headers, rate limiting
Quick Start
Prerequisites
- Docker Engine 24.0+
- Docker Compose v2.20+
- 8GB+ RAM recommended
- (Optional) NVIDIA GPU with drivers for GPU metrics
Installation
Clone the repository
git clone https://github.com/mhajder/openwebui-stack.git
cd openwebui-stack
Run the setup script
chmod +x scripts/*.sh
./scripts/setup.sh
In docker-compose.yml change ENABLE_SIGNUP to true if you want to register the first admin user via Open WebUI. You can disable it again after the first user is created.
Start the stack
docker compose --profile monitoring --profile gpu up -d
Access the services
Local Domain Resolution
Add these entries to your /etc/hosts:
127.0.0.1 localhost grafana.localhost litellm.localhost traefik.localhost
Configuration
Environment Variables
Key environment variables in .env:
| Variable |
Description |
Example |
COMPOSE_PROJECT_NAME |
Docker Compose project name |
openwebui-stack |
DOMAIN |
Base domain for services |
localhost or example.com |
POSTGRES_USER |
PostgreSQL admin user |
postgres |
POSTGRES_PASSWORD |
PostgreSQL admin password |
Generated by setup script |
OPENWEBUI_DB_NAME |
Open WebUI database name |
openwebui |
OPENWEBUI_DB_USER |
Open WebUI database user |
openwebui |
OPENWEBUI_DB_PASSWORD |
Open WebUI database password |
Generated by setup script |
LITELLM_DB_NAME |
LiteLLM database name |
litellm |
LITELLM_DB_USER |
LiteLLM database user |
litellm |
LITELLM_DB_PASSWORD |
LiteLLM database password |
Generated by setup script |
OPENWEBUI_SECRET_KEY |
Secret key for Open WebUI sessions |
Generated by setup script |
LITELLM_MASTER_KEY |
Master API key for LiteLLM |
Generated by setup script |
LITELLM_SALT_KEY |
Salt key for LiteLLM encryption |
Generated by setup script |
TRAEFIK_DASHBOARD_USER |
Traefik dashboard username |
admin |
TRAEFIK_DASHBOARD_PASSWORD |
Traefik dashboard password (plain) |
Generated by setup script |
TRAEFIK_DASHBOARD_PASSWORD_HASH |
Traefik dashboard password (apr1 hash) |
Auto-generated by setup script |
GF_SECURITY_ADMIN_PASSWORD |
Grafana admin password |
Generated by setup script |
Services Overview
Core Services
- Traefik: Reverse proxy with automatic HTTPS, routing, and load balancing
- Open WebUI: Web UI for interacting with LLMs
- LiteLLM: Unified gateway for multiple LLM providers
- PostgreSQL: Shared relational database for Open WebUI and LiteLLM
- Valkey: High-performance Redis alternative for caching and sessions
Storage & Search
- Qdrant: Vector database for semantic search and RAG operations
Observability (LGTM Stack)
- LGTM (Grafana OTel): Integrated stack providing:
- Prometheus/Mimir: Metrics collection and storage
- Loki: Centralized log aggregation
- Tempo: Distributed tracing
- Grafana: Visualization and dashboards
Exporters & Collectors
- Node Exporter: System-level metrics (CPU, memory, disk, network)
- OpenTelemetry Collector: Collects and forwards metrics, logs, and traces
- PostgreSQL Exporter (optional profile): Database metrics
- NVIDIA GPU Exporter (optional profile): GPU metrics (requires GPU)
Production Deployment
For production environments:
Use proper certificates
- Replace self-signed certs with Let's Encrypt or CA-signed certificates
- Update traefik/traefik.yml for ACME configuration (Let's Encrypt)
- Example ACME configuration:
certificatesResolvers:
letsencrypt:
acme:
email: admin@example.com
storage: /data/acme.json
httpChallenge:
entryPoint: web
Update security settings
- Change default passwords in
.env (setup script generates strong ones automatically)
- Enable authentication on all service dashboards
- Configure rate limiting and WAF rules in Traefik
Enable GPU support (if available)
docker compose --profile gpu up -d
This activates the NVIDIA GPU Exporter for monitoring GPU metrics.
Configure persistent backups
- Use external volume drivers for data persistence
- Set up automated backup scripts using cron
- Store backups in secure, off-site locations
Network security
- Use VPN or IP whitelisting for external access
- Configure firewall rules (UFW, iptables)
- Use private networks when possible
Database optimization
- Configure PostgreSQL replication for HA
- Set up automated backup and recovery procedures
- Monitor database performance and storage
Monitoring and alerting
- Configure alert rules in Grafana for critical metrics
- Set up notification channels (email, Slack, PagerDuty)
- Implement log retention policies in Loki
Monitoring
Grafana Dashboards
Access Grafana at https://grafana.localhost with default credentials:
- Username:
admin
- Password: Set in
.env as GF_SECURITY_ADMIN_PASSWORD (generated by setup script)
Pre-configured Dashboards
The stack includes several pre-configured dashboards:
litellm-dashboard.json - LiteLLM proxy metrics and performance
- Request rates and latencies
- Token usage and costs
- Error rates by model
- Model provider health
node-exporter-dashboard.json - System metrics
- CPU, memory, and disk usage
- Network I/O
- Process metrics
- System uptime
openwebui-dashboard.json - Open WebUI application metrics
- Request rates and response times
- User activity
- Message counts
- API endpoint performance
postgresql-dashboard.json - Database metrics
- Query performance
- Connection pool status
- Cache hit rates
- Replication lag (if configured)
traefik-dashboard.json - Reverse proxy metrics
- Request rates by service
- Response time percentiles
- HTTP status codes
- SSL/TLS certificate expiry
opentelemetry-dashboard.json - System-wide observability
- Distributed traces
- Span analysis
- Service dependencies
- Error tracking
nvidia-dcgm-dashboard.json - GPU metrics (if GPU profile enabled)
- GPU memory usage
- Compute utilization
- Temperature monitoring
- Power consumption
Available Metrics
Prometheus/Mimir stores these metric types:
| Category |
Metrics |
| System |
CPU load, memory usage, disk I/O, network traffic |
| Database |
Connection count, query latency, transaction rate |
| HTTP |
Request rate, response time, status codes, error rate |
| Cache |
Hit/miss rates, eviction rates, memory usage |
| Application |
Custom metrics from services |
| GPU |
Memory usage, compute, temperature, power (if enabled) |
Traces in Tempo
OpenTelemetry traces are automatically collected and stored in Tempo:
- Access via Grafana → Explore → Tempo
- View distributed traces across all services
- Analyze service dependencies
- Identify performance bottlenecks
- Track errors through the system
Additional Resources
License
This project is licensed under the MIT License - see the LICENSE file for details.