Skip to content

Hosting my own Nextcloud: a comprehensive guide

Self-hosting Nextcloud can be both a cost-effective and privacy-focused approach to file syncing, online collaboration, and more. In this post, I will discuss how I set up a Nextcloud instance on a Proxmox virtual machine (VM) behind a Cloudflare Tunnel, leveraging my TrueNAS server for affordable, redundant storage. I will also walk through critical backup plans and ongoing maintenance strategies to keep everything secure and reliable.

Nextcloud is an open-source solution that centralizes file sharing, syncing/back-up, calendar and contact management, and collaborative document editing. Unlike commercial cloud providers, I retain the advantage of full control over my own data.

  • Privacy & Ownership: All data resides in my infrastructure, so I set data-retention rules according to my preferences.
  • Extensive Feature Set: Beyond file hosting, Nextcloud offers integrated apps for office documents, chat, video calls, and more.
  • Cost Savings: Hosting on my own hardware eliminates monthly per-user cloud costs. I simply pay for hardware and energy usage.

I already run a TrueNAS instance, so I can capitalize on its CIFS shares for large-capacity storage without ongoing fees from public cloud providers.

  1. Proxmox VM: I created an Ubuntu 24 LTS VM on Proxmox to run Docker, where the Nextcloud AIO (All-In-One) container is deployed.
  2. TrueNAS Storage: My TrueNAS server provides SMB/CIFS shares, mounted directly on the VM to serve as Nextcloud’s main data directory.
  3. Cloudflare Tunnel: I rely on Cloudflare for DNS and a secure tunnel to expose Nextcloud publicly without opening direct ports on my home network. There is a slight caveat — for Nextcloud Talk to work correctly, you’ll have to either open a port or set up a TURN server, which I’ll cover in an upcoming post.
  4. Nextcloud AIO: This image simplifies updates and maintenance by bundling the Nextcloud components (web server, database, etc.) into a cohesive Docker environment.

3. Step-by-step: getting Nextcloud up and running

Section titled “3. Step-by-step: getting Nextcloud up and running”
  1. Create Ubuntu VM
    I prepared an Ubuntu 24 LTS VM with 4 CPU cores and 8 GB of RAM. This allocation should meet my needs for hosting Nextcloud for family members and friends and ensures I can accommodate simultaneous file syncs and occasional group collaboration without issues.
  2. Provision Docker
    Follow the official guide here.
  1. Install cifs-utils

    Terminal window
    sudo apt install cifs-utils -y
  2. Edit /etc/fstab
    Add entries to mount the TrueNAS share under /mnt/prox-data-share and link it to the Nextcloud directory:

    /etc/fstab
    # TrueNAS instance ip address/data-share and mount location with credentials.
    //<nas-ip>/<share-name> /mnt/prox-data-share cifs credentials=/root/smbcredentials,uid=1000,gid=1000,noauto,x-systemd.automount 0 0
    # Mount it to the local nextcloud data directory as you'll see in the docker-compose below.
    /mnt/prox-data-share/nextcloud /home/<user>/Docker/nextcloud none bind,nofail,errors=remount-ro 0 0
  3. Test the Mount

    Terminal window
    sudo mount -a
    ls /mnt/prox-data-share

    If you see your files, the mount is successful.

  1. Create docker-compose.yml
    In /home/<user>/Docker/nextcloud, create the Nextcloud AIO snippet:

    services:
    nextcloud-aio-mastercontainer:
    image: nextcloud/all-in-one:latest
    init: true
    restart: unless-stopped
    container_name: nextcloud-aio-mastercontainer
    volumes:
    - nextcloud_aio_mastercontainer:/mnt/docker-aio-config # This line is not allowed to be changed as otherwise the built-in backup solution will not work
    - /var/run/docker.sock:/var/run/docker.sock:ro
    #ports:
    # - 8080:8080 # uncomment this to access the nextcloud instance via host ip:port. I will be accessing directly via the domain and don't need to map this to the host.
    environment:
    - PUID=1000 # ensure to provide the id that has permission to the required directories, including the SMB/CIFS share
    - PGID=1000
    - NEXTCLOUD_DATADIR=/home/Docker/nextcloud # Allows setting the host directory for Nextcloud's datadir. ⚠️⚠️⚠️ Warning: do not set or adjust this value after the initial Nextcloud installation is done!
    - APACHE_PORT=11000 # Needed when running behind a web server or reverse proxy.
    - APACHE_IP_BINDING=0.0.0.0
    - BORG_RETENTION_POLICY=--keep-within=7d --keep-weekly=4 --keep-monthly=6
    - NEXTCLOUD_ENABLE_DRI_DEVICE=true # ⚠️ only set this true if /dev/dri exists on your host
    networks:
    cloudflared-network:
    ipv4_address: 172.21.0.48 # I usually map all my instances with static address to avoid open port mapping on the host.
    networks:
    cloudflared-network:
    external: true
    volumes:
    nextcloud_aio_mastercontainer:
    name: nextcloud_aio_mastercontainer
  2. Start the Containers

    Terminal window
    docker-compose up -d
  3. Confirm It’s Running

    Terminal window
    docker logs -f nextcloud-aio-mastercontainer

    After a short wait, you should see confirmation messages for successful start-up.

