Fixing Nextcloud 413 file too large errors
February 03, 2024
As you can see from my previous OMV / LetsEncrypt post I’m running a Nextcloud docker behind a nginx proxy. While backing up photos and videos from my phone (using the excellent PhotoSync app to backup to Nextcloud via webdav) I started getting 413 errors on longer video files.
I found a lot of advice on what values to set where but none of them were a complete solution for me. After tinkering with stuff for an entire morning I finally got things working so I wanted to document what was required to help others out.
Ensure nginx proxy sitting in front of Nextcloud isn’t the problem
Since the request is proxied through my LetsEncrypt docker instance we need to make sure that nginx instance isn’t going to limit the size of files we can upload. To do that I dropped into the console for my LetsEncrypt docker and edited the nginx config for my Nextcloud instance to make sure client_max_body_size
was disabled (by setting to 0):
/config/nginx/proxy-confs/nextcloud.subdomain.conf
server {...// make sure you have something like thisclient_max_body_size 0;location / {...}}
Fix Nextcloud server
Looking at the nginx config for the Nextcloud server client_max_body_size 0
was already set in /config/nginx/nginx.conf
so at first I couldn’t figure out why large uploads were failing. I tried a lot of stuff like setting php values and specifying more values in nginx.conf
.
Then I noticed there is a default site config for nginx. Looking at that file:
/config/nginx/site-confs/default.conf
server {...# set max upload size and increase upload timeout:client_max_body_size 512M;...location / {...}}
Updating it to:
/config/nginx/site-confs/default.conf
...# set max upload size and increase upload timeout:client_max_body_size 0;...location / {...}
And restarting the server solved my problem!