Nginx反代m3u8资源加速HLS流媒体

Kevin 杂记 3,213 次浏览 24条评论

现在很多直播源采用HLS流媒体传输协议,只需获得m3u8链接就可以在浏览器上播放,使用简单设备兼容性好。平时有些小众源速度跟不上卡顿,于是研究了下如何反代加速。起初在Github上找现成解决方案,不过类似项目很少且长时间没更新,测试用不了。索性试试Nginx反代,最终弄了个简单版。

反代方法

1. 安装Nginx和确保有http_sub_module替换模块。

2. 编辑Nginx虚拟机配置文件,加入反代规则。

# 适用任何符合指定后缀的请求
location ~* \.(m3u8|ts|aac)$ {
    proxy_cache off;                    # 禁用代理缓存
    expires -1;                         # 禁用页面缓存
    proxy_pass http://example.com;      # 反代目标 URL
    sub_filter 'http://example.com/' 'http://$host/';   # 替换 m3u8 文件里的资源链接
    sub_filter_last_modified off;       # 删除原始响应里的浏览器缓存值
    sub_filter_once off;                # 替换所有匹配内容
    sub_filter_types *;                 # 匹配任何 MIME 类型
}

3. 保存后运行nginx -t命令检查语法是否有问题,避免添加到错误位置。

4. systemctl restart nginx重启Nginx服务生效。之后就可以通过反代访问了。

例如原链接是http://example.com/hls/skynews/playlist.m3u8,将域名改为你自己的,其它不变。

效果测试

HLS反代测试
HLS流媒体反向代理测试,视频与音频源都可以反代,了解m3u8播放列表里的文件类型再设置即可。

评论列表

  1. #1

    hydroxychloroquine stock ticker https://hydroxychloroquine.webbfenix.com/

  2. #2

    zovirax for shingles https://www.herpessymptomsinmen.org/productacyclovir/

  3. #3

    best generic careprost reviews https://carepro1st.com/

  4. #4

    ivermectin dosage humans https://ivermectin.webbfenix.com/

  5. #5

    levitra vs vidalista for hardness https://vidalista.mlsmalta.com/

  6. #6

    can clomiphene cause heart attack https://salemeds24.wixsite.com/clomid

  7. #7

    azithromycin and strep throat https://keflex.webbfenix.com/

  8. #8

    reviews on cialis daily http://www.lm360.us/

  9. #9

    hydroxychloroquine 700 https://hydroxychloroquine.mlsmalta.com/

  10. #10

    ivermectin cost https://ivermectin.mlsmalta.com/

  11. #11

    brand viagra online canadian pharmacy http://droga5.net/

  12. #12

    online pharmacy canada generic priligy https://ddapoxetine.com/

  13. #13

    vidalista soft tabs review https://vidalista40mg.mlsmalta.com/

  14. #14

    price of albuterol hfa inhaler https://amstyles.com/

  15. #15

    how to use cialis daily https://wisig.org/

  16. #16

    tadalafil liquid research chems https://tadalafil.cleckleyfloors.com/

  17. #17

    ask a doctor free chat https://edmeds.buszcentrum.com/

  18. #18

    ask a doctor free chat https://buymeds.mlsmalta.com/

  19. #19

    chloroquine for sale online https://hydroxychloroquinee.com/

  20. #20

    taking dapoxetine with dapoxetine https://dapoxetine.confrancisyalgomas.com/

  21. #21

    over counter antibiotics at walmart https://amoxycillin1st.com/

  22. #22

    prednisone 20 tablet https://bvsinfotech.com/

  23. #23

    chewable cenforce soft tabs http://cavalrymenforromney.com/

  24. #24

    I was wondering iff you ever considered changing the page layout of your site?

    Its very well written; I love what youve gott to say.

    But maybe you could a little more in the way of content
    soo people could connect with it better. Youve goot an awful
    lot of text for ojly hhaving 1 or two images. Maybe you could space it out
    better?

    Have a look at my page :: https://www.cheapdiamondpainting.com/happy-cats-diamond-painting.html

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。