3.4 Integrate with Cloudflare Tunnel (or Pangolin newt tunnel)

Section titled “3.4 Integrate with Cloudflare Tunnel (or Pangolin newt tunnel)”

This step requires minimal effort — see the Cloudflared docs for setup details.

4. Creating the admin user and invitations

Section titled “4. Creating the admin user and invitations”
  1. Initial Login
    On first access, Nextcloud AIO setup will provide you with a password (or passphrase), and you should write this down and store it safely. This is required for you to update and manage Nextcloud containers. I store these credentials securely (for instance, in a password manager like Vaultwarden).
  2. Initial Configuration
    As the administrator, you can now set up the Nextcloud domain, backup location (I use a separate data-share on a different NAS location), timezone, etc.
  3. Let the journey begin
    Once all containers’ status shows green (meaning all downloaded and configured), you’ll be greeted with your initial username (admin) and initial password — I recommend changing these right away with 2FA setup. From here, you can configure the SMTP service and other Nextcloud setup; usually start by checking the admin menu to perform the Nextcloud health checks. You’ll often see some benign error messages that can be handled easily by following the Nextcloud documentation.

Now that Nextcloud is live, I shift my focus to data protection. I rely on the built-in Nextcloud AIO backup feature, which uses Borg for off-site backups.

5.1 Proxmox built-in snapshots and backup feature

Section titled “5.1 Proxmox built-in snapshots and backup feature”
  1. Snapshots
    I can’t count how many times the snapshot feature saved my skin when things went south. I usually have all my mission-critical VMs configured on ZFS storage, which provides redundancy and nice features like live snapshots.
  2. VM Backup or FullClone
    Another step I usually take is to create a full clone of the VM image periodically and store it as backup, in addition to performing incremental backups. Clones are most often used as templates for VMs, but they can also serve as a time-travel feature in most cases.
  3. Nextcloud built-in backup
    Nextcloud uses BorgBackup, which you should run before updating your Nextcloud AIO master container. This is an incremental backup solution, and I house these in a secure location on another NAS. This way you can revert if the update process goes south.
  1. I often find clients interested in their in-house cloud services like Nextcloud, which more often than not require a VPS or VDS that can host a combination of services. Setting up Nextcloud on a VPS/VDS is rather straightforward and easier to maintain than a homelab environment (if you’re not keen to open up your ports). However, creating an off-site backup requires more careful strategy.
  2. This is where the big cloud providers’ cheap storage plans shine. For instance, Google Cloud Storage offers cheap storage plans like Coldline or Archive storage, where Nextcloud can create the backups. Since these are only required as disaster-recovery scenarios, you may or may not ever retrieve from these archives, and it costs only $0.0012 per GB/month for GCS Archive storage. That’s about $6 per 5 TB of storage.
  3. Why am I talking about the off-site backup plan for VPS/VDS-hosted Nextcloud? To list just one scenario out of many: what happens if the service provider goes bankrupt? What happens to your data? This has happened before, and we should have well-thought-out backup plans for such disastrous events.

Hosting my own Nextcloud has proven invaluable for consolidating file storage, collaboration, and user management under my control. By tapping into a TrueNAS share, I sidestep hefty cloud-stored data fees, and with Cloudflare Tunnels, I simplify remote access without broad firewall exposure. Most importantly, I maintain a robust backup infrastructure.

With these measures in place, I can confidently invite friends and family — providing them with johnosoft.org email addresses if desired — knowing my Nextcloud environment is secure, stable, and ready to grow. If I ever need to scale up resources, the Proxmox virtualization platform makes that a breeze. All in all, this approach balances convenience, cost, and control in a single, powerful setup.