WebChat HTTPS Proxy
Standalone HTTPS/WSS reverse proxy for OpenClaw WebChat Control UI:
- - Serves the Control UI over HTTPS (default port 8443)
- WebSocket passthrough to gateway (
ws://127.0.0.1:18789) - INLINECODE1 proxy endpoint to local faster-whisper service (same-origin browser auth; optional Bearer fallback)
- Self-signed TLS certificate management
- SPA fallback for Control UI routing
- Path traversal protection for static file serving
Deploy
CODEBLOCK0
Or expose on LAN:
CODEBLOCK1
This script is idempotent.
Quick verify
CODEBLOCK2
Security Notes
Network isolation
- - Localhost by default: Binds to
127.0.0.1 only. Not reachable from other devices unless VOICE_HOST is explicitly set. - LAN access opt-in: Setting
VOICE_HOST=<LAN-IP> enables trusted LAN access. Re-deploys preserve the existing configured bind host unless you explicitly override VOICE_HOST. - CORS: Single allowed origin only (
VOICE_ALLOWED_ORIGIN). Validated at startup — wildcards (*) and malformed origins are rejected.
TLS
- - TLS 1.2+ enforced: Minimum protocol version set to TLS 1.2. Legacy SSL/TLS 1.0/1.1 rejected.
- Self-signed TLS: Auto-generated certificate. Browser certificate warning on first access.
- Private key permissions:
chmod 600 on TLS key file.
Authentication
- - Bearer token auth:
/transcribe endpoint validates Bearer token against gateway auth token using constant-time comparison (hmac.compare_digest). - When no gateway token is configured, auth is skipped (safe for localhost-only).
Input validation
- - Upload size limit: 50 MB hard limit on
/transcribe proxy requests (HTTP 413). - Empty body rejection: HTTP 400 for empty requests.
- Response size limit: 10 MB cap on upstream response to prevent memory exhaustion.
- Path traversal protection: Static file serving resolves symlinks (
os.path.realpath) and validates the resolved path stays within the Control UI directory.
Error handling
- - No exception leaking: Error responses return generic messages, not internal exception details.
- Upstream timeout: 120s timeout on transcription backend requests.
SSRF protection
- - Upstream URLs (
VOICE_TRANSCRIBE_URL, VOICE_GATEWAY_WS) are validated to point to localhost only. Non-localhost targets are rejected at startup.
No data exfiltration
- - No outbound network calls. Proxy only connects to localhost services.
- No telemetry, analytics, or phone-home behavior.
Persistence
- - User systemd service starts on boot. Use
uninstall.sh to fully revert.
What this skill modifies
| What | Path | Action |
|---|
| Gateway config | INLINECODE16 | Adds HTTPS origin to INLINECODE17 |
| Systemd service |
~/.config/systemd/user/openclaw-voice-https.service | Creates + enables persistent HTTPS proxy |
| Runtime file |
~/.openclaw/workspace/voice-input/https-server.py | Copies proxy server |
| TLS certs |
~/.openclaw/workspace/voice-input/certs/ | Auto-generated self-signed cert on first run |
Uninstall
CODEBLOCK3
Common fixes
- -
404 /chat?... → SPA fallback missing in HTTPS proxy. - INLINECODE22 → ensure deploy used correct
VOICE_HOST and added matching HTTPS origin to gateway.controlUi.allowedOrigins. - INLINECODE25 → open URL with
?token=... once. - INLINECODE27 → approve pending device via
openclaw devices approve <requestId> --token <gateway-token>.
ces approve --token `.
WebChat HTTPS 代理
用于 OpenClaw WebChat 控制界面的独立 HTTPS/WSS 反向代理:
- - 通过 HTTPS 提供控制界面服务(默认端口 8443)
- WebSocket 透传至网关(ws://127.0.0.1:18789)
- /transcribe 代理端点指向本地 faster-whisper 服务(同源浏览器认证;可选 Bearer 回退)
- 自签名 TLS 证书管理
- 控制界面路由的 SPA 回退
- 静态文件服务的路径遍历防护
部署
bash
bash scripts/deploy.sh
或在局域网暴露:
bash
VOICEHOST=10.0.0.42 VOICEHTTPS_PORT=8443 bash scripts/deploy.sh
此脚本是幂等的。
快速验证
bash
bash scripts/status.sh
安全说明
网络隔离
- - 默认本地主机:仅绑定到 127.0.0.1。除非显式设置 VOICEHOST,否则其他设备无法访问。
- 局域网访问可选:设置 VOICEHOST= 可启用可信局域网访问。重新部署会保留现有配置的绑定主机,除非显式覆盖 VOICEHOST。
- CORS:仅允许单一来源(VOICEALLOWED_ORIGIN)。启动时验证——通配符(*)和格式错误的来源将被拒绝。
TLS
- - 强制 TLS 1.2+:最低协议版本设置为 TLS 1.2。传统 SSL/TLS 1.0/1.1 被拒绝。
- 自签名 TLS:自动生成证书。首次访问时浏览器会显示证书警告。
- 私钥权限:TLS 密钥文件权限设置为 chmod 600。
认证
- - Bearer 令牌认证:/transcribe 端点使用常量时间比较(hmac.compare_digest)验证 Bearer 令牌与网关认证令牌。
- 当未配置网关令牌时,跳过认证(仅限本地主机安全)。
输入验证
- - 上传大小限制:/transcribe 代理请求硬限制为 50 MB(HTTP 413)。
- 空请求体拒绝:空请求返回 HTTP 400。
- 响应大小限制:上游响应上限为 10 MB,防止内存耗尽。
- 路径遍历防护:静态文件服务解析符号链接(os.path.realpath)并验证解析后的路径保持在控制界面目录内。
错误处理
- - 无异常泄露:错误响应返回通用消息,而非内部异常详情。
- 上游超时:转录后端请求超时时间为 120 秒。
SSRF 防护
- - 上游 URL(VOICETRANSCRIBEURL、VOICEGATEWAYWS)经验证仅指向本地主机。非本地主机目标在启动时被拒绝。
无数据泄露
- - 无出站网络调用。代理仅连接本地主机服务。
- 无遥测、分析或回传行为。
持久化
- - 用户 systemd 服务随系统启动。使用 uninstall.sh 完全还原。
此技能修改的内容
| 内容 | 路径 | 操作 |
|---|
| 网关配置 | ~/.openclaw/openclaw.json | 将 HTTPS 来源添加到 gateway.controlUi.allowedOrigins |
| Systemd 服务 |
~/.config/systemd/user/openclaw-voice-https.service | 创建并启用持久化 HTTPS 代理 |
| 运行时文件 | ~/.openclaw/workspace/voice-input/https-server.py | 复制代理服务器 |
| TLS 证书 | ~/.openclaw/workspace/voice-input/certs/ | 首次运行时自动生成自签名证书 |
卸载
bash
bash scripts/uninstall.sh
常见问题修复
- - 404 /chat?... → HTTPS 代理中缺少 SPA 回退。
- origin not allowed → 确保部署使用了正确的 VOICE_HOST,并将匹配的 HTTPS 来源添加到 gateway.controlUi.allowedOrigins。
- token missing → 使用 ?token=... 打开 URL 一次。
- pairing required → 通过 openclaw devices approve --token 批准待处理的设备。