Launch offer: -50% for your first 3 months with code LANCEMENT — new customers, VPS, first 50 orders, until 31 Dec 2026. See the VPS plans →
FranceHosta RootLab service
Please note: ordering, the customer area and our terms are currently available in French only.
Practical guide

Self-host Nextcloud on a VPS

Your files, calendar and contacts on a server of your own, hosted in France, rather than with a cloud giant. This guide installs Nextcloud with Docker Compose, over HTTPS, accessible from your computers and your phone.

Which VPS for Nextcloud?

Nextcloud needs a bit of memory for PHP and its database. Count on the VPS Start (2 GB of RAM, 20 GB SSD) for one or two people who mostly sync documents, and the VPS Plus (4 GB, 40 GB) for a family, photos or a few extra apps. The disk space on our plans goes up to 100 GB: comfortable for documents, tight for a full photo library.

Choose a KVM VPS for Docker, and follow our Docker on an IPv6 VPS guide first: it installs Docker, the NAT64 service and the IPv6 setting this guide relies on.

Your backups: our snapshots are stored on the same server as your VPS (see our limits). If Nextcloud becomes the place where your files live, keep a copy elsewhere. The sync client already keeps one on your computers.

1. The domain name and IPv4 access

Create an AAAA record, for example cloud.example.com, pointing to the VPS's IPv6 address. Two cases then arise:

  • All your devices have IPv6 (recent French home routers and mobile plans): nothing else to do, Caddy will get a Let's Encrypt certificate by itself.
  • Some only have IPv4 (hotel Wi-Fi, company network): put the domain behind Cloudflare with the proxy enabled, as in the IPv6 VPS guide, and generate a Cloudflare origin certificate (SSL/TLS tab, "Origin Server").

On Cloudflare's free plan, a request cannot exceed 100 MB. This is not a problem in practice: the web interface and the Nextcloud clients upload large files in small chunks.

2. Prepare the files

mkdir -p /srv/nextcloud/certs && cd /srv/nextcloud

Create a .env file with long, different passwords (openssl rand -base64 24 generates one). The change-me-1 and change-me-2 values below are placeholders: replace them with your own passwords.

DOMAIN=cloud.example.com
MYSQL_ROOT_PASSWORD=change-me-1
MYSQL_PASSWORD=change-me-2
chmod 600 .env

3. The docker-compose.yml file

services:
  db:
    image: mariadb:11
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - db:/var/lib/mysql
    networks: [nc]

  redis:
    image: redis:alpine
    restart: unless-stopped
    networks: [nc]

  app:
    image: nextcloud:stable-apache
    restart: unless-stopped
    depends_on: [db, redis]
    environment:
      MYSQL_HOST: db
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      REDIS_HOST: redis
      NEXTCLOUD_TRUSTED_DOMAINS: ${DOMAIN}
      OVERWRITEPROTOCOL: https
      TRUSTED_PROXIES: 172.16.0.0/12 fd00::/8
    volumes:
      - nextcloud:/var/www/html
    networks: [nc]

  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./certs:/certs:ro
      - caddy:/data
    networks: [nc]

networks:
  nc:
    enable_ipv6: true

volumes:
  db:
  nextcloud:
  caddy:

The named volumes keep your data when the containers are recreated during updates.

4. The Caddyfile

Create /srv/nextcloud/Caddyfile. Without Cloudflare, Caddy obtains and renews a Let's Encrypt certificate by itself:

cloud.example.com {
    reverse_proxy app:80
    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301
}

With Cloudflare, save the origin certificate in certs/origin.pem and its key in certs/origin.key, then add this line just after the opening brace:

    tls /certs/origin.pem /certs/origin.key

In Cloudflare, then set SSL/TLS encryption to "Full (strict)".

5. Start up and finish the installation

docker compose up -d
docker compose logs -f app

Open https://cloud.example.com: Nextcloud asks you to create the administrator account. The database is already configured by the variables in the Compose file.

6. Background jobs

Nextcloud needs to run maintenance tasks regularly. Add this line to root's crontab (crontab -e):

*/5 * * * * docker compose -f /srv/nextcloud/docker-compose.yml exec -T -u www-data app php -f /var/www/html/cron.php

In Nextcloud, open Administration settings, Basic settings, and choose "Cron". Then install the Nextcloud apps on your computers and phone, and connect them to your address.

Updating

cd /srv/nextcloud
docker compose pull
docker compose up -d

Nextcloud cannot skip a major version: the stable image follows versions in order, so update regularly rather than once a year.

Frequently asked questions

How much space do I get for my files?

Up to 100 GB with the VPS Max, part of it taken by the system and Docker. That is comfortable for documents and contacts, tighter for a full photo library or videos.

Does Nextcloud work without Cloudflare?

Yes, if all your devices have IPv6: Caddy obtains a Let's Encrypt certificate by itself. Cloudflare is only there to make your Nextcloud reachable from networks that only have IPv4, such as some public Wi-Fi.

Are my files encrypted?

They travel over HTTPS. On disk, they are unencrypted by default, on a server that you administer. Nextcloud offers a server-side encryption module, to be enabled knowingly: losing the keys means losing the files.

What happens if the VPS goes down?

The sync client keeps a copy of your files on your computers, and they remain accessible offline. Our snapshots are on the same server as your VPS: keep a backup elsewhere. See our limits.

Your cloud, hosted in France

VPS Plus: 2 vCores, 4 GB of ECC RAM, 40 GB SSD, run by a nonprofit, from €3.99 a month.