visit
After over a year of development, SD2, my web server is done.
When I initially set out to build a website, I wanted it ranked #1 when you searched my name on Google. I remember seeing other students like Kevin Frans(MIT/OpenAI) and Gautam Mittal(Berkeley/Stripe) having their websites highly ranked on Google and took inspiration from that to do the same.I also wanted to automate a lot of mundane tasks to ensure that this web server is highly scalable in the event I get a lot of traffic, highly available to prevent any user from having downtime while accessing the many elements to my server, and portable if I need to move over to a different cloud service provider.
After finding out about AWS’ free tier I decided to give EC2 a chance. Using it for a couple days got me comfortable using it, although configuring the launch wizards opposed to VPC on GCP took some to get used to, but I was able to run basic NGINX instances off of it.However, AWS has this somewhat weird structure for CPU usage available here: . Essentially, after several days of running my entire stack, I was beginning to be throttled all the way down to nearly 5% CPU utilization, slowing all my sites to a standstill. It got so bad that any and all my sites were unusable.This prompted me to get some more credits from GCP and continue on there for the finite future.
Note: When developing this server, I used AWS.
A NGINX server to reverse proxy websites I buildHigh availability of my Blog (running on Ghost)Self hosted Analytics EngineSelf hosted storage service (both uploading and downloading)Self hosted email server (SMTP)Self hosted URL shortener
And all of this had to be built using Docker, to make it easily shippable to other servers in the case the one I’m using goes down or something else happens (from experience on moving from DO to GCP to AWS to GCP and in between spinning down and up servers from instance to instance)
I initially created a AWS AMI with Docker baked in (because I couldn’t find one readily available) and started playing with my newfound Docker knowledge (from using it in the workplace).With this in place I started spinning up EC2 instances left and right, trying out Ghost images, setting up ECS, finding out what Fargate is, and trying to see how I can scale.
That’s when I found docker compose. It made it a lot easier to just spin up new containers if I needed to. And scalability? It had it, without even disrupting existing containers.
Running a simple
docker-compose up --scale ghost=3 -d
After doing a little digging, it definitely sounded like a nice option. And using it for a little while made me realize it was manually generating configuration files and it was hard to easily configure, especially with Docker compose.
That’s when I found Traefik, a cloud native edge router.
Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components (Docker, Swarm mode, Kubernetes, Marathon, Consul, Etcd, Rancher, Amazon ECS, ...) and configures itself automatically and dynamically. Pointing Traefik at your orchestrator should be the only configuration step you need.
So it was a batteries included reverse proxy engine which fully supported Docker-compose, fitting exactly my needs.
On the other-hand, with Traefik and Docker Compose, I’m easily able to run everything and anything I want within minutes with Docker and route every service to its intended destination with Traefik.As I’ve said previously; given Docker’s “portability” of shipping containers around, I could even set everything up on my old desktop and have it work seamlessly (with using Cloudflare Argo).Traefik even has a GUI! Here’s how looks like:
So what am I running?
With the power of Traefik and Docker Compose I’m running the following:This Blog (subscribe if you haven’t yet! ), (static sites)ShareLatex (I run my own Latex server for fun)Mongo, Redis, Postgres, MySQL (although I’m probably going to drop MySQL for SQlite soon)URL Shortener ()A commenting server (for you to comment on my posts; don’t like Disqus having you to login everytime)Netdata to check if everything is running or if swap space RAM is being used or to see if CPU is being over-utilizedSo have I accomplished what I sought out for?1. A NGINX server to reverse proxy websites I build
2. High availability of my Blog (running on Ghost)
3. Self hosted Analytics EngineSelf hosted storage service (both uploading and downloading)
4. Self hosted email server (SMTP)
5. Self hosted URL shortenerSomewhat.I’m still working on an analytics engine after both Fathom and Ackee (open sourced analytics engines) gave me mixed results, but gave me the direction that I should self host (I don’t trust that Google Analytics is going to give me the correct results since so many people have adblock on).In regards to a “Google Drive” for myself, it’s at: (where all the images you’re seeing are from) which I host from my Fastmail account (allows me to upload/download/serve files with ease)
In regards to email: I need a reliable email service. Although I trust myself, I trust Fastmail to do it for me with better features. I’ve come to love what features they provide and so far just stuck with them.
At the end of the day I’m more than excited and happy with what I’ve built with the knowledge I’ve accrued from my internship at Renovo and from other various sources.
So what can I as a reader use from your “plethora” of services?Not much unfortunately. This whole setup was more of a feat to show how powerful, simple, and easy self-hosting can be. Although one day I’d like people to use my URL shortener or Latex server, at this point my low spec’d GCP instance probably isn’t good enough for multiple people to join on.However,
You can build everything listed here on your own.Simply install (which coats you server with some butter to start cooking up the main part of the operation)Then simply download and run docker-compose on this file and start traefik with this line:sudo docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v $PWD/traefik.toml:/traefik.toml -p 80:80 -l traefik.frontend.rule=Host:*subdomain*.*yourdomain*.com -l traefik.port=8080 --network proxy --name traefik traefik:1.7.12-alpine --docker