Skip to content

Configuring a self-hosted Nextcloud server

This is something I've wanted to do for a long time, but for one thing or another I kept postponing it... until now!

I don't know much about Nextcloud other that it's Open Source and built with PHP. I'll share everything I learn along the way.

Activity

Task started

One of the apps I've been trying to ditch for the longest time is Dropbox. Some years ago I tried to substitute it with SpiderOAK, but that didn't turn out great. Now I'm taking another stab with Nextcloud.

There are many things I like about Nextcloud; their philosophy, it's built with PHP, and it has a big community. There are also some things I don't look forward to; the fact that it has too many features (I'm only interested in file syncing), and the source code doesn't seem too welcoming if I ever want to get my hands into it. But I don't know much about it beyond the first impressions, so I'm going to spend some time learning how it actually works and finding out how flexible it can be.

I care about flexibility because what I want to do is not as straightforward as it sounds. I don't actually want to have a single server, but many. I'm currently using Dropbox to host documents, but I'd like to use this opportunity to configure a Media Server. Even though I'm calling it "self-hosted", what I actually want to do is installing it in a Cloud provider (probably DigitalOcean or Hetzner). But I don't want to store everything in the cloud, there are some files I'd like to keep in my local network as well. At the same time, I want to have local backups for redundancy outside of the cloud. I'd also like to sync files in my mobile phone to edit offline (I'm currently using Obsidian + Dropsync). And finally, it'd be awesome if I can use it to host my Solid POD.

So yeah, that's a lot of things I want to do and I'm not sure Nextcloud can handle it without too much tinkering. Depending how easy it is to work with, I'll decide how far I take it.

It's been 3 weeks since I started working on this, and... I don't have good news :(. In fact, if you don't care about reading any further, TLDR: I haven't installed anything yet 😅️.

Let me rewind for a bit.

Right after kicking off this task, I made the following diagram of my ideal setup:

My dream Nextcloud architecture

My idea was to set up 2 Nextcloud instances: one running in a local server at home (with a raspberry pi, or an old laptop), and another running in the cloud (with DigitalOcean, Hetzner, or whatever). I also wanted to keep Nextcloud clients in my phone and laptop with a copy of some data for offline access. And I also wanted to tackle other needs, with jellyfin-webdav for media management, and solid-nextcloud for a Solid POD. All of this works great in theory, but it didn't work so well in practice.

So, Nextcloud. I've been tinkering with it, and my general impression is actually very good. Other than PHP, I found it's built with Vue, which is awesome because it's already using my preferred stack (no Laravel though :P). And I confirmed that it's possible to disable most features to use only file management. The UX is also quite straightforward, and I could manage to do mostly everything I wanted.

But there were also a couple of things I didn't enjoy so much. For example, the codebase is enourmous. There are over 67k commits, and cloning the repository meant downloading 3.07 GiB 😱️. That is definitely something I don't like, and reminds me of Moodle (in a bad way). But then, trying to set up a local instance was a lot worse. My idea was to run it with a couple of Docker containers (which they already support), and expose it in a local ip that's only accessible from my local network. But for some reason I still don't understand, that isn't possible. They are actually aware of the use-case, and they have a very helpful document explaining how to achieve it, with the recommended way requiring setting up a pi-hole (WHAT!?). I even entertained the idea and tried to set up said pi-hole, to see how hard it really was. (Un)fortunately, I got into a dead end when I found out that my router doesn't allow configuring DNS server ips. Yes, I could buy another router or whatever, but I'll take this as a sign that I shouldn't keep going down this path. This is so far from what I had in mind — a simple infrastructure — that it wouldn't be worth the trouble.

On the flip-side, I gave Jellyfin a try, and that one lived up to my expectations. I set it up in 5 minutes and got it playing on my phone. But then again, life isn't that perfect, and apparently if I want to have it on my TV I have to compile the app from source :/. At least I got it playing on the TV using the web browser, so that will have to do for the time being (thank god for the Web!).

Something else I've been tinkering with is the Solid integration for Nextcloud. At first, I thought it wouldn't be as ready as I expected, but after talking with the maintainers it seems the project is in pretty good shape. One drawback I noticed is that you have to be an administrator to install it, which is a bummer because I thought anyone with a Nextcloud account would be able to use it. I could make it work with Umai though, and realized that it doesn't support PATCHing documents using application/sparql-update. Incidentally, I had heard about it recently, and it seems like that's actually conforming with the spec. The spec only requires supporting text/n3 PATCHes. So I'll have to update my apps. Which shouldn't be difficult thanks to Soukai, but ESS does not support text/n3 yet, and I'll have to see what to do about it 🤷‍♂️️.

Anyhow, with all that said I've decided to forego the idea of self-hosting a Nextcloud instance in my home network. But I'm still not abandoning the idea of having an instance running on the cloud, we'll see how that goes.

Today's update should be more uplifting than the last, because I've done some progress! In fact, I'm done with the task :D. Let's get into it.

Before getting started, this is the architecture I ended up with:

My actual Nextcloud architecture

As you can see, I abandoned the idea of hosting a Nextclouod instance in my local network. But now that I've learned more about it, I think I could actually pull it off (though I don't see a point anymore). In my last update, I mentioned that a domain is required to run Nextcloud, and all the headaches I ran into with the pi-hole and whatnot. However, once I tried to install it in the server I realized this restriction is only imposed in the All-in-One out-of-the-box solution. After digging into the repository and reading some documentation, I realized I didn't want to do that anyways. Instead, I created my own set up which combines a Manual installation with a Reverse Proxy (using nginx-agora).

