Do you want a personal ‘personal’ cloud? ☁️

Alexandru Știube
Yonder TechBlog
Published in
9 min readFeb 22, 2024

--

Bring your old devices back to life

Photo by Jainath Ponnala on Unsplash

Do you prefer not to pay for cloud storage services like Google Drive, Dropbox, or OneDrive? Is it because you don’t trust these big tech companies to safely store your data and force you to read lengthy terms and conditions (you read them, right)? Do you want to have full ownership of your data and be able to access it from anywhere without even creating an account somewhere?

If the answer to the previous questions is yes, yes, and yes, you are in the right place. Great, now I can stop being a marketer and put my software engineer hat on.

Before we proceed, I want to let you know that this process is not entirely free, it costs electricity and (if you don’t have an old laptop, computer, Raspberry board or something similar) a cheap computer. Oh, and you need internet and a router, but if you are reading this without a connection I would like some explanations. Don’t worry too much about the computer, all you need is a machine (it doesn’t have to be fancy or fast) on which you will run the app and store your data, and a router that will let other devices connect to the app. Therefore, the title ‘personal’ has been added as the app will be running on-premise.

For this purpose, I have a Dell OptiPlex 7050 micro, it’s a mini PC, the size of a pair of glasses, and has 8gb of RAM with an i5 CPU. But again, you don’t need anything fancy, this mini PC is from 2017 and it has way too much power that we actually need. So if you have an old computer don’t even think of buying another one, just repurpose it and minimize the e-waste at the same time. In terms of storage, it’s important to know what you are gonna use this for, I have some eBooks and I want to store my digital library on it, so for my mini PC’s SSD of 250gb that’s an easy job.

In terms of technology stack, we will use Docker, first to launch our app on localhost from a container and also keep the configuration in a docker-compose.yaml file, Directus which is basically the cloud app out of the box, and the router software (you only need to adjust some settings here). The mini PC I mention runs on linux (Debian 12) but this should not affect the process because everything will be containerized.

Architecture Photo

So we have a whale, a rabbit, and a… router. This will be interesting. Lets begin then!

1. Launch Directus from localhost

To simplify things, I am going to use Docker to host Directus locally and make the necessary configurations. I will be using the Docker Guide from Directus as a reference. I can simply copy the volumes and some environmental variables for the admin configuration. Feel free to change them as per your requirement. The docker-compose.yaml file will have the following structure:

version: "3"

services:
directus:
image: directus/directus:10.9.2
ports:
- 8055:8055
restart: unless-stopped
volumes:
- ./__volumes/database:/directus/database
- ./__volumes/uploads:/directus/uploads
- ./__volumes/extensions:/directus/extensions
environment:
ADMIN_EMAIL: "admin@email.com"
ADMIN_PASSWORD: "1234"
KEY: "255d861b-5ea1-5996-9aa3-922530ec40b1"
SECRET: "6116487b-cda1-52c2-b5b5-c8022c45e263"

Note: For security reasons you should change the ADMIN_PASSWORD, KEY, and SECRET, for KEY and SECRET I recommend using a random UUID. You can get one from here.

For the volumes I made another folder (__volumes) to keep things more organized and for the port I just exposed the port Directus works with by default. Now hit docker compose up in a terminal and wait until the container is up, note that you need to have docker installed and running on your machine for this to work.

Now open a browser and paste localhost:8055 in the URL and confirm that it works, after navigating to localhost the app will redirect you to the login page. It should be similar to this:

The login page from Directus

2. Configure Directus for your needs

I chose Directus because it offers an excelent out of the box experience and is somewhat friendly even with not so technical people. You can login with the email and password configured in the environmental section from the docker-compose.yaml file, those are the credentials for the admin. After login feel free to explore by yourself the UI, you have the sidebar for navigating through its pages. And as you can see it looks like a fully functional app, and it really is one. Its also open source and free, so there are endless reasons for using it.

Directus UI after login

Next, I would suggest moving to the settings page and start playing with the settings to fit your preferences. After playing with colors and themes you could also change the order of the side panel elements or add new ones that work as a link. I moved the files icon up to be the first one because that’s where our files will be stored, and also I added a link for my router cloud (it’s a USB stick plugged into my router). I also hide the menus that I don’t need.

