NextCloudPi - Personal Cloud
While in Toronto in the summer, I heard from a friend about this cool project called NextCloud. She showed me this post in her twitter feed, and there was this picture of a laptop sitting vertically in a stand with an external hard drive connected to it. Although I couldn't read the post (it was in Japanese), I was intrigued. If I have old hardware lying around, why don't I make something useful?
I want to share lots of uncompressed photos with my friends, without paying premium pricing. I decided to do this project because:
1) I have free time and I want to build something:)
2) My Google Photos Storage is running out, and I want to be able to share uncompressed photos with my friends without worrying about losing my account space. I could create more Google accounts, but managing multiple Google accounts is tedious.
3) I finished school at UofT, and my 1TB OneDrive subscription likely expires soon.
4) Cloud storage and cloud service providers are expensive! At face value, without considering each service's other perks (VPNs, Dark Web monitoring, etc...), here are the numbers:
When I heard you could build your own cloud at home for cheap, and host it so it's accessible on the internet, I got excited.
NextCloud is an open-source project that aims to act as a private cloud, with the ability to not only share files, but also to act as a private cloud for calendars, photos, email, news, and other community-built apps like health and GPS tracking. You can setup multiple user accounts and share links with anyone, just like Google Drive or Microsoft OneDrive. Below are some of the alternatives for hosting a private NextCloud server:
The cost reduction of a Raspberry Pi compared to the next cheapest alternative (Google Cloud) is 2.64x! Although the Raspberry Pi was the cheapest alternative for me, it is not necessarily the most reliable. We cannot compare consumer computers to enterprise-grade servers in globally-available datacenters with redundant power supplies, storage, and networking. We can always try our best to configure the Pi to be secure, reliable, and highly available!
I then set a static ip for the Pi. I went to the admin panel (nextcloudpi.local:4443), clicked the gear icon (Settings) and navigated to Networking>nc-static-IP. I kept the IP the same as what my router had assigned. If you change the IP, you have to update the IP you forwarded ports for in your router.
To ensure we can access our Pi externally, we must setup a dynamic dns provider, which maps a domain name to the external IP address of our router. The NextCloudPi guide explains that some routers do not have their own external IP address, and are instead behind a CG-NAT, or Carrier Grade NAT. If you are behind a CG-NAT, you must use a VPN or proxy like ngrok to enable external access.
You can use duckDNS, freeDNS, no-ip, or any other provider listed under Settings>Networking after setting up an account. For example, if you use duckDNS, you would add the domain and token from your account. NextCloud should have already added your domain to the Settings>Config>nc-trusted-domains, but if not, you can add your domain there.
To test that the dynamic DNS worked, I used my phone (on WiFi) to navigate to the domain I registered and checked to see if I could login to my NextCloudPi. It didn't work! I realized that my router may not have NAT Loopback or Hairpinning, which allows you to access a domain name pointing to your own external IP.
NextCloudPi has a feature called dnsmasq which aims to alleviate this isue, but I could not get it working.
To access the Pi on my network, I continued to use nextcloudpi.local. Externally (such as my phone on data), I use the domain name I registered, which worked.
I set up Let's Encrypt (SSL encryption) using the NextCloud guide. Let's Encrypt lets you generate an SSL certificate to allow your browser to "trust" a connection to a website (server). This was pretty simple to setup. The only caveat is that if you use nextcloudpi.local in your local network, the certificate will be invalid since it will be under the domain you registered.
I also use at-rest encryption under Settings>Security>nc-encrypt to keep files encrypted.
After getting everything setup, I created a NextCloud user account and tested out the file upload speeds with a 120MB mp4 file. I got around 35.7Mbps upload speed on my Home WiFi, 11.6Mbps download on WiFi outside my network, and on my phone's slow data, 2.6Mbps upload. Although this isn't too impressive, it makes sense given the underpowered Pi. Thankfully, I can easily upload images, which is what I set out to do. I can also stream mp4 video without buffering. Now I can fill up my own photo cloud without worrying about filling up Google Photos:)
It was super cool (well, to me at least) to be able to upload uncompressed images on my private 500GB cloud and share them with my family and friends!
Security is important, so monitoring logs and checking for updates are essential to managing your own cloud. Keeping backups of your data is also important, especially with consumer-grade hardware like the Raspberry Pi. There are periodic backup options under Settings>Backups.
I'm happy with how this project turned out, and hopefully it can inspire others to build their own private cloud!