Nextcloud: server replied: Bad Gateway

On a recently installed Nextcloud, I often run into the error message “server replied: Bad Gateway” on the sync client.


Installation host is an UCS member server running Kopano (in native mode, not as a docker container… was installed before introduction of containers in UCS) + Nextcloud installed via Appcenter in a container behind the Apache automatically configured as reverse proxy. Nextcloud is reachable from everywhere via HTTPS + correct Let’s Encrypt certificate.
Affected Nextcloud storage is AWS S3 and CIFS. This occurs even if I only use one type of storage. The server itself is mostly idling and serves just a couple of clients. No CPU spikes, low memory etc.

“sudo -u www-data php occ files:scan --all” in the docker container shows about 20.000 folders and 100.000 files in total.

Eventually, this error clears out itself and it indicates that all files are transfered - but it takes ages and is not reliable. Also, rescanning occurs quite often and takes long. I can’t be sure that all files have been transfered.

Any ideas where I could start to solve the problem?