At this step, I recommend you create a new user and avoid using the admin each time. To create a new user go to the users page from the side menu and… actually it’s pretty straight forward so I don’t think I have to explain to you how to create a new user 😊. After you have created a new user go to settings then to access control and configure what the new user will have access to.

Directus Access Control page

Here create a new role and… don’t get overwhelmed by the amount of options available there. Directus lets you customize everything in terms of access, but we don’t need to configure everything, but for quick config just make sure to have checked the ‘App Access’ box and you should be good. To be extra sure check the directus_files and directus_folders permissions after you open the ‘System Collections’ permissions panel. You should have a green checkmark for at least create, read, edit, and delete.

Settings for accessing the files

The yellow checklist symbol means that there is a custom permission set, it can be something like ‘the user can delete only the folder that he or she created’. Any time you want to access a page that is available to the admin and not to your user means that there is a permission setting that wasn’t granted to the user. If somehow you don’t know what you changed and just want it back the way Directus generated the permissions you could click on: ‘Recommended Defaults’ just where the list of collections ends.

Also playing with roles and users is great because you could grant access to the entire family. For example, your old grandad doesn’t need to see more pages than he is familiar with when you showed him how he sees the family reunion photos. And even more important, you can limit the delete action so he won’t delete something by mistake.

And now, go ahead and test your users and see if they work as expected!

3. Making the app accessible from anywhere

After everything seems to be working fine on localhost, we move to the router settings. To get there you have to open a browser window and in the URL bar type your default gateway from the home network, mine is 192.168.1.1 and the router login should appear.

If you don’t know how to obtain that address try with the same as mine, if this doesn’t work, the simplest way of getting it for Windows would be to open a cmd terminal, type ipconfig, and scroll through the result until you find ‘Default Gateway’. Actually just type this ipconfig | findstr /i “Default Gateway”, and only the ‘Default Gateway’ option should appear.

After you manage to log into your router dashboard search for a section called ‘Port Forwarding’, it might be hidden under the WAN (wide area network) section. Here, after you enable Port Forwarding you need to add a new rule. As you can see in my configs I have already added one:

Port Forwarding panel from my router

The internal IP address is the LAN (local area network) address from the computer that will run the app, this can also be obtained from ipconfig, using the ipconfig | findstr /i “IPv4 Address” command you will get all IPv4 addresses that are configured on that machine, usually the first one is the ‘Ethernet adapter’, as for the protocol I just use the default option that my router provides, TCP (Transmission Control Protocol).

Note: Forwarding a port exposes it to the whole internet, that’s both good and bad at the same time. Give your IP address only to people you trust!

And after you save your changes open your phone, open a browser and type in the URL your IP followed by :8055 (the port we chose to run Directus). If you don’t know your IP address just google: ‘what is my ip address’ and you should find it in no time. Also keep in mind that your IP may change if your router restarts (if you don’t have a static IP address), and you have to use the new one when accessing the cloud.

The cloud working on my phone through a 4G connection

I also added some folders and uploaded images to make sure it works, and guess what, it really does! All changes are saved in the volumes we created for docker. And even if the container is deleted or stopped all you have to do is rebuild it, but be aware that the files from inside the __volumes are your files, that were uploaded through Directus into your cloud. You can create a bookmark on your phone’s home screen using your browser. This will allow you to access the website like an app, and if you also use Edge like me, even the URL bar will be hidden and it will look like you just use a regular app.

Final Thoughts

Yes, I am aware that there are better and more secure alternatives for hosting like Cloudflare, but for this, I just wanted to keep things as simple as possible, and you just have to like… not give your IP address to everyone? Only share your cloud URL with people whom you trust and want to grant access to.

Using this method you can add other services in the docker-compose.yaml file that runs on different ports, and create a new rule for each port from the router config to make them available. If you need more space for e.g. movies, you could also add an external HDD to the computer from which the app runs to extend the space you have. Also Directus have extensions so you can add new futures to your cloud, for more information about this check this page.

And that’s all, you can go from nothing to a personal cloud in three not so big steps. Enjoy your private cloud!

--

--

Alexandru Știube
Yonder TechBlog

A software engineer that likes to learn new things and sometimes teach others