videojs CORS 跨域 失败 无效 ,添加 add_header Access-Control-Allow-Origin *; 无效

本文介绍了解决使用video.js播放m3u8格式视频时遇到的跨域问题的方法。提供了两种解决方案:一是通过禁用浏览器缓存进行刷新重试;二是通过在提供视频服务的Nginx配置中添加Access-Control-Allow-Origin头部信息。
worker_processes 2; events { worker_connections 8192; } rtmp_auto_push on; rtmp_auto_push_reconnect 1s; rtmp_socket_dir /tmp; rtmp { server { listen 1935; chunk_size 4096; application live { live on; meta copy;#为了兼容flvj.js record off; gop_cache on;#开启GOP缓存 allow publish all; allow play all; } } } http { include mime.types; default_type application/octet-stream; sendfile off; #server_names_hash_bucket_size 128; #tcp_nopush on; #tcp_nodelay on; keepalive_timeout 65; ## Start: Timeouts ## client_body_timeout 10; client_header_timeout 10; #keepalive_timeout 30; send_timeout 10; keepalive_requests 10; ## End: Timeouts ## server { listen 9000; server_name 109.136.146.133; #http-flv的相关配置 location /live{ flv_live on; add_header 'Access-Control-Allow-Origin' '*'; # 允许所有add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; add_header 'Access-Control-Allow-Headers' '*'; # 关键:允许Range头用于流传输 add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Cache-Control' 'no-cache'; chunked_transfer_encoding on; # 处理OPTIONS预检请求 if ($request_method = 'OPTIONS') { add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root nginx-rtmp-module/; } location /control { rtmp_control all; } location / { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }这是我的流媒体服务器配置
10-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值