Most people I meet love building apps, websites, services with infrastructure managed by someone else. You ask them about their infrastructure and it's all AWS Lambdas and AzureCloud Functions with a Cosmos Db for storage, nobody really needs to do anything with bare metal themselves anymore. This is great, we have increased the level of abstraction where I as an engineer can be so far away from bare metal that I will don't need to learn what firewalls and networks are and can spend the rest of my life on the application level code.
This is great but there's a pattern I have noticed, all the great 10x engineers I meet know the ins and outs of infrastructure as well. Heck, one of the engineers who shall remain nameless was a top contributor to Docker at one point... I find this inspiring. The abstraction makes our life easier, but if we don't have an understanding of the "why" behind our abstraction we will never learn the right way to use it.
So with all this inspiration behind my back this Friday I decided to spin up my Raspberry-Pi as an on-premise server. This article is a small document for the steps I took to get my on-premise server onto the cloud.
Let's start with a 10,000 foot above approach to our problem: We want to run a server written in Go-lang that returns a simple straightforward html page when we hit the root route. We know how to get a server up and running locally but we also need to also expose it the outside world.
Now with a rough idea of the 10,000 foot view we can do the following steps to get our server up and running:
Now with my Go server running on port 3001 in the background, my Nginx proxy running on port 3000, with traffic being forwarded to the raspberry-pi from my wifi router, my server was visible to traffic on port 3000 to the public. Now by accessing the public ip for my wifi router on port 3000 I can access my own on-premise web server running a Go-lang server!
This wasn't my usual conventional programming project. But something about removing the idea of a hosting service and managed infrastructure felt very satisfying, and I felt there was value in learning about and managing my own server. Here it is live and in action: Link to my on-premise server
Also I forgot to mention I used systemd to create services that will restart on their own for nginx and go server
So I updated the go server to run a tic tac tow game I wrote!