Hosting Multiple Domains (at home)Reading time: 2 minutes
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 126.96.36.199
halfbathbrewing.com. 299 IN A 188.8.131.52
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
** I didn’t create this, I found it when I originally configured my linux box.
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