From 5e54e4ae629279e26307781d37ba6049a45fec91 Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Wed, 1 Oct 2025 17:48:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 10 +++++++--- docker-compose.yml | 13 ++++++------- rtsp-vue/nginx.conf | 12 ++++++------ ruoyi-admin/src/main/resources/application.yml | 14 +++++++------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.env b/.env index 66441e6..f676eaf 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -# MySQL数据库配置 +# MySQL数据库配置(远程MySQL) MYSQL_HOST=49.232.154.205 MYSQL_PORT=10080 MYSQL_DATABASE=fad_watch @@ -10,9 +10,13 @@ REDIS_HOST=rtsp-redis REDIS_PORT=6379 REDIS_PASSWORD= -# 服务器配置(重要!前端访问视频流使用) +# 服务器配置 SERVER_HOST=49.232.154.205 +# Backend对外端口(重要!) +BACKEND_EXTERNAL_PORT=10082 +MEDIA_SERVER_EXTERNAL_PORT=10083 + # 后端服务配置 BACKEND_HOST=rtsp-backend BACKEND_PORT=8080 @@ -24,7 +28,7 @@ FRONTEND_PORT=10081 PYTHON_SERVICE_HOST=rtsp-python-service PYTHON_SERVICE_PORT=8000 -# MinIO配置 +# MinIO配置(外部服务) MINIO_ENABLED=true MINIO_ENDPOINT=http://49.232.154.205:10900 MINIO_ACCESS_KEY=4EsLD9g9OM09DT0HaBKj diff --git a/docker-compose.yml b/docker-compose.yml index 2e48f1a..73a7636 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,6 +48,10 @@ services: environment: TZ: ${TZ} SERVER_HOST: ${SERVER_HOST:-localhost} + SERVER_PORT: ${BACKEND_EXTERNAL_PORT} + SERVER_ADDRESS: 0.0.0.0 + MEDIA_SERVER_PORT: ${MEDIA_SERVER_EXTERNAL_PORT} + MEDIA_SERVER_ADDRESS: 0.0.0.0 SPRING_DATASOURCE_URL: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true SPRING_DATASOURCE_USERNAME: ${MYSQL_USER} SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD} @@ -59,7 +63,7 @@ services: - backend-logs:/app/logs - backend-upload:/app/upload healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] + test: ["CMD", "curl", "-f", "http://localhost:${BACKEND_EXTERNAL_PORT}/actuator/health"] interval: 30s timeout: 10s retries: 5 @@ -69,19 +73,14 @@ services: build: context: ./rtsp-vue dockerfile: Dockerfile - args: - BACKEND_API_URL: http://localhost:${BACKEND_PORT} container_name: rtsp-frontend restart: always network_mode: "host" - depends_on: - backend: - condition: service_healthy environment: TZ: ${TZ} NGINX_PORT: ${FRONTEND_PORT} healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:${FRONTEND_PORT}"] + test: ["CMD", "sh", "-c", "curl -f http://localhost:${FRONTEND_PORT}"] interval: 30s timeout: 10s retries: 3 diff --git a/rtsp-vue/nginx.conf b/rtsp-vue/nginx.conf index f51e8b0..be00771 100644 --- a/rtsp-vue/nginx.conf +++ b/rtsp-vue/nginx.conf @@ -10,9 +10,9 @@ server { try_files $uri $uri/ /index.html; } - # 后端API代理(backend使用host网络) + # 后端API代理(backend使用host网络,暴露10082端口) location /prod-api/ { - proxy_pass http://127.0.0.1:8080/; + proxy_pass http://127.0.0.1:10082/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -24,7 +24,7 @@ server { # WebSocket支持(用于视频流) location /websocket/ { - proxy_pass http://127.0.0.1:8080/websocket/; + proxy_pass http://127.0.0.1:10082/websocket/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; @@ -45,9 +45,9 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } - # 视频流代理(HTTP-FLV,backend使用host网络) + # 视频流代理(HTTP-FLV,backend使用host网络,暴露10083端口) location /live { - proxy_pass http://127.0.0.1:8866; + proxy_pass http://127.0.0.1:10083; proxy_http_version 1.1; # 重要:禁用所有缓冲,实时传输视频流 @@ -75,7 +75,7 @@ server { # 视频流代理(HLS) location /hls { - proxy_pass http://127.0.0.1:8866; + proxy_pass http://127.0.0.1:10083; proxy_http_version 1.1; # HLS也需要禁用缓冲 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 387411c..9441e9a 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -15,10 +15,10 @@ ruoyi: # 开发环境配置 server: - # 服务器的HTTP端口,默认为8080 - port: 8080 - # 只监听本地地址,外网无法直接访问(通过Nginx代理) - address: ${SERVER_ADDRESS:127.0.0.1} + # 服务器的HTTP端口,支持环境变量配置 + port: ${SERVER_PORT:8080} + # 监听地址,支持环境变量配置 + address: ${SERVER_ADDRESS:0.0.0.0} servlet: # 应用的访问路径 context-path: / @@ -148,9 +148,9 @@ xss: # 流媒体服务端口 mediasServer: - port: 8866 - # 只监听本地地址,外网无法直接访问(通过Nginx代理) - address: ${MEDIA_SERVER_ADDRESS:127.0.0.1} + port: ${MEDIA_SERVER_PORT:8866} + # 监听地址,支持环境变量配置 + address: ${MEDIA_SERVER_ADDRESS:0.0.0.0} # 网络超时,15秒 netTimeout: 15000000 # 读写超时,15秒