修复工作
This commit is contained in:
@@ -50,30 +50,37 @@ server {
|
|||||||
proxy_pass http://127.0.0.1:10083/live;
|
proxy_pass http://127.0.0.1:10083/live;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
# 重要:禁用所有缓冲,实时传输视频流
|
# 关键:禁用所有缓冲,立即转发数据
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_cache off;
|
proxy_cache off;
|
||||||
proxy_request_buffering off;
|
proxy_request_buffering off;
|
||||||
chunked_transfer_encoding on;
|
proxy_max_temp_file_size 0;
|
||||||
|
|
||||||
# 设置超时时间(视频流长连接)- 增加到2小时
|
# 设置超时时间(视频流长连接)- 增加到2小时
|
||||||
proxy_connect_timeout 120s;
|
proxy_connect_timeout 120s;
|
||||||
proxy_send_timeout 7200s;
|
proxy_send_timeout 7200s;
|
||||||
proxy_read_timeout 7200s;
|
proxy_read_timeout 7200s;
|
||||||
|
|
||||||
# 请求头
|
# 请求头(保持连接)
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
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支持
|
# 响应头(CORS + 流媒体)- 使用 always 确保所有响应都有这些头
|
||||||
add_header Access-Control-Allow-Origin *;
|
add_header Access-Control-Allow-Origin * always;
|
||||||
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
|
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
|
||||||
add_header Access-Control-Allow-Headers '*';
|
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;
|
proxy_limit_rate 0;
|
||||||
|
sendfile off;
|
||||||
|
tcp_nopush off;
|
||||||
|
tcp_nodelay on;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 视频流代理(HLS)
|
# 视频流代理(HLS)
|
||||||
|
|||||||
@@ -31,9 +31,26 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
proxy: {
|
proxy: {
|
||||||
// https://cn.vitejs.dev/config/#server-proxy
|
// https://cn.vitejs.dev/config/#server-proxy
|
||||||
'/dev-api': {
|
'/dev-api': {
|
||||||
target: 'http://localhost:8080',
|
target: 'http://localhost:10081',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
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';
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user