Using Google Firebase as free HTTP & HTTPS redirect service
From time to time you move a website, e.g. a personal blog, to a new hosting service or need to change the URL. Keeping the old links going is a very important aspect of any such move, after all somebody (or even many) linked to your articles and you wouldn't want to disappoint your readers with a blank page or error message.
While there are many free HTTP redirect services available on the internet, I so far found only one that actually also deals with HTTPS. As I enabled HTTPS on my blog many years ago, all the links pointing to my blog also use HTTPS. Also, not offering HTTPS is a no-go in today's security-aware Internet.
So I had the problem to find a redirect service that would respond to requests sent to https://blog.schlomo.schapiro.org/some-or-other-path.html and redirect the reader to https://blog.schlomo.schapiro.org/some-or-other-path.html instead. That shouldn't be a big problem, everything is available for free nowadays. A quick search revealed https://redirect.name/ to be a promising candidate for my redirect problem. Indeed, it works well and is really simple to configure (everything configured via DNS records, no signup). But, it doesn't support HTTPS. Also all the other free redirect services I could find did not offer HTTPS redirects.
What is the problem? SSL (TLS) certificates of course. Creating a "free" redirect service that supports HTTPS means dealing with automatic TLS certificate creation, renewal and authorization. Very much not simple and not trivial. So maybe that is the reason why all the free solutions don't offer that.
Next I turned to my currently favourite free hosting platform, Google Firebase. I was ready to create a custom Cloud function or a complicated hosting configuration, but it turns out that Google Firebase can do simple domain redirects via 1-click-configuration.
The following example demonstrates how I set up another domain to redirect to my blog:
- Sign up/in at https://console.firebase.google.com/
- Create a new project by clicking on the "Add project" button:
- Give your project a meaningful name:
You might have to select a "parent organization" and set up billing at this or a later stage.
- Disable Google Analytics:
And click on "Create Project"
- Google will create the project and setup everything:
- Next go to "Hosting" in the left-side menu bar:
- Click on "Get started":
- Click through the wizard without doing anything:
- Now you see the actual hosting console. Click on "Add custom domain":
- Enter the domain that you want to redirect, check the Redirect checkbox and add the destination:
- If this is the first time that you use a Google service on your domain then you will have to setup domain verification, it will look like this:
Go and create the required TXT record in your DNS domain.
- Finally, Google tells you to configure your DNS with these DNS records for the domain to redirect:
- Now Google Firebase will create the necessary TLS certificates and configure both an HTTP and HTTPS redirect for the domain to redirect all traffic to the new domain. It will take a while (minutes to hours) for this process to complete, just be patient and come back to check the status:
- Eventually everything is done: