From 103080171204f314bd5c33e7bb4f9c3488f7afa3 Mon Sep 17 00:00:00 2001 From: zikai Date: Tue, 21 Jul 2026 15:12:15 +0000 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=20Apache=20WebSocket=20?= =?UTF-8?q?=E5=8F=8D=E4=BB=A3=E9=85=8D=E7=BD=AE=E8=AF=B4=E6=98=8E=EF=BC=88?= =?UTF-8?q?/ws/=20=E9=A1=BB=20proxy=5Fwstunnel=20=E9=80=8F=E4=BC=A0?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index be9302a..2e7fe9e 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,16 @@ API 客户端拿到 JSON。可用 `?format=html` 或 `?format=json` 强制指定 Apache(`/etc/apache2/sites-available/f.zikai.wang-le-ssl.conf`)把 `f.zikai.wang` 反代到 `127.0.0.1:6867`(`ProxyPreserveHost On`),因此服务只绑 loopback。 +> **WebSocket 反代**:记事本的实时同步走 `WS /ws/wb/{id}`,经 Apache 反代时必须用 +> `proxy_wstunnel` 模块单独透传 `/ws/` 路径,否则升级请求被当普通 GET 返回 404、前端反复 +> 「连接已关闭,重连中」。vhost 须在通用 `/` 规则**之前**加: +> ```apache +> ProxyPass /ws/ ws://127.0.0.1:6867/ws/ +> ProxyPassReverse /ws/ ws://127.0.0.1:6867/ws/ +> ``` +> (外层 HTTPS 由 Apache 终结,Apache 到 uvicorn 之间是明文 `ws://`。) +> 需启用 `proxy_wstunnel` 模块:`a2enmod proxy_wstunnel && systemctl reload apache2`。 + > **大文件/慢速 HTTP 上传:** Apache 代理段继承全局 `Timeout 300`。多 GB 慢链路传输建议走 > **分片上传**(`/upload` 页面或 `/api/files/chunk-uploads`,单片 4 MiB 在超时内可传完)或 > **SFTP**(完全绕过 HTTP 代理)。要提高 HTTP 上限可在 Apache vhost 加 `ProxyTimeout`/`Timeout`。