How to install Ollama and Open WebUI on a Linux VPS A developer published a step-by-step guide for deploying Ollama 0.40.18 and Open WebUI v0.13.4 on an Ubuntu 24.04 VPS using Docker Compose and Caddy for automatic HTTPS. The setup keeps Ollama's unauthenticated port 11434 on a private Docker network, requires a WEBUI_SECRET_KEY, and disables public signups after the first admin account is created. The guide also maps 4-bit quantized model sizes to VPS memory tiers, recommending 12 GB of RAM for 7B-8B models to avoid OOM kills. Running Ollama with Open WebUI on your own Linux VPS gives you a private AI chat interface and a local model API with flat monthly costs and zero third-party data sharing. This guide deploys Ollama 0.40.18 and Open WebUI v0.13.4 on an Ubuntu 24.04 VPS using Docker Compose and Caddy for automatic HTTPS — keeping port 11434 isolated on the private Docker network and locking public signups right after creating your admin account. Every image tag, environment variable and healthcheck below matches the upstream v0.40.18 Ollama release envconfig/config.go and Dockerfile and v0.13.4 Open WebUI release docker-compose.yaml , backend/open webui/env.py , config.py and Dockerfile . Before deploying, set realistic expectations: on a standard Linux VPS vCPUs and RAM, no dedicated GPU , Ollama runs inference on CPU using system memory bandwidth. That works well for: A CPU-only VPS is not built for dozens of concurrent chat users or 32B/70B models. The table below summarizes practical 4-bit quantized Q4 K M , Ollama's default model sizes by VPS memory: | VPS tier CPU | Comfortable models Q4 | Recommended workload | |---|---|---| | 4 GB RAM · 2 vCPU | 1B to 3B models llama3.2:3b | Quick tests, embeddings nomic-embed-text and light triage | | 8 GB RAM · 4 vCPU | 3B to 4B models qwen3:4b , gemma3:4b | Daily single-user chat in Open WebUI with safe memory headroom | | 12 GB RAM · 6 vCPU | 7B to 8B models qwen2.5:7b , llama3.1:8b | Production Open WebUI, RAG and n8n workflows without OOM kills | | 24 GB RAM · 8 vCPU | 14B models or 8B with larger context windows | Small team usage, longer context and other stacks on the host | Memory rule of thumb. A 4-bit 8B model needs roughly 5 GB to 6 GB of RAM just for weights, plus KV context cache, the Open WebUI backend ~600 MB to 1 GB and the OS. On an 8 GB VPS, an 8B model runs right on the edge; 12 GB of RAM leaves genuine headroom so the Linux OOM killer does not terminate Ollama mid-generation. The most common mistake when self-hosting Ollama on a VPS is publishing port 11434 on 0.0.0.0 . Ollama has no built-in authentication : anyone scanning your IP can pull arbitrary models, fill your disk and peg your CPU at 100%. In this setup, only Caddy binds ports 80 and 443 on the host. Open WebUI 8080 and Ollama 11434 communicate exclusively over the private Docker Compose network: Four details prevent the usual first-day pitfalls: WEBUI SECRET KEY is required in Open WebUI v0.13.4 : docker-compose.yaml leaves it blank, but env.py explicitly aborts startup when WEBUI AUTH=True and ollama list : ollama/ollama:0.40.18 Ubuntu 24.04 image does not bundle curl or wget . Running 11434 is ready. OLLAMA MAX LOADED MODELS=1 and OLLAMA NUM PARALLEL=1 : ENABLE SIGNUP=true stays on only while you create the first account automatically promoted to Admin , then switches to false . v2.20+ , ideally ufw allowing only 22/tcp , 80/tcp and 443 TCP/UDP . A record pointing to the VPS IPv4 ia.example.com in the examples below . If Docker and ufw are not configured yet, start with the server setup in How to install n8n with Docker on a VPS https://nuvits.net/en/blog/install-n8n-docker-vps . .env Create the stack directory and generate a strong random WEBUI SECRET KEY : mkdir -p ~/ollama-webui && cd ~/ollama-webui openssl rand -hex 32 Create .env with your domain, email and generated secret key: ini .env OLLAMA VERSION=0.40.18 OPEN WEBUI VERSION=v0.13.4 CADDY VERSION=2.11 WEBUI DOMAIN=ia.example.com ACME EMAIL= you@example.com mailto:you@example.com WEBUI URL= https://ia.example.com https://ia.example.com WEBUI SECRET KEY=paste-your-64-char-hex-key-here ENABLE SIGNUP=true DEFAULT USER ROLE=pending OLLAMA KEEP ALIVE=5m OLLAMA MAX LOADED MODELS=1 OLLAMA NUM PARALLEL=1 OLLAMA CONTEXT LENGTH=4096 Lock down file permissions on .env : bash chmod 600 .env What each Ollama guard in .env controls: OLLAMA KEEP ALIVE=5m : OLLAMA CONTEXT LENGTH=4096 : 8192 on 12 GB or 24 GB tiers if needed . Caddyfile Caddy provisions and renews the TLS certificate automatically and proxies both streamed chat responses and WebSockets to Open WebUI: caddy Caddyfile { email {$ACME EMAIL} } {$WEBUI DOMAIN} { encode zstd gzip reverse proxy open-webui:8080 } Create docker-compose.yml This Compose file pins tested tags, keeps ollama and open-webui off the host network interface and waits for Ollama to become healthy before starting the UI: yaml docker-compose.yml services: caddy: image: caddy:${CADDY VERSION} restart: unless-stopped ports: - "80:80" - "443:443" - "443:443/udp" environment: - WEBUI DOMAIN=${WEBUI DOMAIN} - ACME EMAIL=${ACME EMAIL} volumes: - ./Caddyfile:/etc/caddy/Caddyfile:ro - caddy data:/data - caddy config:/config depends on: open-webui: condition: service healthy ollama: image: ollama/ollama:${OLLAMA VERSION} restart: unless-stopped environment: - OLLAMA KEEP ALIVE=${OLLAMA KEEP ALIVE} - OLLAMA MAX LOADED MODELS=${OLLAMA MAX LOADED MODELS} - OLLAMA NUM PARALLEL=${OLLAMA NUM PARALLEL} - OLLAMA CONTEXT LENGTH=${OLLAMA CONTEXT LENGTH} volumes: - ollama data:/root/.ollama healthcheck: test: "CMD", "ollama", "list" interval: 15s timeout: 5s retries: 10 start period: 15s open-webui: image: ghcr.io/open-webui/open-webui:${OPEN WEBUI VERSION} restart: unless-stopped environment: - OLLAMA BASE URL=http://ollama:11434 - WEBUI SECRET KEY=${WEBUI SECRET KEY} - WEBUI URL=${WEBUI URL} - ENABLE SIGNUP=${ENABLE SIGNUP} - DEFAULT USER ROLE=${DEFAULT USER ROLE} volumes: - open webui data:/app/backend/data depends on: ollama: condition: service healthy volumes: caddy data: caddy config: ollama data: open webui data: No host ports: on Ollama or Open WebUI. The ghcr.io/open-webui/open-webui:v0.13.4 image already ships a built-in HEALTHCHECK against http://localhost:8080/health , so Caddy waits until the backend is ready. Never add "11434:11434" to ollama , because Docker bypasses ufw — see Docker port still open with ufw https://nuvits.net/en/blog/docker-port-still-open-with-ufw . Validate the Compose configuration and bring the stack up: cd ~/ollama-webui sudo docker compose config --quiet sudo docker compose up -d sudo docker compose ps The first Open WebUI startup takes 1 to 2 minutes while it initializes its SQLite database and assets inside /app/backend/data . Wait until both ollama and open-webui show Up healthy . Now pull a model that fits your VPS memory directly inside the Ollama container. For a fast smoke test on any 4 GB+ server, start with llama3.2:3b ; on 12 GB+ servers, pull a 7B/8B model such as qwen2.5:7b : sudo docker compose exec ollama ollama pull llama3.2:3b On a 12 GB+ VPS: sudo docker compose exec ollama ollama pull qwen2.5:7b Verify the downloaded model and run a quick CLI check before opening the browser: sudo docker compose exec ollama ollama list sudo docker compose exec ollama ollama run llama3.2:3b "Reply in one short sentence: is the server working?" Check the HTTPS health endpoint through Caddy: curl -fsS https://ia.example.com/health You should get {"status":true} . Next: https://ia.example.com in your browser and register the first user — Open WebUI automatically grants ENABLE SIGNUP=false in open-webui : sed -i 's/^ENABLE SIGNUP=true$/ENABLE SIGNUP=false/' .env sudo docker compose up -d open-webui Verify that no internal port leaked onto public host interfaces: sudo ss -tulpn | grep -E ': 80|443|8080|11434 \b' Only ports 80 and 443 should be listening publicly. To call your local models from workflows or another server without opening port 11434 : http://ollama:11434 . https://ia.example.com/api/chat/completions with Authorization: Bearer