Windows命令行代理
因为在Win10上测试时 powershell
和 cmd
进行代理使用的命令是相同的,就不再赘述
标准
1 2
| set http_proxy=http://user:password@IP:port set https_proxy=https://user:password@IP:port
|
范例
1 2
| set http_proxy=http://localhost:1080 set https_proxy=https://localhost:1080
|
清除代理
对于临时代理,目前没有什么好的办法,只能关掉重开 powershell。
有人说下面这种方法能用
1 2 3
| set http_proxy= set https_proxy=
|
对于系统代理(永久代理),直接清除环境变量就好了
同理,如果想设置为系统代理(永久代理),直接添加环境变量就好了


Linux & Git 命令行代理
标准
1 2
| export http_proxy=user:password@IP:port export https_proxy=user:password@IP:port
|
范例
1 2
| export http_proxy=localhost:1080 export https_proxy=localhost:1080
|
清除代理
对于临时代理,可以关掉重开 Terminal
也可以用以下方法
1 2 3
| export http_proxy= export https_proxy=
|
对于系统代理(永久代理),直接清除环境变量就好了
同理,如果想设置为系统代理(永久代理),直接添加环境变量就好了
推荐在 ~/.bashrc 里面设置
1
| echo -e "export http_proxy=localhost:1080\nexport https_proxy=localhost:1080" >> ~/.bashrc
|
1
| echo -e "export http_proxy=\nexport https_proxy=" >> ~/.bashrc
|
验证是否配置成功 :
如果返回的消息中含有 200,301 状态码,皆表示已连通
如果等待一段时间后无响应或返回 404,则代表已断开