Security

The self-hosting security checklist that prevents the boring disasters

Twelve checks that stop the failures people actually have — exposed admin panels, an unpatched container, a backup that never restored — in the order you should do them.

Self-hosted apps get compromised for unglamorous reasons. Not advanced exploits: a dashboard reachable from the open internet with the default password, a container image two years old, a database port left open "just for testing". This is the list that prevents those, ordered by what actually goes wrong.

1. Put admin panels behind something

If a login page is reachable by anyone on the internet, it will be brute-forced. Either put the admin path behind a VPN or an identity proxy, or at minimum restrict it by IP. Application dashboards — Portainer, database admin, Grafana — should almost never be public.

2. Change every default credential before the DNS record exists

Set the admin password before you point the domain at the server. A container that boots with a default login and is reachable for twenty minutes is reachable for twenty minutes too long; scanners find new hosts within hours.

3. Enable two-factor authentication

On the server (SSH keys, not passwords), on the app admin accounts, and on the DNS and hosting accounts. The last one matters most: whoever controls your DNS or your hosting console can take the whole thing over without ever touching your application.

4. Pin image versions and patch monthly

:latest is not a security strategy — it is an unpredictable upgrade. Pin a version, watch its security advisories, and upgrade on a schedule you control. Most compromised self-hosted installs are simply out of date.

5. Close every port except the ones you need

Allow 80, 443 and SSH (ideally from known IPs only). Everything else should be on the internal Docker network. Postgres, Redis and MySQL must never be published to the host, let alone the internet. This single habit removes the largest category of breach in self-hosted setups.

6. Terminate TLS properly and auto-renew it

A proxy — Caddy, Traefik or Nginx with certbot — should handle certificates and redirect HTTP to HTTPS. Add an expiry alert anyway: the certificate outage is the most common self-hosting downtime, and it is entirely preventable.

7. Back up, off the server, and restore once

A backup on the same disk is not a backup. Nightly database dump plus the uploads volume, pushed to object storage at a different provider, retained for two weeks. Then restore one into a throwaway container and confirm it opens. Until you have done that, you have a hope.

8. Set up three alerts

Disk at 80%, certificate expiring in 14 days, and the site unreachable for two minutes. Uptime Kuma does the third for free and the first two with a bit of configuration. These three catch most outages before a customer does.

9. Keep secrets out of Git

Environment files, API keys and database passwords do not belong in a repository, even a private one. If a secret has ever been committed, rotate it — deleting the commit does not remove it from clones or caches.

10. Give each app its own database user

One database per app, one user per app, scoped to that database. A shared superuser is how a vulnerability in one app becomes a breach of all of them.

11. Limit what the app can reach

Run containers as non-root where the image allows it, drop unnecessary capabilities, and put a read-only root filesystem in place if the app supports it. Most apps do not need to write anywhere except their data volume.

12. Write down the recovery plan

One page: where the backups are, which credentials are needed, what order to restore in, who to call. Written while calm, because you will read it while not calm. This is the step everyone skips and everyone regrets.

The order to do them in if you have one hour

  1. Change default credentials and enable 2FA (20 minutes).
  2. Close unused ports and unpublish database ports (10 minutes).
  3. Set the three alerts (15 minutes).
  4. Schedule the nightly backup to external storage (15 minutes).

That gets you most of the risk reduction. Everything else is refinement.

What about the app itself?

Choose software that publishes security advisories and responds to reports. A project's commit history tells you more about its security posture than any feature list: if the last release was eighteen months ago, the app is not being patched, and no amount of hardening on your side compensates for that.

If you would rather not own the patching, a managed host handles image updates for you — RepoCloud is the one we use for quick deployments, affiliate link, same price. Whatever you choose, the twelve checks above still apply to the accounts and the domain.

tf
techifyFlow editorial

We research, test and document software for small teams. Guides are written from primary sources — project documentation, licence text and our own installs — and updated when the facts change. How we work.

This guide contains affiliate links. If you sign up through one we may earn a commission at no extra cost to you. Full disclosure.