{"id":1875,"date":"2026-09-05T09:36:02","date_gmt":"2026-09-05T04:06:02","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-self-host-ollama-private-llm-cloud-vps\/"},"modified":"2026-09-05T12:58:44","modified_gmt":"2026-09-05T07:28:44","slug":"how-to-self-host-ollama-private-llm-cloud-vps","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-self-host-ollama-private-llm-cloud-vps\/","title":{"rendered":"How to Self-Host Ollama and Open WebUI on Cloud Linux VPS (Private AI Assistant)"},"content":{"rendered":"<h2>The Case for Self-Hosted and Private Artificial Intelligence<\/h2>\n<p>While commercial AI platforms like OpenAI ChatGPT and Anthropic Claude provide capable intelligence, sending proprietary enterprise data, confidential source code, customer records, and internal emails to external third-party cloud servers poses severe data privacy and compliance risks. Furthermore, monthly subscription fees and token-based API billing escalate rapidly as usage expands across development teams.<\/p>\n<p><strong>Ollama<\/strong> is the leading open-source framework for running state-of-the-art Large Language Models (LLMs)\u2014including Meta Llama 3, Mistral, DeepSeek Coder, and Google Gemma\u2014locally on CPU and GPU infrastructure. Paired with <strong>Open WebUI<\/strong> (a feature-rich ChatGPT-style web interface with RAG document uploads, web browsing, and multi-model arena chats), you can deploy a 100% private, self-hosted AI assistant on your cloud VPS with zero token fees.<\/p>\n<p>In this technical tutorial, we will configure Ollama on Ubuntu 24.04\/22.04 LTS, download optimized quantized models, deploy Open WebUI via Docker Compose, and configure an Nginx reverse proxy with SSL encryption.<\/p>\n<h2>Step 1: Installing Ollama on Ubuntu Linux VPS<\/h2>\n<p>Install Ollama using the official automated installation binary:<\/p>\n<pre><code># Download and install Ollama core engine\ncurl -fsSL https:\/\/ollama.com\/install.sh | sh\n\n# Verify Ollama service is active\nsudo systemctl status ollama --no-pager<\/code><\/pre>\n<h2>Step 2: Configuring Ollama for Internal Network Listening<\/h2>\n<p>By default, Ollama only listens on <code>127.0.0.1:11434<\/code>. To allow Docker containers (like Open WebUI) to communicate with Ollama, configure systemd environment overrides in <code>\/etc\/systemd\/system\/ollama.service.d\/override.conf<\/code>:<\/p>\n<pre><code># Create systemd override directory\nsudo mkdir -p \/etc\/systemd\/system\/ollama.service.d\n\n# Add host binding configuration\nsudo tee \/etc\/systemd\/system\/ollama.service.d\/override.conf &lt;&lt; 'EOF'\n[Service]\nEnvironment=\"OLLAMA_HOST=0.0.0.0:11434\"\nEnvironment=\"OLLAMA_ORIGINS=*\"\nEnvironment=\"OLLAMA_NUM_PARALLEL=4\"\nEOF\n\n# Reload systemd and restart Ollama\nsudo systemctl daemon-reload\nsudo systemctl restart ollama<\/code><\/pre>\n<h2>Step 3: Downloading Optimized Open-Source LLMs<\/h2>\n<p>Pull high-performance 4-bit quantized (Q4_K_M) models tailored for your server&#8217;s available RAM:<\/p>\n<pre><code># For 4GB to 8GB RAM VPS: Llama 3 8B or Mistral 7B\nollama pull llama3:8b\nollama pull mistral:7b\n\n# For Code Autocompletion &amp; Programming: DeepSeek Coder 6.7B\nollama pull deepseek-coder:6.7b\n\n# Test model execution inside terminal\nollama run llama3:8b \"Explain how Nginx reverse proxy works in 3 sentences.\"<\/code><\/pre>\n<h2>Step 4: Deploying Open WebUI with Docker Compose<\/h2>\n<p>Create a dedicated directory <code>\/var\/www\/ai-webui<\/code> and create <code>docker-compose.yml<\/code>:<\/p>\n<pre><code>services:\n  open-webui:\n    image: ghcr.io\/open-webui\/open-webui:main\n    container_name: open-webui\n    restart: always\n    ports:\n      - \"127.0.0.1:8080:8080\"\n    extra_hosts:\n      - \"host.docker.internal:host-gateway\"\n    environment:\n      - OLLAMA_BASE_URL=http:\/\/host.docker.internal:11434\n      - WEBUI_SECRET_KEY=SuperSecureRandomAiKey2026!\n      - ENABLE_RAG_WEB_SEARCH=true\n      - RAG_WEB_SEARCH_ENGINE=duckduckgo\n    volumes:\n      - open_webui_data:\/app\/backend\/data\n    deploy:\n      resources:\n        limits:\n          memory: 1024M\n\nvolumes:\n  open_webui_data:<\/code><\/pre>\n<p>Launch the container fleet:<\/p>\n<pre><code>docker compose up -d\ndocker compose ps<\/code><\/pre>\n<h2>Step 5: Nginx Reverse Proxy with Streaming WebSockets &amp; SSL<\/h2>\n<p>Open WebUI utilizes server-sent events (SSE) and WebSockets for real-time token streaming. Create <code>\/etc\/nginx\/sites-available\/ai.example.com<\/code>:<\/p>\n<pre><code>server {\n    listen 80;\n    server_name ai.example.com;\n\n    client_max_body_size 100M;\n\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:8080;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_buffering off;\n        proxy_read_timeout 600s;\n    }\n}<\/code><\/pre>\n<p>Enable the site and issue an SSL certificate:<\/p>\n<pre><code>sudo ln -s \/etc\/nginx\/sites-available\/ai.example.com \/etc\/nginx\/sites-enabled\/\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx\nsudo certbot --nginx -d ai.example.com<\/code><\/pre>\n<h2>Popular Open-Source LLMs for Cloud VPS Infrastructure<\/h2>\n<table style=\"width: 100%;border-collapse: collapse;margin: 20px 0;border: 1px solid #334155\">\n<thead>\n<tr style=\"background-color: #0f172a;color: #38bdf8\">\n<th style=\"padding: 12px;border: 1px solid #334155\">Model Name<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">Parameters<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">RAM Requirement<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">Ideal Primary Use Case<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Meta Llama 3<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">8 Billion<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">~4.8 GB RAM<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">General assistant, reasoning, content writing<\/td>\n<\/tr>\n<tr style=\"background-color: #0f172a;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Mistral Instruct<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">7 Billion<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">~4.2 GB RAM<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">High-speed conversational dialog, summarization<\/td>\n<\/tr>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>DeepSeek Coder<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">6.7 Billion<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">~3.9 GB RAM<\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">Full-stack programming, regex, debugging<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Integrating Ollama APIs with Python, LangChain, and n8n<\/h2>\n<p>Ollama provides a native OpenAI-compatible REST API endpoint, allowing you to drop local models directly into existing AI applications, LangChain pipelines, or n8n workflow automations by changing the base URL to <code>http:\/\/127.0.0.1:11434\/v1<\/code>:<\/p>\n<pre><code># Python Integration with OpenAI SDK &amp; Local Ollama\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http:\/\/127.0.0.1:11434\/v1\",\n    api_key=\"ollama\" # Required by SDK but unused locally\n)\n\nresponse = client.chat.completions.create(\n    model=\"llama3:8b\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are an expert DevOps engineer.\"},\n        {\"role\": \"user\", \"content\": \"How do I optimize Nginx gzip compression?\"}\n    ]\n)\n\nprint(response.choices[0].message.content)<\/code><\/pre>\n<h2>Fine-Tuning System Prompts with Custom Modelfiles<\/h2>\n<p>Create specialized custom AI agents tailored for your business using Ollama Modelfiles:<\/p>\n<pre><code># Create custom Modelfile (SysAdminAssistant.Modelfile)\nFROM llama3:8b\nPARAMETER temperature 0.2\nPARAMETER top_p 0.9\nSYSTEM \"\"\"You are a senior Linux system administrator. Provide concise, secure, copy-pasteable terminal commands for Ubuntu 24.04 LTS servers.\"\"\"<\/code><\/pre>\n<p>Build and run the custom model: <code>ollama create sysadmin-bot -f SysAdminAssistant.Modelfile<\/code>.<\/p>\n<h2>Deploying Retrieval-Augmented Generation (RAG) with Open WebUI<\/h2>\n<p>Open WebUI includes an integrated document parser and vector database. You can upload internal PDF training manuals, company policy documents, or proprietary codebases directly into the web chat interface. When you ask questions with the <code>#doc<\/code> hashtag, Open WebUI performs local chunking, calculates vector embeddings using local embedding models (such as <code>nomic-embed-text<\/code>), and injects the most relevant context into the LLM prompt without sending data to external cloud APIs.<\/p>\n<pre><code># Pull high-speed local embedding model\nollama pull nomic-embed-text\n\n# Verify local embedding inference\ncurl http:\/\/localhost:11434\/api\/embeddings -d '{\n  \"model\": \"nomic-embed-text\",\n  \"prompt\": \"Cloud hosting performance benchmarks\"\n}'<\/code><\/pre>\n<h2>Securing Public Ollama Portals against Unauthorized Scanners<\/h2>\n<p>Ensure that port <code>11434<\/code> is never exposed publicly to the internet. Keep Ollama bound to <code>127.0.0.1<\/code> or isolated within the internal Docker bridge network (<code>172.17.0.0\/16<\/code>), routing all client connections through Nginx with SSL and strong user password authentication.<\/p>\n<div style=\"background-color: #0f172a;border-left: 4px solid #38bdf8;padding: 18px 24px;margin: 30px 0;border-radius: 8px\">\n<h3 style=\"color: #38bdf8;margin-top: 0\">Recommended Related Technical Guides<\/h3>\n<ul style=\"margin-bottom: 0;color: #cbd5e1\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-host-n8n-workflow-automation-docker-vps\/\" style=\"color: #38bdf8;text-decoration: underline\">Connecting Ollama AI Nodes to Self-Hosted n8n Workflows<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-run-docker-docker-compose-cheap-linux-vps\/\" style=\"color: #38bdf8;text-decoration: underline\">Running Containerized AI Stacks on Budget Linux VPS<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-secure-linux-vps-fail2ban-ufw-ssh\/\" style=\"color: #38bdf8;text-decoration: underline\">Securing Web Interfaces and AI Portals with UFW &amp; SSL<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 28px;border-radius: 12px;margin: 35px 0;text-align: center\">\n<h3 style=\"color: #ffffff;margin-top: 0;font-size: 22px\">Run Dedicated AI &amp; Local LLMs on CpanelFree Cloud VPS<\/h3>\n<p style=\"color: #e0f2fe;font-size: 15px;max-width: 650px;margin: 0 auto 18px auto\">Take full ownership of your AI infrastructure with high-performance virtual CPU cores, pure NVMe storage, and 100% free hosting options.<\/p>\n<p>  <a href=\"https:\/\/cpanelfree.com\/\" style=\"background-color: #ffffff;color: #0284c7;font-weight: 700;padding: 12px 28px;border-radius: 8px;text-decoration: none;display: inline-block\">Deploy Free Cloud Hosting Today &rarr;<\/a>\n<\/div>\n<div style=\"border-left: 4px solid #38bdf8;border-radius: 8px;padding: 20px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #38bdf8;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-host-website-free-forever-guide\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Host a Website for Free Forever: Complete Beginner Guide (2026)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/free-wordpress-hosting-softaculous-installer\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">Top 5 Free WordPress Hosting Services with 1-Click Softaculous Installer<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-backup-linux-vps-to-cloud-storage-s3-rclone\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Automatically Backup Your Linux VPS to Cloud Storage (S3 \/ Rclone Guide)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/what-is-dns-ttl-best-values-before-migration\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">What is DNS TTL (Time to Live) and What Value Should You Set Before Migration?<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #10b981;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans (NVMe SSD, AutoSSL)<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Deploy Fast, Reliable Web Hosting on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"display: inline-block;background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Claim Free Hosting Account<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Case for Self-Hosted and Private Artificial Intelligence While commercial AI platforms like OpenAI ChatGPT and Anthropic Claude provide capable intelligence, sending proprietary enterprise data, confidential source code, customer records, and internal emails to external third-party cloud servers poses severe data privacy and compliance risks. Furthermore, monthly subscription fees and token-based API billing escalate rapidly [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2504,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[],"class_list":["post-1875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-stacks"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1875"}],"version-history":[{"count":3,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1875\/revisions"}],"predecessor-version":[{"id":2304,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1875\/revisions\/2304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/2504"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}