全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1101|回复: 13

[经验] 给纯v6小鸡/境内鸡自建github代理

[复制链接]
发表于 2025-6-16 19:20:34 | 显示全部楼层 |阅读模式
本帖最后由 吹风秀跳刀 于 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. 安装依赖:

  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:

  1. 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. 设置编译选项、安装路径:

  1. ./configure \
  2. --prefix=/usr/local/nginx \
  3. --sbin-path=/usr/sbin/nginx \
  4. --conf-path=/etc/nginx/nginx.conf \
  5. --error-log-path=/var/log/nginx/error.log \
  6. --http-log-path=/var/log/nginx/access.log \
  7. --pid-path=/var/run/nginx.pid \
  8. --lock-path=/var/run/nginx.lock \
  9. --http-client-body-temp-path=/var/tmp/nginx/client \
  10. --http-proxy-temp-path=/var/tmp/nginx/proxy \
  11. --http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
  12. --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  13. --http-scgi-temp-path=/var/tmp/nginx/scgi \
  14. --with-http_v2_module \
  15. --with-http_ssl_module \
  16. --with-http_realip_module \
  17. --with-http_addition_module \
  18. --with-http_sub_module \
  19. --with-http_dav_module \
  20. --with-http_flv_module \
  21. --with-http_mp4_module \
  22. --with-http_gunzip_module \
  23. --with-http_gzip_static_module \
  24. --with-http_random_index_module \
  25. --with-http_secure_link_module \
  26. --with-http_stub_status_module \
  27. --with-http_auth_request_module \
  28. --with-mail \
  29. --with-mail_ssl_module \
  30. --with-file-aio \
  31. --with-http_v2_module \
  32. --with-threads \
  33. --with-stream \
  34. --with-stream_ssl_module \
  35. --with-stream_realip_module \
  36. --with-stream_ssl_preread_module
复制代码


4. 编译nginx(使用多核加速),安装到系统目录

  1. make -j$(nproc) && make install
复制代码


5. 目录授权:

  1. mkdir -p /var/tmp/nginx/ && chown www-data:www-data /var/tmp/nginx/
复制代码


6. 编辑 /etc/nginx/nginx.conf,这里使用cat+EOF一键写入

(常规编辑文件:删除第一行cat...和最后一行EOF)

  1. cat <<'EOF' > /etc/nginx/nginx.conf
  2. user www-data;
  3. worker_processes auto;
  4. pid /var/run/nginx.pid;
  5. error_log /var/log/nginx/error.log warn;

  6. events {
  7.     worker_connections 1024;
  8. }

  9. http {

  10.     default_type application/octet-stream;

  11.     access_log /var/log/nginx/access.log;

  12.     sendfile on;
  13.     tcp_nopush on;

  14.     server {
  15.         listen 80 default_server;
  16.         listen [::]:80 default_server;
  17.         return 200 "Nginx GitHub Proxy is running.\n";
  18.     }
  19. }

  20. stream {
  21.     resolver 8.8.8.8 1.1.1.1;

  22.     map $ssl_preread_server_name $upstream_host {
  23.         api.github.com                  api.github.com;
  24.         codeload.github.com             codeload.github.com;
  25.         objects.githubusercontent.com   objects.githubusercontent.com;
  26.         ghcr.io                         ghcr.io;
  27.         pkg.github.com                  pkg.github.com;
  28.         npm.pkg.github.com              npm.pkg.github.com;
  29.         maven.pkg.github.com            maven.pkg.github.com;
  30.         nuget.pkg.github.com            nuget.pkg.github.com;
  31.         rubygems.pkg.github.com         rubygems.pkg.github.com;
  32.         uploads.github.com              uploads.github.com;
  33.         raw.githubusercontent.com       raw.githubusercontent.com;
  34.         default                         github.com;
  35.     }

  36.     server {
  37.         listen 443;
  38.         listen [::]:443;
  39.         ssl_preread on;
  40.         proxy_pass $upstream_host:443;
  41.         proxy_timeout 10m;
  42.         proxy_connect_timeout 5s;
  43.     }
  44. }
  45. EOF
复制代码


7. 测试nginx

  1. /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:

  1. /usr/sbin/nginx
复制代码


如需重启:
  1. /usr/sbin/nginx -s reload
复制代码


9. 在需要使用GitHub代理的纯v6的小鸡中,修改 /etc/hosts,添加以下内容(v6地址换成真实地址)

  1. 代理服务器的v6地址 github.com
  2. 代理服务器的v6地址 api.github.com
  3. 代理服务器的v6地址 codeload.github.com
  4. 代理服务器的v6地址 objects.githubusercontent.com
  5. 代理服务器的v6地址 ghcr.io
  6. 代理服务器的v6地址 pkg.github.com npm.pkg.github.com maven.pkg.github.com nuget.pkg.github.com rubygems.pkg.github.com
  7. 代理服务器的v6地址 uploads.github.com
  8. 代理服务器的v6地址 raw.githubusercontent.com
复制代码


注:

服务器的nginx设置是v4和v6都可以用

如果是境内鸡有v4但是速度慢,也可以选择使用代理服务器的v4进行加速(纯v6鸡只能用v6没得选)

---

1-8 是服务器的步骤,9 是客户端的步骤

---

总结:

如果你拥有多台纯v6的小鸡,推荐这么弄,一劳永逸,复用率高。

如果只是个别的一台两台,直接在小鸡上使用proxy软件也许更省事。
发表于 2025-6-17 17:24:37 | 显示全部楼层
虽然用不到,但必须支持
发表于 2025-6-17 17:33:13 | 显示全部楼层
不是很懂,但我记得cf不是有warp可以在v6小鸡上代理走v4地址吗
发表于 2025-6-17 17:37:29 | 显示全部楼层
其实不用这么麻烦 可以用cloudflare worker来白**一个github加速
https://github.com/hunshcn/gh-proxy
发表于 2025-6-17 17:38:01 | 显示全部楼层
只是v6的话,我记得改hosts就行了啊
发表于 2025-6-24 17:45:32 | 显示全部楼层
略显复杂,我也用的cf上放个gh-proxy
发表于 2025-6-24 18:38:51 | 显示全部楼层
wireguard就行,找个有v4v6的vps搭建服务器,纯v6用v6连接服务器获取内网v4,然后服务器上nat出去,共用一个ip就可以了,还是自己独享的。
发表于 2025-6-24 21:04:46 | 显示全部楼层
github怎么不支持ipv6???
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-14 06:35 , Processed in 0.088399 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表