byeCloud: File syncing with Nextcloud

published on on byeCloud, Caddy, Docker, Nextcloud, Selfhosted

In this article I will describe how I set up my Nextcloud instance aiming to replace iCloud Drive. This article is part of the byeCloud series in which I try to replace iCloud with self-hosted services.

The goals for a file syncing infrastructure are simple

  • I want a reliable solution that syncs files as-is,
  • that does not corrupt them
  • and does not cancel uploads all the time.
  • Additionally, I want to be able to access my files on the go using a mobile app, as well as having files on my local hard disk to also be able to use it offline, just in case I have no network connection.
  • Files should be stored again as raw files on the file system so that I can back them up easily.

As it turns out, Nextcloud offers a solid file syncing mechanism. There are many people that say it is somehow unreliable and slow. I cannot reproduce that properties, for me it works great - maybe because I'm not syncing files of the size of modern hard drives. For me, it's more about documents, images, some videos shot on my phone and so on.

System setup

My Nextcloud installation uses Redis for caching and file locking making the web interface fast and responsive.

Nextcloud uses WebDAV, a well-known standard for file management over HTTP as the way of choice for file exchange. Therefore there are many client options as well as native support in almost any relevant operating system.

As described in the first article of the series, I use a Linux VM on my home NAS. All services are provided using Docker containers. I will use docker-compose to define the services of my application. In the end what I want to have is one single project that includes all services for my personal cloud.

The Nextcloud Docker image

The Nextcloud project provides an official docker image (GitHub, DockerHub). Beside the Nextcloud sources, this also provides PHP and Apache (sadly there's no nginx image for this) which is also what I'm using for my deployment.

Project setup

I also set up a reverse proxy service in my docker-compose.yml file that will act as a global reverse proxy for all the services I use. For this purpose I use my favorite web server Caddy. Sadly there's no official Docker image for this yet, so I use abiosoft/caddy. By the way, Caddy offers full Let's Encrypt support so if you plan to run your Nextcloud instance on a publicly accessible server, it's only one line in the config to get a valid SSL certificate and auto-renewal.

Here's a example docker-compose.yml file for running Nextcloud with MySQL:

version: '3'

    image: abiosoft/caddy:0.10.4
    restart: always
    privileged: true
      - nextcloud
      - "80:80"
      - ./Caddyfile:/etc/Caddyfile

    image: mysql:5.7.18
    restart: always
      - MYSQL_ROOT_PASSWORD=myrootpw
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=mynextcloudpw
      - ./data/db:/var/lib/mysql

    image: nextcloud:12.0.0-apache
    restart: always
      - db
      - ./data/nextcloud/apps/:/var/www/html/custom_apps
      - ./data/nextcloud/config/:/var/www/html/config
      - ./data/nextcloud/files:/var/www/html/data

As you can see, I'm a friend of version pinning and mounting data from the host ;-).

Using Caddy as a reverse proxy is super simple, this is my Caddyfile as referred in the docker-compose.yml:

http://foocloud.tld {
    proxy / nextcloud:80 {

Running docker-compose up -d should already give you a running nextcloud instance on the specified host (as long as you have a correct hosts entry/DNS record).

Client side: macOS (also Windows, Linux)

On my macs, I use the official ownCloud client for file syncing. It always runs in the background and has a icon in the menu bar that allows for direct file access, force syncing (a feature that I always missed in iCloud Drive) and many other options. Like on iCloud Drive, there is a directory created in your home directory. All the stuff you put in there will be synced. Easy as that.

There is also an official Nextcloud client that is a fork of the ownCloud client but as it seems to have issues with some TLS certificates, it's not usable for me right now. As soon as it works, I will switch over to it.

Client side: iOS

In the beginning I thought there was no official Nextcloud app and therefore I was using the ownCloud app which really is not a masterpiece of software. It had almost only one feature, which is file sync and even that worked not very reliable.

Some weeks ago I recognized that there is a Nextcloud app by "TWS" but I thought that this is some app of a third-party vendor and decided to not even try it.

But as it turns out, TWS is working (as a contributor?) for the Nextcloud project and this is their official app. So I decided to give it a shot and downloaded it from the App Store for 99 cents. As it turns out, this app is so much better than the ownCloud app. It works reliable on file syncing and provides some more interesting features I will talk about later.

They even made it open source which is great. But hey, support them! The $0.99 is really worth it.


I recently had the problem that the desktop client always got timeouts when trying to connect to my Nextcloud instance. After longer research I found out that Nextcloud has a brute force prevention mechanism that kicks in after too many failed login attempts from one IP address. The problem is that the Nextcloud container only see is the IP of the reverse proxy rather than the real IP address of the client. Therefore it added a timeout of 10 to 30 seconds per request. In my opinion this more risky than helpful because no one really knows about it and no client can come up with useful error messages as the behavior is like normal but slower.

To get rid of this I first truncated the database table oc_bruteforce_attempts and then added the following to my Nextcloud configuration file:

'' => false

Please be aware that I only added this because I’m running my Nextcloud instance on my local network only. If you are running on the publicly accessible server you should take possible security risks into consideration.