配置全局代理
您可以在 Cumulus Linux 的 /etc/profile.d/ 目录中配置 全局 HTTP 和 HTTPS 代理。设置 http_proxy 和 https_proxy 变量,以使用您要用于在命令行上获取 URL 的代理服务器地址配置交换机。这对于 apt、apt-get、curl 和 wget 等程序非常有用,这些程序都可以使用此代理。
在终端中,在
/etc/profile.d/目录中创建一个新文件。cumulus@switch:~$ sudo nano /etc/profile.d/proxy.sh向文件中添加一行以配置 HTTP 或 HTTPS 代理,或两者都配置
HTTP 代理
http_proxy=http://myproxy.domain.com:8080 export http_proxyHTTPS 代理
https_proxy=https://myproxy.domain.com:8080 export https_proxy
在
/etc/apt/apt.conf.d目录中创建一个文件,并将以下行添加到文件中以获取 HTTP 和 HTTPS 代理。以下示例使用http_proxy作为文件名cumulus@switch:~$ sudo nano /etc/apt/apt.conf.d/http_proxy Acquire::http::Proxy "http://myproxy.domain.com:8080"; Acquire::https::Proxy "https://myproxy.domain.com:8080";将代理地址添加到
/etc/wgetrc文件,然后取消注释http_proxy和https_proxy行(如果需要)cumulus@switch:~$ sudo nano /etc/wgetrc ... https_proxy = https://myproxy.domain.com:8080 http_proxy = http://myproxy.domain.com:8080 ...要在当前环境中执行
/etc/profile.d/proxy.sh文件,请运行source命令cumulus@switch:~$ source /etc/profile.d/proxy.sh
使用 echo 命令确认配置
HTTP 代理
cumulus@switch:~$ echo $http_proxy http://myproxy.domain.com:8080HTTPS 代理
cumulus@switch:~$ echo $https_proxy https://myproxy.domain.com:8080