diff --git a/config/config.yaml b/config/config.yaml index 2d3c174..e5786d4 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -151,7 +151,7 @@ policy: # mode: ACL 政策儲存方式(可選 file 或 database) mode: file # path: 當 mode=file 時,ACL HuJSON 檔案的路徑 - path: "" + path: /etc/headscale/policy.hujson dns: diff --git a/config/policy.hujson b/config/policy.hujson new file mode 100644 index 0000000..4dd6c94 --- /dev/null +++ b/config/policy.hujson @@ -0,0 +1,52 @@ +// Headscale ACL policy —— 全互通 + Taildrive 範本 +// 適用 headscale v0.29.0(首度支援 nodeAttrs / Taildrive policy)。 +// +// 套用方式: +// 1) 把本檔放到容器看得到的路徑(config 目錄會掛載為 /etc/headscale)。 +// 2) 在 config/config.yaml 設定: +// policy: +// mode: file +// path: /etc/headscale/policy.hujson +// 3) 重啟容器後驗證:docker exec headscale headscale policy check --file /etc/headscale/policy.hujson +// +// ⚠️ 重要:沒有 policy 檔時 headscale 預設「全部互通」。一旦啟用 policy, +// acls 變成唯一授權來源;下面這條 allow-all 規則務必保留,否則所有節點立即斷線。 + +{ + // ---- 連線授權:維持目前的全互通行為 ---- + "acls": [ + { + "action": "accept", + "src": ["*"], + "dst": ["*:*"] + } + ], + + // ---- Taildrive:開啟「分享 / 存取」能力 ---- + // drive:share = 可把本機目錄分享出去(伺服器端僅 Linux/macOS/Windows 支援) + // drive:access = 可掛載並讀寫他人分享的目錄(iOS/Android 也能存取) + "nodeAttrs": [ + { + "target": ["*"], + "attr": ["drive:share", "drive:access"] + } + ], + + // ---- Taildrive:用 grant 指定可存取哪些 share 與讀寫權限 ---- + // shares: ["*"] 代表所有 share;可改成特定名稱清單。 + // access: "rw" 讀寫 / "ro" 唯讀。 + "grants": [ + { + "src": ["*"], + "dst": ["*"], + "app": { + "tailscale.com/cap/drive": [ + { + "shares": ["*"], + "access": "rw" + } + ] + } + } + ] +}