Tip: create a NGINX template for Nextcloud, to let synchronize files bigger than 10Mb

Hello, i need to share here my found solution for this problem with other HestiaCP users who has installed Nextcloud. I’m quite sure that you will save a lot of hours avoiding this trouble.

NGINX default configuration has a rule to don’t let access to files/directories beginning with a period (.), so hidden files. And this is a problem when you try to upload or synchronize with Nextcloud files bigger than 10Mb, because in this case Nextcloud will temporally store the “file” uploaded in a collection of “chunk” files which finally will re-assemble in a file just with name “.file” which try to move to the corresponding user directory.

So we need to add an exception to NGINX file configuration for this host (subdomain) where we have running Nextcloud. If not, then you will not be able to upload “big” files to server using the web Files app or the desktop/mobile synchronization tools. Both use an HTTPS call to server, passing through NGINX.

We need a PERMANENT change

Each time HestiaCP is updated, some config files are REGENERATED (!!), including NGINX hosts (subdomains/domains) config files. So, we need to create a new template for NGINX on server (from terminal) and then use Hestia panel to assign it to the web host running Nextcloud.

From terminal, create a new NGINX template:

cd /usr/local/hestia/data/templates/web/nginx
cp default.tpl nextcloud.tpl
cp default.stpl nextcloud.stpl

Edit both (.tpl and .stpl) and replace:

    location ~ /\.(?!well-known\/) {

with:

    location ~ /\.(?!well-known\/|file) {

From Hestia panel, edit the WEB domain where is installed Nextcloud and in Advanced Options choose Nextcloud as “Proxy template”. And voilà: HestiaCP will regenerate the NGINX configurations files for this host using the new template.

Note: i’m not a sysadmin expert (neither HestiaCP veteran user), so please, add any suggestion or comment to my proposed solution. I must only aggregate that it worked perfect for me. I hope so! hehehe… let me wait for some weeks to check that all continue running fine.

8 Likes

Well done @caos30 ! Too bad I didn’t see your post earlier, before spending hours in owncloud and nextcloud forums and GitHub, trying to figure this out. After I read that post I immediately knew what was going on!

I confirm that your solution works for me as well, in both Nextcloud and ownCloud. I believe your fix has been included in all default templates :clap:

5 Likes

Thanks for your kindly words and specially thanks for make me see that my little contribution has been already added to the official HestiaCP core code :slight_smile:

I’m really too much grateful with what this super-project has given to me!! So i’m very happy to contribute always i’m possible. Cheers!

2 Likes

Have you tried using the owncloud template? I did that and everything works fine…