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:
@@ -112,12 +112,32 @@ NEXT_PUBLIC_API_BASE_URL=https://<远程机器IP或域名> \
|
|||||||
docker compose --profile remote-dev up -d nginx-remote-dev
|
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`:
|
也可以直接 `docker run`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --rm --name ai-video-nginx \
|
docker run --rm --name ai-video-nginx \
|
||||||
--add-host=host.docker.internal:host-gateway \
|
--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/nginx/ai-video.remote-dev.conf:/etc/nginx/nginx.conf:ro" \
|
||||||
-v "$PWD/deploy/certs:/etc/nginx/certs:ro" \
|
-v "$PWD/deploy/certs:/etc/nginx/certs:ro" \
|
||||||
nginx:alpine
|
nginx:alpine
|
||||||
@@ -132,6 +152,7 @@ https://<远程机器IP或域名>
|
|||||||
### 6. 远程语音 / WebRTC 注意事项
|
### 6. 远程语音 / WebRTC 注意事项
|
||||||
|
|
||||||
- 云安全组至少放行 `80/tcp`、`443/tcp`。
|
- 云安全组至少放行 `80/tcp`、`443/tcp`。
|
||||||
|
- 如果 HTTPS 映射到 `18189`,云安全组要放行 `18189/tcp`。
|
||||||
- 如果浏览器和后端不在同一内网,WebRTC 媒体链路通常需要 TURN。
|
- 如果浏览器和后端不在同一内网,WebRTC 媒体链路通常需要 TURN。
|
||||||
- 启动 coturn:
|
- 启动 coturn:
|
||||||
|
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ services:
|
|||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
profiles: ["tls"]
|
profiles: ["tls"]
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "${NGINX_HTTP_PORT:-80}:80"
|
||||||
- "443:443"
|
- "${NGINX_HTTPS_PORT:-443}:443"
|
||||||
volumes:
|
volumes:
|
||||||
# 整份配置当作 nginx.conf 加载(容器内 proxy_pass 用服务名 api/ui)
|
# 整份配置当作 nginx.conf 加载(容器内 proxy_pass 用服务名 api/ui)
|
||||||
- ./deploy/nginx/ai-video.docker.conf:/etc/nginx/nginx.conf:ro
|
- ./deploy/nginx/ai-video.docker.conf:/etc/nginx/nginx.conf:ro
|
||||||
@@ -161,8 +161,8 @@ services:
|
|||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
profiles: ["remote-dev"]
|
profiles: ["remote-dev"]
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "${NGINX_HTTP_PORT:-80}:80"
|
||||||
- "443:443"
|
- "${NGINX_HTTPS_PORT:-443}:443"
|
||||||
volumes:
|
volumes:
|
||||||
- ./deploy/nginx/ai-video.remote-dev.conf:/etc/nginx/nginx.conf:ro
|
- ./deploy/nginx/ai-video.remote-dev.conf:/etc/nginx/nginx.conf:ro
|
||||||
- ./deploy/certs:/etc/nginx/certs:ro
|
- ./deploy/certs:/etc/nginx/certs:ro
|
||||||
|
|||||||
Reference in New Issue
Block a user