By the end of Part 2 the server was holding contracts, client records and HR policies, and the team could query all of it from a browser. The whole reason we built a private platform was to keep that data under our control, so this part matters more than the other three.
In this post I go through how we locked the server down, layer by layer, and how we check that each layer is actually doing its job.
This is the third post in a four-part series:
- Part 1 - The platform: hardware sizing, Ollama and Open WebUI on a Mac and on a VPS, HTTPS with Caddy.
- Part 2 - A knowledge base: letting the model answer from company documents using Docling.
- Part 3 (this post) - Locking it down: the security steps that keep the server out of the exposed-Ollama statistics.
- Part 4 - Automation: connecting n8n to the local model for real workflows.
Why this matters: exposed Ollama servers

Ollama’s API has no authentication. That is fine on a laptop, where it listens on 127.0.0.1, but it becomes a problem as soon as port 11434 is reachable from the internet. Anyone who finds it can:
- List your models with
/api/tags.- Use your CPU or GPU for free through
/api/generateand/api/chat.- Exploit bugs in the model loader. CVE-2026-7482 “Bleeding Llama”, disclosed by Cyera in May 2026, is a heap out-of-bounds read in Ollama’s GGUF handling. A crafted model file makes Ollama leak process memory, which can include prompts, conversations and environment variables. It is fixed in Ollama 0.17.1.
This is not a theoretical risk. In January 2026 SentinelLABS and Censys published research that found 175,108 Ollama hosts reachable from the internet across 130 countries over 293 days of scanning.
Most of those are not deliberate. A common way it happens with Docker: the official Ollama image already listens on 0.0.0.0 inside the container, so a compose file with - "11434:11434" publishes it on every interface of the server. And because Docker writes its own firewall rules, ufw doesn’t stop it (I covered this in Part 1).
Five layers

