Setting up a custom domain

Using Fly.io and Glitch, as of January 2020

You, like many Glitch app creators, may want to complete a project by pointing a domain you own to one of your Glitch apps. This doc will show you the process of pointing a domain to a Glitch app on Fly.io using their Edge Applications service.

Pre-requisites:

In this doc, I will be pointing a domain I own, dotbiz.dev, to a Glitch app I’ve already created, jennmoney.glitch.me. The following screenshots and directions are all within the Fly.io dashboard that I see when I log in.

Steps:

  1. Log into your Fly.io account and from within the Dashboard, click the “Create new app” button on the top right of the page. fly.io dashboard

  2. In the “Create new app” modal, give your app a descriptive name (I named it after the Glitch app I’ll be working with)

  3. You should then end up in the “Overview” section of your new app.

  1. Go to “Hostnames” so we can set up our custom domain’s DNS records to point to this app. Click the “Add hostname” button and enter the hostname you want (I added dotbiz.dev)
  1. Now that the hostname has been entered, click the “View” button on it’s row in the table so we can start configuring the DNS.
  1. A modal window will pop up that gives you instructions on what DNS records you need to create wherever your domain comes from. Sometimes these records take awhile to start working, and it can be a frustrating waiting game. You can click “Check again” in the modal every few minutes to see if all the dots go green - when they are all green, you’re ready to tell Fly.io what your Glitch app is. Note - if your dns provider says you can only add an ip address for an a record, you can run dig [url the instructions give you] in your local (or glitch app's!) terminal to get an ip address to enter. in this example, i entered dig jennmoney.edgeapp.net.
  1. Go to “CDN” and delete the existing record under “Backends” and then click “Add backend”
  1. “New backend” is where we tell Fly.io what app we are going to create routing rules from our domain to our Glitch app. Select “Glitch application.”
  1. In the “Add Glitch Application Backend” modal, enter the name of your Glitch app - which is the first part of the glitch.me URL of the app you want your domain to point to (mine is jennmoney).
  1. Fly.io knows our hostname and they know our Glitch app. Now we just need to add “Routing rules” to make the connection between the two. Under “Routing rules” click “Add rule”, which will open the “Add rule” modal. Add your hostname (I added “dotbiz.dev”) and under “Action” click “Use a backend.” You’ll then see a dropdown below that where you can select the Glitch app you previously added.
  1. If everything has been set up, your domain should now point to your glitch app - see how dotbiz.dev takes you to jennmoney.glitch.me

You should be all set! If you want to add more domains or subdomains to this app (for example, I also want to add www.dotbiz.dev), add the hostname and route rules like you did in the previous instructions.