Tailnet domains: publish a compose service on a Tailscale tailnet through an injected sidecar (design for the per-app mode of #4312)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- docker, docker-compose, typescript
- Lĩnh vực
- devops, infrastructure
Hướng nghiên cứu
This is a design proposal awaiting maintainer agreement, not a scoped task. Start from the plug-in points it names: the domain schema and publishToCloudflare precedent from #4531, addDomainToCompose, and handle-domain.tsx, then read the Cloudflare Tunnel PRs #4528/#4531 as the model. It spans a new organization-level integration, encrypted credentials, key minting via the Tailscale API, compose injection and lifecycle cleanup — read the thread and the linked issues before writing anything.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What problem will this feature address?
Many Dokploy apps are internal tools that should not answer the internet at all, and their operators already run Tailscale. Today the ways to put such an app on the tailnet all sit outside Dokploy:
- Tailscale on the host plus
tailscale serveper app. Every app shares the host's single name and gets a port of its own (host.<tailnet>.ts.net:8443,:8444, …). Each change needs root on the host. Funnel is limited to 443, 8443 and 10000, so at most three apps can be public. A host that is logged in as a user cannot host Tailscale Services ("You cannot use a device authenticated with a user account as a Service host", KB 1552). On top of that,tailscaledand Traefik compete for:443on the host (#5157). tailscale certplus a custom certificate, the main ask of #4312. Traefik keeps serving it, and certificates have to be renewed by hand.- A hand-written
tailscale/tailscalesidecar in each compose. It works, and we run it in production (see below). But every compose repeats about 40 lines of boilerplate and carries its own auth-key secret, and Dokploy knows nothing about it: the Domains tab is empty and the DNS check (#2615, #4312) does not apply.
A sidecar gives each app what the host-level approaches can't: its own tailnet name (myapp.<tailnet>.ts.net), a valid HTTPS certificate on 443, per-app ACLs through a tag, and optional Funnel. No port is opened on the host, Traefik is not involved, and nothing needs to be installed on a remote server. Dokploy already rewrites the compose file for every domain (addDomainToCompose adds Traefik labels and dokploy-network), so injecting a sidecar for a "tailnet" domain fits the same step.
Describe the solution you'd like
A domain can be published to a tailnet instead of through Traefik. The first iteration covers compose apps only. The shape follows the Cloudflare Tunnel proposal (#4309, PRs #4528/#4531), so the two publishing paths could later share one "publish via" field.
1. Credentials: an organization-level Tailscale integration (Settings → Tailscale)
- It stores an OAuth client ID and secret. The client needs only Keys → Auth Keys → Write, limited to the tags it may assign. Devices → Core → Write is optional and enables cleanup (item 5).
- It also stores the default tag (for example
tag:dokploy-apps) and an optional control URL (baseURL, for Headscale or a custom deployment), plus a "Test connection" button that mints and immediately revokes a key. - The secret is stored with
encryptedText, likecompose.env, and never leaves the Dokploy server. The OAuth secret is not passed to the sidecar. On each deploy Dokploy mints a single-use, pre-authorized, non-ephemeral, tagged auth key that expires after one hour (POST /api/v2/tailnet/-/keys) and passes that key in. The sidecar runs withTS_AUTH_ONCE=true, so the key is used only on the first start. After that the node lives in the state volume, and an expired key in the generated.envis useless to anyone who reads the file. Passing the OAuth secret itself (TS_AUTHKEY=tskey-client-…?ephemeral=false, which the image supports) gains nothing:tailscale upmints the same kind of single-use key from it internally (feature/oauthkey). Meanwhile the long-lived secret would sit in the compose.env, indocker inspect, and in the argv oftailscale up --authkey=…, which containerboot builds fromTS_AUTHKEYand which every local user can read in/proc.
2. Domain fields (same pattern as publishToCloudflare in #4531)
publishToTailnet: booleanandtailscaleId(a foreign key to the integration).hostholds the node name, a single DNS label (myapp). The UI shows it asmyapp.<tailnet>.ts.net, using the suffix the node reports after its first start.port,pathandserviceNamekeep their current meaning.httpsandcertificateTypedo not apply: Tailscale always terminates HTTPS on 443.tailnetFunnel: boolean.validateDomainis skipped for these domains.
3. What Dokploy writes into the compose. For each node name, one service is added. Several domains with the same host become several serve handlers or ports on one node.
configs:
dokploy-ts-<key>:
content: |
{"TCP": {"443": {"HTTPS": true}},
"Web": {"$${TS_CERT_DOMAIN}:443": {"Handlers": {"/": {"Proxy": "http://<serviceName>:<port>"}}}},
"AllowFunnel": {"$${TS_CERT_DOMAIN}:443": false}}
services:
dokploy-ts-<key>:
image: tailscale/tailscale:<version pinned by Dokploy>
restart: unless-stopped
environment:
TS_HOSTNAME: <host>
TS_AUTHKEY: ${DOKPLOY_TS_AUTHKEY_<key>} # single-use key minted at deploy, written to the generated .env
TS_EXTRA_ARGS: --advertise-tags=<tags>
TS_AUTH_ONCE: "true"
TS_STATE_DIR: /var/lib/tailscale
TS_SERVE_CONFIG: /config/serve.json
TS_USERSPACE: "true"
TS_ENABLE_HEALTH_CHECK: "true"
TS_LOCAL_ADDR_PORT: 127.0.0.1:9002
configs: [{source: dokploy-ts-<key>, target: /config/serve.json}]
volumes: [dokploy-ts-<key>:/var/lib/tailscale]
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
networks: <the networks of serviceName> # default network, or the isolated-deployment network
volumes:
dokploy-ts-<key>:
- The target service is left unchanged: it gets no Traefik labels and does not join
dokploy-network. - Userspace networking needs no
/dev/net/tunand no capabilities, because serve only proxies to another container by name. ScaleTail-stylenetwork_mode: service:tailscaleis not needed and would change how the app's own ports behave. randomizeandisolatedDeploymentkeep working: the sidecar takes the suffixed service name and the app's networks.
4. Remote servers. Nothing changes. The compose is generated and written by the existing SSH path, and the sidecar runs next to the app on that server. Keys are minted by the main Dokploy server through the Tailscale API, so neither Tailscale on the remote host nor Traefik there is involved.
5. Lifecycle
- A deploy is idempotent: an unchanged sidecar is not recreated, and a recreated one comes back with the same device because the state is on the volume.
- Removing a tailnet domain drops the sidecar at the next deploy (
--remove-orphans). The device stays in the tailnet, though. With the Devices scope Dokploy deletes it through the API (the node ID comes fromtailscale status --jsoninside the sidecar before it goes); without that scope, the UI says so. - The state volume is the node's identity. If it is lost, the next start registers a new device (
myapp-1) with a freshly minted key, so the old device has to be removed for the name to come back.
6. Funnel. tailnetFunnel sets AllowFunnel in the serve config. The tailnet policy must grant the funnel node attribute to the tag. Dokploy does not edit the policy and only shows that requirement.
Not in this proposal
- Applications (swarm services) are left for a second step. They would need a companion swarm service on the app's network and a state volume pinned to one node.
- The
stackcompose type is excluded for the same reason (state volume placement). - Tailscale Services (
svc:VIPs) are excluded. They require tagged hosts and approval flows, so they are a possible later mode. - Editing the tailnet policy (tags, grants, Funnel attribute) stays with the operator.
- Putting Dokploy's own UI on the tailnet is a separate topic (#2661, #5157).
- Traefik middlewares (basic auth, forward auth, custom middlewares) are not applied, because access control comes from the tailnet ACL. Open question: would you rather route sidecar →
dokploy-traefik→ app to keep them?
Describe alternatives you've considered
- Host-level
tailscale serve: covered above. One name, ports per app, root on every change, three Funnel ports, and conflicts with Traefik on 443. tailscale certplus custom certificates (#4312): still Traefik on the host's IP, with manual renewal.- IP allow-lists per domain (#5420): this restricts who may connect but gives no tailnet name or certificate. It complements this proposal rather than replacing it.
- tsdproxy, DockTail: a separate proxy outside Dokploy's domain model. DockTail needs a tagged host to use Tailscale Services.
- A hand-written sidecar in every compose: what we do today (below).
Additional context
We run this today, by hand. On Dokploy v0.31.0 we added the sidecar from item 3 by hand to a raw compose app (a self-hosted web app with Postgres): tailscale/tailscale:v1.104.7, userspace, cap_drop: ALL. Our deploy script does what item 1 proposes for Dokploy: it keeps the OAuth client and passes the container a single-use, pre-approved, tagged key that expires in an hour. What we saw:
- Name and certificate. The app answers on
https://<app>.<tailnet>.ts.netwith a Let's Encrypt certificate, from the tailnet only. The first deploy, including node registration and the certificate, took about a minute. - Nothing else changed. The app's own services, ports and the existing access path were left as they were. The deploy recreated only the service whose env changed.
- The device survives recreation.
docker compose up --force-recreateof the sidecar came back as the same device (doLogin(regen=false), no<app>-1), even though the single-use key was already spent. A plain Dokploy redeploy doesn't recreate it at all. - Access is set by the tailnet policy. With a grant of only
tcp:443to the tag, every other port of the node is closed. A tag that appears nowhere assrckeeps a compromised app container from reaching anything else in the tailnet. - Gotchas worth handling in Dokploy:
- An OAuth client secret passed as
TS_AUTHKEYregisters an ephemeral node unless?ephemeral=falseis appended (feature/oauthkeydefaults to true). Item 1 sidesteps this. ${TS_CERT_DOMAIN}in an inlineconfigs.contentmust be written as$${TS_CERT_DOMAIN}, or compose interpolates it to an empty string.- Apps that check the request origin (Better Auth and similar) need the new
https://<app>.<tailnet>.ts.netorigin trusted. Dokploy can't do that for the app, but the domain dialog could say so. - Behind a stateless provider firewall that drops inbound UDP, the sidecar connects through DERP relays. It still works, but a direct path needs a fixed
--portand a firewall rule per node.
- An OAuth client secret passed as
Related: #4312 (native Tailscale, whose optional third item is this per-app mode), #5420, #5862, #2615, #5157, #4309 / #4531 (the same plug-in points: domain schema, addDomainToCompose, handle-domain.tsx).
Will you send a PR to implement it?
Yes, for the compose part, once the design is agreed.
- Ngôn ngữ chính
- TypeScript
- Star
- 38.8k
- Fork
- 3.2k
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 110
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Dokploy/dokploy
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Dokploy/dokploy#6151 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Healthy Swarm task shows an empty `(Error:)` suffix on the last row of the Containers tabCó thể đã có người làm @AyhamJo7 đã nhận 5 ngày trước. Đang mởneeds-triage🔍
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Dokploy/dokploy#6115 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Global search (Cmd/Ctrl+J) never sorts results by relevanceCó thể đã có người làm @hamidzr đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Dokploy/dokploy#6107 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`utils/dns/ovh.ts`: the zone-listing 403 handler replaces the provider's error instead of chaining itCó thể đã có người làm @SyncWithRaj đã nhận 9 ngày trước. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
Dokploy/dokploy#6075 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MongoDB with Replica Sets enabled: container exits with code 0 and restarts in a loop (generated startup script never waits on mongod)Có thể đã có người làm @ghazy2001 đã nhận 10 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Dokploy/dokploy#6051 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Dokploy/dokploy
Issue tương tự
-
status: triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
WhiteTowerAI/ohmygame#1225 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: KBS TV SDĐang mởstreams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ardia-browser/ardia#5042 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
keycloakify/oidc-spa#211 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày