转于:https://zcdll.github.io/2018/01/27/proxy-on-windows-terminal/
et http_proxy=http://127.0.0.1:1080
set https_proxy=http://127.0.0.1:1080
set http_proxy_user=user
set http_proxy_pass=pass
set https_proxy_user=user
set https_proxy_pass=pass
# 恢复
set http_proxy=
set https_proxy=
# Ubuntu 下命令为 export
# export http_proxy=http://127.0.0.1:1080
ping 还是不行的原因
ping的协议不是https,也不是https,是ICMP协议。
验证方式
curl -vv [http://www.google.com](http://www.google.com)
,用这条命令来验证,如果返回如下结果表示代理设置成功。
这里还有一个坑是,cmd,Git Bash,PowerShell 设置的方式不同!!!有点精神分裂了。。。
- cmd 中用
set http_proxy
设置 - Git Bash 中用
export http_proxy
设置 - PowerShell 中按照这样设置
```cppNOTE: registry keys for IE 8, may vary for other versions
$regPath = ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings’
function Clear-Proxy { Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 0 Set-ItemProperty -Path $regPath -Name ProxyServer -Value ‘’ Set-ItemProperty -Path $regPath -Name ProxyOverride -Value ‘’
[Environment]::SetEnvironmentVariable('http_proxy', $null, 'User')
[Environment]::SetEnvironmentVariable('https_proxy', $null, 'User')
}
function Set-Proxy { $proxy = ‘http://example.com‘
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1
Set-ItemProperty -Path $regPath -Name ProxyServer -Value $proxy
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value '<local>'
[Environment]::SetEnvironmentVariable('http_proxy', $proxy, 'User')
[Environment]::SetEnvironmentVariable('https_proxy', $proxy, 'User
```