跳到主要内容

使用 nginx 负载均衡稳定收看江苏移动 IPTV问题已解决/话题已结束讨论

  • 新帖
  • 热门
  • 精选

使用 nginx 负载均衡稳定收看江苏移动 IPTV 问题已解决/话题已结束讨论

coding 2y ago in IPTV · 27 views

Update:

最新版已有更简单的方式,此贴关闭,使用方法参考 https://pixman.io/topics/16

也可以使用新版的 nginx 配置,参考: https://pixman.io/topics/39


江苏移动直播源 最近新增了阿里云 CDN,但是也存在不稳定性,以及对于 UA 的限制,有些播放器或者电视机上的 APP 不太容易调整 UA,而且 CDN 可用性的变化会导致在播放中可能需要时不时调整订阅,体验很不好。

下面分享一种使用 nginx 负载均衡来提高观看稳定性的方式,这种方式仅限于部署在自家软路由或内网内的服务器,不建议部署到云服务器,除非你服务器的流量不要钱 (Doge。

有两种使用方法,我建议直接用 Docker Compose 方式。

使用命令行操作

首先我们创建一个目录来保存自定义的 nginx 配置文件 (放在任何位置都可以,下面以 /opt/pixman/nginx 为例

mkdir -p /opt/pixman/nginx
touch /opt/pixman/nginx/tptv.conf

tptv.conf 内容如下

server {
    listen 8001 default_server;
    location / {
        set $ua 'okhttp/3';
        if ($arg_ua) {
            set $ua $arg_ua;
        }
        proxy_pass http://tptv1.mobaibox.com;
        proxy_set_header Host tptv1.mobaibox.com;
        proxy_set_header User-Agent $ua;
        proxy_connect_timeout 3;
    }
}

server {
    listen 8002 default_server;
    location / {
        set $ua 'okhttp/3';
        if ($arg_ua) {
            set $ua $arg_ua;
        }
        proxy_pass http://tptv2.mobaibox.com;
        proxy_set_header Host tptv2.mobaibox.com;
        proxy_set_header User-Agent $ua;
        proxy_connect_timeout 3;
    }
}

upstream cdn_server {
    server 127.0.0.1:8001 weight=1 max_fails=1 fail_timeout=60s;

    # tptv2.mobaibox.com 貌似被关闭,暂时注释掉
    # server 127.0.0.1:8002 weight=1 max_fails=1 fail_timeout=60s;
}

server {
    listen 8000 default_server;

    # 修改 YOUR_DOMAIN 为你自己的域名,没有域名就删除 server_name 这一行
    server_name YOUR_DOMAIN;

    location / {
        proxy_next_upstream error timeout http_502 http_503 http_504;
        proxy_pass http://cdn_server;
    }
}

编辑好这个文件后,使用下面命令启动 nginx

docker run -d --name=pixman-nginx -p 8000:8000 -v /opt/pixman/nginx:/etc/nginx/conf.d --restart=always nginx

启动完成后,pixman 容器也需要启动,具体可以看 https://pixman.io/topics/17

然后使用 http://ip:port/tptv.m3u?cdn=YOUR_DOMAIN:8000 播放。

如果你在前面修改 nginx 的时候删掉了 server_name 设置,则直接使用宿主机的 ip 来访问,http://ip:5000/tptv.m3u?cdn=ip:8000

Docker Compose 部署

这是我推荐的方式,也可以直接与 pixman 一起部署,方便快捷,以下示例中,文件全部放在 /opt/pixman 目录下,具体的文件结构如下:

docker-compose.yml 内容 (192.168.50.50:7890 换成你自己的代理服务器)

services:
  pixman:
    image: pixman/pixman:latest
    restart: always
    container_name: pixman
    environment:
      - http_proxy=http://192.168.50.50:7890
      - https_proxy=http://192.168.50.50:7890
      - MYTVSUPER_TOKEN=TOKEN
    ports:
      - 5000:5000
  pixman-nginx:
    image: nginx:latest
    restart: always
    container_name: pixman-nginx
    ports:
      - 8000:8000
    volumes:
       - ./nginx:/etc/nginx/conf.d

tptv.conf 内容与前面的一致,不再重复

准备完毕后,在 /opt/pixman 目录下运行 docker compose up -d 即可一键拉起 pixman 和 nginx 容器,接下来的操作与上面命令行方式一致,订阅,观看,Enjoy it ~

  • 引用文章
  • 被文章引用
江苏移动魔百盒 全国 CDN 版本 Docker 镜像 pixman/pixman 使用说明 Nginx 代理 TPTV 和 iTV
江苏移动魔百盒 全国 CDN 版本 Docker 镜像 pixman/pixman 使用说明 江苏移动 IPTV 频道更新 无需 IPV6,三网通看移动 iTV 直播源
coding 在 Docker 镜像 pixman/pixman 使用说明 提及了此话题。 2024年06月15日
stronghu #2 2024年06月15日

6得一逼

回复此楼 修改
qinsmoon #3 2024年06月15日

👍👍👍

回复此楼 修改
sha #4 2024年06月15日

江苏省内完全无惧,哈哈

回复此楼 修改
guilove #5 2024年06月15日

用群晖docker如何设置呢

回复此楼 修改
iamfang #6 2024年06月15日

非常流畅,thanks

回复此楼 修改
coding #7 2024年06月15日
对 sha #4 回复

哈哈哈哈,省内确实舒服

回复此楼 修改
coding #8 2024年06月15日
对 guilove #5 回复

一样,直接新建一个项目,使用 docker compose 的方式

回复此楼 修改
feng #9 2024年06月16日

牛啊,全用pixman了

回复此楼 修改
coding #10 2024年06月16日
对 feng #9 回复

这就是 docker compose 的魅力所在

回复此楼 修改
coding 在 江苏移动魔百盒 全国 CDN 版本 提及了此话题。 2024年06月16日
ohjust #12 2024年06月16日

里面的YOUR_DOMAIN和ip+端口,具体是指哪个地址?

回复此楼 修改
coding #13 2024年06月16日
对 ohjust #12 回复

ip 指的是宿主机的 ip,比如运行 docker 的 openwrt 软路由 ip; 如果完全按照教程里写的,那订阅地址就是 你的ip:5000/tptv.m3u?cdn=你的ip:8000

如果你没有域名,不需要关心 YOUR_DOMAIN 这个值

回复此楼 修改
guilove #14 2024年06月16日

群晖部署,我的文件都是放在 /volume1/docker/pinman,运行 docker compose up -d后 pixman-nginx容器错误,出现mount failed: '/opt/stacks/pixman/nginx' does not exists pinman容器正常 我看上面也没有说要挂载到/opt/stacks/pixman/nginx

回复此楼 修改
15 楼 已删除
16 楼 已删除
coding #17 2024年06月16日
对 guilove #14 回复

群晖不用这么麻烦,假设你的 compose 文件和 nginx 配置都在 /volume1/docker/pixman 下,那你 compose 内容这么写

services:
  pixman:
    image: pixman/pixman:latest
    restart: always
    container_name: pixman
    environment:
      - http_proxy=http://192.168.50.50:7890
      - https_proxy=http://192.168.50.50:7890
      - MYTVSUPER_TOKEN=EXAMPLE
    ports:
      - 5050:5000
  pixman-nginx:
    image: nginx:latest
    restart: always
    container_name: pixman-nginx
    ports:
      - 8000:8000
    volumes:
       - ./nginx:/etc/nginx/conf.d

目录结构如下

你应该理解一下目录的含义,而不是直接照搬我的配置。

回复此楼 修改
guilove #18 2024年06月16日
对 coding #17 回复

谢谢,我的配置就是这样写,运行就显示要挂载到/opt那边的目录,不知道问题在哪里,我现在只能到opt那边新建文件

回复此楼 修改
coding #19 2024年06月16日
对 guilove #18 回复

你看我的回帖,没有用到 /opt 目录

回复此楼 修改
guilove #20 2024年06月16日

看了你上面文件的内容pixman-nginx容器也没有哪里说需要挂载到、opt/stacks,就是运行compose pixman-nginx 容器错误无法启动,出现 mount failed: '/opt/stacks/pixman/nginx' does not exists

回复此楼 修改
coding #21 2024年06月16日
对 guilove #20 回复

群晖就不需要用命令了,直接在 Container Manager 上手动创建项目

回复此楼 修改
Oldliu #22 2024年06月17日

感谢大佬!我这里搭建好后有部分台如cctv9,cctv13,cctv14,cctv17播不了,其他都很流畅

回复此楼 修改
guilove #23 2024年06月17日
对 coding #17 回复

如果要把4gtv加到conf反代出去给外面没有科学上网的机器,该加什么内容到conf呢,感知大佬

回复此楼 修改
coding #24 2024年06月17日
对 Oldliu #22 回复

这应该不会的呀,其他频道正常,这几个应该也正常才是

回复此楼 修改
coding #25 2024年06月17日
对 guilove #23 回复

那有点复杂,需要改不少东西。。

回复此楼 修改
inzaghi458 #26 2024年06月17日

又来求教了,群晖DOCKER的话怎么操作呢?

回复此楼 修改
Oldliu #27 2024年06月17日
对 coding #24 回复

是有些奇怪呢。我电视上是用Fongmi TV播放器,这几个台播不了。到服务器上用iptv-checker(https://github.com/freearhey/iptv-checker) 测试了一下,这几个台返回:FFMPEG Undefined Error

回复此楼 修改
yifan33539 #28 2024年06月17日

江苏电信 江苏联通也可以用吗?

回复此楼 修改
coding 在 江苏移动 IPTV 频道更新 提及了此话题。 2024年06月17日
coding #30 2024年06月17日
对 yifan33539 #28 回复

可以,全国 cdn

回复此楼 修改
  • 1
  • 2
  • 下一页
收到新回复,点击立即加载
需要 登录 后方可回复, 如果你还没有账号请 注册新账号
Coding
@coding
有事请发帖 @coding 或 联系 [email protected]
统计信息
会员
1,799
话题
260
回帖
2,984
活跃会员 查看排行
stronghu
Brian9394
mengzehe
coding
fandaz
Raymon
duboy
v6wind
jefflyrop
daisy_rain
john
jerainlvjing
rudy
tiao
jiangwl
server
winship
xiasufern
ccf
tvbjack

A digital lifestyle community co-maintained by Pixer

本网站服务器由 提供,CDN 由 提供,基于 Homeland 构建,采用 Docker 部署。