修复工作

This commit is contained in:
2025-10-01 23:27:08 +08:00
parent e462a99645
commit 182f045517
2 changed files with 34 additions and 10 deletions

View File

@@ -50,30 +50,37 @@ server {
proxy_pass http://127.0.0.1:10083/live;
proxy_http_version 1.1;
# 重要:禁用所有缓冲,实时传输视频流
# 关键:禁用所有缓冲,立即转发数据
proxy_buffering off;
proxy_cache off;
proxy_request_buffering off;
chunked_transfer_encoding on;
proxy_max_temp_file_size 0;
# 设置超时时间(视频流长连接)- 增加到2小时
proxy_connect_timeout 120s;
proxy_send_timeout 7200s;
proxy_read_timeout 7200s;
# 请求头
# 请求头(保持连接)
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_set_header Connection "keep-alive";
proxy_set_header Upgrade $http_upgrade;
# CORS支持
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers '*';
# 响应头CORS + 流媒体)- 使用 always 确保所有响应都有这些头
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers '*' always;
add_header Cache-Control 'no-cache, no-store, must-revalidate' always;
add_header Pragma 'no-cache' always;
add_header X-Accel-Buffering 'no' always;
# 禁用限速
# 禁用限速和缓存
proxy_limit_rate 0;
sendfile off;
tcp_nopush off;
tcp_nodelay on;
}
# 视频流代理HLS

View File

@@ -31,9 +31,26 @@ export default defineConfig(({ mode, command }) => {
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: 'http://localhost:8080',
target: 'http://localhost:10081',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
},
// 视频流代理HTTP-FLV
'/live': {
target: 'http://localhost:10083/live',
changeOrigin: true,
// 关键:禁用所有缓冲,实时转发
configure: (proxy, options) => {
proxy.on('proxyReq', (proxyReq, req, res) => {
console.log('🎬 代理视频流请求:', req.url);
});
proxy.on('proxyRes', (proxyRes, req, res) => {
console.log('📺 收到视频流响应,开始转发...');
// 禁用缓冲
proxyRes.headers['x-accel-buffering'] = 'no';
proxyRes.headers['cache-control'] = 'no-cache';
});
}
}
}
},