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.

In my case I moved my blog from blog.schlomo.schapiro.org to schlomo.schapiro.org.

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://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:

  1. Sign up/in at https://console.firebase.google.com/
  2. Create a new project by clicking on the "Add project" button:
  3. Give your project a meaningful name:

    You might have to select a "parent organization" and set up billing at this or a later stage.
  4. Disable Google Analytics:

    And click on "Create Project"
  5. Google will create the project and setup everything:
     ... 
  6. Next go to "Hosting" in the left-side menu bar:
  7. Click on "Get started":
  8. Click through the wizard without doing anything:
  9. Now you see the actual hosting console. Click on "Add custom domain":
  10. Enter the domain that you want to redirect, check the Redirect checkbox and add the destination:

  11. 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.
  12. Finally, Google tells you to configure your DNS with these DNS records for the domain to redirect:
  13. 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:

  14. Eventually everything is done:
That's it! Now you can enjoy your free HTTPS redirect powered by Google Firebase.

A diagnostic check with curl shows how http://demo-for-blog.schapiro.org is redirected first to HTTPS and then to the destination https://schlomo.schapiro.org (this blog). I shortened the curl output to show only the interesting lines:

$ curl --head --location --verbose --http1.1 http://demo-for-blog.schapiro.org

* Connected to demo-for-blog.schapiro.org (151.101.65.195) port 80 (#0)
> HEAD / HTTP/1.1
> Host: demo-for-blog.schapiro.org

< HTTP/1.1 301 Moved Permanently
< Server: Varnish
< Retry-After: 0
< Location: https://demo-for-blog.schapiro.org/

* Issue another request to this URL: 'https://demo-for-blog.schapiro.org/'
* Connected to demo-for-blog.schapiro.org (151.101.65.195) port 443 (#1)
* Server certificate:
*  subject: CN=demo-for-blog.schapiro.org
*  start date: Aug 31 17:53:58 2020 GMT
*  expire date: Nov 29 17:53:58 2020 GMT
*  subjectAltName: host "demo-for-blog.schapiro.org" matched cert's "demo-for-blog.schapiro.org"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
> HEAD / HTTP/1.1
> Host: demo-for-blog.schapiro.org

< HTTP/1.1 301 Moved Permanently
< Location: https://schlomo.schapiro.org/

* Issue another request to this URL: 'https://schlomo.schapiro.org/'
* Connected to schlomo.schapiro.org (216.239.36.21) port 443 (#2)
* Server certificate:
*  subject: CN=schlomo.schapiro.org
*  start date: Aug 30 19:20:51 2020 GMT
*  expire date: Nov 28 19:20:51 2020 GMT
*  subjectAltName: host "schlomo.schapiro.org" matched cert's "schlomo.schapiro.org"
*  issuer: C=US; O=Google Trust Services; CN=GTS CA 1D2
*  SSL certificate verify ok.
> HEAD / HTTP/1.1
> Host: schlomo.schapiro.org

< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Expires: Mon, 31 Aug 2020 19:15:10 GMT
< Date: Mon, 31 Aug 2020 19:15:10 GMT
< Cache-Control: private, max-age=0
< Last-Modified: Mon, 31 Aug 2020 18:53:23 GMT
< ETag: "9dec7d55-8f4a-4cff-98bb-eeab655ecc04"
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Content-Length: 0
< Server: GSE

As redirects don't cost much data transfer, the 10 GB / month free Spark plan should be enough even for very busy websites.

Please let me know in the comments if you find a better alternative that offers more features for the same price: Free.

Comments

Like this content? You could send me something from my Amazon Wishlist. Need commercial support? Contact me for Consulting Services.

Popular posts from this blog

Overriding / Patching Linux System Serial Number

The Demise of KaiOS - Alcatel 3088X

A Login Security Architecture Without Passwords