给纯v6小鸡/境内鸡自建github代理
本帖最后由 吹风秀跳刀 于 2025-6-16 20:41 编辑众所周知,5202年github仍然不支持ipv6访问
使用纯v6小鸡,下载软件、跑各种脚本会出现多多少少的问题。
---
最容易的一个办法,在小鸡上使用proxy软件。
---
另一个办法,在一台双栈鸡搭建nginx的stream转发,例如这个公益免费的github代理:
https://danwin1210.de/github-ipv6-proxy.php?lang=zh-Hans
公益服务器位于hz德国,之前使用过一两次,感觉是挺方便的,
然而,最近遇到了几次无法使用的情况,排查后确定了原因:
公益服拥有一个固定的ipv4,而github对单个ip有访问速率限制,一小时内超过多少次就会禁止。
也就是说,这个公益服,在一些时间段,使用人次过多,就会触发官方的限制,可用性难以保障。
---
而自建一个专用的就可以在极大程度上保障可用性(只要小鸡没死,就是100%可用)
https://danwin1210.de/github-ipv6-proxy.php?lang=zh-Hans
原创作者已经提供了nginx配置,可以达到相同效果。有经验的老哥微调一下就ok了。
---
下边提供一个新手参考,
一台v4v6双栈鸡(未使用80和443端口)境外服务器,编译安装nginx,配置github代理
---
1. 安装依赖:
apt update && apt install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev tar unzip ca-certificates mercurial libunwind-dev pkg-config make cmake gcc git wget
2. 下载、解压nginx:
wget https://nginx.org/download/nginx-1.28.0.tar.gz && tar -zxvf nginx-1.28.0.tar.gz && cd nginx-1.28.0
3. 设置编译选项、安装路径:
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module
4. 编译nginx(使用多核加速),安装到系统目录
make -j$(nproc) && make install
5. 目录授权:
mkdir -p /var/tmp/nginx/ && chown www-data:www-data /var/tmp/nginx/
6. 编辑 /etc/nginx/nginx.conf,这里使用cat+EOF一键写入
(常规编辑文件:删除第一行cat...和最后一行EOF)
cat <<'EOF' > /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
server {
listen 80 default_server;
listen [::]:80 default_server;
return 200 "Nginx GitHub Proxy is running.\n";
}
}
stream {
resolver 8.8.8.8 1.1.1.1;
map $ssl_preread_server_name $upstream_host {
api.github.com api.github.com;
codeload.github.com codeload.github.com;
objects.githubusercontent.com objects.githubusercontent.com;
ghcr.io ghcr.io;
pkg.github.com pkg.github.com;
npm.pkg.github.com npm.pkg.github.com;
maven.pkg.github.com maven.pkg.github.com;
nuget.pkg.github.com nuget.pkg.github.com;
rubygems.pkg.github.com rubygems.pkg.github.com;
uploads.github.com uploads.github.com;
raw.githubusercontent.com raw.githubusercontent.com;
default github.com;
}
server {
listen 443;
listen [::]:443;
ssl_preread on;
proxy_pass $upstream_host:443;
proxy_timeout 10m;
proxy_connect_timeout 5s;
}
}
EOF
7. 测试nginx
/usr/sbin/nginx -t
如果成功没有报错,会显示:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
8. 启动运行nginx:
/usr/sbin/nginx
如需重启:
/usr/sbin/nginx -s reload
9. 在需要使用GitHub代理的纯v6的小鸡中,修改 /etc/hosts,添加以下内容(v6地址换成真实地址)
代理服务器的v6地址 github.com
代理服务器的v6地址 api.github.com
代理服务器的v6地址 codeload.github.com
代理服务器的v6地址 objects.githubusercontent.com
代理服务器的v6地址 ghcr.io
代理服务器的v6地址 pkg.github.com npm.pkg.github.com maven.pkg.github.com nuget.pkg.github.com rubygems.pkg.github.com
代理服务器的v6地址 uploads.github.com
代理服务器的v6地址 raw.githubusercontent.com
注:
服务器的nginx设置是v4和v6都可以用
如果是境内鸡有v4但是速度慢,也可以选择使用代理服务器的v4进行加速(纯v6鸡只能用v6没得选)
---
1-8 是服务器的步骤,9 是客户端的步骤
---
总结:
如果你拥有多台纯v6的小鸡,推荐这么弄,一劳永逸,复用率高。
如果只是个别的一台两台,直接在小鸡上使用proxy软件也许更省事。
阔亦 虽然用不到,但必须支持 不是很懂,但我记得cf不是有warp可以在v6小鸡上代理走v4地址吗 其实不用这么麻烦 可以用cloudflare worker来白**一个github加速
https://github.com/hunshcn/gh-proxy 只是v6的话,我记得改hosts就行了啊
略显复杂,我也用的cf上放个gh-proxy wireguard就行,找个有v4v6的vps搭建服务器,纯v6用v6连接服务器获取内网v4,然后服务器上nat出去,共用一个ip就可以了,还是自己独享的。 github怎么不支持ipv6??? 直接转发
页:
[1]
2
