As you noticed, the blog and the newsletter moved from https://vvsevolodovich.dev/ to https://blog.vvsevolodovich.dev/. The former consult.vvsevolodovich.dev went away.
Now the main site is my business card - courses, workshops and links to the other resources. I also would like to start selling some merch, but we will see how soon shop.vvsevolodovich.dev will appear :)
Anyway, the movement was not very smooth, and I would like to tell you the story about it.
State Before
So, I have my domain registrator and primary DNS at GoDaddy. The blog(which you are reading now) is hosted in GCP on a single virtual machine(don't worry, it's getting backed up). Formerly, I just pointed the CNAME record at GoDaddy DNS to this Google VM. I also had a A record pointing to Tilda for consult.* domain. Indeed, I had some cross-links between each other. It was all working nice.
Reasons to move
When the blog started I was thinking about doing just that - writing articles. However, I started a newsletter couple of years ago and began my consultant practice around the same time. After that I decided to run a course for system design. And recently I added the workshops to the list of my services. It was obvious to me, I need a better setup for my website to properly offer all of those resource to my audience. So I sighed and decided to move.
State After
The tilda and Blog VM left where it was, but the domain names changed. The blog VM is now connected to blog.vvsevolodovich.dev, while Tilda has the main host name.
Old posts problem
Why would you need Cloudflare then?
Well, google indexes your site. That means that you need to let the end users know that the page accessible earlier by for example https://vvsevolovovich.dev/architecture-weekly-140 is now moved to https://blog.vvsevolovovich.dev/architecture-weekly-140. If you open the latter link, you will discover it works. This is how it is achieved.
So, the first idea is to introduce the redirect on Tilda as it now serves the main hostname. However, Tilda can not redirect to a different hostname - it is simply not supported.
Another option would be leveraging the redirect rules available on GoDaddy. That was a promising option, until it wasn't, because they stopped supported custom url path redirect several years ago. Too bad, but it is what it is.
It means that we need a different entity to handle the redirects and Cloudflare makes the best of it. In order to switch the DNS resolution for the website, which domain register is GoDaddy you need to take the Cloudflare DNS servers addresses and put them as primary name servers. This is exactly what I did:
Now we need to put the redirection in place. For that Cloudflare conveniently offers the Rules. Let's create a redirect rule to move all the /architecture-weekly-* links to a new location:
Alright, this problem solved!
HTTPS issues
Now if you open blog.vvsevolodovich.dev then you will receive an HTTPS error. And no wonder: we still use the https certificate for vvsevolodovich.dev, rather than blog.vvsevolodovich.dev. Well, let's fix it!
We will need certbot first. It can work with Nginx and Apache, but I have Nginx option installation:
sudo apt update
sudo apt install certbot python3-certbot-nginx
Now we need to update the nginx config with the new hostname:
server {
server_name blog.vvsevolodovich.dev;
root /var/www/blog;
index index.html;
}
Reload nginx:
sudo nginx -t && sudo systemctl reload nginx
And finally request a certificate:
sudo certbot --nginx -d blog.vvsevolodovich.dev
Let's verify the certificates are appropriately used:
server {
server_name blog.vvsevolodovich.dev;
root /var/www/blog;
index index.html;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/blog.vvsevolodovich.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/blog.vvsevolodovich.dev/privkey.pem;
}
Don't forget to setup auto-renewal!
Conclusion
In general it took only 50 minutes to solve basic problems, but I was fixing the other ones for couple of days. Looks like a bunch of pretty straigtforward steps for an SRE, but I never worked as one and didn't have a chance to configure all of it for production systems. Nice experience neverless.
Liked the post? I run a newsletter about Software Architecture and System Design. Subscribe to get a collection of blog posts every Monday!
Aside from newsletter, I run a Business Oriented System Design course too and the new cohort starts late January. If you still have the learning budget left, this is a good idea to spend it! Sign up here!