Something else I did which was non-standard is storing the actual files in a Hetzner Storage Box. The awesome part about it is that even if I mess something up in the server or botch up some upgrades, the files are decoupled. So it'd be very easy to rebuild on a brand new server. And I'm only paying 3.81€ for 1TB of storage. Doing this wasn't completely straightforward, but thanks to my tinkering from last time, I learned about WebDAV. And it turns out to be a perfect solution for this. Essentially, I am mounting Hetzner's Storage Box on the server like a normal folder, and I've configured Nextcloud to use that folder to store the files.

If you're interested in the details, you can find my configuration up in GitHub: github.com/NoelDeMartin/nextcloud

So yeah, that pretty much settles all my storage needs for the time being. I've installed Nextcloud clients in all the other machines, and it seems to be working fine so far. I have to say that the user experience is not super smooth; it's a bit clunky at times, with more than a few glitches here and there. But so far I haven't run into any important bugs, so it seems good enough.

Something I've also postponed is hosting my Solid data with Nextcloud. I continued tinkering with the solid-nextcloud extension, but I realized something that was a deal-breaker for me. The id of the documents are very cumbersome :/. But I think there's still a possibility that I use it in the future. The UX of having Solid data in Nextcloud was great, and even though I ran into some issues I could work around most of them. But I think I'd need to dedicate a lot more time to make it good enough, so I'll leave it here for now.

About the home server, I haven't done much since the last update other than installing the Nextcloud client. I tried to come up with a solution to turn it on and off easily, but unfortunately it seems like my old laptop doesn't support Wake-On-Lan or any other viable solution. So right now I'm opening the lid, pressing the power button, and closing it again. Which doesn't seem too bad, but it's a bit annoying for a "server". In the future I'll look into hosting it on a Raspberry PI instead, and I should be able to keep it running 24/7. But for my current needs, it's ok to just turn it on sporadically.

And that's it for this task! There's definitely more things I want to look into, but I'm itching to get back into coding again so that's where I'll leave it this time.

Before closing this though, I'd like to give a shout-out to Derek Sivers for his recently created Tech Independence guide. It's a fun coincidence that shortly after I started working on this task, he made a reappearance in Tim's podcast talking exactly about this. I've looked at the guide, and even tried some of the tools he mentions (I didn't know about Hetzner Storage Box before!). But ultimately, I think most of them are "too simple" for my needs. Which is funny to say, because I've been talking about how I want to simplify my infrastructure and all that. The thing I've realized is that I want simplicity, but I also crave good UIs and hands-off experiences. Most of the tools he's recommending are great, but either don't have a nice UI or are too cumbersome to use regularly. In any case, I think we're super aligned when it comes to values and the idea of tech independence. If you've been reading this and found it interesting, I strongly suggest checking out Derek's guide. You may find something you like :).

Task completed