# Windows Server 部署 ## 前置条件 - Windows Server 2022 或更高版本。 - 指向服务器的 DNS 域名。 - 位于 `LocalMachine\My` 的受信任服务器证书,私钥对 `NETWORK SERVICE` 可读。 - 管理员 PowerShell。 ## 发布与安装 ```powershell .\tools\publish-server.ps1 -Version 1.0.0 ``` 把 `artifacts/server/win-x64/` 复制到服务器后,以管理员身份执行: ```powershell .\LumaTunnel.Server.exe service install ` --host node.example.com ` --thumbprint 0123456789ABCDEF0123456789ABCDEF01234567 ``` 安装命令会: 1. 写入 `C:\ProgramData\LumaTunnel\config\server.json`。 2. 创建自动启动的 `LumaTunnelServer`,账户为 `NetworkService`。 3. 配置服务失败后的三级重启策略。 4. 为 `https://+:443/` 添加 URL ACL。 5. 为 `node.example.com:443` 添加 HTTP.sys SSL 证书绑定。 6. 添加入站 TCP 443 防火墙规则并启动服务。 检查状态和配置: ```powershell .\LumaTunnel.Server.exe config validate .\LumaTunnel.Server.exe service status Invoke-RestMethod https://node.example.com/api/v1/health ``` ## 配对与设备管理 ```powershell .\LumaTunnel.Server.exe pair create --ttl 10m .\LumaTunnel.Server.exe device list .\LumaTunnel.Server.exe device rename DEVICE_ID "Surface Laptop" .\LumaTunnel.Server.exe device revoke DEVICE_ID ``` 配对码只可使用一次。服务通过设备数据库文件监视器接收 CLI 的吊销变更,并关闭该设备的现有 WSS 会话。 ## 数据和日志 ```text C:\ProgramData\LumaTunnel\ ├─ config\server.json ├─ data\devices.json ├─ data\pairing-codes.json ├─ data\traffic.json └─ logs\ ``` 请只授予 Administrators、SYSTEM 和服务账户访问权限。备份时把 `config` 和 `data` 视为敏感数据;虽然没有令牌明文,但设备元数据和令牌摘要仍不应公开。 ## 卸载 ```powershell .\LumaTunnel.Server.exe service uninstall ``` 命令会停止并删除服务、URL ACL、SSL 绑定和防火墙规则。为防止误删,`C:\ProgramData\LumaTunnel` 数据默认保留;确认无需备份后再由管理员手动删除。 ## 证书轮换 先导入新证书并授予私钥权限,再删除旧 `hostnameport` 绑定、添加新绑定并重启服务。轮换期间不要把 `AllowPrivateTargets` 设为 `true`,该设置仅用于隔离测试网。