给 Windows 的终端配置代理 |
您所在的位置:网站首页 › win10查看代理 › 给 Windows 的终端配置代理 |
跟在 Linux 下没什么区别。 设定 set 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就是两条命令,前两条。 要点 一定要加 http://,直接写域名或者 IP 不行。 http 和 https 都要设置。 然后如果想验证是否成功配置了代理的话,用 ping 命令是不可以的ping 还是不行的原因 ping的协议不是https,也不是https,是ICMP协议。 验证方式 curl -vv http://www.google.com用这条命令来验证,如果返回如下结果表示代理设置成功。 坑cmd,Git Bash,PowerShell 设置的方式不同 cmd 中用 set http_proxy 设置Git Bash 中用 export http_proxy 设置PowerShell 中按照这样设置 #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 '' [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 '' [Environment]::SetEnvironmentVariable('http_proxy', $proxy, 'User') [Environment]::SetEnvironmentVariable('https_proxy', $proxy, 'User') }纠结于应该用 set 还是 export 还有一个判断方法是,敲一下这两个命令,如果返回一个长长的列表,就表示应该用这个命令,反之,如果返回找不到这个命令,就不应该用这个命令。 refers: https://zcdll.github.io/2018/01/27/proxy-on-windows-terminal/ |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |