Tailnet domains: publish a compose service on a Tailscale tailnet through an injected sidecar (design for the per-app mode of #4312)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 18/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- docker, docker-compose, typescript
- 領域
- devops, infrastructure
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 38.8k
- フォーク
- 3.2k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 110
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Dokploy/dokploy のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Dokploy/dokploy#6151 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Healthy Swarm task shows an empty `(Error:)` suffix on the last row of the Containers tab対応中かも @AyhamJo7 が 4 日前に担当しました。 オープンneeds-triage🔍
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Dokploy/dokploy#6115 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Global search (Cmd/Ctrl+J) never sorts results by relevance対応中かも @hamidzr が 6 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Dokploy/dokploy#6107 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`utils/dns/ovh.ts`: the zone-listing 403 handler replaces the provider's error instead of chaining it対応中かも @SyncWithRaj が 8 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
Dokploy/dokploy#6075 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
MongoDB with Replica Sets enabled: container exits with code 0 and restarts in a loop (generated startup script never waits on mongod)対応中かも @ghazy2001 が 10 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Dokploy/dokploy#6051 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
Dokploy/dokploy の issue をすべて見る
似ている issue
-
[Bug]: RUN_STARTED resets the run's tool-call tally even when a subscriber suppresses the eventオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
ag-ui-protocol/ag-ui#3504 ·
メンテナーはふだん 1 日以内に返信
-
area/profiles area/sessions comp/desktop desktop/chat desktop/sessions P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
NousResearch/hermes-agent#161712 ·
メンテナーはふだん 1 日以内に返信
-
bug p3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rothgar/rabble.radio#283 ·
メンテナーはふだん 1 日以内に返信
-
bug from-app needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
nightly-labs/openbot#19805 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
OHDSI/Data2Evidence#3760 ·
メンテナーはふだん 3 日以内に返信