Skip to main content

Domains

Defang helps you provision SSL certificates and expose your services to the internet. You can expose your services using Defang-hosted domains or bring your own custom domain with Defang BYOC. This page explains how to configure your services to be accessible from the public internet.

Defang-hosted Domains

To make your service accessible from the public internet with Defang-hosted domains (under defang.app), you simply expose ports in your service definition.

Structure

Defang-hosted domains use a structure that is based on your username and service name.

If you have a publicly accessible service, you will automatically receive a domain to access it. If you're deploying to the Defang Playground, your domain will be structured as follows:

https://<username>-<service-name>--<port>.defang.dev

Sample Configuration

services:
# [...]
serviceName:
ports:
- mode: ingress
target: 3000
protocol: http

Bring Your Own Domain

You can also bring your own domain to a Defang project. This allows you to use your own domain name to access your services, and varies a little bit depending on your setup.

BYOC or Defang Playground

If you are using Defang BYOC and do not have your domain's DNS hosted with your cloud provider, or if you are using the Defang Playground, you will need to follow this flow:

  1. Add the domainname to your service definition.
  2. Run defang compose up to deploy your project.
  3. Run defang cert generate to generate an SSL certificate. This command will provide instructions for where to point your domain's DNS before the certificate can be issued.

BYOC

If you are using Defang BYOC and the DNS for your domain is hosted with your cloud provider (i.e. a Hosted Zone in Route 53, if you're using AWS), all you need to do is specify the domainname in your service definition, as in the example below.

warning

For the time being, you can only use one domain per service. If you need to use multiple domains, please vote on this issue.

Sample Configuration

services:
# [...]
serviceName:
domainname: example.com
ports:
- mode: ingress
target: 3000
protocol: http