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使用外部服务,不需要代理