最近要给unraid装点插件, 奈何插件在github上, 不配合科学上网, 基本上就是卡死或者下载失败, 但是切换网络吧, 又得把整个整列停了, 感觉甚是麻烦...
索性自己用
nginx反向代理
搭个桥算了吧, 由于只是单纯的反向代理, 并不能完成
整个插件的安装: 因为配置文件中还有具体的插件下载地址, 那么就需要结合sub_filter
来篡改一下返回数据了!
由于
raw.githubusercontent.com
返回的数据被gzip
压缩过, 导致sub_filter
无法正常工作, 所以需要绕一绕, 先解压
过后, 再进行sub_filter
操作, 差不多思路都讲完了, 直接上关键代码
location /go/ {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host raw.githubusercontent.com;
proxy_redirect off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_pass https://raw.githubusercontent.com/;
}
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host raw.githubusercontent.cc;
proxy_redirect off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Accept-Encoding '';
gzip off;
sub_filter_types *; #替换所有类型
sub_filter '//github.com' '//github.xiaoc.cn'; #替换为github加速域名
sub_filter '//raw.githubusercontent.com' '//raw.githubusercontent.cc'; #替换为githubusercontent加速域名
sub_filter_once off; ####所有匹配到的都替换
proxy_pass http://127.0.0.1/go/;
}
解决方案
将插件下载地址
https://raw.githubusercontent.com/xxxxxxxx
中的com
替换为cc
, 即:https://raw.githubusercontent.cc/xxxxxxxx
ps: 有条件的朋友还是自己搭最好, 因为中间是可以给你插入点别的东西的, 我只能保证我不会.
最后, 访问
https://raw.githubusercontent.cc/dlandon/unassigned.devices/master/unassigned.devices.plg
, 发现原本的https://github.com/&author;/&name;/raw/master
被成功替换为https://github.xiaoc.cn/&author;/&name;/raw/master
没听懂
_(:з」∠)_ 文笔有限