Spaces:
Paused
Paused
添加 webssh 模块 (ttyd) 及 Caddy 路由配置
Browse files基于 ttyd 的浏览器终端模块,通过 /webssh 路径访问,提供容器内 bash shell。支持 SSH 客户端功能。
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- README.md +4 -1
- caddy/Caddyfile +5 -0
- modules/webssh/install.sh +16 -0
- modules/webssh/start.sh +13 -0
README.md
CHANGED
|
@@ -116,4 +116,7 @@ hf-framework/
|
|
| 116 |
| 端口 | 用途 |
|
| 117 |
|------|------|
|
| 118 |
| 7860 | Caddy(对外,HF Space 默认) |
|
| 119 |
-
| 8000
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
| 端口 | 用途 |
|
| 117 |
|------|------|
|
| 118 |
| 7860 | Caddy(对外,HF Space 默认) |
|
| 119 |
+
| 8000 | api 模块 |
|
| 120 |
+
| 8001 | example 模块 |
|
| 121 |
+
| 8002 | webssh 模块(ttyd) |
|
| 122 |
+
| 8003+ | 预留 |
|
caddy/Caddyfile
CHANGED
|
@@ -27,6 +27,11 @@
|
|
| 27 |
reverse_proxy localhost:8001
|
| 28 |
}
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
handle {
|
| 31 |
header Content-Type "application/json; charset=utf-8"
|
| 32 |
respond `{"name":"hf-framework","version":"0.1.0","status":"running"}`
|
|
|
|
| 27 |
reverse_proxy localhost:8001
|
| 28 |
}
|
| 29 |
|
| 30 |
+
handle /webssh/* {
|
| 31 |
+
uri strip_prefix /webssh
|
| 32 |
+
reverse_proxy localhost:8002
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
handle {
|
| 36 |
header Content-Type "application/json; charset=utf-8"
|
| 37 |
respond `{"name":"hf-framework","version":"0.1.0","status":"running"}`
|
modules/webssh/install.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
apt-get update && apt-get install -y openssh-client curl
|
| 5 |
+
|
| 6 |
+
ARCH=$(uname -m)
|
| 7 |
+
case "$ARCH" in
|
| 8 |
+
x86_64) TTYD_ARCH="x86_64" ;;
|
| 9 |
+
aarch64) TTYD_ARCH="aarch64" ;;
|
| 10 |
+
armv7l) TTYD_ARCH="arm" ;;
|
| 11 |
+
*) echo "不支持的架构: $ARCH"; exit 1 ;;
|
| 12 |
+
esac
|
| 13 |
+
|
| 14 |
+
echo "下载 ttyd ($TTYD_ARCH)..."
|
| 15 |
+
curl -sL "https://github.com/tsl0922/ttyd/releases/latest/download/ttyd.${TTYD_ARCH}" -o /usr/local/bin/ttyd
|
| 16 |
+
chmod +x /usr/local/bin/ttyd
|
modules/webssh/start.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
PORT="${WEBSSH_PORT:-8002}"
|
| 5 |
+
|
| 6 |
+
exec ttyd \
|
| 7 |
+
--port "$PORT" \
|
| 8 |
+
--interface 127.0.0.1 \
|
| 9 |
+
--writable \
|
| 10 |
+
--max-clients 10 \
|
| 11 |
+
--ping-interval 30 \
|
| 12 |
+
--terminal-type xterm-256color \
|
| 13 |
+
bash
|