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

Kevin 杂记 4,024 次浏览 53条评论

现在很多直播源采用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

  25. #25

    cialis vs viagra living https://cialis.adicbc.com/

  26. #26

    cialis vs viagra living https://cialis.advantagetriseal.com/

  27. #27

    Post writing is also a fun, if you be familiar with afterward you can write
    or else it is complex to write. http://antiibioticsland.com/Stromectol.htm

  28. #28

    side effect of hydroxychloroquine https://hhydroxychloroquine.com/

  29. #29

    Thank you for thee good writeup. It in fact was a amusement accounnt it.
    Loook advanced to more addded agreeable from you!

    By the way, hhow could we communicate?

    My site Diamond Painting accessories

  30. #30

    tadalafil pills 20mg: http://tadalafilonline20.com/ tadalafil gel

  31. #31

    Thanks for sharing such a pleasant thinking, paragraph is pleasant, thats why i
    have read it fully http://herreramedical.org/ivermectin

  32. #32

    india pharmacy mail order: https://genericwdp.com/ pills without a doctor prescription

  33. #33

    cheap generic drugs from india purchase tadalafil

  34. #34

    vidalista 10mg

  35. #35

    buy medication without an rx medications without a doctor’s prescription

  36. #36

    generic pills for sale: https://genericwdp.com/ buying prescription drugs from canada

  37. #37

    kamagra

  38. #38

    https://www.tanhu.com.tr

  39. #39

    Muchas gracias. ?Como puedo iniciar sesion?

  40. #40

    google buy hacklink services instagram.

    https://www.idigic.net/buy-instagram-likes/

  41. #41

    google buy hacklink services instagram.

    https://blastup.com/buy-likes-on-instagram

  42. #42

    google buy hacklink services instagram.

    https://www.influencive.com/10-best-sites-to-buy-instagram-likes-real-and-safe/

  43. #43

    google buy hacklink services instagram.

    https://famoid.com/buy-instagram-likes/

  44. #44

    google buy hacklink services tiktok.

    https://tikfuel.com/

  45. #45

    google buy hacklink services youtube and social media.

    https://www.qqtube.com/en/

  46. #46

    google buy hacklink services instagram and social media.

    https://azbigmedia.com/business/buy-instagram-views/

  47. #47

    I do believe aall of the ideas you’ve offered on your post.

    They’re really convincing and can definitely work.
    Nonetheless, the posts are very short for newbies.
    May just you please lengthen them a little from subsequent time?
    Thanks for the post.

    my blog: https://www.diamondpaintingclearance.com/christmas-diamond-painting-kit-5d-season-2-54

  48. #48

    google buy hacklink services instagram and social media.

    https://azbigmedia.com/business/buy-instagram-views/

  49. #49

    google buy hacklink services instagram and social media.

    https://sproutsocial.com/insights/buy-instagram-likes/

  50. #50

    google buy hacklink services facebook and social media.

    https://www.fbpostlikes.com/

  51. #51

    this web site best buy hacklink services and twitter services.

    https://follows.com/twitter/likes

  52. #52

    this web site best buy hacklink services and twitter and tiktok services.

    https://celebian.com/buy-tiktok-likes

  53. #53

    google buy Instagram hacklink services.

    https://socialnomics.net/2021/02/15/buy-instagram-comments/

发表评论

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