NextCloud Deployment
I was thinking building my own cloud file storage service in recent days, and yes, I have heard about (and even tried) about NextCloud before, but due to my VPS limitations that time, I didn't get a good experience at my first try.
I just purchase a 4-core 6GB memory cloud VPS with a 2TB HDD disk space and 4TB monthly bandwidth, which I think will be a waste not to deploy a private cloud storage service. So, I looked into Google and found that in the end I still only have two major choices, NextCloud
or OwnCloud
.
Of course, NextCloud is my final choice. (partly because I have deployed it before and it's kind of familiar to me than OwnCloud
)
Mount My Disk
That 2TB disk did not automatically mount to my VPS at the first time so I need to do this work myself. Unfortunately, I don't know how. Special thanks to grok AI, who help me step by step to successfully mount my disk on an Ubuntu system.
I choose the mount point to /sto
(stands for storage
), however, I'm not sure if it's a wise move to set a mount point in the root file system directory like this, maybe I will figure out later lol.
Install NextCloud
It looks like this step is quite simple and straight-forward: just run the installation php
file NextCloud provided. Enter your username and password, determine which database to use, boom, it's done!
Well that indeed the first step of the deployment, but definitely not the last step.
Failed to Install Apps
After installation of NextCloud itself, I started to install apps in the NextCloud app store for my NextCloud instance, and yes, it failed. However, this issue is easy to solve since I could imply there is something wrong because of my server control panel's "PHP protection" policy which will ban the calls to high-risk php functions (and some of them are required by NextCloud itself or the apps I want to install), I removed certain protections, and it worked.
Failed to Mount External Storage
Well, the actual reason is quite simple: It's my server manage panel protection again.
As the image above, I should turn off such directory protection myself.
Nginx Configurations
I have to say this step should be done by highly cautious, one single small trivial mistake made here could cause a huge problem on the Web UI and it's so hard to find out the problem for someone who doesn't have any experience on Nginx configuration before. It's recommended to follow (or at least read about) the official Nginx guide before writing our own one.
My final configuration is something like this, I actually have lots of versions before this one.
If you find some of your resource files not loading, maybe it's because you have wrong Nginx config. For example, two location
with same file type like js
, which may cause your site failed to load some key js
files for UI rendering. Or maybe you forgot to add a javascript
MIME types for your js
and mjs
files, which will also cause NextCloud UI failed to work properly.
Also, you make want to set a long expire time or equivalent Cache-Control
header for those static resources like css
and js
file. NextCloud official Nginx conf recommend to config them as "cached forever" items.
Ensuring HTTP 2.0 Enabled
NextCloud will send a lot of request to relatively small resource files when loading WebUI, so it's strongly recommended to ensure that the HTTP/2.0 has been enabled on the server.
To check if requests have been sent using HTTP/2.0, you could checkout the browser devtools as below:
Also, you could check if this resources have been cached correctly using devtools with "disable cache" turned off.
Setup Image Preview Generation Server
Nothing special, just follow the official NextCloud fine tuning guide to install the Imaginary server (probably using Docker) and update config.php
of the NextCloud instance and it's done.
Note you could check out the docker container log to figure out if the NextCloud is really using this image preview generation server.
Also, if you want to manage image using NextCloud, it's recommended to install an NextCloud app called "Memories", it has a good UI, and it has a really amazing support with mobile web browser too!
Removing "index.php"
Ok this one is a little bit hard to find a direct solution from top Google result.
The key point is:
- Set a proper and correct rewrite rules in Nginx config, check out the example one above.
- Update
configl.php
For the config php files, following two are the key:
'htaccess.IgnoreFrontController' => true,
'htaccess.RewriteBase' => '/',
The Google result will mention the second line, but for Nginx server, the first line is also required. You could check out the official config.sample.php
to learn more about these configs.
I will share my config.php
file example here
Failed On Uploading Big Files
Two points here.
- Are you using a CDN service like Cloudflare?
- What's your Nginx global config looks like?
- What's your PHP global config looks like?
To clarify, CDN providers will usually limit the max upload size in a single request (100MB
for Cloudflare free tire for example), so if you trying to upload a file using WebDAV connection without a segmentation strategy implemented, it will failed on any files larger than the limitation imposed by the factors mentioned above.
Note there are two conditions:
- Using WebDAV
- That WebDAV client does not implement fragmentation protocol which NextCloud supported.
For example, rclone also have a WebDAV backend options, however, it allows files upload larger than limitation imposed above since it have implemented the fragmentation protocol (or you could say, "chunked" upload) and will enable it if the WebDAV backend is NextCloud (check out their config documentaion for more info).
The negative example is GoodNotes WebDAV backup feature, which does not support such chunked upload and will cause big file to fail.
Using NextCloud
WebUI
The most straight way to use this private cloud is using its WebUI to manipulate files directly. And this approach also (partly) support "Resume Download" feature. When you try to download a single file from the server using WebUI, the NextCloud will make use of its chunked transmission API to achieve transmission resuming feature.
NextCloud Desktop
This is recommended approach to use NextCloud on your laptop or PC if you want to sync your data with the cloud.
Only use with VFS enabled
NextCloud apps allows VFS(Virtual File System) on NTFS-formatted (and some other) file system, only use the app if your file system support VFS, otherwise there could be some problems.
- Must sync all selected files at first, which means no more "load when needed".
- NextCloud will consider the local version newer and reupload it from local to the cloud, even if you haven't changed those files on your sync folder.
Note that if you really want a good exprience with NextCloud Windows applications, you shall consider reformat your drive to NTFS file system.
Do not mount large directories
Even if you are using VFS feature to sync files, don't try to use NextCloud official apps to sync a "large" folder. For example, do not try to sync your whole cloud drive to some local directory called "C:/MyData/NextCloud".
The direct reason is that NextCloud official apps is not good at such situations which have a large total file count, it will spend too much time for just sync the metadata of that sync directory.
Rclone Mount
Another way to mound NextCloud directory is to using rclone mount
rclone mount nextcloud:Shares/some/path X: --vfs-cache-mode writes --cache-dir D:\.rclone_cache
When using rclone, you may get errors like the one below:
vfs cache: truncate: failed to set as a sparse file: DeviceIoControl FSCTL_SET_SPARSE: Incorrect function.
This indicates that the cache directory does not support sparse file, you could disable this feature using --local-no-sparse
if you want, check out Rclone forum - Getting failed to create sparse file error for more info.
Again, some common default file system format like
exFAT
doesn't support sparse file whileNTFS
support. So reformat for better experience.
Note that it's recommended to use NextCloud desktop application to mount directories instead of rclone if possible. This is because rclone may not works well with some NextCloud features sometimes, for example, the "File Histroy" feature. And there are possibilities that cache files uploads/downloads messed up the Activities of the NextCloud, check out the image below:
Watch Video Online via PotPlayer
PotPlayer itself support WebDAV/FTP connection natively and we don't need to mount directory ourselves.
To do this, we need to open the playlist, then add a new album:
Or you could use context menu to open a remote directory:
Two things to notice:
- Must enable
SSL
connection and set port to443
if your site support SSL encryption. - Do not include
http://
orhttps://
on the host URL
Check out this guide for more info.
Use As Image Hosting Site
You could achieve a image-hosting like service using NextCloud public share feature. To make direct link works and images could be used in other places (for example add a image link in your blogs), you need to create a share link directly for that single image file.
After copying that link, you need to add a /preview
subfix on that link, then all things are ready!
Something Else
I have to say, the issues I met in this process could be really frustrated and annoying sometimes, but in the end, it's such a rejoice to see the service I deployed from scretch is becoming better and better. It's a true enjoyment!
Also, a huge respect to the open-source community that make such a good and open solution for self-hosted cloud file management system, you definitely make this world a better place.
About This Article
Write at 4.9.2025
Update at 4.11.2025
No comment