命令行下配置代理服务器

 

通过设置环境变量来配置代理,一种方式是直接在系统设置中配置(这个就不解释了),另一种方式是在需要时通过 set 命令临时设置。

  • [Windows命令行]

控制代理的环境变量分别是 http_proxy、http_proxy_user、http_proxy_pass,不区分大小写,分别代表代理地址(应是 http://ip:port 的形式)、代理用户名、代理密码,一般情况下只需要配置 http_proxy 即可,参数格式大致如下所示。

#设置参数
set http_proxy=http://localhost:8080
set http_proxy_user=username
set http_proxy_pass=password
​
#删除参数
set http_proxy=
set http_proxy_user=
set http_proxy_pass=

另外经测试还有 https_proxy 环境变量可配置,用于配置 https 的代理,如果未配置则将使用 http_proxy 的配置。据此可推测有 https_proxy_user 等参数。

【Linux命令行】

可配置的环境变量名分别为 http_proxy、https_proxy、ftp_proxy、no_proxy,分别是配置 http 代理、https 代理、ftp 代理、不使用代理的地址,参数格式大致如下所示(正确性有待考察,可能需要加http://前缀),no_proxy 较特殊。

http_proxy=192.168.10.91:3128
https_proxy=192.168.10.91:3128
ftp_proxy=192.168.10.91:3128
no_proxy="127.0.0.1, localhost, 172.26.*, 172.25.6.66, 192.168.*"

在linux下也有两种配置方式,一是需要在相关系统文件中配置,二是通过 export 命令临时设置,这里不做详细介绍。

猜你喜欢

转载自blog.csdn.net/hailangnet/article/details/104304995