docker运行的clash自动更新订阅

# docker运行的clash自动更新订阅

我们用两个容器 实现了 基于docker的可视化clash

1
2
docker run --restart=always  -p 7880:80 -d  --name clash-web haishanh/yacd
docker run -d --name=clash -v "/www/wwwroot/clash.config.yaml:/root/.config/clash/config.yaml" -p "7890:7890" -p "7891:7891" -p "9090:9090" --restart=unless-stopped dreamacro/clash-premium 

clash.config.yaml 这个文件 是我们从 某些订阅平台拿到的。但是里面的一些配置项目 ,比如 没有打开 局域网访问,还有9090 端口 只允许本机链接等 就是下面两个

1
2
allow-lan: true
external-controller: '0.0.0.0:9090'

先找一个在线订阅转化工具 百度搜有很多,比如 https://ppc.linshenkx.cn/ 也可以自己搭建 https://github.com/qier222/proxy-provider-converter

# 自己搭建转化服务

我这里直接使用 tindy2013/subconverter 查看官网文档 https://github.com/tindy2013/subconverter/blob/master/README-cn.md

1
docker run -d --restart=always -p 25500:25500 tindy2013/subconverter:latest

http://你的ip:25500/sub?target=clash&url=订阅地址URLEncode

可以直接拿到一个可用的修改好的.yaml

剩下的就简单了

在容器外部添加一个定时任务shell

1
2
3
4
cd /www/wwwroot/
curl -o new.clash.yaml 'http://10.0.0.9:25500/sub?target=clash&url=https%3A%2F%2Fxn--xxxxx.com%2Fapi%2Fv1%2Fclient%2Fsubscribe%3Ftoken%xxx'
rm -rf clash.config.yaml
mv new.clash.yaml   clash.config.yaml
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计