Troubleshooting Traefik Redirection and Efficient Static Website Hosting with Docker Images
Traefik Redirection
Traefik redirection is fairly straightforward to setup. However, what tripped me up was the correct regex and the replacement regex operation. I was redirecting to https://shuaib.org/$${1}
but was getting a 502 - Bad Gateway message. Many trail and errors later, I enabled the debug log in traefik using --log.level=DEBUG
. Then I was able to see there was a parse error. The messag was
'502 Bad Gateway' caused by: https://shuaib.org/$${1} parse first path segment in URL cannot contain colon"
So I had to actually copy the scheme from the regex and add it behind the root domain in the replacement string. I used the exact syntax described here.
The other thing to note is when the redirection was working, but the ghost configuration had not been changed to reflect that the blog url has been changed from the subdomain to the root, the Login button and Subscribe buttons were not working.
I also just realized that since the domain has been switched, I will need to change the domains in commento, analytics, search console and potentially all the other pixels.
Lightweight docker solution for hosting a static website
At one point, I thought I had to host my profile page website on my own server rather than using free static hosting. This is because of how I wanted to configure my DNS. However, the cons of hosting on my own server are not taking advantage of CDN's and taking on maintenance. I may need to use it in future for something else. I did a quick research and found this useful: The smallest Docker image to serve static websites by Florin Lipan. Side note: Love the aesthetic on his site.