How to Install and Configure OpenWebUI on Ubuntu with Docker Compose, OpenRouter AI (No Ollama Required) – Permanent Production Setup
OpenWebUI is a sleek web UI for LLMs. This guide sets it up on Ubuntu using Docker Compose with OpenRouter.ai (cloud APIs, no local Ollama needed). Includes persistence, auto-restart, and optional HTTPS.
1. Prerequisites and Docker Installation
- Prerequisites:
- Ubuntu 22.04+ (tested on 24.04)
- Root/sudo access
- Docker & Docker Compose (v2+)
- OpenRouter.ai account & API key (https://openrouter.ai/keys)
- Install Docker (Official Ubuntu method):
sudo apt update && sudo apt upgrade -y sudo apt install ca-certificates curl -y sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y sudo usermod -aG docker $USER newgrp dockerTest:
docker compose version
2. Permanent Setup with Docker Compose
mkdir ~/openwebui && cd ~/openwebui
Create docker-compose.yml:
version: '3.8'
services:
openwebui:
image: ghcr.io/open-webui/open-webui:main
container_name: openwebui
restart: unless-stopped
ports:
- "3000:8080"
environment:
- WEBUI_SECRET_KEY=your-secure-random-key # Generate: openssl rand -hex 32
- OPENAI_API_BASE=https://openrouter.ai/api/v1
- OPENAI_API_KEY=your-openrouter-api-key-here
volumes:
- openwebui:/app/backend/data
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
openwebui:
Run:
docker compose up -d
Access: http://your-server-ip:3000
3. Configure OpenRouter in OpenWebUI
- Sign up/login at OpenWebUI.
- Admin > Connections > OpenAI > Edit:
- Base URL:
https://openrouter.ai/api/v1 - API Key:
sk-or-...(from OpenRouter dashboard) - Save. Models auto-load (e.g., openai/gpt-4o-mini).
4. Production Hardening
sudo systemctl enable --now docker.socket docker.service
sudo ufw allow 3000
Optional HTTPS (Caddy):
sudo apt install caddy -y
cat <<EOF | sudo tee /etc/caddy/Caddyfile
your-domain.com {
reverse_proxy localhost:3000
}
EOF
sudo systemctl restart caddy
5. Troubleshooting
| Issue | Fix |
|---|---|
| No models | Check API key/base URL. Test: curl https://openrouter.ai/api/v1/models -H "Authorization: Bearer $OPENAI_API_KEY" |
| Port conflict | Change 3000:8080 in Compose. |
| Updates | docker compose pull && docker compose up -d |
Quick Setup: Download and run the automated setup.sh script: setup.sh (Co-authored by
References
