From b4e8cf5c33301c8d8b89caad5eeaf6eaac682f19 Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Tue, 30 Sep 2025 21:12:52 +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 --- rtsp-vue/nginx.conf | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/rtsp-vue/nginx.conf b/rtsp-vue/nginx.conf index bdad6df..f51e8b0 100644 --- a/rtsp-vue/nginx.conf +++ b/rtsp-vue/nginx.conf @@ -47,26 +47,55 @@ server { # 视频流代理(HTTP-FLV,backend使用host网络) location /live { - proxy_pass http://127.0.0.1:8866/live; + proxy_pass http://127.0.0.1:8866; proxy_http_version 1.1; + + # 重要:禁用所有缓冲,实时传输视频流 + proxy_buffering off; + proxy_cache off; + proxy_request_buffering off; + chunked_transfer_encoding on; + + # 设置超时时间(视频流长连接) + proxy_connect_timeout 60s; + proxy_send_timeout 3600s; + proxy_read_timeout 3600s; + + # 请求头 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Connection ""; - proxy_buffering off; - proxy_cache off; - chunked_transfer_encoding off; + + # CORS支持 + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; + add_header Access-Control-Allow-Headers '*'; } # 视频流代理(HLS) location /hls { - proxy_pass http://127.0.0.1:8866/hls; + proxy_pass http://127.0.0.1:8866; proxy_http_version 1.1; + + # HLS也需要禁用缓冲 + proxy_buffering off; + proxy_cache off; + proxy_request_buffering off; + + # 超时设置 + proxy_connect_timeout 60s; + proxy_send_timeout 3600s; + proxy_read_timeout 3600s; + proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_buffering off; - proxy_cache off; + + # CORS支持 + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; + add_header Access-Control-Allow-Headers '*'; } # MinIO使用外部服务,不需要代理