DEV Community

Cover image for Use your own domain name with a Fly app
Brian Morrison II
Brian Morrison II

Posted on

Use your own domain name with a Fly app

Fly has made it incredibly simple to deploy web apps to the public internet, and registering your own domain name and generating an SSL certificate is just as easy.

In this article, I’ll show you how to do just that!

Prerequisites

If you want to follow along, you’ll need the following already set up:

  • The Fly CLI installed on your computer.
  • An app deployed to Fly.
  • A domain name with the registrar of your choice.

I have a boilerplate Remix app deployed to https://victorbot-dev.fly.dev and I’ll be setting it up to use https://victorbot.dev. I’m hosting my domain name using Namecheap. Each registrar’s UI looks a bit different, but they are all based on the same concepts.

Issuing the SSL certificate

The first step is to have an SSL certificate issued. The fly certs add command can be used to create a certificate and add it to your Fly application. You’ll need to specify the domain name you want to use along with the command as well:

fly certs add victorbot.dev
Enter fullscreen mode Exit fullscreen mode

The output should look something like this:

A Record (1.2.3.4) does not match app's IP (5.6.7.8)
Address resolution (1.2.3.4) does not match app's IP (5.6.7.8/1111:2222:3::44:5555:6)
You are creating a certificate for victorbot.dev
We are using lets_encrypt for this certificate.

You can direct traffic to victorbot.dev by:

1: Adding an A record to your DNS service which reads

    A @ 5.6.7.8

You can validate your ownership of victorbot.dev by:

2: Adding an AAAA record to your DNS service which reads:

    AAAA @ 1111:2222:3::44:5555:6
Enter fullscreen mode Exit fullscreen mode

This output will be used in the next steps to configure your DNS provider to point to the Fly app.

Setting up DNS

As mentioned earlier, every registrar has a slightly different UI, so refer to the docs for your registrar to create the required records if you need further assistance. You’ll need to create two records to properly route traffic and prove that you own the domain name.

The following table outlines the required records using the info from the output in the previous step. Note that your values WILL be different.

Type Host Value
A @ 5.6.7.8
AAAA @ 1111:2222:3::44:5555:6

If an expiration or TTL is required, you can leave the value as the default or set it to 3600 (which is 1 hour). Here is what this looks like configured in my Namecheap dashboard:

The Namecheap dashboard showing the records created from the terminal output.

Wait and check

The unfortunate part of working with DNS is that sometimes it takes a while for the system to update. This can happen within a few minutes, or take a few hours.

The first thing you’ll need to wait for is the certificate to be issued. You can check in your terminal with the following command, replacing victorbot.dev with your domain name:

fly certs list victorbot.dev

# Output:
The certificate for victorbot.dev has not been issued yet.
Enter fullscreen mode Exit fullscreen mode

When the certificate is issued, running the command will show this output instead:

The certificate for victorbot.dev has been issued.
Enter fullscreen mode Exit fullscreen mode

Next, you can check to see if entering the domain name in the browser shows the website. If it does, you’re good to go! Otherwise, you’ll need to grab a cup of coffee and check later.

If it’s been a day and is still not working, double-check the DNS values in your registrar! To view the proper DNS records again, remove the existing cert with fly certs remove and try to add the cert again.

Top comments (0)