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.
- Playground
- BYOC
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
If you're using Defang BYOC, your domain will be:
https://<service-name>--<port>.username.defang.app
Sample Configuration
- Compose
- Pulumi
services:
# [...]
serviceName:
ports:
- mode: ingress
target: 3000
protocol: http
As of now, the Pulumi provider does not support Defang BYOC.
const service = new defang.DefangService("serviceName", {
// [...]
ports: [{
target: 3000,
mode: "ingress",
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:
- Add the
domainname
to your service definition. - Run
defang compose up
to deploy your project. - 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.
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
- Compose
- Pulumi
services:
# [...]
serviceName:
domainname: example.com
ports:
- mode: ingress
target: 3000
protocol: http
As of now, the Pulumi provider does not support Defang BYOC and the Defang Playground does not support bringing your own domain, since it is not for production use.