环境:
Windows 10 x64
Git for windows 2.18.0-64
Shadowsocks-windows 4.1.0
Proxifier 3.31
配置任意程序代理:
最简单的方式,使用 Proxifier 强制任意程序,使用指定代理。
免去不同程序不同配置的繁琐操作,推荐使用。
Linux 下可使用 ProxyChains 代替。
单独配置 git 代理:
1. 创建 C:\Users\xxx\.gitProxy 文件
1 2 3 4 5 6 7 |
#!/bin/sh # 使用 socks 代理 connect -S 127.0.0.1:8388 "$@" ## 使用 http 代理 #connect -H 127.0.0.1:8388 "$@" |
2. 创建 C:\Users\xxx\.gitSSHProxy 文件
1 2 3 |
#!/bin/sh ssh -o ProxyCommand="~/.gitProxy %h %p" "$@" |
3. 创建 C:\Users\xxx\.gitconfig 文件
1 2 3 4 5 6 7 8 9 10 |
[core] gitProxy = ~/.gitProxy # 代理 ssh:// git@ sshCommand = ~/.gitSSHProxy # 代理 http:// https:// git:// [http] proxy = socks5://127.0.0.1:8388 # 使用 socks 代理 #proxy = http://127.0.0.1:8388 # 使用 http 代理 |
单独配置 nodejs 代理:
nodejs 仅支持配置 http 代理
1 2 3 4 |
proxy=http://127.0.0.1:8388/ #https-proxy=http://127.0.0.1:8388 #no-proxy=npm.xxxxxx.work #strict-ssl=false |
注意事项:
Shadowsocks 支持 socks 和 http 代理,但不支持 https 代理。
奇怪的是 Chrome 可以配置使用 http 代理访问 https 资源。
但 nodejs 不可以,即便是设置 strict-ssl 为 false 也不行。
表现为从 npm 仓储安装走了代理,但预安装脚本中的自定义下载没有走代理。
原因待查。
参考:
Shadowsocks-windows
ProxyChains
Proxifier
git-config(1) Manual Page
服务器上的 Git – 协议
如何为 Git 设置代理?
我的软件清单
Pros and cons of using a Http proxy v/s https proxy?