How to Deploy Open WebUI on a VPS: Self-Hosted ChatGPT Interface for Ollama and OpenAI
Open WebUI is a feature-rich, self-hosted web interface for large language models — it works with Ollama (local models) and the OpenAI API simultaneously, supports multi-user access with role-based permissions, enables RAG (Retrieval Augmented Generation) with document uploads, integrates web search, and provides conversation history, model management, and system prompts. Deploy it on a VPS to give your team a private ChatGPT-like experience backed by local or cloud models.
What Open WebUI Provides
- Multi-model interface: Switch between Ollama local models and OpenAI/Claude/Gemini APIs in one UI
- Multi-user: User registration, role-based access (admin, user), per-user conversation history
- RAG: Upload PDFs, Word docs, or URLs — the model answers questions based on your documents
- Web search: Integrate SearXNG or web search APIs — models answer with current information
- Image generation: Connect to DALL-E, Stable Diffusion, or ComfyUI
- Tools/Functions: Extend models with custom Python functions called as tools
- Prompt templates: Save and share system prompts for consistent model behavior
- API: OpenAI-compatible API — use Open WebUI as a gateway for your applications
Prerequisites
- Ollama installed on the VPS (see the Ollama guide — Post 114), or an OpenAI API key
- Docker and Docker Compose
- 2+ GB RAM for the WebUI itself (plus model RAM if using Ollama)
Step 1: Docker Compose Setup
<code">mkdir -p /opt/open-webui && cd /opt/open-webui nano docker-compose.yml
<code">version: '3.8'
services:
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: always
ports:
- "127.0.0.1:3000:8080"
environment:
# Connect to Ollama on the host machine
OLLAMA_BASE_URL: http://host.docker.internal:11434
# Optional: Add OpenAI API key for GPT-4, Claude, etc.
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
# Enable user registration (set to false after creating admin)
ENABLE_SIGNUP: "true"
# Default admin email (first user to register with this email becomes admin)
DEFAULT_USER_ROLE: pending # Require admin approval for new users
# RAG configuration
ENABLE_RAG_WEB_SEARCH: "true"
RAG_WEB_SEARCH_ENGINE: searxng
SEARXNG_QUERY_URL: http://searxng:8080/search?q=&format=json
volumes:
- open_webui_data:/app/backend/data
extra_hosts:
- "host.docker.internal:host-gateway" # Access host machine's Ollama
# Optional: SearXNG for web search integration
searxng:
image: searxng/searxng:latest
container_name: searxng
restart: always
ports:
- "127.0.0.1:8888:8080"
volumes:
- searxng_data:/etc/searxng
environment:
SEARXNG_SECRET_KEY: your_searxng_secret
volumes:
open_webui_data:
searxng_data:
<code">nano .env
<code">OPENAI_API_KEY=sk-your-openai-api-key-here # Optional
<code">chmod 600 .env docker compose up -d docker compose logs -f open-webui
Step 2: Nginx Reverse Proxy
<code">sudo nano /etc/nginx/sites-available/open-webui
<code">server {
listen 80;
server_name chat.yourdomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name chat.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/chat.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chat.yourdomain.com/privkey.pem;
client_max_body_size 50M; # Allow large document uploads for RAG
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Long timeout for model generation responses
proxy_read_timeout 600s;
proxy_buffering off;
}
}
<code">sudo ln -s /etc/nginx/sites-available/open-webui /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx sudo certbot --nginx -d chat.yourdomain.com
Step 3: Initial Admin Setup
- Visit
https://chat.yourdomain.com - Register the first account — this automatically becomes the admin
- Admin Panel → Users → change pending users to “User” role to grant access
- Admin Panel → Settings → disable “Enable New User Registration” if you want invite-only
Step 4: Add Model Connections
Ollama (Local Models)
- Admin Panel → Connections → Ollama → verify URL:
http://host.docker.internal:11434 - Models list auto-populates from Ollama’s installed models
OpenAI API
- Admin Panel → Connections → OpenAI → add API key
- Now GPT-4o, GPT-4o-mini, o1 appear in the model selector
Other APIs (Anthropic Claude, Google Gemini)
- Admin Panel → Connections → OpenAI-Compatible APIs
- Add: Name: Claude, URL:
https://api.anthropic.com/v1, Key: your Anthropic key - Model IDs:
claude-3-5-sonnet-20241022
Step 5: Configure RAG with Document Upload
- Start a new conversation → click the paperclip icon → upload PDF, Word, or TXT file
- The document is chunked, embedded, and stored in a vector database
- Ask questions: “What does section 3.2 say about refunds?” — model answers from the document
Configure embedding model (better RAG quality):
- Admin Panel → Documents → Embedding Model
- Select:
nomic-embed-text(from Ollama) ortext-embedding-3-small(from OpenAI)
Step 6: Web Search Integration
<code"># Configure SearXNG to allow JSON API docker exec -it searxng nano /etc/searxng/settings.yml
<code"># Add to settings.yml:
server:
secret_key: "your_searxng_secret"
search:
formats:
- html
- json # Enable JSON format for Open WebUI integration
<code">docker compose restart searxng
In a conversation, toggle the web search icon to enable real-time web search augmentation.
Step 7: System Prompts and Model Templates
<code"># Example system prompts to save as templates: # Customer support agent: "You are a helpful customer support agent for Acme Corp. Be concise, professional, and empathetic. If you cannot help, say 'I'll escalate this to our team.' Never share pricing without first checking the current catalog." # Code review assistant: "You are a senior software engineer reviewing code. Focus on: security vulnerabilities, performance issues, readability, and test coverage. Provide specific, actionable feedback with examples."
Getting Started
Open WebUI needs 500 MB–1 GB RAM on its own. Combined with Ollama running a 7B model (6 GB RAM), a VPS at VPS.DO with 8 GB RAM handles the full stack. For teams using OpenAI or Anthropic APIs (no local model), a 2 GB VPS is sufficient — Open WebUI is just a frontend that proxies API calls. The NVMe storage speeds up document embedding for RAG use cases.
Conclusion
Open WebUI provides a complete, self-hosted AI workspace: a polished chat interface, multi-model access (local Ollama models + OpenAI/Anthropic APIs), RAG with document uploads, web search integration, multi-user access control, and conversation history — all on your VPS with no data sent to third-party AI dashboard services. For teams that want a ChatGPT Team-like experience with their own models and data policies, Open WebUI on a VPS is the definitive self-hosted solution.