Back to tutorials
Tutorial

Run Open WebUI On a VPS With Caddy and HTTPS

Run Open WebUI on a VPS with Docker + Caddy for automatic HTTPS, safe auth, and a clean chat UI for your own models.

By Anurag Singh
Updated on Nov 29, 2026
Category: Tutorial
Share article
Run Open WebUI On a VPS With Caddy and HTTPS

A self-hosted chat UI only matters if it’s reachable and encrypted. It also needs safe defaults so you don’t accidentally expose it to random internet traffic. This tutorial shows how to run Open WebUI on a VPS with Docker and Caddy.

By the end, you’ll have a URL like https://chat.example.com. Caddy will terminate TLS and reverse-proxy to Open WebUI on a private Docker network. You’ll also connect an Ollama backend (on the same VPS) and add guardrails like firewall rules, request limits, and basic hardening.

What you’ll build (and what it isn’t)

  • Open WebUI running in Docker
  • Caddy in front, issuing and renewing TLS certificates automatically
  • Ollama as the model runtime (local to the VPS in this guide)
  • Safe defaults: closed ports, controlled exposure, and predictable paths

This is not a GPU performance guide. If you need an OpenAI-compatible API at scale, start with an inference server built for that job. Then put a UI on top.

For that approach, see Set Up vLLM OpenAI API on a GPU Dedicated Server.

Infrastructure requirements (honest sizing)

Open WebUI is lightweight. Inference is what burns CPU and RAM.

  • VPS OS: Ubuntu 24.04 LTS or Debian 12 (commands below assume Ubuntu)
  • CPU-only minimum: 2 vCPU / 4 GB RAM for UI + small models (expect slow tokens/sec)
  • Comfortable CPU-only: 4 vCPU / 8–16 GB RAM for typical 7B-class quantized models
  • Disk: 30–60 GB free (models and Docker layers add up fast)
  • GPU (optional): not required for this tutorial. If you have one, you’ll likely run a larger model or get better latency.

If you’re picking a server, a standard HostMyCode VPS is enough for a private UI and small-to-medium models.

If this is headed toward a production chatbot with steadier latency, step up to HostMyCode dedicated servers. This matters even more if you’re adding GPU inference.

Prerequisites

  • A domain/subdomain you control (example: chat.example.com)
  • DNS A/AAAA record pointing to your VPS IP
  • Root or sudo access to the VPS

If DNS isn’t pointed at your VPS yet, do that first. Then wait for propagation.

If you still need to register a domain, HostMyCode Domains keeps registration and renewals in one place.

Step 1: Prepare the VPS (updates, firewall, basic tooling)

SSH into the server and update packages:

sudo apt update
sudo apt -y upgrade

Install the small set of tools used later for checks and firewalling:

sudo apt -y install ca-certificates curl ufw

Enable UFW and allow only SSH plus HTTP/HTTPS. If you use a non-standard SSH port, adjust the rule.

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw --force enable
sudo ufw status verbose

Leave port 3000 closed to the internet. Caddy should be your only public entry point.

Step 2: Install Docker and Docker Compose plugin

On Ubuntu, Docker’s official repo is the most predictable option. First remove conflicting packages (if any):

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt -y remove $pkg; done

Add Docker’s repo and install:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] 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 -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Verify:

docker --version
docker compose version

(Optional) If you want to run Docker without sudo:

sudo usermod -aG docker $USER
newgrp docker

Step 3: Create a clean directory layout

Keep everything under /opt. It’s easier to back up, migrate, and reason about later.

sudo mkdir -p /opt/openwebui/{caddy,data}
sudo chown -R $USER:$USER /opt/openwebui
cd /opt/openwebui

We’ll store:

  • Open WebUI persistent data in /opt/openwebui/data
  • Caddy config and certificates in a Docker volume (recommended)

Step 4: Bring up Ollama (local model runtime)

Open WebUI talks to Ollama over HTTP. Running both in the same Compose stack keeps networking simple.

It also avoids exposing extra ports.

Create docker-compose.yml:

nano /opt/openwebui/docker-compose.yml
services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    volumes:
      - ollama:/root/.ollama
    networks:
      - internal

  openwebui:
    image: ghcr.io/open-webui/open-webui:latest
    container_name: openwebui
    restart: unless-stopped
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
      - WEBUI_AUTH=true
      - WEBUI_NAME=Open WebUI
    volumes:
      - ./data:/app/backend/data
    depends_on:
      - ollama
    networks:
      - internal

  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - internal

