Files
product/REMOTE_ACCESS.md
T
2026-03-27 10:49:34 +08:00

73 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 跨机器访问说明
## 1) 服务监听
已默认监听 `0.0.0.0:8080`,同网段机器可访问:
- `http://<你的机器IP>:8080/`
推荐用服务脚本管理(避免旧进程占端口):
```bash
bash /home/xsl/product/scripts/service.sh start
bash /home/xsl/product/scripts/service.sh status
bash /home/xsl/product/scripts/service.sh logs
bash /home/xsl/product/scripts/service.sh restart
bash /home/xsl/product/scripts/service.sh stop
```
查询本机 IP:
```bash
ip addr
```
## 2) 浏览器麦克风权限(关键)
跨机器访问时,浏览器通常要求 **HTTPS** 才允许 `getUserMedia`
### 方案 A(推荐):启用 HTTPS
```bash
bash /home/xsl/product/scripts/gen-self-signed-cert.sh
```
然后编辑 `.env`:
```env
SSL_CERTFILE=/home/xsl/product/certs/dev-cert.pem
SSL_KEYFILE=/home/xsl/product/certs/dev-key.pem
```
启动:
```bash
bash /home/xsl/product/scripts/service.sh restart
```
访问:
- `https://<你的机器IP>:8080/`
首次需要在浏览器信任自签证书。
### 方案 BHTTP 测试
如果仅做 UI 验证,可先用 HTTP;但麦克风可能被浏览器拒绝。
## 3) WSL2 网络注意事项
如果服务跑在 WSL2,其他机器无法直接访问时,需要在 Windows 做端口转发与防火墙放行。
最简单做法:在 Windows 上运行同样服务,或配置端口代理到 WSL IP。
## 4) WebRTC 联通
系统已配置 STUN`.env` 里的 `STUN_URL`),用于获取可达候选地址:
```env
STUN_URL=stun:stun.l.google.com:19302
```
若跨公网且 NAT 复杂,需增加 TURN(后续可加)。