注意:若在 WSL/WSL2 或虚拟机中使用,需要查看主机的虚拟网卡例如 vEthernet (WSL) 的IP地址,而不是直接使用127.0.0.1,以下主机地址都以 127.0.0.1 代替

Linux 终端代理

1
2
3
4
5
6
7
# 设置 http/https 代理
export http_proxy=http://127.0.0.1:1024
export https_proxy=$http_proxy

设置 socks5 代理
export http_proxy=socks://127.0.0.1:1024
export https_proxy=$http_proxy

Windows CMD 代理

1
2
3
4
5
6
7
# 设置 http/https 代理
set http_proxy=http://127.0.0.1:1080
set https_proxy=http://127.0.0.1:1080

设置 socks5 代理
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

Git 命令代理

命令行中配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 设置 http/https 代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080

# 设置 socks5 代理
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

# 清除代理
git config --global --unset http.proxy
git config --global --unset https.proxy

~/.gitconfig 文件

1
2
3
4
[http]
        proxy = socks5://172.26.0.1:1117
[https]
        proxy = socks5://172.26.0.1:1117

Curl 命令代理

命令行中配置

1
2
3
4
# 设置 socks5 代理, -x 等价于 --proxy
curl -x socks5://127.0.0.1:1080 http://www.google.com
# 设置 http/https 代理
curl -x http://127.0.0.1:1080 http://www.google.com