通过设置 http_proxy 和 https_proxy 能够使当前机器访问外网时指向代理。
参考链接
How to set up proxy using http_proxy & https_proxy environment variable in Linux?,https://www.golinuxcloud.com/set-up-proxy-http-proxy-environment-variable/
查看代理
echo $http_proxy
echo $https_proxy
代理设置效果
The
http_proxy
andhttps_proxy
environment variable is used to specify proxy settings to client programs such ascurl
andwget
.
当设置了https_proxy
和http_proxy
变量时,客户端程序如 curl 和 wget 都会使用该代理。代理语法
没有密码:
export http_proxy=http://SERVER:PORT/
使用用户密码
# export http_proxy=http://USERNAME:PASSWORD@SERVER:PORT/
- 使用用户密码+域名
# export http_proxy=http://DOMAIN\\USERNAME:PASSWORD@SERVER:PORT/
实战-设置代理
把当前机器指向另外的机器:
#export proxy="http://swproxy:Qwe123456@47.101.143.53:80"
#export all_proxy=$proxy
#export http_proxy=$proxy
#export https_proxy=$proxy
#export no_proxy="localhost,127.0.0.1,0.0.0.0,::1"
#export ALL_PROXY=$proxy
#export HTTP_PROXY=$proxy
#export HTTPS_PROXY=$proxy
#export NO_PROXY="localhost,127.0.0.1,0.0.0.0,::1"