I have a habbit of buying domains whenever I have an idea for pretty much anything. Sometimes friends and I will be joking around and it will trigger a domain buying spree. Most of the time those domains sit unused until I forget to renew them. In the past I have hosted the domains on Github Pages. There is nothing wrong with that if you want to host a static site like this blog.

Host all the things

Hosting websites from your home has some technical limitations. Specifically in my case I have a single external IP Address. For this post, I am going to point two domains to my IP Address. I start by creating the DNS entries and openning up ports 80 and 443 to serve web traffic.

beards.ly. 284 IN A 99.72.75.144
halfbathbrewing.com.	299	IN	A	99.72.75.144

Automatic reverse proxy configuration with SSL Certificates

At this point I have two domains pointing to my external IP Address. The plan is to host each website in its own docker container and have a single docker container that sits in front of the traffic to route it to the appropriate container.

I want the reverse proxy configuration to be automatically generated as docker containers come online. I also want to ensure SSL certificates are generated automatically via lets-ecnrypt.

To accomplish this, I will use nginx, docker-gen and letsencrypt-nginx-proxy-companion docker iamges.

To start, I need to create folders under my docker-compose.yml file called proxy-templates, certs and vhost.d

docker-compose.yml

proxy-templates/nginx-compose-v2.tmpl

** I didn’t create this, I found it when I originally configured my linux box.

beards.ly domain

For the first website, I want to host beards.ly, scott.beards.ly and www.beards.ly by the same blog. To do that, I add the following section to the docker-compose file.

halfbathbrewing.com domain

For the second website, I want to host brew.beards.ly, halfbathbrewing.com and www.halfbathbrewing.com by the same blog. To do that, I add the following section to the docker-compose file.

Docker Up!

To spin all of this up, I run

> docker-compose up -d

As long as docker is set to run at startup it should automatically start the docker-compose services that are marked

restart: always

More Domains

Now all I need to do is add more services like I did for beards.ly and halfbathbrewing.com