We approached it as five layers, where each layer assumes the one outside it has already failed:
- 1. Network - Who can reach the server at all.
- 2. Host - Who can log in to it.
- 3. Services - What is listening and which versions are running.
- 4. Application - Who can see what inside Open WebUI.
- 5. Data - What survives if something goes wrong.
Layer 1: Network
Provider firewall
In Part 1 we enabled ufw on the server. We also turned on the provider’s firewall in the hosting control panel (Hostinger has one under the VPS settings), with the same rules:
| Port | Protocol | Purpose |
|---|---|---|
| 22 | TCP | SSH |
| 80 | TCP | Caddy certificate challenge and redirect to HTTPS |
| 443 | TCP | Caddy (HTTPS) |
| everything else | - | dropped |
The provider firewall filters traffic before it reaches the server, so Docker’s rules on the host can’t bypass it. Having both means a mistake in one doesn’t expose anything. If the office has a static IP address, restrict port 22 to that address too.
Scan yourself from outside
The only reliable way to know what is exposed is to look from outside. From a laptop that is not on the server:
| |
We run this after every change to the compose file. It takes a few minutes, and it is the only check that sees the server the way an attacker does.
Layer 2: Host
Key-only SSH
In Part 1 we logged in with SSH keys from the start. Now we turn password logins off completely and block root. On Ubuntu 24.04, cloud images often include a file in /etc/ssh/sshd_config.d/ that sets PasswordAuthentication yes. sshd uses the first value it reads, so we create a file that sorts before it:
| |
Note : Keep your current SSH session open and test a new login from a second terminal before closing it. If something is wrong, you can still fix it from the first session.
fail2ban
Even with passwords off, bots will keep trying port 22. fail2ban bans an IP after repeated failed attempts. On Ubuntu 24.04 the package already reads from the systemd journal and enables the sshd jail, so we only override the timings:
| |
Automatic security updates
Ubuntu Server includes unattended-upgrades. We make sure it is installed and turned on, so security patches for the OS are applied without waiting for someone to log in:
| |
The hosting account
The server is only as safe as the account that controls it. Anyone with access to the hosting control panel can open a console, reset the root password or restore a snapshot somewhere else. We turned on 2FA on the hosting account and limited who has access to it.
Layer 3: Services
Bind to 127.0.0.1, always
Every port in our compose file is bound to 127.0.0.1, which we set up in Part 1 and Part 2. The rule is simple: never publish 11434 (Ollama) or 5001 (Docling) on a public interface. Open WebUI reaches them over the Docker network, and Caddy is the only thing that faces the internet.
Check it on the server:
| |
Pin image versions
In Part 1 we used :latest and :main to get started. On a server holding company data, we want to know exactly what is running and change it on purpose. We moved the versions into .env:
| |
And in docker-compose.yml:
| |
Use the latest release of each project when you set this up. The point is that an update only happens when we change this file, not whenever a container restarts.
The update routine
Once a month, or straight away for a security fix:
| |
Then we log in to Open WebUI, ask one question from the Part 2 test list and check the citations still appear. If anything is wrong, we restore the snapshot.
Layer 4: Application
Why the environment variable is not enough
In Part 1 I said the admin panel setting matters more than the environment variable. This is why.
Many Open WebUI settings, including ENABLE_SIGNUP, are PersistentConfig settings. On the first start Open WebUI reads the environment variable and saves the value in its database. After that the database value is used and the environment variable is ignored. So if you add ENABLE_SIGNUP=false to the compose file after the first start, it can look like it is set while sign-ups are still open.
We did both: added it to the compose file (so a fresh install starts closed), and turned off Enable New Sign Ups in Admin Panel → Settings → General, which is the value that actually applies.
| |
Then check from outside that the sign-up form is gone, by opening the login page in a private browser window.
SSO and MFA
The organisation already used Microsoft 365, so we connected Open WebUI to Microsoft Entra ID through OAuth. Staff log in with their work account, and MFA is enforced by Entra ID, so we didn’t have to build it ourselves. When someone leaves, disabling their Microsoft account removes their access here too.
| |
The secrets go in .env (which is chmod 600 from Part 1), not in the compose file. New accounts created through SSO still get the pending role, so an admin approves each person before they can use anything.
Knowledge per group
In Part 2 we split the documents into knowledge bases. Under Admin Panel → Users → Groups we created groups that match the teams (for example Finance and Management), and set each knowledge base’s access to the groups that should see it. A user who is not in the Finance group can’t select the Finance knowledge base, and its chunks never appear in their answers.
We kept the number of admins to two. An admin can see every setting and every knowledge base, so it is not a role to hand out for convenience.
Layer 5: Data
Snapshots before every update
The provider’s snapshot feature gives us a way back if an update goes wrong. We take one before every change to the server, as the first step of the update routine above.
Off-box backups
A snapshot lives with the same provider, so it doesn’t help if the account is compromised. We also back up the data to storage somewhere else using restic, which encrypts backups by default.
What needs backing up:
- open-webui volume - Users, chats, settings (SQLite database), uploaded files and the ChromaDB vectors.
- n8n volume - Workflows and credentials (added in Part 4).
- ~/ai-stack - The compose file and
.env.
The Ollama volume is not backed up because the models can be downloaded again. Docker Compose prefixes volume names with the project folder name, which is why the paths below start with ai-stack_ (check yours with docker volume ls). Until n8n is added in Part 4, leave that line out. A nightly cron job stops Open WebUI briefly so the SQLite database is consistent, runs the backup and starts it again:
| |
Note : Keep the restic password somewhere outside the server, such as the organisation’s password manager. Without it the backups can’t be restored. And test a restore on a separate machine at least once, because a backup you have never restored is only a hope.
Encryption and retention
We treat the VPS disk as something the provider could, in principle, access. That’s why the backups are encrypted with our own key before they leave the server. We also agreed a retention policy with the organisation: staff delete chats they no longer need, and we review old uploads and knowledge base documents every quarter. Less data on the server means less to lose.
What the provider’s terms say
In Part 1 I mentioned the provider’s terms on regulated data. Hostinger’s hosting agreement says its services are not intended to provide a PCI or HIPAA compliant environment. That was fine for this organisation, which doesn’t process card payments or US health data. If yours does, you need a provider and a setup built for that, and this series is not a compliance guide. Check your own obligations (for us, UK GDPR) before putting personal data on any server.
Checklist
This is the list we go through before giving a new deployment to a team:
- Provider firewall and ufw allow only 22, 80 and 443.
nmapfrom outside shows only 22, 80 and 443, and port 11434 times out.- SSH password login and root login are off, and fail2ban is running.
unattended-upgradesis enabled, and 2FA is on for the hosting account.- Every container port is bound to
127.0.0.1.- Image versions are pinned and Ollama is 0.17.1 or later.
- Sign-ups are off in the admin panel, not only in the environment.
- SSO with MFA is working, and new users start as
pending.- Each knowledge base is restricted to the right groups.
- A snapshot exists, off-box backups run nightly, and a restore has been tested.
What’s next
The platform is now private, it answers from company documents, and it is locked down. In Part 4 I connect n8n to the local model, so it can do work on its own: triaging the support inbox and pulling key dates out of contracts, with a person approving anything that goes out. n8n will be reachable only through an SSH tunnel, using the same rules as this post.
Sources : Cyera: Bleeding Llama, SentinelLABS: exposed Ollama hosts, Docker packet filtering and firewalls, Open WebUI env configuration, Open WebUI roles, restic documentation, Hostinger terms of service.
