Skip to content

代理配置生成器

输入协议、IP 和端口,自动生成 CMD、PowerShell、Git Bash、Linux Bash 的代理环境变量和持久化指令。

如果 Clash 不在本机运行,可以把 IP 改成局域网内运行代理的机器地址,例如 192.168.31.233

当前代理地址:http://127.0.0.1:7890

CMD 临时环境变量

set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890

CMD 取消代理

set http_proxy=
set https_proxy=

PowerShell 临时环境变量

$Env:HTTP_PROXY = "http://127.0.0.1:7890"
$Env:HTTPS_PROXY = "http://127.0.0.1:7890"

PowerShell 持久化到 $PROFILE

'$Env:HTTP_PROXY = "http://127.0.0.1:7890"' >> $PROFILE
'$Env:HTTPS_PROXY = "http://127.0.0.1:7890"' >> $PROFILE

PowerShell 取消代理

$Env:HTTP_PROXY = $null
$Env:HTTPS_PROXY = $null

Git Bash 临时环境变量

export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"

Git Bash 持久化到 ~/.bashrc

echo 'export HTTP_PROXY="http://127.0.0.1:7890"' >> ~/.bashrc
echo 'export HTTPS_PROXY="http://127.0.0.1:7890"' >> ~/.bashrc
source ~/.bashrc

Git 全局代理

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

Git 全局代理 SOCKS5 示例

git config --global http.proxy socks5://127.0.0.1:7891
git config --global https.proxy socks5://127.0.0.1:7891

Linux Bash 临时环境变量

export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"
export ALL_PROXY="socks5://127.0.0.1:7891"

Linux Bash 持久化到 ~/.bashrc

echo 'export HTTP_PROXY="http://127.0.0.1:7890"' >> ~/.bashrc
echo 'export HTTPS_PROXY="http://127.0.0.1:7890"' >> ~/.bashrc
echo 'export ALL_PROXY="socks5://127.0.0.1:7891"' >> ~/.bashrc
source ~/.bashrc

Linux Bash 取消代理

unset HTTP_PROXY
unset HTTPS_PROXY
unset ALL_PROXY

🔹 验证代理是否生效

bash
curl -I https://www.google.com

🔹 相关链接