增加局域网内部自签名使用方式

This commit is contained in:
Misaki
2026-06-08 22:33:23 +08:00
parent 36660519c1
commit e2b65ac735
4 changed files with 72 additions and 10 deletions
+50 -5
View File
@@ -19,19 +19,64 @@
> 要求:Chrome / Edge 浏览器,通过 `localhost` 或 HTTPS 访问。
### 直接运行
从 [Releases](https://git.taurusxin.com/taurusxin/ncmdump-go/releases/latest) 下载对应平台的 `ncmdump-web` 二进制,或自行编译:
```shell
./build-wasm.sh
# 单机使用
./ncmdump-web --port 8080
# 浏览器访问 http://localhost:8080
```
### 局域网使用
`localhost` 下浏览器要求 HTTPS 才能启用文件夹选择功能。用 [mkcert](https://github.com/FiloSottile/mkcert) 生成自签名证书:
```shell
# 在运行服务器的机器上,替换为实际 IP
mkcert -install
mkcert 192.168.1.100 localhost
# 启动
./ncmdump-web --port 8080 --cert 192.168.1.100+1.pem --key 192.168.1.100+1-key.pem
```
然后局域网内其他设备访问 `https://192.168.1.100:8080` 即可正常使用。
### 交叉编译
纯 Go,无 CGO 依赖,可交叉编译到任意平台:
```shell
# Windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o ncmdump-web.exe ./cmd/server
# macOS (Intel)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o ncmdump-web ./cmd/server
# macOS (Apple Silicon)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o ncmdump-web ./cmd/server
# Linux (arm64)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o ncmdump-web ./cmd/server
```
编译出的二进制约 15MB,前端和 WASM 运行时全部内嵌,拷贝到目标机器直接运行。
### Docker 部署
```shell
docker compose up -d --build
# 访问 http://localhost:8080
```
然后浏览器访问 `http://localhost:8080`
### 本地开发
如需提取二进制单独部署:
```shell
./build-wasm.sh # 编译 WASM + 前端 + 服务器
./ncmdump-web --port 8080
docker cp $(docker create ncmdump-web):/usr/local/bin/ncmdump-server ./ncmdump-web
```
## 命令行