feat: add wildcard domain support with DNS challenge#3929
feat: add wildcard domain support with DNS challenge#3929semihanadolu wants to merge 6 commits intoDokploy:canaryfrom
Conversation
- Use HostRegexp for wildcard domains (*.example.com) in Traefik v3 syntax - Auto-select letsencrypt-dns resolver for wildcard domains with HTTPS - Add letsencrypt-dns certificate resolver with DNS challenge to default Traefik config - Show wildcard domain info alert in domain form - Show DNS challenge configuration warning when wildcard + Let's Encrypt is selected - Guide users to configure DNS provider credentials in Traefik Environment settings
- Validate wildcard domain format (must be *.example.com) - Block 'none' certificate type for wildcard domains with HTTPS - Add DNS challenge provider guide in Traefik Environment dialog - Show common DNS provider env vars (Cloudflare, Route53, DigitalOcean, Hetzner) - Update placeholder with DNS challenge credential examples
- Handle ?traefikEnv=true in Web Server settings to automatically open Traefik Env dialog - Show DNS challenge instructions only when dialog is opened via wildcard warning link
…g link - Move URL parameter reading from EditTraefikEnv to WebServer component - EditTraefikEnv was inside DropdownMenu and never mounted on page load - Render standalone EditTraefikEnv at WebServer level with autoOpen prop - DialogTrigger is now conditional (only rendered when children exist) - Clean up URL parameter when dialog is closed
apps/dokploy/components/dashboard/settings/web-server/edit-traefik-env.tsx
Outdated
Show resolved
Hide resolved
apps/dokploy/components/dashboard/settings/web-server/edit-traefik-env.tsx
Show resolved
Hide resolved
- traefik-setup.ts: use TRAEFIK_DNS_PROVIDER env var with cloudflare fallback - edit-traefik-env.tsx: fix useEffect to setIsOpen(autoOpen) pattern - edit-traefik-env.tsx: context-aware placeholder (HTTP challenge for normal, DNS for wildcard)
aaf932b to
33cb7b7
Compare
| {showDnsGuide && ( | ||
| <AlertBlock type="info"> | ||
| <strong>DNS Challenge for Wildcard Certificates:</strong>{" "} | ||
| To use wildcard domains (e.g., *.example.com) with HTTPS, | ||
| add your DNS provider API credentials here. Common providers: | ||
| <ul className="mt-1 ml-4 list-disc text-xs space-y-0.5"> | ||
| <li><strong>Cloudflare:</strong> <code>CF_DNS_API_TOKEN=your_token</code></li> | ||
| <li><strong>Route53:</strong> <code>AWS_ACCESS_KEY_ID</code> + <code>AWS_SECRET_ACCESS_KEY</code></li> | ||
| <li><strong>DigitalOcean:</strong> <code>DO_AUTH_TOKEN=your_token</code></li> | ||
| <li><strong>Hetzner:</strong> <code>HETZNER_API_KEY=your_key</code></li> | ||
| </ul> | ||
| </AlertBlock> | ||
| )} |
There was a problem hiding this comment.
DNS guide omits the required TRAEFIK_DNS_PROVIDER variable
The guide correctly shows per-provider API credentials (CF_DNS_API_TOKEN, AWS_ACCESS_KEY_ID, DO_AUTH_TOKEN, HETZNER_API_KEY), but these are Traefik environment variables. The provider name embedded in traefik.yml is controlled by a separate environment variable — TRAEFIK_DNS_PROVIDER — that must be set in Dokploy's own environment (not Traefik's), because it is read at config-generation time in getDefaultTraefikConfig/getDefaultServerTraefikConfig:
provider: process.env.TRAEFIK_DNS_PROVIDER || "cloudflare",A user who follows the Route 53, DigitalOcean, or Hetzner rows, sets the correct API credentials in the Traefik Env dialog, but never sets TRAEFIK_DNS_PROVIDER=route53 (or digitalocean / hetzner) in Dokploy's environment will end up with provider: "cloudflare" in traefik.yml — their DNS challenge will call the Cloudflare API with the wrong credentials and silently fail.
The guide should mention that TRAEFIK_DNS_PROVIDER also needs to be set, along with where (Dokploy env vs. Traefik env).
| <DialogTitle>Update Traefik Environment</DialogTitle> | ||
| <DialogDescription> | ||
| Update the traefik environment variables | ||
| Update the traefik environment variables. For wildcard | ||
| SSL certificates, configure your DNS provider credentials | ||
| below. | ||
| </DialogDescription> |
There was a problem hiding this comment.
Dialog description unconditionally references wildcard certificates
The updated DialogDescription always reads "For wildcard SSL certificates, configure your DNS provider credentials below." This text is rendered every time the Traefik Env dialog is opened — including in the existing, non-wildcard flows where users open it from the regular server settings page. It is misleading for users who are not configuring wildcard certificates.
Consider making the description conditional on showDnsGuide:
| <DialogTitle>Update Traefik Environment</DialogTitle> | |
| <DialogDescription> | |
| Update the traefik environment variables | |
| Update the traefik environment variables. For wildcard | |
| SSL certificates, configure your DNS provider credentials | |
| below. | |
| </DialogDescription> | |
| <DialogDescription> | |
| {showDnsGuide | |
| ? "Update the traefik environment variables. For wildcard SSL certificates, configure your DNS provider credentials below." | |
| : "Update the traefik environment variables."} | |
| </DialogDescription> |
What does this PR do?
Adds full wildcard domain support (e.g.,
*.example.com) to Dokploy, including correct Traefik routing rules, automatic DNS challenge certificate resolver selection, and user-friendly UI guidance.Changes
Backend
HostRegexp()instead of Host() for Traefik v3 Go regex syntaxletsencrypt-dnscert resolver is automatically selectedletsencrypt-dnsresolver with DNS challenge alongside the existingletsencryptHTTP challenge resolver*.example.com) and blocksnonecertificate type for wildcard HTTPS domainsFrontend
*.host, an info message explains wildcard matchingHow to test
*.example.comGreptile Summary
This PR adds full wildcard domain support (
*.example.com) to Dokploy, including correct Traefik v3HostRegexprouting rules, automaticletsencrypt-dnscert resolver selection, a new default DNS challenge resolver in the Traefik config, and UI guidance for DNS provider setup.Key concerns:
createDefaultTraefikConfigreturns early whentraefik.ymlalready exists, so the newletsencrypt-dnsresolver block is never written for any currently-running Dokploy instance. Users who upgrade and configure a wildcard domain will get a router referencingcertresolver=letsencrypt-dns, but Traefik won't find the resolver — certificate issuance will silently fail.CF_DNS_API_TOKEN,AWS_ACCESS_KEY_ID), but omits the fact thatTRAEFIK_DNS_PROVIDERmust also be set in Dokploy's environment to match the chosen provider. Without it, the generatedtraefik.ymldefaults toprovider: cloudflare, causing Traefik to use Cloudflare API calls with the wrong credentials.DialogDescriptionunconditionally mentions wildcard SSL even when the dialog is opened in non-wildcard settings contexts.Confidence Score: 2/5
TRAEFIK_DNS_PROVIDERdocumentation, non-Cloudflare users following the in-app guide will also fail silently.packages/server/src/setup/traefik-setup.ts(migration of existing configs) andapps/dokploy/components/dashboard/settings/web-server/edit-traefik-env.tsx(incomplete DNS provider guidance).Comments Outside Diff (2)
packages/server/src/setup/traefik-setup.ts, line 401-402 (link)acme.jsonis explicitly chmod'd to600(line 401), which Traefik requires. However, the newacme-dns.jsonreferenced in the config is never initialized or chmod'd. For consistency and to prevent Traefik permission errors, add equivalent initialization:packages/server/src/setup/traefik-setup.ts, line 395-423 (link)Existing installations won't receive the
letsencrypt-dnsresolvercreateDefaultTraefikConfig(which writestraefik.yml) returns early when the file already exists:This means any Dokploy instance that was set up before this PR will never have the
letsencrypt-dnscert resolver written to itstraefik.yml. When a wildcard domain is configured withletsencrypt, the router will referencecertresolver=letsencrypt-dnsbut Traefik will silently ignore the resolver (or log an error) because it isn't defined in the config — certificates will never be issued.Existing users will need to either manually add the resolver block to their
traefik.ymlor delete the file and let Dokploy regenerate it. Consider adding a migration step or an explicit check that merges the new resolver into an existing config.Last reviewed commit: 33cb7b7