Update Docker Compose configuration to support customizable Nginx ports

- Modify `docker-compose.yaml` to use environment variables for HTTP and HTTPS port mappings, allowing flexibility in port configuration.
- Enhance `README.md` with instructions for using non-standard HTTPS ports, including examples for remote development setups.
This commit is contained in:
Xin Wang
2026-07-09 22:38:42 +08:00
parent fa6693ce46
commit d857401ef3
2 changed files with 26 additions and 5 deletions

View File

@@ -112,12 +112,32 @@ NEXT_PUBLIC_API_BASE_URL=https://<远程机器IP或域名> \
docker compose --profile remote-dev up -d nginx-remote-dev
```
如果远程机器希望用非标准 HTTPS 端口,例如 `18189`,把宿主机端口映射到
容器的 `443` 即可:
```bash
NGINX_HTTPS_PORT=18189 docker compose --profile remote-dev up -d nginx-remote-dev
```
此时前端也要使用带端口的同源地址:
```bash
NEXT_PUBLIC_API_BASE_URL=https://<远程机器IP或域名>:18189 \
npm run dev -- --hostname 0.0.0.0
```
浏览器访问:
```text
https://<远程机器IP或域名>:18189
```
也可以直接 `docker run`:
```bash
docker run --rm --name ai-video-nginx \
--add-host=host.docker.internal:host-gateway \
-p 80:80 -p 443:443 \
-p 80:80 -p 18189:443 \
-v "$PWD/deploy/nginx/ai-video.remote-dev.conf:/etc/nginx/nginx.conf:ro" \
-v "$PWD/deploy/certs:/etc/nginx/certs:ro" \
nginx:alpine
@@ -132,6 +152,7 @@ https://<远程机器IP或域名>
### 6. 远程语音 / WebRTC 注意事项
- 云安全组至少放行 `80/tcp``443/tcp`
- 如果 HTTPS 映射到 `18189`,云安全组要放行 `18189/tcp`
- 如果浏览器和后端不在同一内网,WebRTC 媒体链路通常需要 TURN。
- 启动 coturn:

View File

@@ -142,8 +142,8 @@ services:
image: nginx:alpine
profiles: ["tls"]
ports:
- "80:80"
- "443:443"
- "${NGINX_HTTP_PORT:-80}:80"
- "${NGINX_HTTPS_PORT:-443}:443"
volumes:
# 整份配置当作 nginx.conf 加载(容器内 proxy_pass 用服务名 api/ui)
- ./deploy/nginx/ai-video.docker.conf:/etc/nginx/nginx.conf:ro
@@ -161,8 +161,8 @@ services:
image: nginx:alpine
profiles: ["remote-dev"]
ports:
- "80:80"
- "443:443"
- "${NGINX_HTTP_PORT:-80}:80"
- "${NGINX_HTTPS_PORT:-443}:443"
volumes:
- ./deploy/nginx/ai-video.remote-dev.conf:/etc/nginx/nginx.conf:ro
- ./deploy/certs:/etc/nginx/certs:ro