fix(server): disable Traefik insecure API by default#4107
fix(server): disable Traefik insecure API by default#4107knowsuchagency wants to merge 1 commit intoDokploy:canaryfrom
Conversation
Both getDefaultTraefikConfig and getDefaultServerTraefikConfig hardcode api.insecure: true, which enables the Traefik dashboard on port 8080 without any authentication on every new Dokploy installation. Change the default to false. Users who want the dashboard can enable it explicitly through the Dokploy UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| }, | ||
| api: { | ||
| insecure: true, | ||
| insecure: false, |
There was a problem hiding this comment.
"Enable Dashboard" UI feature broken for new installations
Setting api.insecure: false (repeated at line 357 for getDefaultServerTraefikConfig) correctly hardens new installations, but it also silently breaks the existing "Enable Dashboard" feature in the Dokploy UI for those same new installs.
The toggleDashboard tRPC mutation in apps/dokploy/server/api/routers/settings.ts only publishes/removes port 8080 from the Traefik container's port bindings — it never reads or updates traefik.yml. When api.insecure: false is in the config, Traefik does not start its built-in dashboard listener on port 8080; an explicit router pointing to api@internal is required. So after a user clicks "Enable Dashboard" on a new installation, port 8080 is published to the host but nothing is served on it, making the feature silently non-functional.
The toggleDashboard handler should also patch traefik.yml to mirror the api.insecure flag:
// In the toggleDashboard mutation handler, after computing newPorts:
const mainConfig = readMainConfig();
if (mainConfig) {
const parsed = parse(mainConfig) as MainTraefikConfig;
parsed.api = { ...(parsed.api ?? {}), insecure: input.enableDashboard };
writeMainConfig(stringify(parsed));
}This keeps the secure default for new installs while ensuring the UI toggle actually works end-to-end.
Description
Both
getDefaultTraefikConfig()andgetDefaultServerTraefikConfig()hardcodeapi.insecure: true, which enables the Traefik dashboard on port 8080 without any authentication on every new Dokploy installation.While the dashboard port is not published to the host by default, it is accessible from within the Docker network. If a user enables the dashboard via Dokploy UI (which publishes port 8080), it becomes publicly accessible with no auth.
This changes the default to
false. Users who want the dashboard can still enable it through the Dokploy UI — the existingtraefik.ymlon disk is preserved and not overwritten (the code checksexistsSync(mainConfig)and returns early increateDefaultTraefikConfig), so this only affects new installations.Changes
getDefaultTraefikConfig():api.insecure: true→api.insecure: falsegetDefaultServerTraefikConfig():api.insecure: true→api.insecure: falseChecklist
canary🤖 Generated with Claude Code
Greptile Summary
This PR correctly hardens new Dokploy installations by defaulting
api.insecuretofalsein bothgetDefaultTraefikConfig()andgetDefaultServerTraefikConfig(), preventing the Traefik dashboard from being exposed unauthenticated on port 8080 out of the box.However, the change introduces a regression: the existing "Enable Dashboard" toggle in the Dokploy UI will be silently broken for all new installations. The
toggleDashboardmutation only publishes/removes port 8080 from the container's port bindings — it never writes back totraefik.yml. Whenapi.insecure: falseis in effect, Traefik does not start its built-in dashboard listener on port 8080 at all, so users who click "Enable Dashboard" will get port 8080 opened on the host but no dashboard served.Key changes:
getDefaultTraefikConfig()line 301:api.insecure: true→falsegetDefaultServerTraefikConfig()line 357:api.insecure: true→falsetoggleDashboardhandler inapps/dokploy/server/api/routers/settings.tsis not updated to also patchtraefik.ymlwhen the user toggles the dashboard, which is required for the feature to work whenapi.insecuredefaults tofalseConfidence Score: 3/5
Not safe to merge as-is: the Enable Dashboard UI feature will be silently broken for all new installations until toggleDashboard is updated to also patch traefik.yml.
The security intent of the PR is sound, but it introduces a P1 regression: publishing port 8080 via the UI Enable Dashboard toggle no longer makes the dashboard accessible because the Traefik config file is never updated to set api.insecure:true. The toggleDashboard mutation must also write the corresponding api.insecure value to traefik.yml for the feature to work end-to-end on new installs.
packages/server/src/setup/traefik-setup.ts (both changed functions) and apps/dokploy/server/api/routers/settings.ts (toggleDashboard mutation, which is unchanged but must be updated to remain functional).
Important Files Changed
Reviews (1): Last reviewed commit: "fix(server): disable Traefik insecure AP..." | Re-trigger Greptile
(4/5) You can add custom instructions or style guidelines for the agent here!