It’s been a long time since I’ve done server ops stuff for websites. A long time. That’s why I got myself into a pickle with my domain names that I only recently got myself out of upon discovering that I am, in fact, an idiot.
A Tale of Two Domains
I had scopique.com for a while now. I had originally set up shop at levelcapped.com, but as I found that I was writing less and less about games and more and more about things like motion graphics, VFX, and development, I wanted a domain that was more general purpose. How can a domain be more general purpose than to name it after oneself? Or, at least, one’s online handle. Not only that, but I would have email addressed “@scopique.com” which was kind of cool.
I had .com hosted with a company, and everything was OK until I got involved in the Fediverse and wanted to try some self-hosted (or self-managed) things. Rather than risk .com on these ventures, I picked up “scopique.online”, fancying this to be the “activities arm” of the Scopique eEmpire. One thing I had planned to try was to set up an OwnCast server for streaming, but I’ve been vacillating on that front.
For a while there I opted to park .online, until I decided to really mess up my life.
Self-Hosting For Headaches and No Profit
I set up a home server. It was originally designed to be a home lab for testing stuff in a Linux environment, but I thought that if I could host my site in my home I could save some money.
I set up a Docker container with WordPress, and spent some time porting my .com site design and data over to this instance. It took some trial and error, but it works for the most part.
But there was an issue: I have some email attached to .com, and I wasn’t confident that I could rememebr how to work the DNS records to point the website to my server while leaving the MX records intact. Truthfully, it’s not hard, but I was paranoid because we end up with so many services relying on a valid email address these days; if I did screw something up and lost access to email, I would panic and lose my shit.
So I made the decision to point the .online domain at my home server. Because I’m using a reverse proxy with Docker, I had to add the “blog” prefix to get traffic to where it needed to be, but I assumed this would be temporary until I could get .com cleaned up and pointed at the new site instance.
That is why I stupidly chose to assign a 301 from .com to .online, and the shit hit the fan.
HTTP Status Codes
301 isn’t something that the public sees often. Most folks are familiar with 404, and maybe various 500 series codes. HTTP status codes are returned from the web server to the browser to indicate the operational status of the request. A success — you get the content you request — is a 200. 404 is, of course, not found. 500 is “uh oh” in various flavors.
301 and it’s little sibling 302 are redirect status codes. When a browser receives a 301/302, it looks for an accompanying header value location which provides the URL that the browser should redirect to. In my case, I wanted anyone who requested “scopique.com” to be redirected to “blog.scopique.online”.
The problem is that 301 is a permanent redirection, while 302 is a temporary redirection. A 301 should only really be used when an old URL is being completely decommissioned and we need users to be punted to a new URL without the users really having to know (yet) the new URL. In effect, that old URL is never coming back. A 302 is used when an old URL needs to point elsewhere for a while, but should return to service on its own at some point.
I did a 301 for some reason. I don’t know why.
Reversal of Fortune
Once I got my .com situation figured out, it was time to get .com to point to the site, and for .online to go back to the parking lot. I removed the 301 forwarding directive that I had set up with my registrar, and updated my reverse proxy script to send “scopique.com” traffic to the website instead of sending “blog.scopique.online” traffic to the website.
Of course, nothing happened. I was getting redirects from .com to .online every single time. It’s made worse by the facts that A) I don’t have a loopback set up with my reverse proxy, so traffic inside my house needs to go out via VPN in order to hit my own site, and B) I can only set up one direct URL to receive traffic through my reverse proxy, meaning it has to be either .com or .online.
So now I’m freaking out that “permanent” means “until the Sun burns out”. I contacted the registrar to confirm that my DNS was configured as expected. I messed around with the proxy scripts. I swapped back and forth between .com and .online at the DNS and proxy levels. Everything from .com was redirecting to .online, and I couldn’t stop it.
The Light Dawns on Marble Head
Of course, everything I was reading kept leading me back to the website, telling me that the website was responsible for redirects. But I had set the 301 at the registrar! How could that change my website settings?
Wait. Website settings.
Ah, shit. These two bastards had been set to “blog.scopique.online” ever since I had installed the software on my home server, and they are very serious about their job. That meant that when the proxy was correctly receiving .com traffic and sending it to WordPress, WP was attempting to course correct itself to “blog.scopique.online” which the proxy didn’t know about any more. This resulted in a 404 for .com, and a 404 for .online.
I have been fighting this issue for weeks, so believe me when I tell you that I feel like the biggest idiot on the Internet right now, and that’s a very high bar to clear.