volumes:
  ollama:
  caddy_data:
  caddy_config:

networks:
  internal:
    driver: bridge

Notes:

  • ollama is not published to the host. Only other containers can reach it.
  • openwebui is also not published to the host. Caddy proxies to it.
  • WEBUI_AUTH=true prevents an accidentally open chat UI.

Step 5: Configure Caddy for automatic TLS and reverse proxy

Create a Caddyfile. Replace chat.example.com with your hostname.

nano /opt/openwebui/caddy/Caddyfile
chat.example.com {
  encode zstd gzip

  # Basic security headers
  header {
    Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
    X-Content-Type-Options "nosniff"
    X-Frame-Options "DENY"
    Referrer-Policy "strict-origin-when-cross-origin"
    Permissions-Policy "geolocation=(), microphone=(), camera=()"
  }

  # Keep request sizes reasonable
  request_body {
    max_size 20MB
  }

  # Reverse proxy to Open WebUI container
  reverse_proxy openwebui:8080 {
    header_up X-Forwarded-Proto {scheme}
    header_up X-Forwarded-Host {host}
    header_up X-Real-IP {remote_host}
  }

  # Simple abuse guard: rate limit by IP
  rate_limit {
    zone webui {
      key {remote_host}
      events 120
      window 1m
    }
  }
}

About rate_limit: In Caddy this requires the rate limit module in some builds. If your Caddy image doesn’t support it, remove that block. Then rely on firewalling plus application auth. Keep the rest of the Caddyfile.

Step 6: Start the stack and verify certificates

Start everything:

cd /opt/openwebui
docker compose up -d

Follow the Caddy logs while it requests certificates:

docker logs -f caddy

Confirm Caddy can reach Open WebUI over the internal network:

docker exec -it caddy sh -lc "wget -qO- http://openwebui:8080 | head"

Visit https://chat.example.com.

In most default setups, the first user you create becomes the admin. Use a long password. Don’t treat it like a throwaway account.

Step 7: Pull a model and run your first chat

Enter the Ollama container and pull a small model. This validates the full path end-to-end.

Pick a model that fits your RAM. Smaller quantized models are the safest first test.

docker exec -it ollama ollama pull llama3

If that model name doesn’t exist in your environment, list what’s available in Ollama’s registry. Then pick a smaller option (or use a model you already trust). Confirm what’s installed:

docker exec -it ollama ollama list

In the Open WebUI interface:

  1. Open Settings → Models (or the model selector)
  2. Select your newly pulled model
  3. Send a simple prompt like: “Write a one-paragraph status page update for a database outage.”

Slow responses are normal on CPU. Smaller models, more cores, or GPU acceleration make a big difference.

Step 8: Make it production-safe on a real VPS

A public AI UI gets probed quickly. Keep it private-by-default.

Only open what you actually need.

Keep backend ports private

This Compose file does not publish 11434 (Ollama) or 8080 (Open WebUI) to the host. That’s deliberate.

Confirm it:

docker ps --format "table {{.Names}}\t{{.Ports}}"

You should see ports only for caddy.

Optional: restrict access to office/home IPs

If this is only for your team, IP allowlisting is simple and effective.

In UFW, allow 443 only from known IPs and remove the general rule. Example (replace 203.0.113.10):

sudo ufw delete allow 443/tcp
sudo ufw allow from 203.0.113.10 to any port 443 proto tcp
sudo ufw allow from 203.0.113.11 to any port 443 proto tcp
sudo ufw status numbered

If you need private access without pinning IPs, a tunnel is usually the cleanest route. HostMyCode has a walkthrough for private admin access patterns via Cloudflare Tunnel: Set Up Cloudflare Tunnel on a VPS for Private Admin.

Add brute-force protection (recommended)

Even with auth enabled, your login page is still public. An IPS reduces scan noise and lowers risk.

CrowdSec is a practical fit for internet-facing VPS hosts.

Follow: Install CrowdSec on Ubuntu VPS to Block Bruteforce.

Enable automatic container updates (carefully)

For internal tooling, auto-updates can be fine. You just need to accept occasional surprises.

If you go that route, use Watchtower and set a maintenance window.

See: Docker Compose Auto-Updates With Watchtower on a VPS.

