skip to content
wihan.dev
view as markdown
browse the dokploy docs

dokploy_domain (Resource)

A domain, a Traefik router rule, on a Dokploy application or compose service.

Example Usage

terraform
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
}
terraform
# 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 example app.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 of application_id or compose_id. A change replaces the domain.
  • certificate_type (String) Certificate strategy: letsencrypt, none, or custom. Defaults to "none".
  • compose_id (String) Id of the compose service that this domain serves. Set exactly one of application_id or compose_id. A change replaces the domain.
  • custom_cert_resolver (String) Traefik certificate resolver name, for certificate_type = "custom".
  • custom_entrypoint (String) Traefik entrypoint to bind, instead of the default.
  • enabled (Boolean) Serve this domain. false removes the route from Traefik but keeps the configuration, so you can enable it again without a new certificate and path setup. Defaults to true.
  • forward_auth_enabled (Boolean) Route this domain through the configured forward-auth middleware. Defaults to false.
  • https (Boolean) Serve over HTTPS. Defaults to false.
  • 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 to 3000.
  • service_name (String) Compose service to route to. It has an effect only with compose_id.
  • strip_path (Boolean) Strip path before the forward. Defaults to false.

Read-Only

  • created_at (String) Creation timestamp from the server.
  • domain_type (String) application or compose. The provider derives it from application_id or compose_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:

terraform
# Domains are imported by their domain id.
import {
  to = dokploy_domain.app
  id = "8qZjMb4MS3y9kAEtbefgQ"
}

The terraform import command can be used, for example:

shell
terraform import dokploy_domain.app 8qZjMb4MS3y9kAEtbefgQ