Installing Ollama and Open WebUI on Ubuntu 24.04: Self-Host Internal AI with 100% Data Control

Ubuntu tutorial - IT technology blog
Ubuntu tutorial - IT technology blog

Data Leakage Concerns When Sending Prompts to Cloud AI

Adopting AI in an enterprise often hits a major roadblock: data security. When employees paste source code, financial reports, or customer records into ChatGPT, that sensitive information immediately slips outside company control.

To solve this challenge, engineering teams typically weigh three approaches:

  • Commercial Cloud APIs (OpenAI, Anthropic): Top-tier model quality, deployable within minutes of integration. In return, your data is sent off-premises. A team of 30 engineers using it actively can easily rack up $200 to over $500 in token costs each month.
  • Self-hosted infrastructure with specialized inference engines (vLLM, TGI, llama.cpp): Maximizes hardware utilization and delivers high throughput when serving hundreds of concurrent connections. However, this path demands solid DevOps skills, the effort to build a custom UI, and writing your own role-based user management.
  • The Ollama + Open WebUI combo: Ollama handles downloading, managing, and running models via a clean API. Open WebUI provides an intuitive ChatGPT-like chat interface, complete with built-in authentication and RAG (document upload for Q&A).

A Practical Comparison of the Three Deployment Paths

Each approach involves clear trade-offs between upfront investment, maintenance overhead, and data security.

1. Using Commercial Cloud APIs

Pros: No need to invest in expensive graphics cards. You always get access to the latest models without managing physical servers.

Cons: Risk of leaking business secrets when employees transmit sensitive data. Monthly bills can also spike unpredictably without strict quota limits.

2. Self-Hosting a vLLM or Text Generation Inference Cluster

Pros: Blazing-fast inference speeds thanks to PagedAttention. This is the gold standard when serving thousands of concurrent requests in enterprise settings.

Cons: Complex CUDA environment setup. Engineering teams must also build or integrate a separate UI layer for non-technical staff.

3. The Ollama + Open WebUI Duo

Pros: Straightforward setup, fully deployed in about 15 minutes. Runs smoothly across CPUs as well as NVIDIA/AMD GPUs. Features built-in role-based access control (RBAC) and drag-and-drop support for PDF and DOCX files to chat directly with your docs.

Cons: A single Ollama instance will struggle with concurrent requests if more than 50 users submit prompts simultaneously.

When Should You Choose Ollama with Open WebUI?

This stack is ideal for teams of 10–50 people or research labs that require a private sandbox environment. You get a user-friendly interface ready for non-technical departments while keeping all company data strictly confined to your local network.

From hands-on deployments across multiple Ubuntu servers, I have found that Ubuntu 24.04 LTS (Noble Numbat) with Linux kernel 6.8 detects GPU drivers and maps them into containers with rock-solid stability. Packaging Open WebUI inside Docker keeps the host OS clean and prevents Python library conflicts.

Step-by-Step Deployment on Ubuntu 24.04

Step 1: Install Official Docker Engine from Upstream

First, SSH into your Ubuntu 24.04 server with sudo privileges. Update your system and add the official Docker repository:

# Update repositories and install prerequisites
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl ca-certificates gnupg

# Add Docker's official GPG key
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

# Set up the repository for Ubuntu 24.04 (noble)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Engine and Compose plugin
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Add current user to the docker group to run containers without sudo
sudo usermod -aG docker $USER
newgrp docker

Step 2: Install and Configure Ollama to Accept Container Connections

Running Ollama natively as a systemd service maximizes GPU utilization and prevents virtualization overhead across software networking layers.

# Install Ollama using the official script
curl -fsSL https://ollama.com/install.sh | sh

By default, Ollama only listens on 127.0.0.1:11434. If left as-is, the Open WebUI container cannot reach this API via the host gateway. You need to bind it to the Docker bridge network by creating a systemd service override:

# Create an environment override file for Ollama
sudo systemctl edit ollama.service

Add the following two lines between the comment blocks:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Save the file and restart the service:

sudo systemctl daemon-reload
sudo systemctl restart ollama

# Verify that the service is listening on the expected port
sudo ss -tulpn | grep 11434

Step 3: Download Models Suitable for Your Hardware

Model selection directly depends on your GPU VRAM or available system RAM:

  • 16GB RAM or 8GB–12GB GPU (RTX 3060, 4060): Smoothly runs 4-bit quantized versions (Q4_K_M) of qwen2.5:7b or llama3.1:8b.
  • 16GB–24GB GPU (RTX 3090, 4090, A4000): Easily handles 14B models like qwen2.5:14b for superior coding and reasoning capabilities.

Download and test the Qwen 2.5 7B model (which offers excellent multilingual performance):

# Pull the model
ollama pull qwen2.5:7b

# Check local storage usage
ollama list

# Test run a prompt directly from the terminal
ollama run qwen2.5:7b "Summarize 3 advantages of Docker bridge network in 3 bullet points:"

Step 4: Deploy Open WebUI Using Docker Compose

Create a dedicated working directory to organize configuration files and persistent data:

mkdir -p ~/ai-stack && cd ~/ai-stack
nano docker-compose.yml

Paste the following configuration into your docker-compose.yml file:

services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: always
    ports:
      - "127.0.0.1:3000:8080"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      - OLLAMA_BASE_URL=http://host.docker.internal:11434
      - WEBUI_AUTH=True
    volumes:
      - open-webui-data:/app/backend/data

volumes:
  open-webui-data:
    driver: local

Start the container:

docker compose up -d

Notice the port binding: we bind to 127.0.0.1:3000 instead of 0.0.0.0:3000. This prevents the web interface from being exposed directly to the public Internet and automated botnet scanners.

Step 5: Establish a Secure Connection via SSH Tunnel

Instead of exposing ports on your VPS firewall, connect securely using SSH Port Forwarding from your local machine:

# Run this command on your local machine
ssh -N -L 8080:127.0.0.1:3000 user@your-server-ip

Now, open your browser and navigate to http://localhost:8080.

The first account you register automatically receives Admin privileges. Immediately after creating the admin account, navigate to Admin Panel > Settings > General and turn off Enable New Sign Ups. This prevents unauthorized users from registering accounts.

All chat history, RAG documents, and vector embeddings are stored locally within the open-webui-data volume on the server. Your queries circulate entirely on-premises—not a single byte of data leaves your control.

Share: