Architecture
VPS
├── Ollama (port 11434) — LLM inference
├── Open WebUI (port 3000) — Chat interface
└── n8n (port 5678) — Workflow automation
└── calls Ollama via the internal networkAll three communicate over a private Docker network. Only the web interfaces are exposed publicly, behind Nginx and HTTPS.
Requirements
- VPS with 8 GB RAM minimum (16 GB recommended)
- Ubuntu 22.04 or 24.04
- A domain name
Step 1: Install Docker
apt update && apt upgrade -y
curl -fsSL https://get.docker.com | sh
apt install -y docker-compose-pluginStep 2: Install Ollama
curl -fsSL https://ollama.com/install.sh | shConfigure it for Docker network access:
mkdir -p /etc/systemd/system/ollama.service.d
cat > /etc/systemd/system/ollama.service.d/override.conf << EOF
[Service]
Environment="OLLAMA_HOST=0.0.0.0"
EOF
systemctl daemon-reload && systemctl restart ollamaPull a model:
ollama pull llama3.1:8bStep 3: Deploy the Full Stack
mkdir ~/ai-stack && cd ~/ai-stack
nano docker-compose.ymlversion: '3.8'
services:
open-webui:
image: ghcr.io/open-webui/open-webui:main
restart: always
ports:
- "3000:8080"
environment:
- OLLAMA_BASE_URL=http://host.docker.internal:11434
volumes:
- open-webui-data:/app/backend/data
extra_hosts:
- "host.docker.internal:host-gateway"
n8n:
image: n8nio/n8n:latest
restart: always
ports:
- "5678:5678"
environment:
- N8N_HOST=n8n.yourdomain.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://n8n.yourdomain.com/
- GENERIC_TIMEZONE=UTC
volumes:
- n8n-data:/home/node/.n8n
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
open-webui-data:
n8n-data:docker compose up -dStep 4: Configure Nginx
apt install -y nginx certbot python3-certbot-nginxCreate configs for both services:
for subdomain in ai n8n; do
cat > /etc/nginx/sites-available/$subdomain << EOF
server {
server_name $subdomain.yourdomain.com;
location / {
proxy_pass http://localhost:$([ "$subdomain" = "ai" ] && echo "3000" || echo "5678");
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
}
}
EOF
ln -s /etc/nginx/sites-available/$subdomain /etc/nginx/sites-enabled/
done
certbot --nginx -d ai.yourdomain.com -d n8n.yourdomain.com
nginx -t && systemctl reload nginxStep 5: Connect n8n to Ollama
In n8n, create an HTTP Request node pointed at http://host.docker.internal:11434/api/generate. This lets your workflows call your local LLM directly — summarize documents, classify inputs, generate responses — without any external API.
What This Costs
A single NoctHost Pro VPS (4 vCPU, 8 GB RAM) handles this entire stack at $62/month. Compared to paying for ChatGPT Team ($25/user/month), n8n Cloud ($20/month), and API costs on top — this pays for itself quickly for any team running more than a few hundred AI-powered workflows per month.