When we deploy a Rails app with Hatchbox, we are given
an internal URL for publicly accessing our app. It is something like
https://123abc.hatchboxapp.com
. That's useful as we are getting things up and
running, but eventually we want to point our own domain at the app.
The first step is to tell Hatchbox what domain we are going to use.
From our app's Domain & SSL page we can enter a domain into the Add A
Domain input. For instance, I have the
visualmode.dev domain and I want the
still.visualmode.dev subdomain pointing at my
Rails app. I submit the full name still.visualmode.dev
and I get an A
Record ipv4 address (e.g. 23.12.234.82
).
The second step is to configure a DNS record with our domain registrar.
From the DNS settings of our registrar (e.g. Cloudflare) we can add an A
Record where we specify the name (e.g. still
) and then include the ipv4
address provided by Hatchbox. We can save this and wait a minute for it to
propagate.
And soon enough we can visit our Rails app at the custom domain.