Linux 系统包含 Ubuntu、CentOS 等系统,设置方法都类似,都是修改配置文件
/etc/profile 或 ~/.bashrc 或 ~/.bash_profile
1)Linux 系统设置临时全局代理
a)代理ip无密码授权
##无密码授权代理格式:
export http_proxy=http://ip:port
export https_proxy=http://ip:port
实例如下:
export http_proxy=http://178.63.41.235:9999
export https_proxy=http://198.229.231.13:8080
访问 http 和 https 网址
$ curl ‘http://proxy.mimvp.com/test_proxy2.php‘
{"remote_addr":"118.24.76.45","http_via":"null","client_ip":"null","http_x_forwarded_for":"null"}
$
$ curl ‘https://proxy.mimvp.com/test_proxy2.php‘
{"remote_addr":"118.24.76.45","http_via":"null","client_ip":"null","http_x_forwarded_for":"null"}
查看临时变量
$ echo $http_proxy
http://118.24.76.45:27423
$
$ echo $https_proxy
http://118.24.76.45:27423
取消临时变量
unset http_proxy
unset https_proxy
查看取消后的临时变量
$ unset http_proxy
$ unset https_proxy
$
$ echo $http_proxy
$ echo $https_proxy
原文:https://www.cnblogs.com/smqh-bokeyuan/p/13235581.html