Ollama gives you a local model runtime and an HTTP API. Open WebUI gives you a browser chat interface in front of that API: conversations, model switching and, if you enable them, extra features such as accounts. Together they are a common self-hosted “ChatGPT-style” stack on a VPS.
This article is the UI and Compose layer, not a second copy of how to host Ollama on a VPS. Read that guide for CPU vs GPU, model sizing and keeping the Ollama API private. Then use the steps below to put Open WebUI in front of it with Docker Compose.
What you need before Compose
- A Linux VPS with Docker Engine and the Compose plugin installed. The general container notes in VPS hosting for Docker still apply.
- Enough RAM and, if you will run mid-size or large models locally, a GPU that fits the model. Size VRAM with the VRAM guide, and use a CPU VPS only when a small model or a remote API is enough, as discussed in GPU VPS vs CPU VPS.
- A domain and a reverse proxy with TLS if anyone will open the UI from the internet. Do not leave the UI or port 11434 open without authentication.
- Disk space for model files and for Open WebUI’s data volume. Model pulls fail in dull ways when the disk is full; see how to fix a disk-full VPS.
A Compose file that runs both services
Open WebUI’s documented Docker run command publishes container port 8080 on host port 3000, stores data in a volume at /app/backend/data, and expects a long random WEBUI_SECRET_KEY. When Ollama runs in the same Compose project, point Open WebUI at the service name on port 11434 instead of host.docker.internal.
Create a directory, for example /opt/open-webui, and a docker-compose.yml along these lines. Generate the secret with openssl rand -hex 32 and put it in a .env file that is not committed anywhere public:
services:
ollama:
image: ollama/ollama:latest
volumes:
- ollama:/root/.ollama
restart: unless-stopped
open-webui:
image: ghcr.io/open-webui/open-webui:main
ports:
- "127.0.0.1:3000:8080"
environment:
OLLAMA_BASE_URL: http://ollama:11434
WEBUI_SECRET_KEY: ${WEBUI_SECRET_KEY}
volumes:
- open-webui:/app/backend/data
depends_on:
- ollama
restart: unless-stopped
volumes:
ollama:
open-webui:
Binding 127.0.0.1:3000 is deliberate. The UI should be reached through a local reverse proxy, not published on 0.0.0.0. Ollama has no host port in this file, so the model API is reachable only on the Docker network, which is what you want.
If you have an NVIDIA GPU and the NVIDIA Container Toolkit is already working, attach the GPU to the Ollama service with the Compose device reservation your Docker version supports (the deploy.resources.reservations.devices form, or the equivalent gpus flag). Confirm with docker compose exec ollama nvidia-smi before you pull a large model. If that command fails, fix the toolkit and the driver; more Compose YAML will not invent a GPU.
Start, pull a model and sign in
cd /opt/open-webui
docker compose up -d
docker compose logs -f --tail=80
When both containers are healthy, pull a model from the Ollama service, starting with something small enough for the machine:
docker compose exec ollama ollama pull llama3.2
docker compose exec ollama ollama list
Use whatever model name you actually intend to run; the command above is an example, not a recommendation. Open http://127.0.0.1:3000 over an SSH tunnel first, create the admin account immediately, and disable open signup if you are not running a public community. The first account created is typically the admin; do not leave that step for later on a host that will have a public DNS name.
Put TLS and access control in front
Point a hostname at the VPS, issue a certificate, and proxy to 127.0.0.1:3000. Nginx, Caddy or another reverse proxy is fine. Terminate TLS at the proxy, send the usual forwarding headers, and do not proxy Ollama’s 11434 port at all. The firewall and SSH advice in the VPS security guide applies: allow 443 (and 22 from your IP if you can), and keep 3000 and 11434 off the public interface.
Optional but useful: HTTP basic auth or an SSO layer in front of Open WebUI, plus the app’s own login. One lock is not as good as two if the UI will be on the internet. If you only need access from your laptop, skip public DNS and use an SSH tunnel or a VPN such as the one in the WireGuard VPS guide.
What usually breaks
- Open WebUI cannot see any models. Check
OLLAMA_BASE_URL. Inside Compose it should behttp://ollama:11434, notlocalhost(that would be the UI container itself) and not a host-gateway address unless Ollama runs on the host rather than in Compose. - The UI is public and unauthenticated. Confirm the port bind, the proxy, and that you created the admin user and closed signup.
- Pulls fail or the model is “loaded” but replies are tiny and slow. Recheck disk space, RAM and VRAM. CPU-only inference of a mid-size model can look like a hang.
- Data vanishes after a recreate. The named volumes in the Compose file are required. Do not switch to ephemeral containers for either service.
Once the chat UI is stable, you can point other tools at Ollama only on the internal network, or keep using Open WebUI as the only front door. If you later need a high-concurrency API rather than a personal UI, compare runtimes in vLLM vs Ollama before you expose anything new.
Frequently asked questions
Can I run Open WebUI on one VPS and Ollama on another?
Yes. Set OLLAMA_BASE_URL to the internal URL of the Ollama host and protect that API with a network policy, a tunnel, or a reverse proxy that requires a credential. Do not put Ollama on a public port just to make the UI work.
Do I have to use Docker Compose?
No. The official docs also show a single docker run command for Open WebUI, with Ollama on the host and host.docker.internal:11434 as the default API address. Compose is easier to restart, back up and keep aligned on a VPS.
Which host port should I publish?
The container listens on 8080. The documented examples map that to host port 3000. Mapping to 127.0.0.1 keeps it off the public interface. You can use another free host port if 3000 is taken; change the proxy accordingly.
Does Open WebUI replace Ollama’s authentication?
No. Ollama’s API is plain HTTP by default. Keep it off the public internet and treat Open WebUI’s login (and any proxy auth) as the human front door, not as protection for a publicly exposed 11434 port.
How do I back this stack up?
Back up both volumes, plus your Compose file and .env. The model volume is large; the Open WebUI volume holds users and chat history. A volume snapshot or docker compose down followed by a consistent copy is safer than copying files from a running container.