Open WebUI¶
Overview¶
Open WebUI is a feature-rich, self-hosted web interface for AI chat models that provides a user-friendly alternative to command-line interfaces. It supports both local LLMs through Ollama integration and external AI providers like OpenAI and Anthropic. The interface offers a ChatGPT-like experience with additional features for model management, conversation history, and user administration.
Key Features¶
- Multi-Model Support: Connect to local Ollama models and external AI providers simultaneously
- User Management: Built-in authentication and user administration
- Conversation Management: Save, search, and organize chat histories
- Model Switching: Seamlessly switch between different models mid-conversation
- Document Upload: Support for various file formats for context-aware conversations
- Customizable Interface: Dark/light themes and adjustable settings
- API Access: RESTful API for programmatic interaction
Architecture¶
Open WebUI follows a modular architecture with several key components:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Web Browser │────▶│ Traefik │────▶│ Open WebUI │
│ │ │ (Reverse Proxy) │ │ Container │
└─────────────────┘ └─────────────────┘ └────────┬────────┘
│
┌─────────────────────────────────┴───────────┐
│ │
┌─────▼─────────┐ ┌───────────▼──────────┐
│ Ollama │ │ External AI APIs │
│ (Local Host) │ │ (OpenAI, Anthropic) │
└───────────────┘ └────────────────────┘
Components¶
- Frontend: React-based SPA with responsive design
- Backend: Python FastAPI server handling authentication, model routing, and data persistence
- Database: SQLite for user data, conversations, and settings
- Storage: Local filesystem for uploaded documents and vector embeddings
- Model Providers: Ollama for local models, API clients for external providers
Integration with Ollama¶
Overview¶
Ollama integration allows Open WebUI to interact with locally-hosted LLMs without requiring internet connectivity or API keys. In this deployment, Ollama runs as a system service on the Docker host, not as a container.
Configuration Details¶
The integration is configured through environment variables in /srv/dockerdata/open-webui/.env:
Important: The IP address 172.17.0.1 is the Docker bridge network gateway, allowing containers to access services running on the host.
How It Works¶
- Host Service: Ollama runs as a systemd service on the host machine
- Model Storage: Models are stored in
/srv/dockerdata/ollama/models/ - API Access: Ollama exposes its API on port 11434
- Container Access: Open WebUI accesses Ollama through the Docker bridge network
Available Models¶
Current Ollama models (as shown by ollama list):
- gemma3n:e4b - Google's Gemma 3 Nano model (7.5 GB)
- deepseek-r1:latest - DeepSeek R1 reasoning model (5.2 GB)
- llama3.1:8b-instruct-q4_0 - Meta's Llama 3.1 8B instruction model (4.7 GB)
Managing Ollama Models¶
# List installed models
ollama list
# Pull a new model
ollama pull llama3.2
# Remove a model
ollama rm model_name
# Run a model directly (for testing)
ollama run llama3.1:8b-instruct-q4_0
Integration with External AI Providers¶
Supported Providers¶
Open WebUI supports multiple external AI providers through their respective APIs:
- OpenAI - GPT models (GPT-3.5, GPT-4, etc.)
- Anthropic - Claude models
- Google - Gemini models
- Groq - Fast inference for open models
Configuration¶
API keys are configured in /srv/dockerdata/open-webui/.env:
# provider / app secrets go below (edit after generation)
# OPENAI_API_KEY=sk-...
# ANTHROPIC_API_KEY=sk-ant-...
# GEMINI_API_KEY=AI...
# GROQ_API_KEY=gsk_...
After adding API keys:
Provider-Specific Features¶
- OpenAI: Function calling, vision models, embeddings
- Anthropic: Long context windows, Claude 3 vision capabilities
- Google: Multimodal support, Gemini Pro features
- Groq: Ultra-fast inference, cost-effective for supported models
Configuration Details¶
Environment Variables¶
Key environment variables in /srv/dockerdata/open-webui/.env:
# Core Configuration
APP_NAME=open-webui
APP_PORT=3000 # Note: Internal port is actually 8080
APP_DOMAIN=open-webui.rbnk.uk
# Security
WEBUI_SECRET_KEY=change-this-to-a-random-secret-key # IMPORTANT: Change this!
# Network Configuration
TRAEFIK_NETWORK=traefik_proxy
TRAEFIK_CERTRESOLVER=cf
TRAEFIK_ENTRYPOINT=websecure
# Ollama Integration
OLLAMA_BASE_URL=http://172.17.0.1:11434
ENABLE_OLLAMA=true
# Optional Features
# ENABLE_SIGNUP=false # Disable public signups
# DEFAULT_USER_ROLE=user # Role for new users
# WEBUI_AUTH=false # Disable authentication (not recommended)
Docker Compose Configuration¶
The service is defined in /srv/dockerdata/open-webui/docker-compose.yml:
services:
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: unless-stopped
env_file:
- ./.env
networks:
- default
volumes:
- ./data:/app/backend/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.open-webui.rule=Host(`openwebui.rbnk.uk`)"
- "traefik.http.routers.open-webui.entrypoints=websecure"
- "traefik.http.routers.open-webui.tls.certresolver=cf"
- "traefik.http.services.open-webui.loadbalancer.server.port=8080"
User Management¶
- First User: The first user to sign up becomes the admin
- User Roles:
- Admin: Full access to settings, user management, model configuration
- User: Can chat with models, manage own conversations
-
Pending: Awaiting admin approval (if approval required)
-
Managing Users (as admin):
- Navigate to Settings → Admin → Users
- Add, edit, or remove users
- Change user roles
- Reset passwords
Model Configuration¶
- Model Selection:
- Click the model dropdown in the chat interface
- Select from available Ollama or API models
-
Set default model in user settings
-
Model Parameters:
- Temperature: Controls randomness (0-2)
- Max Tokens: Maximum response length
- Top P: Nucleus sampling parameter
-
Frequency Penalty: Reduce repetition
-
Model Aliases: Create friendly names for models in Settings → Models
Common Issues and Solutions¶
Port 8080 vs 3000 Confusion¶
Issue: The .env file shows APP_PORT=3000 but the container actually runs on port 8080.
Explanation:
- Open WebUI's container internally runs on port 8080
- The APP_PORT variable in the template is misleading
- Traefik correctly routes to port 8080 as specified in the labels
Solution: The current configuration is correct. The Traefik label specifies:
Ollama Connection Issues¶
Issue: "Ollama not found" or connection errors.
Solutions: 1. Verify Ollama is running:
-
Test Ollama API:
-
Check Docker bridge IP:
-
Ensure firewall allows local connections:
Model Download Failures¶
Issue: Models fail to download or appear stuck.
Solutions: 1. Check disk space:
-
Monitor download progress:
-
Retry with smaller model first:
Authentication Problems¶
Issue: Cannot log in or password reset not working.
Solutions: 1. Access the SQLite database:
-
For password reset, use the admin interface or contact admin
-
If locked out completely, temporarily disable auth (not recommended for production):
Usage Patterns and Best Practices¶
Conversation Management¶
- Organizing Chats:
- Use descriptive titles for conversations
- Archive completed conversations
-
Use tags for categorization
-
Context Management:
- Clear context when switching topics
- Use system prompts for consistent behavior
-
Upload relevant documents for context
-
Model Selection:
- Use smaller models for simple tasks
- Switch to larger models for complex reasoning
- Consider API models for latest capabilities
Prompt Engineering¶
- System Prompts: Configure default behavior in Settings → Interface
- Templates: Save frequently used prompts
- Variables: Use {{variable}} syntax for dynamic prompts
Multi-User Environments¶
- User Isolation: Each user has separate conversation history
- Shared Models: All users access the same model pool
- Resource Management: Monitor usage for fair access
Performance Considerations¶
Resource Usage¶
- Memory Requirements:
- Open WebUI container: ~500MB-1GB RAM
- Ollama models: 4-8GB RAM per loaded model
-
Disk cache for embeddings and documents
-
CPU Usage:
- Minimal for Open WebUI itself
- Ollama inference depends on model size
- Consider GPU acceleration for better performance
Optimization Tips¶
-
Model Management:
-
Database Maintenance:
-
Cache Management:
Monitoring¶
-
Container Stats:
-
Logs:
-
Ollama Status:
Security Considerations¶
API Key Management¶
- Storage: Never commit API keys to version control
- Permissions: Ensure
.envfile has restricted permissions: - Rotation: Regularly rotate API keys
- Audit: Monitor API usage through provider dashboards
User Access Control¶
- Authentication:
- Always keep authentication enabled in production
- Use strong passwords
-
Consider implementing 2FA (if supported in future versions)
-
Authorization:
- Limit admin access
- Review user permissions regularly
- Disable signup if not needed:
Network Security¶
- TLS/SSL: Always access through HTTPS (handled by Traefik)
- Internal Access: Ollama only accessible from localhost
- Firewall: Ensure only necessary ports are exposed
Data Protection¶
- Conversations: Stored in SQLite database
- Uploads: Stored in local filesystem
- Embeddings: Cached locally for performance
Backup and Data Persistence¶
What to Backup¶
- Database:
/srv/dockerdata/open-webui/data/webui.db - User accounts and settings
- Conversation history
-
Model configurations
-
Uploads:
/srv/dockerdata/open-webui/data/uploads/ - User-uploaded documents
-
Generated images
-
Vector Database:
/srv/dockerdata/open-webui/data/vector_db/ -
Document embeddings for RAG
-
Configuration:
/srv/dockerdata/open-webui/.env - API keys and settings
Backup Script¶
Create /srv/dockerdata/_scripts/open-webui-backup.sh:
#!/bin/bash
set -e
BACKUP_DIR="/srv/dockerdata/_backup/open-webui"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_NAME="open-webui-backup-${TIMESTAMP}"
# Create backup directory
mkdir -p "${BACKUP_DIR}"
# Stop container for consistent backup
cd /srv/dockerdata/open-webui
docker compose stop open-webui
# Create backup
tar -czf "${BACKUP_DIR}/${BACKUP_NAME}.tar.gz" \
--exclude='data/cache' \
data/ .env
# Restart container
docker compose start open-webui
# Keep only last 14 days of backups
find "${BACKUP_DIR}" -name "open-webui-backup-*.tar.gz" -mtime +14 -delete
echo "Backup completed: ${BACKUP_DIR}/${BACKUP_NAME}.tar.gz"
Restore Procedure¶
# Stop the container
cd /srv/dockerdata/open-webui
docker compose down
# Backup current data (just in case)
mv data data.old
# Extract backup
tar -xzf /srv/dockerdata/_backup/open-webui/open-webui-backup-TIMESTAMP.tar.gz
# Start container
docker compose up -d
# Verify restoration
docker compose logs
Automated Backups¶
Add to crontab:
# Daily backup at 3:30 AM
30 3 * * * /srv/dockerdata/_scripts/open-webui-backup.sh >> /var/log/open-webui-backup.log 2>&1
Troubleshooting Guide¶
Container Won't Start¶
# Check logs
docker compose -f /srv/dockerdata/open-webui/docker-compose.yml logs
# Verify network exists
docker network ls | grep traefik_proxy
# Check permissions
ls -la /srv/dockerdata/open-webui/data
Slow Response Times¶
-
Check Ollama model loading:
-
Monitor resource usage:
-
Consider using smaller/quantized models
Database Corruption¶
# Check database integrity
docker exec open-webui sqlite3 /app/backend/data/webui.db "PRAGMA integrity_check;"
# If corrupted, restore from backup or reset
Maintenance Tasks¶
Regular Maintenance¶
- Weekly:
- Review user activity
- Check disk usage
-
Monitor API usage
-
Monthly:
- Update Open WebUI image
- Vacuum database
-
Review and update models
-
Quarterly:
- Rotate API keys
- Audit user permissions
- Review backup retention
Updating Open WebUI¶
cd /srv/dockerdata/open-webui
# Pull latest image
docker compose pull
# Backup before update
/srv/dockerdata/_scripts/open-webui-backup.sh
# Restart with new image
docker compose up -d
# Monitor logs
docker compose logs -f
Integration with Other Services¶
LiteLLM Proxy¶
If using LiteLLM as a unified API proxy:
# In Open WebUI settings, add custom model:
# Model: litellm/model-name
# API Base: http://litellm:4000
# API Key: your-litellm-virtual-key
Virtual Keys: Our LiteLLM deployment uses virtual keys for enhanced security and cost tracking. Each service gets its own virtual key with budget limits. For implementation details, see: LiteLLM Virtual Keys Implementation
Monitoring Integration¶
For Prometheus/Grafana monitoring, Open WebUI exposes metrics at /metrics endpoint (requires configuration).
Conclusion¶
Open WebUI provides a powerful, user-friendly interface for interacting with both local and cloud-based AI models. Its integration with Ollama enables completely offline AI capabilities, while support for external providers ensures access to the latest models. Proper configuration, security practices, and regular maintenance ensure a smooth and secure experience for all users.