
Teams rarely leave Google Drive or Dropbox because they dislike the interface. They leave when pricing changes, compliance requirements tighten, or data residency stops being optional.
If you want control without losing the “it just works” feel, self-host Nextcloud on a VPS. You get a modern sync platform that runs where your infrastructure runs.
This guide stays practical. You’ll use Docker Compose, an Nginx reverse proxy with HTTPS, and storage choices that hold up under real usage.
It also covers backups you can actually restore and an upgrade routine that won’t ruin your Monday.
Nextcloud: what it is, who it’s for, and why teams choose it
Nextcloud is a self-hosted file sync and collaboration platform (AGPL-3.0 licensed). It covers the core Drive/Dropbox workflow: web access, desktop and mobile sync clients, share links, file versioning, and user/group management.
You can run it as a private file hub. You can also extend it with apps like calendar, contacts, editing integrations, and talk/video.
It’s a strong fit if you manage:
- Client work with per-customer folders, expiring links, and auditability.
- Distributed teams that need access controls beyond “anyone with the link.”
- Regulated data where storage region and retention policies must be documented.
- Ops-heavy environments that already maintain a VPS or dedicated server and want one more service under the same roof.
If you already host WordPress, a CRM, or internal tools, Nextcloud fits in as another service behind your reverse proxy and monitoring.
You run it. You control it. You can move it when requirements change.
Self-host Nextcloud on a VPS vs Google Drive/Dropbox
Hosted file platforms are convenient. They also come with constraints you can’t tune.
That includes region choices, data processing terms, admin controls, and the long-term “pay per user” curve.
With Nextcloud, you pay for infrastructure. You scale users on your own terms.
- Data locality: you pick the datacenter, disks, and backup destination. That often matters in client contracts.
- Identity + access: integrate LDAP/OIDC/SAML if you need it, or keep it simple with local users.
- Storage economics: put the database + previews on fast NVMe, and move user files to separate volume/block storage as you grow.
- Trade-off: patching, backups, and uptime are your job. If you don’t want that responsibility, managed hosting may be a better match.
If you want control without turning someone into a full-time admin, start with a predictable VPS on a clean baseline.
You can move to dedicated hardware later without rethinking the whole app stack.
Infrastructure sizing and storage planning (before you deploy)
Most “Nextcloud is slow” stories aren’t about Nextcloud. They usually come from weak I/O, a database stuck on a busy disk, or previews/versions/trash growing without limits.
A sensible starting point in 2026 for a small team (10–30 active users, typical office files):
- VPS: 2–4 vCPU
- RAM: 4–8 GB (8 GB if you enable previews and office integrations)
- Disk: NVMe preferred; keep at least 30–40% free for healthy database and background jobs
- Network: 1 Gbps port is fine; latency matters more than raw bandwidth for UI responsiveness
Storage planning details that save you pain later:
- Separate concerns: keep the database and Nextcloud config on fast disk; put user files on a separate volume if you can. Growth and restores get easier.
- Know your multipliers: versions, deleted files, and previews can add up fast. If you keep 180 days of versions, size for it.
- Backups need space too: account for offsite retention. Your backup target has to handle peak usage plus history.
If you expect hundreds of users or heavy collaborative editing, start bigger or skip straight to a dedicated machine.
HostMyCode offers a clean path from HostMyCode VPS to dedicated servers when storage and IOPS become the real bottleneck.
Deploy Nextcloud with Docker Compose (clean, maintainable)
Nextcloud supports a few deployment styles. For most teams, Docker Compose is the practical choice.
It gives you repeatable setup, straightforward upgrades, and backups that don’t depend on tribal knowledge.
Persist the right volumes. Keep secrets out of git.
Assumptions for this blog post:
- Ubuntu 24.04/24.10 or Debian 12+ (similar steps on AlmaLinux/Rocky with minor package changes)
- You’ll run Nextcloud at
cloud.example.com - Nginx runs on the host as the reverse proxy
Install Docker Engine and Compose plugin (Ubuntu example):
sudo apt update
sudo apt install -y docker.io docker-compose-plugin
sudo usermod -aG docker $USER
newgrp docker
Create a working directory:
sudo mkdir -p /opt/nextcloud
sudo chown -R $USER:$USER /opt/nextcloud
cd /opt/nextcloud
Example compose.yml (Nextcloud + PostgreSQL + Redis). This layout keeps the database, app config, and user files on named volumes.
If you later outgrow the root disk, you can map nextcloud_data to a mounted storage volume.
services:
db:
image: postgres:16
container_name: nextcloud-db
environment:
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: CHANGE_ME_LONG_RANDOM
volumes:
- db_data:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7-alpine
container_name: nextcloud-redis
command: ["redis-server", "--save", "", "--appendonly", "no"]
restart: unless-stopped
app:
image: nextcloud:apache
container_name: nextcloud-app
environment:
POSTGRES_HOST: db
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: CHANGE_ME_LONG_RANDOM
REDIS_HOST: redis
NEXTCLOUD_TRUSTED_DOMAINS: cloud.example.com
volumes:
- nextcloud_html:/var/www/html
- nextcloud_data:/var/www/html/data
depends_on:
- db
- redis
restart: unless-stopped
volumes:
db_data:
nextcloud_html:
nextcloud_data:
Bring it up:
docker compose up -d
docker ps
At this point, Nextcloud is listening on the container’s port 80.
Next, you’ll publish it through Nginx with TLS.
Reverse proxy with Nginx + HTTPS (and settings that prevent weird bugs)
Nextcloud is picky about proxy headers, upload limits, and timeouts. Set these correctly up front.
You’ll avoid common WebDAV errors and “uploads die at 1 GB” tickets.
Install Nginx and Certbot:
sudo apt install -y nginx python3-certbot-nginx
Create an Nginx site file at /etc/nginx/sites-available/nextcloud.conf:
server {
listen 80;
server_name cloud.example.com;
location /.well-known/acme-challenge/ { root /var/www/html; }
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name cloud.example.com;
# Certbot will manage ssl_certificate/ssl_certificate_key
client_max_body_size 5G;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600;
proxy_send_timeout 3600;
}
}
Now publish Nextcloud locally on port 8080. A simple approach is to add a port mapping for the app service:
# in compose.yml under app:
# ports:
# - "127.0.0.1:8080:80"
Apply the change:
docker compose up -d
sudo ln -s /etc/nginx/sites-available/nextcloud.conf /etc/nginx/sites-enabled/nextcloud.conf
sudo nginx -t
sudo systemctl reload nginx
Issue TLS certificates:
sudo certbot --nginx -d cloud.example.com
Two follow-ups inside Nextcloud prevent redirect and URL issues later:
- Set
trusted_proxiesand overwrite protocol inconfig/config.phpif needed (common in multi-proxy setups). - Enable background jobs via cron for consistent performance. Webcron works, but cron is better.
If you prefer a proxy with fewer moving parts and automatic HTTPS, Caddy is a solid alternative.
HostMyCode keeps a current guide here: Set Up Let’s Encrypt With Caddy for a VPS Site.
Backups: what to copy, how often, and a restore test you can actually run
A Nextcloud backup isn’t just “copy the files.” You need three pieces that line up in time:
- Database (PostgreSQL dump)
- App config + installed apps (the
nextcloud_htmlvolume) - User data (the
nextcloud_datavolume or your mounted storage path)
A good baseline is nightly backups with 7–14 days retention, plus a weekly snapshot kept for 4–8 weeks.
For client-critical data, add offsite replication.
Example backup script directory:
sudo mkdir -p /var/backups/nextcloud
sudo chown -R $USER:$USER /var/backups/nextcloud
Database backup (run from host):
docker exec -t nextcloud-db pg_dump -U nextcloud nextcloud \
> /var/backups/nextcloud/nextcloud-db-$(date +%F).sql
Volume backup using a temporary container (portable approach):
# Backup nextcloud_html
docker run --rm \
-v nextcloud_nextcloud_html:/volume \
-v /var/backups/nextcloud:/backup \
alpine sh -c "cd /volume && tar -czf /backup/nextcloud-html-$(date +%F).tar.gz ."
# Backup nextcloud_data
docker run --rm \
-v nextcloud_nextcloud_data:/volume \
-v /var/backups/nextcloud:/backup \
alpine sh -c "cd /volume && tar -czf /backup/nextcloud-data-$(date +%F).tar.gz ."
Run a restore test quarterly. Put it on the calendar. Treat it like real work, not a nice-to-have.
The simplest test is restoring to a staging VPS and confirming:
- Admin login works
- Recent files exist and download correctly
- A client can sync a folder
If you want a repeatable method for backups plus restore verification, the same discipline applies across databases and apps.
For backup process thinking (including tested restores), this HostMyCode guide is useful even if it’s MySQL-focused: Set Up Automatic MySQL Backups With Tested Restores.
Updates and upgrades: staying current without downtime drama
Docker makes upgrades easier, but you still need a routine. Don’t rely on “latest” and hope for the best.
If you have change control, pin major versions. Read release notes before big jumps.
A practical update runbook:
- Check free space (
df -h) and confirm backups exist for the day. - Pull images and restart containers.
- Run Nextcloud’s upgrade step if prompted.
- Verify login + upload + sync.
Example commands:
cd /opt/nextcloud
docker compose pull
docker compose up -d
docker exec -u www-data -it nextcloud-app php occ status
docker exec -u www-data -it nextcloud-app php occ db:add-missing-indices
docker exec -u www-data -it nextcloud-app php occ maintenance:repair
Schedule these like OS patching. If you don’t want to own that lifecycle, managed hosting can be a better fit than “DIY forever.”
HostMyCode’s managed VPS hosting is built for teams that need a real server but prefer to hand off routine maintenance and incident response.
Operational hardening you’ll feel immediately
Once Nextcloud is on the public internet, basic hygiene matters.
Lock down SSH, rate-limit noisy traffic, and keep firewall rules boring and consistent.
- Firewall: allow only 22 (or your SSH port), 80, 443. Block everything else.
- Fail2ban: protect Nginx and SSH from brute-force noise.
- Security headers: you can add them at Nginx, but test for app compatibility.
For a straightforward Fail2ban baseline on an Nginx VPS, follow: Set Up Fail2ban for Nginx on Ubuntu VPS.
Common pitfalls (and quick diagnostics)
Most “Nextcloud is broken” reports fall into a handful of buckets. These are the usual first hits:
- Uploads fail at a specific size: check
client_max_body_sizein Nginx and PHP limits inside the container. - Wrong URLs or redirect loops: proxy headers or trusted domains/proxies are mis-set.
- Slow web UI after a few weeks: cron jobs aren’t running; previews are ballooning; database lacks maintenance.
- Disk fills unexpectedly: versions + trash + previews. Set retention policies and monitor free space.
Quick checks you can run:
# Container health
docker ps
docker logs --tail=200 nextcloud-app
docker exec -u www-data -it nextcloud-app php occ background:status
docker exec -u www-data -it nextcloud-app php occ config:system:get trusted_domains
Watch your I/O. If CPU looks fine but the UI still stutters, disk latency is often the real problem.
Moving user data to a dedicated storage volume (or stepping up a VPS tier) usually fixes it fast.
Where HostMyCode fits for Nextcloud teams
Nextcloud likes stable infrastructure: consistent CPU, fast disk, and predictable networking. For most teams, a properly sized VPS is the cheapest place to start.
As the dataset grows, you can scale up or migrate to dedicated hardware. You won’t need to change how Nextcloud is deployed.
If you want the platform but not the ongoing server chores, a managed plan keeps patching and monitoring off your plate.
If you’re planning to self-host file sync for a team, start with a VPS that has predictable CPU and NVMe storage. HostMyCode offers HostMyCode VPS for DIY operators, and managed VPS hosting if you’d rather keep upgrades and server hygiene off your calendar.
FAQ: self-hosting Nextcloud for teams
Do I need a dedicated server to run Nextcloud well?
No. Many teams run comfortably on a 2–4 vCPU VPS with 4–8 GB RAM. Dedicated servers make sense once storage/IOPS or concurrent usage outgrows a single VPS.
Should I use PostgreSQL or MariaDB?
Both work. PostgreSQL is a solid default for new installs and behaves well under load. If your team already standardizes on MariaDB, keep consistency—but size your disk and backups accordingly.
What should I back up first if I’m short on time?
Back up the database and the data directory. Without the database, you lose shares, metadata, and the state that makes files “belong” to users.
Can I put Nextcloud behind Cloudflare?
Yes, but be careful with caching rules and upload limits. If you use Cloudflare Proxy, confirm WebDAV and large file uploads behave as expected for your clients.
How do I migrate an existing Nextcloud to a new VPS?
Plan it like any app move: lower DNS TTL, copy data, restore database, and validate logins and sync before switching traffic. If you want help moving production services, HostMyCode offers assisted migrations: HostMyCode migrations.
Summary: a controlled alternative to Drive/Dropbox
Nextcloud is one of the few projects that can replace a mainstream SaaS file platform without feeling like a downgrade.
The upside is control: where data lives, how it’s backed up, and how access is managed.
The downside is operational ownership. Keep the routine small and repeatable: monitor disk, run cron jobs, take restorable backups, and update on schedule.
If you’re ready to run it on real infrastructure, start with a dependable VPS and expand as usage grows.
HostMyCode can host your stack on HostMyCode VPS today, and support a smooth move to larger instances or dedicated hardware as your storage and team usage scale.