Feature: Support subpath deployment for Go web UI
Add optional YAMA_WEB_BASE_PATH to mount the whole web UI (index, manifest, static assets, /health, /api/devices, /ws) under a URL prefix such as /remoter behind a reverse proxy. index.html now uses a __BASE_PATH__ placeholder substituted at serve time, the PWA manifest start_url is rooted at the base path, and a mount wrapper redirects the bare prefix to prefix/ and strips it before routing. Include nginx, systemd, and env-file deployment examples for the subpath setup. The shared placeholder is also handled by the MFC server, which serves from the domain root and strips __BASE_PATH__ (to "") so its web remote desktop URLs stay rooted. Co-Authored-By: deepseek-v4-pro
This commit is contained in:
1 parent
32cc7af371
commit
42df128f62
7 files changed
+254
-12
No files matched your search
@@ -0,0 +1,68 @@
|
||||
# ============================================================
|
||||
# YAMA 网页端 nginx 反代示例(方案B:子路径部署)
|
||||
# 作为站点配置放入 /etc/nginx/sites-available/yama 后软链到 sites-enabled
|
||||
# 核心原则:nginx 只做 TLS 终止 + 完整路径转发,由 Go 端
|
||||
# YAMA_WEB_BASE_PATH=/remoter 负责 strip
|
||||
# ============================================================
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name 你的域名.com;
|
||||
|
||||
# TLS 证书(路径换成你自己的,如 certbot/letsencrypt 生成的位置)
|
||||
ssl_certificate /etc/letsencrypt/live/你的域名.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/你的域名.com/privkey.pem;
|
||||
|
||||
# 裸 /remoter(没写结尾斜杠)→ 301 到 /remoter/
|
||||
location = /remoter {
|
||||
return 301 /remoter/;
|
||||
}
|
||||
|
||||
# 子路径:完整路径原样转发,Go 端按 YAMA_WEB_BASE_PATH 再 strip
|
||||
location /remoter/ {
|
||||
# 结尾没有 "/" → /remoter/... 原样转发(不要写成 http://127.0.0.1:8080/)
|
||||
# Go 服务端若在另一台机器,换成 http://192.168.1.50:8080;
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# WebSocket 升级(远程桌面走 /remoter/ws,不配这两行连不上)
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# 远程桌面连接长时间空闲,避免默认 60s 被 nginx 掐断
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
|
||||
# 大文件/流式传输时避免缓冲占内存(可选)
|
||||
# proxy_buffering off;
|
||||
}
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# 方案A(根路径部署):不设 YAMA_WEB_BASE_PATH,用下面这段替代上面
|
||||
# ============================================================
|
||||
# server {
|
||||
# listen 443 ssl http2;
|
||||
# server_name 你的域名.com;
|
||||
# ssl_certificate /etc/letsencrypt/live/你的域名.com/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/你的域名.com/privkey.pem;
|
||||
#
|
||||
# location / {
|
||||
# proxy_pass http://127.0.0.1:8080;
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection "upgrade";
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# proxy_read_timeout 3600s;
|
||||
# proxy_send_timeout 3600s;
|
||||
# }
|
||||
# }
|
||||
@@ -0,0 +1,64 @@
|
||||
# ============================================================
|
||||
# YAMA 服务端环境变量(完整版)
|
||||
# systemd 通过 EnvironmentFile=-/etc/yama/server.env 读取
|
||||
# 行首 "#" = 未启用(保持默认);去掉 "#" 即生效
|
||||
# ============================================================
|
||||
|
||||
# ---------- 账号 / 密码 ----------
|
||||
|
||||
# Web 管理员账号 "admin" 的初始密码。回退链:
|
||||
# YAMA_WEB_ADMIN_PASS → YAMA_PWD → 硬编码 "admin"
|
||||
# 生产环境务必设置,否则会以 admin/admin 裸奔(启动日志会红色告警)
|
||||
YAMA_WEB_ADMIN_PASS=ChangeMe_Strong
|
||||
|
||||
# 超级密码(明文)。TCP 授权用,也是上面 Web 管理员密码的回退来源
|
||||
#YAMA_PWD=
|
||||
|
||||
# TCP 授权的密码哈希(SHA-256 十六进制)。与 YAMA_PWD 二选一;
|
||||
# 未设置时用内置占位默认值(生产应覆盖)
|
||||
#YAMA_PWDHASH=
|
||||
|
||||
# 持久化 Web 用户文件路径(默认相对工作目录的 users.json)
|
||||
#YAMA_USERS_FILE=/opt/yama/users.json
|
||||
|
||||
# ---------- 网页端 / 反向代理 ----------
|
||||
|
||||
# 子路径部署前缀(方案B)。空 = 根路径(方案A);有值须与 nginx location 一致
|
||||
YAMA_WEB_BASE_PATH=/remoter
|
||||
|
||||
# "1" = 信任反向代理的 X-Forwarded-For(nginx 在 Go 前面时务必开启,
|
||||
# 否则登录限流会把所有客户端当成 nginx 同一个 IP)
|
||||
YAMA_WEB_TRUST_PROXY=1
|
||||
|
||||
# WebSocket Origin 白名单(逗号分隔)。空 = 仅允许同源
|
||||
#YAMA_WEB_ALLOWED_ORIGINS=https://你的域名
|
||||
|
||||
# ---------- 授权 / 许可(signer)----------
|
||||
# 优先级:YAMA_SIGN_PASSWORD > YAMA_LICENSE_DISABLED=1 > YAMA_LICENSE_TOKEN > 匿名试用
|
||||
|
||||
# 本地签名主密钥(HMAC)。设置即进入 LocalSigner 模式(运营方自部署)
|
||||
#YAMA_SIGN_PASSWORD=
|
||||
|
||||
# "1" = 关闭授权校验(NoOpSigner,离线/开发用;客户端将拒绝屏幕/文件功能)
|
||||
#YAMA_LICENSE_DISABLED=1
|
||||
|
||||
# 许可服务器 URL(RemoteSigner 付费客户 / 试用模式的默认地址)
|
||||
#YAMA_LICENSE_SERVER=
|
||||
|
||||
# 客户 JWT(付费客户解锁设备配额)
|
||||
#YAMA_LICENSE_TOKEN=
|
||||
|
||||
# 缓存 TTL(小时,RemoteSigner 离线缓存,默认 24)
|
||||
#YAMA_LICENSE_OFFLINE_HRS=24
|
||||
|
||||
# ---------- 兼做许可服务器(可选,LocalSigner-as-LS)----------
|
||||
|
||||
# issue-token 子命令用:RSA 私钥 PEM 路径(与公钥配对)
|
||||
#YAMA_LICENSE_PRIVATE_KEY=
|
||||
|
||||
# 对外签发许可用:RSA 公钥 PEM 路径 + 监听地址(如 ":8443")
|
||||
#YAMA_LICENSE_PUBLIC_KEY=
|
||||
#YAMA_LICENSE_HTTP_ADDR=:8443
|
||||
|
||||
# 配额状态持久化文件路径
|
||||
#YAMA_LICENSE_STATE_PATH=/opt/yama/license_state.json
|
||||
@@ -0,0 +1,35 @@
|
||||
[Unit]
|
||||
Description=YAMA Remote Administration Server
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=yama
|
||||
Group=yama
|
||||
WorkingDirectory=/opt/yama
|
||||
|
||||
# 密钥 / 部署参数集中放这里(权限 600)。前面的 "-" 表示文件不存在也不报错。
|
||||
EnvironmentFile=-/etc/yama/server.env
|
||||
|
||||
# 6543 = 客户端(agent)回连端口;8080 = 网页端 HTTP(由 nginx 反向代理)
|
||||
# arm64 机器请把二进制名换成 server_linux_arm64
|
||||
ExecStart=/opt/yama/server_linux_amd64 -port 6543 -http-port 8080 -no-console
|
||||
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
# --- 安全加固(可选,不需要可删掉整段) ---
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
# 若服务需要写 /opt/yama 之外的目录,再放开这一行:
|
||||
# ReadWritePaths=/opt/yama/data
|
||||
|
||||
# 日志交给 journald
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=yama
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in new issue
Block a user