I've recently undertaken a fun and challenging experiment in my tech journey. As some of you know, I've been a software engineer for the majority of my professional career. I started off at an early age building computers for my dads computer business. I was around 13 years of age at the time that I started doing that and never thought that I would be where I am now.
I started off my professional career as a tech writer for a company that I worked for when I first moved to Texas. They needed someone who could write web applications, and at that time, there wasn't much documentation or examples to find because the web was still in its infancy. I immediately volunteered for the project. I knew it would be a challenge, but also in my arrogance thought 'how hard could it be?'. Well, it was a challenge that I eagerly took. I bought books upon books about the basics of programming in VBScript, JScript, SQL and XML. I'm pretty sure I have some of those books in boxes in the garage somewhere.
As the technology has progressed over the years, it became more and more exciting to find and develop different solutions to problems out there. One of those technologies is containerization. There are several container options out there at the moment, but I decided to go with Docker. Docker has a large community out there, so it's easy to find examples on setting up a new system, and if you can't find the examples you are looking for, there are many communities to search on. For the adventurous, you can even use ChatGPT or other LLM's to ask for help.
With the knowledge and experience I have, I asked myself: Are there any better ways to host my data? And why would I want to do that?
- Cost
- While I'm not paying for all that many services, and the ones that I do use are great, but I may need more space, or more features, it comes at a cost. Money. No one likes spending money when we don't have to. This was the initial reason for going down the road of self hosting. I figured I have a few older machines laying around that I'm not actively using, why not put them to good use?
- Privacy & Control
- I've never been a fan of letting someone else have control of my personal documents that I store on places like Google Drive, One Drive, and the like.
- If I can control my files on my devices, I would prefer that more than letting someone or some company that I don't know, control those files.
- Experience
- I've had my hand in writing some very highly available and high load applications in my previous jobs. I could have written some of the applications I use myself, but I decided to go down a different path and use some open source application that are hosted in Docker (I'll touch on those applications below).
As I mentioned earlier, I needed a computer to host these applications on on. Luckily I had a couple old machines running Windows. One was an old i5 Fujitsu laptop, the other is a Dell i5 desktop. I started off with the laptop because, who doesn't like portability? I've been using this laptop for a while know for recording some guitar tracks and decided that the laptop would be a perfect candidate to start with. A while ago I already loaded Ubuntu Linux on it with all the bells and whistles of recording software that I needed. I haven't been recording for some time now so I decided to start setting this up as a "server".
- Choosing an OS
- I've downloaded multiple flavors of Linux to play around with and see which one I'm most comfortable with. I've tested these different distributions out on VMWare (this let's me load up an operating system without affecting my primary OS)
- I finally landed on using Ubuntu. This isn't because it's the 'best' distribution for my use case, it's just the one that I am more comfortable with at the moment. Eventually I realized I didn't need a nice graphical user interface, so I installed the Ubuntu Server distro. It's all command line and I can SSH into the machine and do everything I need via the terminal.
- I could just as easily have set this up on a Mac, WIndows or any other flavor of Linux if I wanted to, but this. Docker can easily be used on all 3 of the most popular operating systems out there with similar outcomes.
- Setting up the domain and routing
- To be able to self host these applications, I needed a way to host them. I have the computers, I have an internet connection and I have a home router (one that I bought and is not being leased through the ISP - however, you don't need to own your own router. Most routers provided by your ISP have a nice web interface that allows you to make changes directly to your router.
- First I needed a way for the outside world to gain access to the applications I'm hosting (such as this website). This is where my home router comes into play. From the router (using port forwarding), I can direct traffic to a specific machine/port on my server. For instance if I want to host a website (which is typically hosted on port 80), I can forward the traffic to my server on port 80 which serves up the webpage.
- Once I had my proof of concept up and running, I wanted an easy way for anyone to get to my site, so I set up my domain name to point to my home IP address. This can be done with any domain name if you own it. Whoever your registrar is should have an interface where you can change your "A Records" to point to any IP address of your choosing.
- Now that I had the port forwarding on the router set up along with the domain name pointing to my IP address properly, I was in business! I could start setting up services to my hearts content.
- There was a catch though. I have several hosted applications that are accessed via the web. They can't all run on the same port (80). Only one application at a time can use a single port. That's where I set up a proxy server to handle that. I'll talk about that more below.
- Deciding how to host applications
- As I've mentioned already, I've decided to use Docker to host the containers that hold the applications
- Docker uses the container concept to run applications. What this does for me is removes the need to "install" the application or software directly on the host machine. A container has access to all of the memory, CPU and storage on the machine. The reason I prefer using containers is that they are very easy to set up and tear down. When installing applications on a Windows machine and you decide that you don't like that application anymore and install it, the uninstall is typically not clean. The installation process will usually install DLL's and make changes to your registry, and during the uninstall process, they typically leave remnants of the application around in the file system and registry. However, with Docker, nothing like that happens with the containers. Once the container is removed, everything is removed.
- Which applications do I want to host?
- Nginx Proxy
- This is the proxy I mentioned above. What is a proxy? Well, it's a slick little application that allows traffic to come in on one port and be directed to different ports on the same server, or different server all together.
- Let's say I have 2 (or more) applications that want to be hosted on port 80. Well, this isn't possible in a normal situation. Using Docker, I can set up an application to use a different port for each application. The proxy server will see the traffic coming in and determine which application to use and serve up the proper site to the user.
- Homarr
- Homarr is a nice dashboard that lets me quickly access the applications I've set up. Trying to remember IP addresses and the ports that the application is hosted on can be a bit cumbersome when you start adding more and more services to your homelab landscape.
- Immich
- This is one of my favorites. Immich has everything and then some of Google photos. It also has a mobile app on the app store for both Android and iPhones. You can sync your photos on your phone directly with your Immich server hosted at home.
- Nextcloud
- This is another of my favorites, and quite honestly one of the original reasons I started going down the path of self hosting different services. Think of Nextcloud as a replacement for the Google suit of file sharing, document creation, calendar and contacts. Any time you run out of space, just add another drive to your servers and you don't have to pay the big G any extra monthly storage fees.
- Like Immich, Nextcloud also has mobile apps that sync up your data seamlessly.
- Website CMS
- I initially went down the road of trying to write my own website... after all, I am an application developer. It's what I do for a living. What I quickly came to realize is: I don't want to spend a lot of my time writing a website that would do everything that a normal CMS (content management system) can do for me out of the box. I landed on Drupal. I've tried several other CMS's out there and this one just worked. I set up the database, the front end and let it go. Like all of the other applications, this is hosted in a Docker container that is easy to update.
- Nginx Proxy
So far this little journey I'm going on has been challenging along with bits of frustration along the way. I've learned quite a bit so far and it has been very rewarding. It also gives me just one more thing I can put on my experience and hopefully use more in the future. This will definitely be an on going experiment for me and I look forward to adding more services in my homelab.
- Log in to post comments