这里处理的是服务器拉取 GitHub 代码问题,自己电脑慢开个纸飞机。
我们需要两个服务器,一个是代理端,一个是客户端。代理端基本使用频率很低,买个临时的 抢占式实例 进行代理配置即可,另外带宽记得选按量计费然后进度条拉满。
安装
代理端配置:
- 安装程序
1
| $ curl -L https://raw.githubusercontent.com/snail007/goproxy/master/install_auto.sh | bash
|
- 获取公网 IP,可以通过控制台看到或者通过接口获取到,后期启动需要用到。
1 2
| $ curl ip.sb 47.56.216.105
|
HTTP
代理端启动
12345
是自定义的端口号,需要在安全组配置打开。
1 2 3
| $ proxy http -t tcp -p "0.0.0.0:12345" -g "47.56.216.105" # 后台运行 $ proxy http -t tcp -p "0.0.0.0:12345" -g "47.56.216.105" --daemon
|
客户端使用
本地设置全局代理
1 2
| $ git config --global http.proxy https://47.56.216.105:12345 $ git config --global https.proxy https://47.56.216.105:12345
|
测试
1 2 3 4 5 6 7 8
| $ git clone https://github.com/leokhoa/laragon.git Cloning into 'laragon'... remote: Enumerating objects: 35, done. remote: Counting objects: 100% (35/35), done. remote: Compressing objects: 100% (33/33), done. remote: Total 1673 (delta 14), reused 10 (delta 1), pack-reused 1638 Receiving objects: 100% (1673/1673), 56.35 MiB | 946.00 KiB/s, done. Resolving deltas: 100% (786/786), done.
|
SOCKS5
代理端启动
1
| $ proxy socks -t tcp -p "0.0.0.0:12345" -g "47.56.216.105"
|
客户端使用
配置环境
1
| $ yum -y install connect-proxy
|
~/.ssh/config
1 2 3
| Host github.com HostName github.com ProxyCommand connect-proxy -S 47.56.216.105:12345 %h %p
|
本地设置全局代理
1 2
| $ git config --global http.proxy 'socks5://47.56.216.105:12345' $ git config --global https.proxy 'socks5://47.56.216.105:12345'
|
测试
1 2 3 4 5 6 7 8 9
| $ git clone https://github.com/leokhoa/laragon.git Cloning into 'laragon'... Enter SOCKS5 password for root@47.56.216.105: remote: Enumerating objects: 35, done. remote: Counting objects: 100% (35/35), done. remote: Compressing objects: 100% (33/33), done. remote: Total 1673 (delta 14), reused 10 (delta 1), pack-reused 1638 Receiving objects: 100% (1673/1673), 56.35 MiB | 676.00 KiB/s, done. Resolving deltas: 100% (786/786), done.
|
Enter SOCKS5 password
直接回车就可以了
取消
1 2
| $ git config --global --unset http.proxy $ git config --global --unset https.proxy
|
文档
goproxy 使用手册