Skip to main content

How to Use Your Own Domain

In our latest version of Defang BYOC (Bring Your Own Cloud), you can now use your own domain name. (Currently, this new feature is not applicable to Defang Playground)

Step 1 : Check your Defang BYOC settings

If you use the AWS CLI, you can verify that your are authenticated against AWS using the following command (note that the AWS CLI itself is not required to use the defang cli in BYOC mode):

aws sts get-caller-identity

Step 2: Setup a Hosted Zone in AWS Route 53

info

If you purchased your domain with AWS, you can skip this step.

For Defang to be able to manage your domain, you need to create a public hosted zone in AWS Route 53. It should list four AWS nameservers and should look like this:

Hosted Zone UI Screenshot

Step 3: Configure your DNS settings in your domain registrar

info

If you purchased your domain with AWS, you can skip this step.

You'll need to create NS records in your domain registrar that point to the AWS Route 53 name servers which we got in the previous step. For example, in CloudFlare, the NS records would look like this:

CloudFlare NS Records Screenshot

Step 4: Set up Your Compose File

In your compose file, specify the domain name you want to use, for example

services:
web:
domainname: nextjs.defang.chewydemos.com
build:
context: ./web
dockerfile: Dockerfile
ports:
target: 3000
mode: ingress

Step 5: Deploy

Run the following command to deploy your service:

defang compose up

This will deploy your service and set up the necessary DNS records in Route 53 as seen in the screenshot below as well as provision SSL certificates. You can now access your service at the domain you specified in your compose file.

Route 53 DNS Records Screenshot