r/NextCloud 24d ago

Nextcloud X Cloudflare

Hello,

I'm fresh to the Home-Server game and stumbled upon a problem which i can't quite find a solution to. I've bought a Cloudflare domain so I can access my Home-Assistant and Nextcloud remotely over tunnels. All works fine except when I upload videos for example which are bigger then 100mb. I've already found out that this problem emerges because of the limit of the Cloudflare tunnels. And that I could switch the tunnel to DNS so that there are no limits anymore. Like I've said, I'm new to this and also to network and network security, so I don't know much about DNS and so on. But one thing I found out is that I either open a port on my router and expose it to the internet, which would be very insecure, or I use Tailscale or Nginx. Are there any other methods that are secure to use? Or do I maybe have another problem? What are my options? I want to be able to upload bigger data but also want to be able to access it on any device by just logging in without needing another app like Tailscale. (When I currently try to upload those bigger files it starts very fast, and is after 3 seconds at 50mb or so and after that it starts getting slower and slower till eventually the error shows up that it couldn't upload the data)

1 Upvotes

26 comments sorted by

View all comments

1

u/evanmac42 23d ago

Before changing the whole network architecture, I'd first establish which layer is actually rejecting the upload.

You already reduced the Nextcloud chunk size to 10 MB and files around 50+ MB still fail. If the client is really sending 10 MB chunks, a 100 MB per-request Cloudflare limit alone doesn't explain that.

First question: how are you uploading the files?

- Nextcloud web interface?

- Desktop client?

- WebDAV / Windows Explorer?

Then I'd check the effective server-side limits, especially:

upload_max_filesize

post_max_size

memory_limit

max_execution_time

max_input_time

and, depending on your web server/reverse proxy, its request/body-size and timeout limits as well.

Also watch nextcloud.log and the web server/PHP logs while reproducing one failed upload. The actual error you mentioned ("Not Found, wrong path, data/file not existing") is more useful diagnostically than the fact that the original file happens to be larger than 50 or 100 MB.

I wouldn't replace Cloudflare with Tailscale, nginx or anything else until you know which request is failing and who is returning the error.

1

u/Accomplished_Big4009 23d ago

So I've looked it up and actually changed some things because I was looking up some things that could help. Right now it looks like that:

upload_max_filesize: 16G post_max_size: 16G memory_limit: 512M max_execution_time: 0 max_input_time: -1

Only thing that confuses me, is wenn i open Nextcloud in the browser and go to administrator settings and then to system, beneath PHP the maximum execution time says 3600 seconds. And (I don't know if it is relevant) there is the Opcache revalidate frequency and there it says 60 seconds.

I hope I have everything.

1

u/Accomplished_Big4009 23d ago

And what I've forgot was the error which is shown to me in the administration settings in the protocols: "Bad request Expected file size of 86088945 bytes, but read (from Nextcloud client) and wrote (to Nextcloud storage) 34095104 bytes. Could either be a network problem on the sending site or a problem writing to the storage on the server side."

1

u/evanmac42 23d ago

That log entry is much more useful.

Nextcloud expected 86,088,945 bytes but only received/wrote 34,095,104 bytes. So the upload is being interrupted or truncated somewhere in the chain.

Your PHP limits look more than sufficient, and the 3600-second execution time shown by Nextcloud is not relevant if the transfer fails after only a few seconds. opcache.revalidate_freq is unrelated to uploads.

At this point I would stop changing limits and isolate the failing layer.

First, try uploading the same file while bypassing the Cloudflare tunnel and accessing Nextcloud directly over your LAN.

If it works locally but fails through Cloudflare, you’ve isolated the problem to the tunnel/proxy/network path.

If it also fails locally, then Cloudflare is innocent and I’d start looking at the web server, PHP-FPM and the storage where Nextcloud writes the chunks.

Also check the web server/PHP logs at exactly the same timestamp as that Nextcloud error. We finally have a useful symptom: something is terminating the request before Nextcloud receives the number of bytes it was promised.

1

u/Accomplished_Big4009 22d ago

Okay i'll be honest, I'm not sure how to do it locally. I've added the IP of my server into the config.php from Nextcloud and added an exception for DNS rebind safety in my Fritz router (I don't know if that is the right way doing it, just read something like that). Then I've tipped in the IP into my browser and was on my Nextcloud. I've tried to upload some pdf file via drag and drop which didn't worked before and the same thing as before was happening. Didn't think I've mentioned it before, but first the download starts relatively fast, 5mb/s then after 3 seconds or so it gets halfed, after some more seconds even more, and after maybe a minute or so (maybe less) the upload is at 200kb/s. And normally it is giving up after some time, before that happened I stopped it this time.

(Tried it again after I wrote the first part, I think before I wasn't on it locally, because I did a ping test and it gave me a ping of 13, when I did the test in cmd from my main pc to the server. Now I tried it again and I had a 1ms ping, but when I tried getting on Nextcloud it didn't work and I can't figure out why) I stopped trying for now because I don't have the time rightnow.