How to enable large file uploads with NextCloud, Nginx & Docker

Recently we encountered an issue uploading large files on our NextCloud server. Our NextCloud instance runs as a Docker container behind an Nginx reverse proxy.

Whenever we tried to upload a large file (> 1MB) the upload would fail and NextCloud would report "Unknown Error."

After hunting around a bit we were able to determine that the issue had two sources:

  1. NextCloud's default upload_max_filesize.
  2. Nginx's default client_max_body_size.

First, we connected to the console of our NextCloud container. The php configurations are located in /usr/local/etc/php/conf.d/. We set the upload_max_filesize=25M by typing:

echo "upload_max_filesize=25M" > max_upload.ini

and then restarted the container.

Second, we navigated to the ngnix configuration directory on the docker host. On our system this is located in /var/lib/docker/volumes/nginx-proxy_conf/_data. It was necessary to do this a root as the docker volumes are not readable by a normal user account.

Here we created a file custom.conf with the single line:

client_max_body_size 25m;

We then restarted the nginx proxy stack.

This resolved the issue and enabled file uploads up to 25MB.