Skip to content

fix(traefik): restrict default Dokploy route (#5036) - #5054

Open
9MidhunPM wants to merge 1 commit into
Dokploy:canaryfrom
9MidhunPM:fix/restrict-default-traefik-route
Open

fix(traefik): restrict default Dokploy route (#5036)#5054
9MidhunPM wants to merge 1 commit into
Dokploy:canaryfrom
9MidhunPM:fix/restrict-default-traefik-route

Conversation

@9MidhunPM

@9MidhunPM 9MidhunPM commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #5036.

Summary

The generated Dokploy fallback router is bound to Traefik's public web entrypoint and trusts the client-controlled Host: dokploy.docker.localhost header. That exposes the Dokploy UI through port 80 even when port 3000 is firewalled.

Fix

Adds a route-specific Traefik ipAllowList middleware to the default fallback router. It permits only loopback and RFC1918 IPv4 ranges:

  • 127.0.0.1/32
  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16

This preserves local/private default access while public requests are denied before they reach Dokploy.

Migration design

On startup, existing valid fallback configurations are reconciled unconditionally to Dokploy's canonical local-access middleware definition and router attachment. This avoids relying on presence-based correctness detection, which can miss malformed or permissive definitions under the Dokploy-owned middleware key. Both canonical fallback forms are reconciled: the generated Host(...) && PathPrefix(...) rule and the Host(...) rule produced when server settings select dokploy.docker.localhost.

Migration has two explicit skip categories:

  • Cannot safely reconcile: unreadable or unparseable files, a non-object root, or invalid/missing HTTP router or middleware structure. The migration logs the reason, leaves the existing file untouched, and does not abort startup.
  • Deliberately not our router to touch: dokploy-router-app no longer has either canonical fallback rule, indicating it has been configured with a real custom domain. The configuration is left untouched.

Test coverage

  • Fresh-install router and canonical allowlist generation.
  • Migration of a pre-fix default configuration while preserving unrelated config.
  • Fallback host configured through server settings protects both HTTP and HTTPS routers.
  • Custom-domain router remains untouched.
  • Malformed/unparseable existing configuration does not crash startup or modify the file.
  • An existing local-access middleware with incorrect content is reconciled to the canonical ipAllowList value.

Verification

  • pnpm typecheck — passed.
  • pnpm --filter=dokploy exec vitest run --config __test__/vitest.config.ts __test__/traefik/server/update-server-config.test.ts — passed (16/16).
  • pnpm exec biome check packages/server/src/setup/traefik-setup.ts packages/server/src/utils/traefik/file-types.ts apps/dokploy/__test__/traefik/server/update-server-config.test.ts — passed; Biome reports one existing informational parseInt radix notice outside this change.

Greptile Summary

The PR adds a private-network allowlist to Dokploy’s default Traefik route and reconciles existing fallback configurations during startup.

  • Generates the canonical dokploy-local-access middleware for new installations.
  • Migrates valid existing fallback routers while preserving unrelated configuration.
  • Skips malformed configurations and custom-domain routers.
  • Adds regression coverage for generation, migration, malformed files, custom domains, and ineffective middleware definitions.

Confidence Score: 3/5

The PR is not yet safe to merge because assigning the fallback host after startup can restore public access to the Dokploy dashboard.

The startup migration correctly protects existing fallback routers, but the live settings path subsequently replaces their middleware configuration without preserving or reapplying the allowlist, leaving the previously reported fallback-host exposure reachable.

Files Needing Attention: packages/server/src/setup/traefik-setup.ts and packages/server/src/utils/traefik/web-server.ts

Security Review

The fallback-host restriction remains bypassable after startup: assigning dokploy.docker.localhost through server settings replaces the protected router middleware and creates an unrestricted secure router. The dashboard can therefore become publicly reachable until the next restart.

Reviews (8): Last reviewed commit: "fix(traefik): restrict default Dokploy r..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used:

@9MidhunPM
9MidhunPM marked this pull request as ready for review August 12, 2026 03:57
@9MidhunPM
9MidhunPM requested a review from Siumauricio as a code owner August 12, 2026 03:57
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 12, 2026
Comment thread packages/server/src/setup/traefik-setup.ts Outdated
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 12, 2026
Comment thread packages/server/src/setup/traefik-setup.ts Outdated
Comment thread packages/server/src/setup/traefik-setup.ts Outdated
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 12, 2026
Comment thread packages/server/src/setup/traefik-setup.ts Outdated
@9MidhunPM
9MidhunPM force-pushed the fix/restrict-default-traefik-route branch from 757b79b to 04ed74d Compare August 12, 2026 04:49
Comment thread packages/server/src/setup/traefik-setup.ts Outdated
@9MidhunPM
9MidhunPM force-pushed the fix/restrict-default-traefik-route branch from 04ed74d to fb4e92d Compare August 12, 2026 04:52
@9MidhunPM
9MidhunPM force-pushed the fix/restrict-default-traefik-route branch from fb4e92d to e9c2af4 Compare August 12, 2026 05:10
@9MidhunPM

Copy link
Copy Markdown
Author

@Siumauricio Final update: the fallback-host regression is fixed, all Greptile threads are resolved, and typecheck, the 16-test targeted Traefik suite, and Biome pass. Ready for human review.

Comment on lines +229 to +231
const fallbackHostRule = `Host(\`${appName}.docker.localhost\`)`;
const isFallbackRule = (rule: unknown) =>
rule === defaultRule || rule === fallbackHostRule;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Fallback restriction is later removed

When an administrator assigns dokploy.docker.localhost after startup, updateServerTraefik replaces the HTTP middleware list and recreates the secure router without dokploy-local-access. Because this reconciliation runs only during startup, the fallback dashboard becomes publicly reachable again until the next production restart.

Knowledge Base Used:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default Traefik route exposes Dokploy UI on port 80 via dokploy.docker.localhost Host header

1 participant