iptv-app/web/README.md
李岩岩 52fc8099ae feat(web): 创建 Docker Web 服务端
- 添加 Express 服务端,提供频道 API
- 添加 M3U8/TS 流代理,解决跨域问题
- 添加 Dockerfile 和 docker-compose.yml
- 添加 Nginx 反向代理配置
- 支持多阶段构建,自动打包前端
2026-02-05 12:41:50 +08:00

85 lines
1.9 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.

# IPTV Web Docker 版
基于 Node.js + Express 的 IPTV Web 服务端,提供:
- 📺 频道列表 API
- 🔀 M3U8/HLS 流代理(解决跨域)
- 📦 Docker 一键部署
- 🚀 可选 Nginx 反向代理
## 快速开始
### 1. 构建并启动
```bash
# 基础版本
docker-compose up -d
# 带 Nginx 的版本
docker-compose --profile nginx up -d
```
### 2. 访问
```
http://localhost:3000 # 直接访问 Node 服务
http://localhost # 通过 Nginx如果启用
```
## API 接口
| 接口 | 说明 |
|------|------|
| `GET /health` | 健康检查 |
| `GET /api/channels` | 获取频道列表 |
| `GET /proxy/m3u8?url=xxx` | 代理 M3U8 播放列表 |
| `GET /proxy/ts?url=xxx` | 代理 TS 视频片段 |
| `GET /proxy/stream?url=xxx` | 通用流代理 |
## 目录结构
```
web/
├── src/
│ └── index.js # Express 服务端
├── nginx/
│ └── nginx.conf # Nginx 配置
├── public/ # 前端静态文件(构建时复制)
├── Dockerfile # Docker 构建
├── docker-compose.yml # 编排配置
└── README.md
```
## 更新频道数据
频道数据来自 `ui/dist-web/api/result.txt`,更新方式:
```bash
# 方法1重新构建
docker-compose up -d --build
# 方法2挂载数据卷已配置
# 修改 ui/dist-web/api/result.txt 后自动生效
```
## 环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `PORT` | 3000 | 服务端口号 |
| `NODE_ENV` | production | 运行环境 |
## 单独运行(不依赖 Docker
```bash
cd web
npm install
npm start
```
## 注意事项
1. **跨域问题** - 所有流媒体通过 `/proxy/*` 接口代理,解决浏览器 CORS 限制
2. **性能优化** - 静态资源使用 Nginx 缓存API 请求直连 Node
3. **HTTPS** - 生产环境建议启用 HTTPS配置 `nginx/ssl/` 目录)