Step 9: Backups and upgrades you’ll actually use

Open WebUI state lives in /opt/openwebui/data. Models live in the Docker volume ollama.

Back up both if recovery time matters.

Back up Open WebUI data directory

sudo tar -C /opt -czf /root/openwebui-data-$(date +%F).tar.gz openwebui/data

Back up the Ollama models volume

This exports the volume contents to a tarball. Expect it to be large.

sudo docker run --rm \
  -v openwebui_ollama:/volume \
  -v /root:/backup \
  alpine sh -lc "cd /volume && tar -czf /backup/ollama-volume-$(date +%F).tar.gz ."

If your disk is tight, you can hit “no space left on device” during backups. Fix storage first. Then download models.

This diagnostic helps: Disk Full on VPS: Find Large Files and Free Space Safely.

Upgrade the stack

From /opt/openwebui:

docker compose pull
docker compose up -d
docker image prune -f

Don’t prune blindly if you rely on rollback images.

If uptime matters, keep a small change log. Upgrade during a quiet window.

Troubleshooting: quick checks that save time

Caddy won’t issue a certificate

  • Confirm DNS points to the VPS: dig +short chat.example.com
  • Ensure ports 80 and 443 are open in UFW and your provider firewall
  • Check for another service already bound to 80/443: sudo ss -lntp | egrep ':80|:443'
  • Read Caddy logs: docker logs --tail=200 caddy

Open WebUI loads but models don’t respond

  • Confirm Ollama is running: docker logs --tail=200 ollama
  • Check Open WebUI can reach it: docker exec -it openwebui sh -lc "wget -qO- http://ollama:11434/api/tags"
  • Watch RAM usage; the kernel may be killing processes: dmesg -T | tail -n 50

It’s painfully slow on CPU

  • Use a smaller model or more aggressive quantization
  • Increase VPS cores and RAM
  • Move inference to a GPU host and keep the UI on a smaller VPS

If you want to make quantized models for Ollama specifically, follow Quantize Llama Models for Ollama on a VPS.

Step 10: Optional improvements (practical add-ons)

Run Open WebUI on a VPS, inference elsewhere

A common pattern is simple: Open WebUI on a small VPS (public), inference on a private GPU server (not public). Connect them over a VPN or private network.

This keeps your expensive inference endpoint off the open internet.

If you do expose an OpenAI-style inference API, put it behind a proper reverse proxy and authentication layer. Start here: vLLM Behind Nginx: OpenAI API on a GPU Server.

Add RAG (search your docs) later

RAG pays off quickly for operators. It makes runbooks, internal docs, and tickets searchable from the chat UI.

If that’s your next step, pgvector is a straightforward fit on VPS infrastructure.

Follow: Open WebUI RAG With pgvector on a VPS.

If you want a clean place to host private AI tools, start with a VPS that delivers consistent CPU and disk performance. A HostMyCode VPS is a solid fit for Open WebUI + Ollama on CPU, and you can move inference later without rebuilding the UI.

If you don’t want to own OS patching, firewall tuning, and Docker upkeep, use managed VPS hosting and spend your time on models and workflows instead.

FAQ

Can I expose Open WebUI without authentication?

You can, but it’s a bad idea. A public, unauthenticated AI UI becomes a spam magnet quickly. It can also burn compute. Keep WEBUI_AUTH=true and restrict access if it’s internal.

Do I need a GPU to run Open WebUI on a VPS?

No. The UI itself runs fine on CPU. A GPU only changes inference speed and the model sizes you can run comfortably. If you want fast replies or larger models, plan for GPU inference.

Where is Open WebUI data stored in this setup?

In /opt/openwebui/data on the VPS. Back it up along with your ollama Docker volume if you want to keep downloaded models.

What ports must be open on the VPS firewall?

Only 80/tcp and 443/tcp for Caddy, plus your SSH port. Do not open Ollama’s port publicly.

Summary

You now have Open WebUI behind Caddy with automatic HTTPS. Backend ports are not exposed directly.

You also have a sensible baseline for operating it on a VPS.

From here, keep it private for internal use, add RAG, or split inference onto a GPU box.

If you want a straightforward starting point that can grow later, deploy this on a HostMyCode VPS. If it’s becoming a team tool with uptime expectations, managed VPS hosting cuts the ops load while keeping your stack under your control.