Using Google Drive or OneDrive is quite common these days. People need storage for their documents and pictures so they can share, backup and access them from everywhere. What if you want to build your own and trusted cloud service based on Open Source software? What is more: why would you want to do it?

A neighbor saving your pictures

I met many people using Google Photos for backing up their phone pictures. Some of them did not even realize they were backed up online. That really surprised me.

Cloud

Would you ask your neighbor yo keep a copy of all your pictures? Well, alright, your neighbor is a trustworthy person who does not earn money by offering safeguarding your pictures for you. Maybe you have enough confidence to share all your pictures with them, but probably you would not think it is a good idea.

Google and Microsoft offer you an easy (“free”) way to backup your pictures, but they are not your trustworthy neighbor. What does this mean? It means y ou will send them every picture you take with your phone. They will make a copy, store it somewhere in the United States (and/or somewhere else) and use it for learning things from you. We’ll cover privacy in another post though.

Alright, but… what is a cloud?

The Cloud is nothing but a service running at some servers (computers) so you can access it via internet. For example, Google Drive is one of the services offered by the Google Cloud. Usually you can use it for storing your pictures, a calendar, files and notes.

Networks

Image: The Cloud runs on public servers to be accessed via Internet.

However, paying with your data is not the only way of using a cloud service. You can pay a cloud service or self-host it. How? There are some choices, but here we will cover how to use Nextcloud running on your VPS server.

Hosting and domain name

As you will want your cloud to be accessible via public Internet, you will need a public server. It’s up to you, but my choice would be hiring a VPS (Virtual Private Server), which is the cheapest option for you having a public-available server. Have a look at Dinahosting1 and OVH2.

You will also need a name for your server. That’s easy: pay for a domain name (like martinord.eu) and then add your VPS IP address. We will need it for your pretty, proffesional and amazing URL and for your secure TLS connection via web.

Alternatives to Nextcloud

Nextcloud clients

Image: Nextcloud clients. src: nextcloud.com

Get on with it: Nextcloud

Nextcloud is a self-hosted and cloud-based solution for:

  • Storing you files.
  • Backing up you pictures.
  • Managing your notes.
  • Keep your contacts.
  • Get a centralized calendar.
  • Much more3

We will see here how to install you own self-hosted instance in your VPS. However, you can use an existing one by paying the service.

Install Nextcloud: use Docker

I love Docker so here I will explain how you can start your Nextcloud instance with a couple of Docker images: Nextcloud and the Database.

Docker containers

Image: Docker containers in this deployment.

In the following gist you can find an example of deployment with docker-compose. For using this example, you should create some text files (see the bottom) to save your secret deployment passwords in secret environment Docker variables.

This will create two containers and two volumes to store your persistent data. Start it with docker-compose up -d.

Deploy it with Nginx

Once you have your localhost Dockers, you can deploy it to the public by using a web server like NGINX. Here you can see an example of a reverse proxy to your Docker container and a TLS deployment with Let’s Encrypt.

  • Download it in /etc/nginx/sites-available/nextcloud.mydomain.my.
  • Edit it with your configuration.
  • Link it to enable it: ln -s /etc/nginx/sites-available/nextcloud.mydomain.my /etc/nginx/sites-enabled/nextcloud.mydomain.my.
  • Reboot nginx: sudo systemctl restart nginx.

How to use your Nextcloud

You should also check the available apps3 for Nextcloud, like notes, calendar or an online document editor.

Obri! Next week more and more :D You can also check my web deployment in this article.