设置

  1. #gitBash
  2. export http_proxy=http://127.0.0.1:1080
  3. export https_proxy=http://127.0.0.1:1080
  4. #cmd
  5. set http_proxy=http://127.0.0.1:1080
  6. set https_proxy=http://127.0.0.1:1080
  7. set http_proxy_user=user
  8. set http_proxy_pass=pass
  9. set https_proxy_user=user
  10. set https_proxy_pass=pass
  11. # 恢复
  12. set http_proxy=
  13. set https_proxy=
  14. # Ubuntu 下命令为 export
  15. # export http_proxy=http://127.0.0.1:1080

只需要执行前2条
SS不管开全局模式还是pac模式都可以,gitBash每次打开都要重新设置一次

验证

不要用ping, ping的协议不是https,也不是https,是ICMP协议
用下列命令验证:

  1. curl -vv http://www.google.com

像下面这样就说明设置成功
image.png

不同终端的区别

  • cmd 中用 set http_proxy 设置
  • Git Bash 中用 export http_proxy 设置
  • PowerShell 中按照这样设置 ```bash

    NOTE: 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 ‘’

  1. [Environment]::SetEnvironmentVariable('http_proxy', $null, 'User')
  2. [Environment]::SetEnvironmentVariable('https_proxy', $null, 'User')

}

function Set-Proxy { $proxy = ‘http://example.com

  1. Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1
  2. Set-ItemProperty -Path $regPath -Name ProxyServer -Value $proxy
  3. Set-ItemProperty -Path $regPath -Name ProxyOverride -Value '<local>'
  4. [Environment]::SetEnvironmentVariable('http_proxy', $proxy, 'User')
  5. [Environment]::SetEnvironmentVariable('https_proxy', $proxy, 'User')

} ```