0–5 分钟:分类 exposure
列出 hostnames、ports、tunnels、CDN、proxies 与 intended audience。
成功标准没有 public route 缺少 named need/owner。
Self-hosted 公网暴露检查表 · 更新 2026-07-05
面向 NGINX、Caddy、tunnels、VPN 与 home-server gateways 后 self-hosted apps 的公网暴露检查表。
在 self-hosted app 前放一个 reverse proxy,并不会自动让服务适合上公网。真实 exposure chain 包含 DNS、TLS、proxy trust、client-IP handling、authentication、admin surface separation、WebSocket upgrades、upload limits、request/connection limits、logs、fail-open behavior 与 emergency shutoff。
这份 checklist 适用于 CasaOS、Umbrel、Nextcloud、YunoHost、RomM、Penpot 等系统,并把 LAN-only、VPN-only、authenticated public access 与 public anonymous content 当成不同 operating modes。
RepoDaily 判断
默认选择 LAN-only 或 VPN-only,除非公网暴露是真实产品需求。必须 public 时,在受控 edge termination TLS,显式定义 trusted proxies,分离 admin surfaces,在不信任 arbitrary forwarding headers 的前提下保留 real client IP,专门测试 WebSockets 与 large uploads,按 endpoint 设计 rate/connection limits,并保留 tested emergency shutoff path。
| 表面 | 基线规则 | 失败信号 | 证据 |
|---|---|---|---|
| DNS | 只有 intended names 指向 public ingress | Wildcard/stale records 暴露 forgotten services | DNS inventory 与 owner |
| TLS | Valid cert + automated renewal + alerts | Expired cert 或 plaintext fallback | Renewal test 与 expiry monitor |
| Trusted proxies | 只信任 known proxy addresses/ranges | App 信任 arbitrary X-Forwarded-* | Proxy chain map 与 spoof negative test |
| Client IP | Reviewed proxy chain 保留 real client identity | 所有用户变成 proxy IP 或 source IP 可 spoof | Access-log sample 与 spoof test |
| Authentication | Privileged access 前做真实 auth | Internet reachability 等于 authorization | Anonymous/wrong-role tests |
| Admin surface | Admin routes private 或强隔离 | 同一 public entry 暴露 root/admin console | Route inventory 与 access test |
| WebSockets | 显式 proxy upgrade 并 auth session | HTTP 正常但 socket bypass controls | Handshake/origin/auth tests |
| Uploads | 设置 intentional size/timeouts | Unlimited uploads 耗尽 disk 或 legitimate upload 被误伤 | Boundary-size tests |
| Rate limits | 按 endpoint 设计 request/connection controls | Login/API 可无限 hammer | Load/abuse test |
| Logs | 记录 auth/proxy/upstream/security events 并 redaction | 无 client identity 或 logs 泄露 tokens | Sample incident trace |
| Shutoff | 有 tested disable-public-ingress path | 只能在线热改 production | Runbook 与 exercise result |
给 internet → app 的完整 exposure path 打分,不只看 reverse proxy config。
| 控制项 | 0 分 | 1 分 | 2 分 | Owner 问题 |
|---|---|---|---|---|
| Exposure mode | Everything public | Some private routes | LAN/VPN/public modes 显式分类 | 哪些 service 真需要 internet access? |
| TLS lifecycle | Manual/unclear | Auto renewal only | Auto renewal + expiry monitor + failure alert | 谁会发现 renewal failure? |
| Proxy trust | Trust all headers | Single proxy configured | Explicit chain + trusted ranges + spoof tests | 哪个 hop 可声明 client identity? |
| Authentication | App default only | Strong app auth | Strong auth + admin separation + session controls | Public users 能否触达 admin flows? |
| Protocol handling | 只测 HTTP | Manual WS/upload tests | Automated HTTP/WS/upload boundary tests | 非 HTTP path 是否保留相同 policy? |
| Abuse controls | None | Basic rate limit | Endpoint-aware rate/connection/body-size/timeout controls | 哪个 endpoint 最容易被滥用? |
| Observability | Proxy logs only | App + proxy logs | Correlated client/proxy/upstream/security events + redaction | 能否重建 abusive session? |
| Emergency response | Manual edits | Documented disable | Tested ingress shutoff + DNS/tunnel revoke + rollback | 多快能 stop public access? |
Self-hosted service 上公网前运行。
列出 hostnames、ports、tunnels、CDN、proxies 与 intended audience。
成功标准没有 public route 缺少 named need/owner。
记录 TLS termination 与 trusted proxy addresses;从 untrusted client 尝试 spoof forwarded headers。
成功标准Direct request 无法伪造 client identity。
测试 anonymous、normal user、wrong role、direct-origin paths。
成功标准Public users 不能触达 admin surfaces 或 bypass proxy。
测试 WebSocket upgrade、normal upload、oversize upload、slow request 与 burst requests。
成功标准Legitimate flow 正常,abuse boundaries 可预测 fail。
跨 proxy/app logs 追踪 login failure 与 successful session,并检查 redaction。
成功标准Client identity/events 可 trace 且不泄露 secrets。
关闭 public route,同时保留 private operator access,再 deliberate restore。
成功标准Emergency response 不依赖 improvising production edits。
| 场景 | 推荐 exposure mode | 必需控制 | 停止条件 |
|---|---|---|---|
| CasaOS admin dashboard | LAN/VPN only | Private routing、strong admin auth、no direct public port | Dashboard 对 arbitrary internet clients 可达 |
| Umbrel home cloud | VPN-first;只选择性公开 app | Per-app route review、TLS、auth、update owner | 因一个 app 需要 sharing 就公开 whole appliance |
| Nextcloud | Authenticated public if needed | Trusted proxies、TLS、brute-force protection、upload/WebDAV tests、logs | Forwarded IP trust broad 或 abuse 无法 trace |
| YunoHost multi-app server | Per-domain/per-app policy | TLS、app auth、admin separation、firewall、app review | 一个 weak app 污染所有 domain 的 trust assumption |
| RomM sharing | Authenticated public 或 VPN | User roles、upload limits、WS test、storage monitor | Friend-sharing 获得 broader library/admin access |
| Penpot collaboration | Authenticated public 或 VPN-only | Auth review、WebSocket support、upload limits、private admin ops | Realtime collaboration 绕过 proxy controls |
| Temporary demo | Short-lived authenticated route | Expiry、narrow DNS、no prod secrets、auto shutoff | Demo 在 review window 后仍在线 |
| Emergency incident | Public ingress off,operator path private | Preserve logs、revoke route/tunnel、rotate secrets、patch privately | Root cause/credential scope 未知就 reopen |
Proxy 可做 TLS termination 和 central policy,但 weak auth、broad admin routes 与 trusted-header mistakes 仍然危险。
App 若信任 arbitrary clients 的 X-Forwarded-*,attacker 可 spoof client identity,影响 logs、redirects 与 abuse controls。
Home-server dashboard、container manager、backup console 与 root admin panel 不应因为 app traffic 走同一 proxy 就一起 public。
HTTP protected 不代表 WebSocket upgrade 正确;socket 可能 bypass middleware 或超长存活。
Unlimited body size、long timeouts 与 public upload endpoints 会消耗 disk、memory、temp space、upstream workers。
一个 generic limit 可能破坏 sync/upload,又没有真正保护 login 或 expensive APIs。
Access logs、debug traces、query strings、headers 与 upstream errors 可能泄露 tokens、share links、filenames 与 personal data。
Compromise 时需要 stop public ingress,同时保留 private operator access 与 evidence。
Host dashboards/admin interfaces 留在 LAN/VPN,只公开真正需要 public access 的 named services。
记录哪个 proxy 能 set client identity headers,并相应配置 downstream trusted-proxy lists。
通过 separate hostnames、routes、VPN policy 或 identity-aware access,让 public user traffic 不能触达 admin surfaces。
维护 HTTP redirect、login、WebSocket upgrade、representative upload size 与 real-client-IP logging 的简单自动测试。
Login、password reset、expensive search、upload 与 API endpoints 使用比 static assets 更严格的 controls。
保留 documented/rehearsed hostname、route、tunnel 或 public listener disable path,同时保持 private operator access。
面向 self-hosted operator 的简短回答。
不够。HTTPS 只保护 transport;仍需要 auth、proxy trust、admin separation、updates、abuse controls、logs、backups 与 incident response。
通常 host/platform administration 应留在 LAN/VPN,只公开真正需要 public access 的 application routes。
App 常使用 forwarded headers 判断 client IP、host 与 scheme;只有 known proxies 应被允许声明这些值。
要。Upgrade handling、auth、origin expectations、idle timeouts 与 connection limits 与普通 HTTP 不完全相同。
不应。Login、password reset、expensive search、API、upload 有不同成本和 abuse characteristics。
能快速 disable public ingress,同时保留 private operator access、logs 与 recovery capability 的 tested path。
Feedback
匿名反馈只用于判断内容是否真正有用。