1.

在 Ubuntu 上: 设置 > 网络 > 网络代理 > 手动
在 Debian 上: 设置 > 网络 > 网络代理 > 手动

2. 填充 http、https 和 ftp 的代理值。如果您有 SOCKS 代理,也请进行相应设置。保存更改后,系统将自动选择它们。

如果您使用的是 Firefox 浏览器,则需要在首选项 > 网络设置 > 手动代理配置下更新代理设置。
firefox set proxy

3. 在 CLI 上设置系统范围代理设置

我们将在/etc/profile.d/proxy.sh下添加一个shell脚本文件。这将确保设置适用于所有登录的用户。
sudo vim /etc/profile.d/proxy.sh
填充您的代理值。

set proxy config via profie.d - should apply for all users

export http_proxy="http://10.10.1.10:8080/"
export https_proxy="http://10.10.1.10:8080/"
export ftp_proxy="http://10.10.1.10:8080/"
export no_proxy="127.0.0.1,localhost"

For curl

export HTTP_PROXY="http://10.10.1.10:8080/"
export HTTPS_PROXY="http://10.10.1.10:8080/"
export FTP_PROXY="http://10.10.1.10:8080/"
export NO_PROXY="127.0.0.1,localhost"

将 10.10.1.10:8080 替换为您的代理服务器 IP 地址和代理服务侦听端口。将要从代理中排除的其他 IP 添加到 NO_PROXY 和 no_proxy 环境变量。

使其可执行。

sudo chmod +x /etc/profile.d/proxy.sh

获取文件以开始使用代理设置,或者注销并重新登录。

source /etc/profile.d/proxy.sh

确认 :

$ env | grep -i proxy

4. 为 APT 包管理器设置代理

上述设置适用于应用程序和命令行工具。如果您只想为 APT 包管理器设置代理,请按如下所示进行配置。

$ sudo vim /etc/apt/apt.conf.d/80proxy
Acquire::http::proxy "http://10.10.1.10:8080/";
Acquire::https::proxy "https://10.10.1.10:8080/";
Acquire::ftp::proxy "ftp://10.10.1.10:8080/";

将 10.10.1.10 替换为代理服务器的正确 IP 地址。如果需要认证,则这样设置。

Acquire::http::proxy "http://:@:/";
Acquire::https::proxy "https://:@:/";
Acquire::ftp::proxy "ftp://:@:/";

5. 仅为 wget 设置代理

要设置与 wget 命令一起使用的代理设置,请将它们添加到 ~/.wgetrc 文件中。

$ vim ~/.wgetrc
use_proxy = on
http_proxy = http://10.10.1.10:8080/
https_proxy = http://10.10.1.10:8080/
ftp_proxy = http://10.10.1.10:8080/

posted on 2024-04-23 14:47  keleman  阅读(145)  评论(0编辑  收藏  举报