mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
docs(cli): secure Unix socket proxy setup
This commit is contained in:
1 parent
16808e7403
commit
bb36fc5221
4 files changed
+19
No files matched your search
@@ -58,6 +58,13 @@ describe('authHook — authentication matrix', () => {
|
|||||||
['rejects /api/* with wrong token', '/api/v1/status', 'Bearer wrong_token', false, 401],
|
['rejects /api/* with wrong token', '/api/v1/status', 'Bearer wrong_token', false, 401],
|
||||||
['allows /api/* with correct token', '/api/v1/status', `Bearer ${VALID_TOKEN}`, false, 0],
|
['allows /api/* with correct token', '/api/v1/status', `Bearer ${VALID_TOKEN}`, false, 0],
|
||||||
['rejects /_web/* without Bearer when requireAuth=true', '/_web/sessions', undefined, true, 401],
|
['rejects /_web/* without Bearer when requireAuth=true', '/_web/sessions', undefined, true, 401],
|
||||||
|
[
|
||||||
|
'rejects the token-bearing automation config without Bearer when requireAuth=true',
|
||||||
|
'/_web/automation/config',
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
401,
|
||||||
|
],
|
||||||
['rejects /_web/* with wrong token when requireAuth=true', '/_web/sessions', 'Bearer bad', true, 401],
|
['rejects /_web/* with wrong token when requireAuth=true', '/_web/sessions', 'Bearer bad', true, 401],
|
||||||
['allows /_web/* with correct token when requireAuth=true', '/_web/sessions', `Bearer ${VALID_TOKEN}`, true, 0],
|
['allows /_web/* with correct token when requireAuth=true', '/_web/sessions', `Bearer ${VALID_TOKEN}`, true, 0],
|
||||||
['allows static file paths without auth', '/index.html', undefined, false, 0],
|
['allows static file paths without auth', '/index.html', undefined, false, 0],
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ clb web --headless # 仅启动 API,不提供 Web UI(供脚本 / AI Agent
|
|||||||
|
|
||||||
常用选项:`--port <端口>`(默认 `3110`)、`--host <地址>`、`--token <令牌>`。在 macOS 和 Linux 上,可以使用 `--socket <路径>` 监听 Unix 域套接字而不占用 TCP 端口,例如 `clb web --socket /tmp/chatlab.sock --no-open`。可通过 `curl --unix-socket /tmp/chatlab.sock http://localhost/api/v1/status` 访问(需要身份验证),或在其前面配置反向代理。
|
常用选项:`--port <端口>`(默认 `3110`)、`--host <地址>`、`--token <令牌>`。在 macOS 和 Linux 上,可以使用 `--socket <路径>` 监听 Unix 域套接字而不占用 TCP 端口,例如 `clb web --socket /tmp/chatlab.sock --no-open`。可通过 `curl --unix-socket /tmp/chatlab.sock http://localhost/api/v1/status` 访问(需要身份验证),或在其前面配置反向代理。
|
||||||
|
|
||||||
|
如果反向代理以另一个 Unix 用户运行,请在 ChatLab 启动后为代理所属组授予套接字访问权限:`sudo chgrp <代理组> /tmp/chatlab.sock && sudo chmod 660 /tmp/chatlab.sock`。每次重启后都需要重新应用,建议使用服务管理器的启动后钩子。ChatLab 与代理以同一用户运行时通常无需修改权限。
|
||||||
|
|
||||||
|
如果代理可从本机可信环境之外访问,请使用 `--require-auth` 启动 ChatLab(或在代理层强制身份验证),避免 Web UI 路由和令牌配置公开暴露。
|
||||||
|
|
||||||
如果希望服务常驻后台,可以使用:
|
如果希望服务常驻后台,可以使用:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ clb web --headless # Start the API without serving the Web UI (for scripts / AI
|
|||||||
|
|
||||||
Common options: `--port <port>` (default `3110`), `--host <address>`, and `--token <token>`. On macOS and Linux, use `--socket <path>` to listen on a Unix domain socket instead of a TCP port, for example `clb web --socket /tmp/chatlab.sock --no-open`. Access it with `curl --unix-socket /tmp/chatlab.sock http://localhost/api/v1/status` (with authentication) or place a reverse proxy in front of it.
|
Common options: `--port <port>` (default `3110`), `--host <address>`, and `--token <token>`. On macOS and Linux, use `--socket <path>` to listen on a Unix domain socket instead of a TCP port, for example `clb web --socket /tmp/chatlab.sock --no-open`. Access it with `curl --unix-socket /tmp/chatlab.sock http://localhost/api/v1/status` (with authentication) or place a reverse proxy in front of it.
|
||||||
|
|
||||||
|
If the reverse proxy runs as a different Unix user, give its group access to the socket after ChatLab starts: `sudo chgrp <proxy-group> /tmp/chatlab.sock && sudo chmod 660 /tmp/chatlab.sock`. Reapply this after each restart, preferably with a service-manager post-start hook. No permission change is normally needed when ChatLab and the proxy run as the same user.
|
||||||
|
|
||||||
|
If the proxy is accessible beyond the local trusted machine, start ChatLab with `--require-auth` (or enforce authentication at the proxy) so the Web UI routes and token configuration are not public.
|
||||||
|
|
||||||
To keep ChatLab running as a background service:
|
To keep ChatLab running as a background service:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ clb web --headless # 僅啟動 API,不提供 Web UI(供腳本 / AI Agent
|
|||||||
|
|
||||||
常用選項:`--port <連接埠>`(預設 `3110`)、`--host <位址>`、`--token <令牌>`。在 macOS 和 Linux 上,可以使用 `--socket <路徑>` 監聽 Unix 網域通訊端而不占用 TCP 連接埠,例如 `clb web --socket /tmp/chatlab.sock --no-open`。可透過 `curl --unix-socket /tmp/chatlab.sock http://localhost/api/v1/status` 存取(需要驗證身分),或在其前方設定反向代理。
|
常用選項:`--port <連接埠>`(預設 `3110`)、`--host <位址>`、`--token <令牌>`。在 macOS 和 Linux 上,可以使用 `--socket <路徑>` 監聽 Unix 網域通訊端而不占用 TCP 連接埠,例如 `clb web --socket /tmp/chatlab.sock --no-open`。可透過 `curl --unix-socket /tmp/chatlab.sock http://localhost/api/v1/status` 存取(需要驗證身分),或在其前方設定反向代理。
|
||||||
|
|
||||||
|
如果反向代理以另一個 Unix 使用者執行,請在 ChatLab 啟動後為代理所屬群組授予通訊端存取權限:`sudo chgrp <代理群組> /tmp/chatlab.sock && sudo chmod 660 /tmp/chatlab.sock`。每次重新啟動後都需要再次套用,建議使用服務管理器的啟動後掛鉤。ChatLab 與代理以相同使用者執行時通常不需要修改權限。
|
||||||
|
|
||||||
|
如果代理可從本機信任環境之外存取,請使用 `--require-auth` 啟動 ChatLab(或在代理層強制驗證身分),避免 Web UI 路由和權杖設定公開暴露。
|
||||||
|
|
||||||
若要讓服務常駐後台,可以使用:
|
若要讓服務常駐後台,可以使用:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Reference in new issue
Block a user