Build a self-hosted AI inference server
A self-hosted AI server runs open-weight language models on hardware you rent and control, with no per-token bill and no prompts leaving your machine. This guide sets one up end to end on Ubuntu 24.04: Ollama for inference, Open WebUI as the team chat frontend, and Caddy for TLS, with an honest look at what CPU-only inference can and cannot do.
Server.Biz rents unmanaged dedicated servers, so you are the sysadmin here. Every command below is standard Linux practice and runs on a fresh box. Where you need a GPU we say so plainly, and we never pretend a many-core CPU is a datacenter accelerator.
Why self-host inference
Renting a box to run your own LLM makes sense for three concrete reasons, not one.
Data control
Prompts and documents stay on your server in the datacenter partner's Naaldwijk facility. Nothing is sent to a third-party API, which keeps EU data residency simple and attribution clear.
Flat monthly cost
You pay for the box, not per token. At steady daily load a fixed rental beats metered pricing, and a runaway script cannot run up a surprise bill.
Model freedom
Run any open-weight model you like, pin a version, and keep it available. No deprecation notice takes your model away mid-project.
What CPU inference actually delivers
On a modern many-core CPU, a quantized 7B or 8B model runs at a usable interactive pace: a handful of tokens per second up to low double digits, fine for chat, drafting and coding help for a small team. The limit is memory bandwidth, not core count. Once the model no longer fits in cache, every generated token reads the whole set of active weights from RAM, so faster and wider memory matters more than raw clock speed. AMD EPYC parts in the range have many memory channels, which is exactly what helps here.
CPU inference stops being pleasant when the model gets large or the users get many. A 70B model at a sensible quantization will run, but slowly, and every extra concurrent request divides the throughput. If you need low latency, big models, or many people hitting it at once, that is a GPU job. Server.Biz lists GPU-capable and high-core options under the AI and ML server category; check the live configurator and catalog for what is currently available rather than trusting a number in a guide.
How much RAM a model needs
The rule of thumb: a model needs roughly its file size in RAM, plus a few gigabytes for the context window and the OS. Quantization is the lever. Q4 roughly halves memory versus Q8 and quarters it versus FP16, at a small and usually acceptable quality cost. These are approximate working-set sizes in gigabytes; add 2 GB to 4 GB of headroom for context and the system.
| Model size | Q4 | Q8 | FP16 |
|---|---|---|---|
| 7-8B params | ~5 GB | ~8 GB | ~16 GB |
| 13-14B params | ~8 GB | ~14 GB | ~28 GB |
| 32-34B params | ~20 GB | ~35 GB | ~65 GB |
| 70B params | ~40 GB | ~75 GB | ~140 GB |
Store models on NVMe. An 8B download is a few gigabytes and a 70B is tens of gigabytes, so fast local storage makes model swaps and cold starts far less painful than they are on spinning disks.
Harden the box before you serve anything
Before anything listens on a port, do the first-hour basics: change the delivered root password, create your own user with an SSH key, disable SSH password login, apply all updates, enable unattended security upgrades, and set a default-deny firewall. Our getting-your-server-online guide walks through each step, and the rest of this guide assumes it is done.
The security posture that matters most for an AI box is simple. The model service listens only on localhost, and the only thing the public reaches is an authenticated HTTPS proxy. Everything below follows that rule.
Install and run Ollama
Ollama is the quickest way to get a model serving a local API. The official install script sets up a systemd service on Ubuntu 24.04. By default it binds to localhost, and we keep it that way: the outside world will reach it only through the proxy we add later.
curl -fsSL https://ollama.com/install.sh | sh
Pin the bind address and set the tuning knobs with a systemd drop-in. Adjust the numbers to your box.
[Service]
Environment="OLLAMA_HOST=127.0.0.1:11434"
Environment="OLLAMA_NUM_PARALLEL=2"
Environment="OLLAMA_MAX_LOADED_MODELS=1"
Environment="OLLAMA_KEEP_ALIVE=30m"
Reload systemd, restart the service, and pull a model. Model names change fast, so check the Ollama library for current tags; llama3.1:8b is a solid, widely available example. For a coding assistant, pull a code-tuned model the same way, for example a current qwen2.5-coder tag.
sudo systemctl daemon-reload
sudo systemctl restart ollama
ollama pull llama3.1:8b
Confirm it answers on localhost:
curl http://127.0.0.1:11434/api/chat -d '{
"model": "llama3.1:8b",
"messages": [{"role": "user", "content": "Say hello in one sentence."}],
"stream": false
}'
OLLAMA_NUM_PARALLEL sets how many requests a loaded model handles at once. OLLAMA_MAX_LOADED_MODELS caps how many different models sit in memory together, which matters because each one holds its full weight set in RAM. OLLAMA_KEEP_ALIVE controls how long an idle model stays loaded: raise it to avoid cold starts, or set it to -1 to keep a model resident on a busy shared box.
A team chat frontend with Open WebUI
Open WebUI gives your team a familiar chat interface over Ollama, with accounts, history and model selection. Run it in Docker, bound to localhost, so it is never directly exposed; the proxy handles public access and TLS. This assumes Docker is installed, which on Ubuntu 24.04 is one apt package.
Start the container, mapped only to the loopback address so it stays private:
docker run -d \
--name open-webui \
--restart unless-stopped \
-p 127.0.0.1:3000:8080 \
--add-host=host.docker.internal:host-gateway \
-e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
-v open-webui:/app/backend/data \
ghcr.io/open-webui/open-webui:main
The first account you create becomes the admin. Open WebUI also supports OIDC single sign-on, which is the clean way to let a team in without sharing one password. Set it up under the admin settings once the site is reachable over HTTPS.
Put TLS in front with Caddy
Never expose the raw Ollama port or the WebUI port to the internet. Put Caddy in front instead: it terminates TLS with an automatic Let's Encrypt certificate and proxies to the local WebUI. Point A and AAAA records for YOUR_DOMAIN at the server first, since the certificate step needs the name to resolve.
Install Caddy from its official repository:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install -y caddy
Generate a password hash for basic auth:
caddy hash-password
Write the site config. Replace YOUR_DOMAIN, the username, and the hash you just generated.
YOUR_DOMAIN {
basic_auth {
yourname PASTE_THE_HASH_HERE
}
reverse_proxy 127.0.0.1:3000
}
Open only the web ports and reload Caddy to issue the certificate:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo systemctl reload caddy
Basic auth is the fastest gate. For a team, Open WebUI's own OIDC login is nicer and lets you drop the Caddy basic_auth block. Either way, ports 80 and 443 are the only inference-related ports the public should ever reach; the Ollama and WebUI ports stay on localhost.
The GPU path: vLLM for scale
When you outgrow a single-user pace, vLLM is the server to reach for. It adds continuous batching, so many concurrent requests share the GPU efficiently, and it exposes an OpenAI-compatible API that drops in for the hosted one. It needs an NVIDIA GPU and the NVIDIA Container Toolkit to shine; on CPU it runs but gives up its main advantage.
Serve a model on the GPU, again bound to localhost:
docker run -d \
--name vllm \
--restart unless-stopped \
--runtime nvidia --gpus all \
--ipc=host \
-p 127.0.0.1:8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:latest \
--model meta-llama/Llama-3.1-8B-Instruct
This serves an OpenAI-compatible API on 127.0.0.1:8000, behind the same Caddy pattern. Gated models on Hugging Face need an access token passed as an environment variable. GPU availability changes, so check the configurator and the AI and ML category for current options rather than assuming a specific card.
Point your existing tools at the box
Both Ollama and vLLM speak the OpenAI API, so most SDKs and apps switch over by changing two settings: the base URL and the API key. Ollama ignores the key, so any non-empty string works; when you expose the endpoint through the proxy, use real authentication there instead.
An existing OpenAI SDK call points at your box like this:
from openai import OpenAI
# On the box or over an SSH tunnel, talk to Ollama directly.
# Publicly, point base_url at your authenticated https proxy instead.
client = OpenAI(
base_url="http://127.0.0.1:11434/v1",
api_key="not-needed",
)
resp = client.chat.completions.create(
model="llama3.1:8b",
messages=[{"role": "user", "content": "Summarize this support ticket in two lines."}],
)
print(resp.choices[0].message.content)
To reach the box from a laptop without opening the port, forward it over SSH and keep base_url pointed at localhost:
ssh -L 11434:127.0.0.1:11434 you@YOUR_DOMAIN
The same base URL works for anything that accepts an OpenAI endpoint: editor plugins, CI scripts, internal tools. Change one setting and your stack runs against your own hardware.
Running it day to day
Keep models current by re-pulling their tag: ollama pull llama3.1:8b fetches the latest build of that tag. List what you have with ollama list and reclaim disk with ollama rm when a model is no longer used, since a few large models fill an NVMe quickly.
Watch memory. The free -h command shows how close you are to the edge; if the box starts using swap during inference, throughput collapses, so either drop to a smaller quantization or move up a RAM size class. A backup of your Open WebUI volume and your Caddyfile is enough to rebuild the setup fast, and the model files themselves are always re-pullable.
Do not let the box become a public free API
The single biggest mistake is binding the model service to 0.0.0.0 and forgetting it. An open inference port is a free CPU or GPU for anyone who scans for it. Keep Ollama and the WebUI on localhost, let only the authenticated HTTPS proxy face the internet, and keep the firewall default-deny.
Match the setup to the job
Pick the smallest thing that does the work, then grow into hardware only when real usage asks for it.
| Situation | Setup | Good for |
|---|---|---|
| One team, chat and light coding | CPU server, Ollama and Open WebUI | A quantized 7-8B model on a single box |
| Many concurrent users or low latency | GPU server, vLLM | Continuous batching, OpenAI-compatible API |
| Batch or overnight processing | CPU server, Ollama scripted | Cost stays flat regardless of volume |
Start on CPU with an 8B model. It is enough to prove the workflow and the security setup. Move to a GPU only when real usage tells you to, and let the live catalog decide the hardware.
