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
If you are using Defang BYOC, you can bring your own custom domain to use with your services.
There are two main limitations to keep in mind when using Defang BYOC:
- You can only use one domain per service.
- Currently you must host your domain's DNS with the provider you are using.
If you want to use your existing DNS provider for other aspects of your system, you can do so and just point a subdomain to your provider's nameservers using NS records.
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.