dokploy_domain (Resource)
A domain, a Traefik router rule, on a Dokploy application or compose service.
Example Usage
resource "dokploy_domain" "app" {
application_id = dokploy_application.frontend.id
host = "app.example.com"
port = 3000
https = true
certificate_type = "letsencrypt"
enabled = true
}
# A second hostname for the same application is a second domain resource.
# This one is disabled as an example: `enabled = false` removes the route from
# Traefik but keeps the configuration, so you can enable it again later
# without a new certificate and path setup.
resource "dokploy_domain" "app_www" {
application_id = dokploy_application.frontend.id
host = "www.app.example.com"
port = 3000
https = true
certificate_type = "letsencrypt"
enabled = false
}# A domain with a Let's Encrypt certificate on an application. Point the DNS
# record of the host at the Dokploy server before the apply. Traefik requests
# the certificate on the first request to the host.
resource "dokploy_application" "web" {
name = "web"
environment_id = dokploy_project.example.production_environment_id
docker = {
image = "traefik/whoami:v1.10"
}
}
resource "dokploy_domain" "web" {
application_id = dokploy_application.web.id
host = "web.example.com"
port = 80
https = true
certificate_type = "letsencrypt"
}Schema
Required
host(String) Hostname to serve, for exampleapp.example.com. Dokploy does not enforce uniqueness, so the same host can attach twice.
Optional
application_id(String) Id of the application that this domain serves. Set exactly one ofapplication_idorcompose_id. A change replaces the domain.certificate_type(String) Certificate strategy:letsencrypt,none, orcustom. Defaults to"none".compose_id(String) Id of the compose service that this domain serves. Set exactly one ofapplication_idorcompose_id. A change replaces the domain.custom_cert_resolver(String) Traefik certificate resolver name, forcertificate_type = "custom".custom_entrypoint(String) Traefik entrypoint to bind, instead of the default.enabled(Boolean) Serve this domain.falseremoves the route from Traefik but keeps the configuration, so you can enable it again without a new certificate and path setup. Defaults totrue.forward_auth_enabled(Boolean) Route this domain through the configured forward-auth middleware. Defaults tofalse.https(Boolean) Serve over HTTPS. Defaults tofalse.internal_path(String) Path that Traefik forwards to the container. Defaults to"/".path(String) External path that this rule matches. Defaults to"/".port(Number) Container port Traefik forwards to. Defaults to3000.service_name(String) Compose service to route to. It has an effect only withcompose_id.strip_path(Boolean) Strippathbefore the forward. Defaults tofalse.
Read-Only
created_at(String) Creation timestamp from the server.domain_type(String)applicationorcompose. The provider derives it fromapplication_idorcompose_id.id(String) Domain id.middlewares(List of String) Traefik middlewares on this domain. Read-only: middlewares come from outside this provider, so a writable list would reference names that Terraform cannot manage.unique_config_key(Number) Ordering key that the server assigns. Dokploy ignores any submitted value.
Import
Import is supported using the following syntax:
In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:
# Domains are imported by their domain id.
import {
to = dokploy_domain.app
id = "8qZjMb4MS3y9kAEtbefgQ"
}The terraform import command can be used, for example:
terraform import dokploy_domain.app 8qZjMb4MS3y9kAEtbefgQ