记录常用命令行工具、包管理器、开发工具等在代理环境下的配置方法。
所有代理地址统一为:http://127.0.0.1:7890(若工具支持 SOCKS5,可相应替换为 socks5://127.0.0.1:7890)。

博主博客

Curl

# 设置代理(http)
curl -x http://127.0.0.1:7890 -O https://example.com/file

# 使用 socks5 代理
curl -x socks5://127.0.0.1:7890 -O https://example.com/file

Snap

# 设置
sudo snap set system proxy.https="http://127.0.0.1:7890"
sudo snap set system proxy.http="http://127.0.0.1:7890"

# 取消
sudo snap set system proxy.http=""
sudo snap set system proxy.https=""

Windows CMD

# 设置(http / socks5 均可)
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890
set ftp_proxy=http://127.0.0.1:7890
# 若使用 socks5
set http_proxy=socks5://127.0.0.1:7890
set https_proxy=socks5://127.0.0.1:7890

# 取消
set http_proxy=
set https_proxy=
set ftp_proxy=

OpenWrt (opkg)

编辑 /etc/opkg.conf,在文件末尾添加:

option http_proxy http://127.0.0.1:7890

然后执行:

opkg update
opkg install <package>

Git

# 设置
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

# 取消
git config --global --unset http.proxy
git config --global --unset https.proxy

# 查询
git config --global --get http.proxy
git config --global --get https.proxy

npm 与 yarn

# npm 设置
npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890

# npm 取消
npm config rm proxy
npm config rm https-proxy

# yarn 设置
yarn config set proxy http://127.0.0.1:7890
yarn config set https-proxy http://127.0.0.1:7890

# yarn 取消
yarn config delete proxy
yarn config delete https-proxy

Zsh / Bash (环境变量)

~/.zshrc~/.bashrc 中添加以下函数:

function setproxy() {
    export ALL_PROXY=http://127.0.0.1:7890
    export HTTP_PROXY=http://127.0.0.1:7890
    export HTTPS_PROXY=http://127.0.0.1:7890
    export http_proxy=http://127.0.0.1:7890
    export https_proxy=http://127.0.0.1:7890
    export no_proxy="localhost,127.0.0.1,::1"
}

function unsetproxy() {
    unset ALL_PROXY
    unset HTTP_PROXY
    unset HTTPS_PROXY
    unset http_proxy
    unset https_proxy
    unset no_proxy
}

# 默认开启代理(可选)
setproxy

Vagrant

需要先安装插件 vagrant-proxyconf

vagrant plugin install vagrant-proxyconf

然后在 ~/.vagrant.d/Vagrantfile 中添加:

Vagrant.configure("2") do |config|
    puts "proxyconf..."
    if Vagrant.has_plugin?("vagrant-proxyconf")
        puts "find proxyconf plugin !"
        if ENV["http_proxy"]
            puts "http_proxy: " + ENV["http_proxy"]
            config.proxy.http     = ENV["http_proxy"]
        end
        if ENV["https_proxy"]
            puts "https_proxy: " + ENV["https_proxy"]
            config.proxy.https    = ENV["https_proxy"]
        end
        if ENV["no_proxy"]
            config.proxy.no_proxy = ENV["no_proxy"]
        end
    end
end

APT (Debian/Ubuntu)

两种方式:

方式一:使用 apt.conf

echo 'Acquire::http::Proxy "http://127.0.0.1:7890";' | sudo tee /etc/apt/apt.conf.d/95proxies
echo 'Acquire::https::Proxy "http://127.0.0.1:7890";' | sudo tee -a /etc/apt/apt.conf.d/95proxies

方式二:使用环境变量(sudo 时需要保留)

export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
sudo -E apt update

YUM (RHEL/CentOS)

编辑 /etc/yum.conf,在末尾添加:

proxy=http://127.0.0.1:7890

Docker

Docker Daemon 代理:创建目录和配置文件

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/systemd/system/docker.service.d/proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.1"
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

Docker Client 代理:在 ~/.docker/config.json 中添加

{
  "proxies": {
    "default": {
      "httpProxy": "http://127.0.0.1:7890",
      "httpsProxy": "http://127.0.0.1:7890",
      "noProxy": "localhost,127.0.0.1"
    }
  }
}

pip (Python)

# 设置
pip config set global.proxy http://127.0.0.1:7890

# 取消
pip config unset global.proxy

# 临时使用
pip install --proxy=http://127.0.0.1:7890 package_name

gem (Ruby)

# 设置
gem sources --add http://rubygems.org/
gem install --http-proxy http://127.0.0.1:7890 package_name

# 或者设置环境变量
export http_proxy=http://127.0.0.1:7890
gem install package_name

Maven

编辑 ~/.m2/settings.xml

<settings>
  <proxies>
    <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>127.0.0.1</host>
      <port>7890</port>
    </proxy>
  </proxies>
</settings>

Gradle

~/.gradle/gradle.properties 中添加:

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890

Wget

~/.wgetrc 中添加:

http_proxy = http://127.0.0.1:7890
https_proxy = http://127.0.0.1:7890
use_proxy = on

或通过命令行:

wget -e use_proxy=yes -e http_proxy=http://127.0.0.1:7890 https://example.com/file

SSH

SSH 本身不支持 HTTP 代理,但可以通过 nc (netcat) 配合 ProxyCommand 实现:

# 在 ~/.ssh/config 中添加
Host *
    ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p

或使用 socat

Host *
    ProxyCommand socat - SOCKS4A:127.0.0.1:%h:%p,socksport=7890

rsync

通过 --socks 或使用 rsh 包装,通常建议走 SSH 隧道。若必须,可使用 rsync -e 'ssh -o ProxyCommand="nc -X 5 -x 127.0.0.1:7890 %h %p"'

Java (JVM 应用程序)

通过环境变量或 JVM 参数:

export JAVA_OPTS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=7890"
java $JAVA_OPTS -jar app.jar

Systemd 服务

编辑 service 文件(如 /etc/systemd/system/xxx.service),在 [Service] 段添加:

Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"

然后 systemctl daemon-reload && systemctl restart xxx

pnpm

# 设置
pnpm config set proxy http://127.0.0.1:7890
pnpm config set https-proxy http://127.0.0.1:7890

# 取消
pnpm config delete proxy
pnpm config delete https-proxy

Go (Golang)

# 设置环境变量
go env -w GOPROXY=http://127.0.0.1:7890,direct
go env -w HTTP_PROXY=http://127.0.0.1:7890
go env -w HTTPS_PROXY=http://127.0.0.1:7890

# 取消
go env -u GOPROXY
go env -u HTTP_PROXY
go env -u HTTPS_PROXY

Rust / Cargo

编辑或创建 ~/.cargo/config.toml

[http]
proxy = "http://127.0.0.1:7890"

[https]
proxy = "http://127.0.0.1:7890"

或使用环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
cargo build

Composer (PHP)

# 设置
composer config -g http-proxy http://127.0.0.1:7890
composer config -g https-proxy http://127.0.0.1:7890

# 取消
composer config -g --unset http-proxy
composer config -g --unset https-proxy

dotnet (NuGet)

编辑 ~/.nuget/NuGet/NuGet.Config

<configuration>
  <config>
    <add key="http_proxy" value="http://127.0.0.1:7890" />
    <add key="https_proxy" value="http://127.0.0.1:7890" />
  </config>
</configuration>

或通过环境变量 http_proxy / https_proxy

Conda

# 设置
conda config --set proxy_servers.http http://127.0.0.1:7890
conda config --set proxy_servers.https http://127.0.0.1:7890

# 取消
conda config --remove-key proxy_servers.http
conda config --remove-key proxy_servers.https

kubectl

kubectl 本身无专用代理配置,但可复用环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
kubectl get pods

若需代理访问 API server,可使用 --proxy-url 参数(kubectl >= 1.24):

kubectl --proxy-url=http://127.0.0.1:7890 get pods

Helm

Helm 复用环境变量或通过 --proxy 参数:

export HTTP_PROXY=http://127.0.0.1:7890
helm repo add stable https://charts.helm.sh/stable

# 或直接
helm --proxy http://127.0.0.1:7890 repo update

Terraform

Terraform 复用环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
terraform init

AWS CLI

# 配置
aws configure set proxy http://127.0.0.1:7890

# 或在 ~/.aws/config 中添加
[default]
proxy = http://127.0.0.1:7890

Pacman (Arch Linux)

编辑 /etc/pacman.conf,在相应位置添加:

XferCommand = /usr/bin/curl -x http://127.0.0.1:7890 -C - -f -L -o %o %u

Flatpak

# 设置系统代理环境变量(systemd 或通过 flatpak override)
sudo flatpak override --system --env=HTTP_PROXY=http://127.0.0.1:7890
sudo flatpak override --system --env=HTTPS_PROXY=http://127.0.0.1:7890

# 用户级
flatpak override --user --env=HTTP_PROXY=http://127.0.0.1:7890

Podman

与 Docker 类似,通过 systemd 服务或环境变量:

# 设置容器引擎代理
sudo systemctl edit podman.service

添加:

[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"

然后 systemctl daemon-reload && systemctl restart podman

Homebrew (macOS / Linux)

Homebrew 主要通过环境变量工作,但可以使用 HOMEBREW_CURLRCHOMEBREW_VERBOSE 等:

export HOMEBREW_CURLRC=1
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
brew update

NVM (Node Version Manager)

NVM 使用 curlwget 下载 Node,因此复用环境变量即可:

export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
nvm install node

Python Poetry

# 配置
poetry config http-proxy http://127.0.0.1:7890
poetry config https-proxy http://127.0.0.1:7890

# 取消
poetry config http-proxy --unset
poetry config https-proxy --unset

Android SDK Manager (sdkmanager)

设置环境变量或通过 ~/.android/sdkmanager.cfg

proxyHost=127.0.0.1
proxyPort=7890

或使用 --proxy 参数:

sdkmanager --proxy=http --proxy_host=127.0.0.1 --proxy_port=7890 "platforms;android-33"

LXC (Linux Containers)

# 设置环境变量
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
lxc launch ubuntu:22.04 mycontainer

# 或在容器配置中设置
lxc config set mycontainer environment.http_proxy http://127.0.0.1:7890
lxc config set mycontainer environment.https_proxy http://127.0.0.1:7890

Scoop (Windows)

# 设置
scoop config proxy 127.0.0.1:7890

# 取消
scoop config rm proxy

Chocolatey (Windows)

# 设置
choco config set proxy http://127.0.0.1:7890

# 取消
choco config unset proxy

Subversion (SVN)

编辑 ~/.subversion/servers

[global]
http-proxy-host = 127.0.0.1
http-proxy-port = 7890

或通过环境变量:

export http_proxy=http://127.0.0.1:7890
svn checkout https://example.com/repo

Mercurial (hg)

编辑 ~/.hgrc

[http_proxy]
host = 127.0.0.1:7890

[https_proxy]
host = 127.0.0.1:7890

Bazel

~/.bazelrc 中添加:

build --http_proxy=http://127.0.0.1:7890
build --https_proxy=http://127.0.0.1:7890

或通过环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
bazel build //...

Google Cloud SDK (gcloud)

gcloud config set proxy/type http
gcloud config set proxy/address 127.0.0.1
gcloud config set proxy/port 7890
# 取消
gcloud config unset proxy/type

Ansible

通过环境变量(执行 playbook 时):

export HTTP_PROXY=http://127.0.0.1:7890
ansible-playbook playbook.yml

或在 ansible.cfg 中:

[defaults]
http_proxy = http://127.0.0.1:7890
https_proxy = http://127.0.0.1:7890

Puppet

编辑 /etc/puppetlabs/puppet/puppet.conf

[main]
http_proxy_host = 127.0.0.1
http_proxy_port = 7890

Chef

~/.chef/config.rb/etc/chef/client.rb 中添加:

http_proxy "http://127.0.0.1:7890"
https_proxy "http://127.0.0.1:7890"

Visual Studio Code

  • 方法一:设置环境变量后从终端启动 code .
  • 方法二:在 settings.json 中配置:
{
  "http.proxy": "http://127.0.0.1:7890",
  "http.proxyStrictSSL": false
}
  • 方法三:使用扩展如 “Proxy SwitchyOmega”(需配合浏览器)

IntelliJ IDEA / JetBrains IDEs

File → Settings → Appearance & Behavior → System Settings → HTTP Proxy
选择 Manual proxy configuration

  • HTTP: 127.0.0.1:7890
  • 勾选 “Use HTTP proxy for HTTPS connections”

Eclipse

Window → Preferences → General → Network Connections
选择 Manual,添加 HTTP / HTTPS 代理:

  • Host: 127.0.0.1,Port: 7890

Firefox (命令行启动代理)

firefox -no-remote -proxy http://127.0.0.1:7890

Chrome / Chromium (命令行启动代理)

google-chrome --proxy-server="http://127.0.0.1:7890"

ProxyChains (通用代理包装器)

安装 proxychains4,编辑 /etc/proxychains4.conf~/.proxychains/proxychains.conf

[ProxyList]
http 127.0.0.1 7890
# 或 socks5 127.0.0.1 7890

使用:

proxychains4 curl https://example.com
proxychains4 git clone https://github.com/xxx/xxx

tsocks

编辑 /etc/tsocks.conf

server = 127.0.0.1
server_port = 7890
server_type = 5  # 5 for SOCKS5

使用:

tsocks curl https://example.com

Windows 系统代理(netsh winhttp)

# 设置
netsh winhttp set proxy 127.0.0.1:7890
# 重置
netsh winhttp reset proxy

影响 Windows 的 WinHTTP 应用程序(如某些后台服务)。

Linux 桌面系统代理 (GNOME)

# 设置全局代理(GNOME)
gsettings set org.gnome.system.proxy mode 'manual'
gsettings set org.gnome.system.proxy.http host '127.0.0.1'
gsettings set org.gnome.system.proxy.http port 7890
gsettings set org.gnome.system.proxy.https host '127.0.0.1'
gsettings set org.gnome.system.proxy.https port 7890
gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '::1']"

# 关闭代理
gsettings set org.gnome.system.proxy mode 'none'

KDE Plasma

通过 systemsettingsNetworkProxy 手动设置,或使用 kwriteconfig5

kwriteconfig5 --file kioslaverc --group Proxy --key ProxyType 1
kwriteconfig5 --file kioslaverc --group Proxy --key httpProxy "http://127.0.0.1:7890"
kwriteconfig5 --file kioslaverc --group Proxy --key httpsProxy "http://127.0.0.1:7890"

ADB (Android Debug Bridge)

ADB 本身不直接支持代理,但可通过 adb connect 连接已代理的设备,或使用环境变量:

export http_proxy=http://127.0.0.1:7890
adb install app.apk   # 不会走代理,仅用于下载工具链

若需代理 adb 的端口转发流量,可使用 proxychains

Xcode / xcodebuild

通过环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
xcodebuild -project MyApp.xcodeproj -scheme MyScheme build

Swift Package Manager

~/.gitconfig 中已配置 Git 代理(因为 SPM 底层使用 Git),或通过环境变量:

export http_proxy=http://127.0.0.1:7890
swift package resolve

OPAM (OCaml 包管理器)

opam config set-proxy http://127.0.0.1:7890
# 或环境变量
export http_proxy=http://127.0.0.1:7890
opam update

Redis CLI (redis-cli)

Redis 客户端通常直连,但可通过 socatproxychains 包装:

proxychains4 redis-cli -h some-redis-server -p 6379

MySQL CLI (mysql)

同样可使用 proxychainstsocks

proxychains4 mysql -h some-db-host -u root -p

PostgreSQL CLI (psql)

proxychains4 psql -h some-db-host -U postgres

阿里云 OSS 命令行工具 (ossutil)

# 通过环境变量
export HTTP_PROXY=http://127.0.0.1:7890
ossutil ls oss://bucket

# 或配置文件 ~/.ossutilconfig 中添加
[Credentials]
proxy-host = 127.0.0.1
proxy-port = 7890

Azure CLI (az)

az config set proxy=http://127.0.0.1:7890
# 取消
az config set proxy=

Terraform (补充私有模块代理)

除了环境变量,可在 ~/.terraformrc 中配置:

provider_installation {
  network_mirror {
    url = "https://terraform.example.com/"
    include = ["example.com/*"]
    proxy = "http://127.0.0.1:7890"
  }
}

Buildroot / Yocto

对于源码下载,通常通过设置 http_proxy 环境变量:

export http_proxy=http://127.0.0.1:7890
make

在 Buildroot 的 .config 中:

BR2_CCACHE_HTTP_PROXY="http://127.0.0.1:7890"

wsl.conf (Windows Subsystem for Linux)

/etc/wsl.conf 中添加:

[network]
httpProxy = http://127.0.0.1:7890
httpsProxy = http://127.0.0.1:7890

重启 WSL 后生效。

容器内代理传递 (Podman/Docker 补充)

除了 daemon 配置,运行时可直接传递环境变量:

docker run -e HTTP_PROXY=http://127.0.0.1:7890 -it ubuntu bash

cURL (补充:使用 .curlrc)

创建 ~/.curlrc

proxy = http://127.0.0.1:7890

此后每次 curl 自动使用代理。

aria2 (命令行下载工具)

编辑 ~/.aria2/aria2.conf

all-proxy=http://127.0.0.1:7890

或命令行:

aria2c --all-proxy=http://127.0.0.1:7890 "magnet:?xt=..."

Flutter

export HTTP_PROXY=http://127.0.0.1:7890
flutter doctor

或在 ~/.flutter_settings 中(不推荐)。

electron-builder

环境变量即可:

export HTTP_PROXY=http://127.0.0.1:7890
npm run build

DNF(Fedora / RHEL 8+)

编辑 /etc/dnf/dnf.conf,在末尾添加:

proxy=http://127.0.0.1:7890

Zypper(openSUSE)

编辑 /etc/zypp/zypp.conf,取消注释并修改:

http_proxy = http://127.0.0.1:7890
https_proxy = http://127.0.0.1:7890

或通过命令行:

zypper ar --http-proxy http://127.0.0.1:7890 repo

Bower(前端包管理器)

通过环境变量(bower 底层使用 git 和 curl):

export HTTP_PROXY=http://127.0.0.1:7890
bower install jquery

或配置 .bowerrc

{
  "proxy": "http://127.0.0.1:7890",
  "https-proxy": "http://127.0.0.1:7890"
}

Lerna(多包管理)

直接复用 npm 代理配置(因 lerna 调用 npm/yarn),或设置环境变量。

CPAN(Perl 模块安装)

# 使用环境变量
export HTTP_PROXY=http://127.0.0.1:7890
cpan install Module::Name

# 或配置 cpan(永久)
cpan
o conf http_proxy http://127.0.0.1:7890
o conf commit

Bundler(Ruby)

# 设置环境变量
export HTTP_PROXY=http://127.0.0.1:7890
bundle install

# 或通过 bundle config
bundle config set --global http.proxy http://127.0.0.1:7890

SBT(Scala)

编辑 ~/.sbt/1.0/proxy.sbt~/.sbt/0.13/proxy.sbt

sys.props += ("http.proxyHost" -> "127.0.0.1")
sys.props += ("http.proxyPort" -> "7890")
sys.props += ("https.proxyHost" -> "127.0.0.1")
sys.props += ("https.proxyPort" -> "7890")

或通过 JVM 参数:sbt -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890

Stack(Haskell)

设置环境变量(底层使用 Git 和 curl):

export HTTP_PROXY=http://127.0.0.1:7890
stack build

或在 ~/.stack/config.yaml 中:

http-proxy: http://127.0.0.1:7890
https-proxy: http://127.0.0.1:7890

Mix(Elixir)

设置环境变量(http_proxy 会被 mixhex 识别):

export HTTP_PROXY=http://127.0.0.1:7890
mix deps.get

Pub(Dart)

设置环境变量或通过 pubspec.yaml 配置(较少见),推荐环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
pub get

Julia

# 设置环境变量(在 Julia 中)
ENV["HTTP_PROXY"] = "http://127.0.0.1:7890"
using Pkg
Pkg.add("Example")

# 或永久写入 startup.jl(~/.julia/config/startup.jl)

R / renv

# 设置环境变量
Sys.setenv(http_proxy = "http://127.0.0.1:7890")
Sys.setenv(https_proxy = "http://127.0.0.1:7890")
install.packages("ggplot2")

# renv 配置
renv::settings$set(http_proxy("http://127.0.0.1:7890"))

Spring Boot(application.properties)

# 对于 RestTemplate / WebClient 等,需代码中设置代理
# 但 JVM 全局代理可通过启动参数:
# -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890

或在 application.properties 中添加(部分场景):

spring.cloud.gateway.httpclient.proxy.host=127.0.0.1
spring.cloud.gateway.httpclient.proxy.port=7890

Django(Python)

settings.py 中配置(用于 requests / urllib 等):

import os
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'

或通过中间件(全局代理)。

Kafka 生产者/消费者

通过 JVM 代理参数启动 Kafka 工具:

export KAFKA_OPTS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=7890"
kafka-console-producer --bootstrap-server localhost:9092 --topic test

RabbitMQ 客户端

依赖所使用的语言客户端,通常通过环境变量或配置。例如 Python pika:

import os
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
# 或使用 proxy 参数(部分客户端支持)

QEMU 虚拟机代理

通过 QEMU 的 -netdev 参数指定代理(不常见),更常用的是设置宿主机代理并让虚拟机通过 NAT 访问。若需强制虚拟机流量走代理,可配置 qemu 的用户模式网络:

qemu-system-x86_64 -netdev user,id=net0,net=10.0.2.0/24,hostfwd=tcp::2222-:22 -device e1000,netdev=net0

然后在虚拟机内部配置代理(同上文的 Linux 环境变量)。

VirtualBox 虚拟机代理

与 QEMU 类似,需在虚拟机内部配置代理。若需让虚拟机流量强制通过宿主机代理,可使用 NAT 网络 + 端口转发,或在 VirtualBox 中设置全局代理(不支持)。建议在客户机内设置。

Kubernetes Pod 代理注入

在 Pod 的 Deployment 或 Pod 模板中添加环境变量:

env:
- name: HTTP_PROXY
  value: "http://127.0.0.1:7890"
- name: HTTPS_PROXY
  value: "http://127.0.0.1:7890"
- name: NO_PROXY
  value: "localhost,127.0.0.1,.cluster.local"

对于需要代理访问集群外部服务的场景,也可通过配置 spec.containers[].env 注入。

Helm 图表代理(补充:下载 charts 时)

除了 helm --proxy,也可使用环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
helm repo add bitnami https://charts.bitnami.com/bitnami
helm pull bitnami/nginx

OpenShift 路由代理

OpenShift 的路由本身是反向代理,不需要额外配置。但若需在 build 或 deployment 中使用代理,可在 BuildConfigDeploymentConfig 中注入环境变量(同上 Kubernetes)。

PAC 文件配置(代理自动配置)

创建 proxy.pac 文件:

function FindProxyForURL(url, host) {
    return "PROXY 127.0.0.1:7890";
}

在系统或浏览器中指向该文件(file:///path/to/proxy.pac 或 http 服务)。

redsocks(透明代理)

将 TCP 流量重定向到 HTTP/SOCKS 代理。编辑 /etc/redsocks.conf

base {
    log_debug = off;
    log_info = on;
    daemon = on;
    redirector = iptables;
}

redsocks {
    local_ip = 127.0.0.1;
    local_port = 12345;
    ip = 127.0.0.1;
    port = 7890;
    type = http-connect;  # 或 socks5
}

配合 iptables 规则使用。

gost(多协议代理工具)

gost 本身可做代理客户端,配置本地代理转发:

# 启动一个本地 SOCKS5 代理,转发到 HTTP 代理
gost -L socks5://:1080 -F http://127.0.0.1:7890

或作为全局透明代理网关。

浏览器(补充:Chrome 代理扩展)

使用命令行启动 Chrome 时指定代理(已提),或安装 SwitchyOmega 扩展,配置 HTTP 代理 127.0.0.1:7890

微信开发者工具(Windows/Mac)

在工具的设置中找到“网络代理”,手动填写 127.0.0.1:7890

VS Code 远程开发(Remote-SSH)

Remote-SSH 依赖 SSH 代理配置(已在 SSH 部分说明),或使用 VS Code 的 settings.json

{
    "remote.SSH.remotePlatform": {
        "your-host": "linux"
    },
    "http.proxy": "http://127.0.0.1:7890"
}

Android 模拟器代理

启动模拟器时指定代理:

emulator -avd Nexus_5X_API_30 -http-proxy http://127.0.0.1:7890

或在模拟器的设置 → Wi-Fi → 修改网络 → 手动代理。

iOS 模拟器代理

通过系统代理(macOS 系统代理设置)即可,模拟器默认跟随系统。

Steam 客户端

在 Steam 设置 → 网络 → 代理服务器,填写 127.0.0.1:7890

Docker Compose(补充:服务代理)

docker-compose.yml 中对每个服务添加环境变量:

services:
  app:
    environment:
      - HTTP_PROXY=http://127.0.0.1:7890
      - HTTPS_PROXY=http://127.0.0.1:7890

CVS(Concurrent Versions System)

设置环境变量 CVS_RSH 或使用 cvs-e 参数,一般走 ssh,需配合 SSH 代理(已在 SSH 部分说明)。若需直接 HTTP 代理,可通过 cvspass 配合 http_proxy 环境变量(某些封装版本支持):

export HTTP_PROXY=http://127.0.0.1:7890
cvs -d :pserver:[email protected]:/cvsroot checkout module

GNU Make(源码下载)

Makefile 中常有 wgetcurl 命令,可在调用 make 时传递代理变量:

make http_proxy=http://127.0.0.1:7890

或在 Makefile 中添加:

export http_proxy := http://127.0.0.1:7890

Conan(C++ 包管理器)

# 设置
conan config set proxies.http=http://127.0.0.1:7890
conan config set proxies.https=http://127.0.0.1:7890

# 取消
conan config rm proxies.http
conan config rm proxies.https

或编辑 ~/.conan/conan.conf

proxies = 
    http: http://127.0.0.1:7890
    https: http://127.0.0.1:7890

vcpkg(Microsoft C++ 包管理器)

设置环境变量(vcpkg 调用 curlgit):

export HTTP_PROXY=http://127.0.0.1:7890
./vcpkg install boost

或永久配置:在 vcpkg/triplets 中修改,但不推荐。

Spack(HPC 包管理器)

编辑 ~/.spack/config.yamletc/spack/config.yaml

config:
  proxy: http://127.0.0.1:7890

或环境变量 http_proxy

Deno(JavaScript/TypeScript 运行时)

# 环境变量
export HTTP_PROXY=http://127.0.0.1:7890
deno run https://example.com/script.ts

# 或命令行参数
deno run --proxy=http://127.0.0.1:7890 https://example.com/script.ts

Bun(JavaScript/TypeScript 运行时)

Bun 复用环境变量 HTTP_PROXY / HTTPS_PROXY

export HTTP_PROXY=http://127.0.0.1:7890
bun install
bun run index.ts

Nim(Nimble 包管理器)

export HTTP_PROXY=http://127.0.0.1:7890
nimble install <package>

Zig(Build 系统)

Zig 获取依赖时走 http_proxy 环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
zig build

Dub(D 语言包管理器)

export HTTP_PROXY=http://127.0.0.1:7890
dub fetch <package>

或编辑 ~/.dub/settings.json

{
    "proxy": "http://127.0.0.1:7890"
}

Luarocks(Lua 包管理器)

export HTTP_PROXY=http://127.0.0.1:7890
luarocks install luasocket

阿里云 CLI(aliyun)

# 配置代理
aliyun configure set --profile default --mode AK --region cn-hangzhou --proxy "http://127.0.0.1:7890"

# 或环境变量
export HTTP_PROXY=http://127.0.0.1:7890
aliyun ecs DescribeInstances

腾讯云 CLI(tccli)

tccli configure set proxy.http http://127.0.0.1:7890
tccli configure set proxy.https http://127.0.0.1:7890

华为云 CLI(hcloud)

export HTTP_PROXY=http://127.0.0.1:7890
hcloud ecs list

IBM Cloud CLI(ibmcloud)

ibmcloud config --http-proxy http://127.0.0.1:7890
ibmcloud config --https-proxy http://127.0.0.1:7890

Oracle Cloud CLI(oci)

oci setup oci-cli-rc --proxy-host 127.0.0.1 --proxy-port 7890
# 或环境变量
export HTTP_PROXY=http://127.0.0.1:7890
oci os object list

百度云 CLI(bce)

bce config --proxy http://127.0.0.1:7890

七牛云 CLI(qshell)

export HTTP_PROXY=http://127.0.0.1:7890
qshell account <AccessKey> <SecretKey> <Name>

GitHub CLI(gh)

gh 默认使用系统代理,也可通过环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
gh repo clone user/repo

或配置 ~/.config/gh/config.yml

proxy: http://127.0.0.1:7890

Bitbucket CLI(bb)

export HTTP_PROXY=http://127.0.0.1:7890
bb --version

Leiningen(Clojure)

编辑 ~/.lein/profiles.clj

{:user {:http-proxy "http://127.0.0.1:7890"
        :https-proxy "http://127.0.0.1:7890"}}

或环境变量 HTTP_PROXY

Boot(Clojure)

export HTTP_PROXY=http://127.0.0.1:7890
boot watch

Jenkins CLI

启动 Jenkins 客户端时传递 JVM 参数:

java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890 -jar jenkins-cli.jar -s http://jenkins:8080 help

GitLab Runner

编辑 /etc/gitlab-runner/config.toml

[[runners]]
  environment = ["HTTP_PROXY=http://127.0.0.1:7890", "HTTPS_PROXY=http://127.0.0.1:7890"]

GitHub Actions Self-Hosted Runner

在 runner 目录的 .env 文件中添加:

HTTP_PROXY=http://127.0.0.1:7890
HTTPS_PROXY=http://127.0.0.1:7890

Drone CI Runner

在 drone runner 的配置中设置环境变量:

environment:
  HTTP_PROXY: http://127.0.0.1:7890

TeamCity Agent

在 agent 的 buildAgent.properties 中添加:

env.HTTP_PROXY=http://127.0.0.1:7890
env.HTTPS_PROXY=http://127.0.0.1:7890

CircleCI CLI

export HTTP_PROXY=http://127.0.0.1:7890
circleci config validate

Netlify CLI

export HTTP_PROXY=http://127.0.0.1:7890
netlify deploy

Vercel CLI

export HTTP_PROXY=http://127.0.0.1:7890
vercel --prod

Heroku CLI

heroku config:set HTTP_PROXY=http://127.0.0.1:7890 --app your-app
# 或环境变量
export HTTP_PROXY=http://127.0.0.1:7890
heroku logs --tail

OpenFaaS CLI(faas-cli)

export HTTP_PROXY=http://127.0.0.1:7890
faas-cli deploy

Knative CLI(kn)

export HTTP_PROXY=http://127.0.0.1:7890
kn service create ...

Istio CLI(istioctl)

export HTTP_PROXY=http://127.0.0.1:7890
istioctl install

Linkerd CLI(linkerd)

export HTTP_PROXY=http://127.0.0.1:7890
linkerd check

Teleport CLI(tsh)

export HTTP_PROXY=http://127.0.0.1:7890
tsh login --proxy=teleport.example.com

Vault CLI(vault)

export HTTP_PROXY=http://127.0.0.1:7890
vault secrets list

Consul CLI(consul)

export HTTP_PROXY=http://127.0.0.1:7890
consul members

Nomad CLI(nomad)

export HTTP_PROXY=http://127.0.0.1:7890
nomad job status

Packer

在 Packer 配置文件中使用环境变量,或在 ~/.packerconfig 中:

{
  "proxy": "http://127.0.0.1:7890"
}

Sublime Text 命令行工具(subl)

subl 本身不联网,但若安装 Package Control 等需网络访问的插件,可通过环境变量:

export HTTP_PROXY=http://127.0.0.1:7890
subl .

Emacs(包管理器)

~/.emacs.d/init.el 中:

(setq url-proxy-services
      '(("http" . "127.0.0.1:7890")
        ("https" . "127.0.0.1:7890")))

Vim(插件管理器 vim-plug)

let g:plug_url_http_proxy = 'http://127.0.0.1:7890'

或设置环境变量。

Neovim(Lazy.nvim)

vim.g.lazy_proxy = "http://127.0.0.1:7890"

tmux(终端复用器)

tmux 本身不发起网络请求,但可以在 tmux 会话中设置环境变量:

tmux set-environment -g HTTP_PROXY http://127.0.0.1:7890

screen

类似 tmux,在 screen 中设置环境变量:

screen -X setenv HTTP_PROXY http://127.0.0.1:7890

irssi(IRC 客户端)

/set proxy_address 127.0.0.1
/set proxy_port 7890
/set proxy_type HTTP

WeeChat

/proxy add http http 127.0.0.1 7890
/set irc.server_default.proxy "http"

Mutt(邮件客户端)

编辑 ~/.muttrc

set http_proxy = "http://127.0.0.1:7890"
set use_http_proxy = yes

w3m(文本浏览器)

w3m -o http_proxy=http://127.0.0.1:7890 https://example.com

Lynx

lynx -cfg=~/.lynx.cfg
# 在 ~/.lynx.cfg 中添加
HTTP_PROXY:http://127.0.0.1:7890
elinks -http-proxy 127.0.0.1:7890 https://example.com

apt-cacher-ng(APT 代理缓存服务器)

配置上游代理:编辑 /etc/apt-cacher-ng/acng.conf

UpstreamProxy: http://127.0.0.1:7890

squid(反向代理/缓存)

squid 作为客户端时,可配置上层代理:编辑 /etc/squid/squid.conf

cache_peer 127.0.0.1 parent 7890 0 no-query default

nginx(作为代理转发)

nginx.conflocationserver 块中配置 proxy_pass 时,nginx 本身可设置代理请求到上游代理:

location / {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    # 如果需要走上级代理,可使用 ngx_http_proxy_connect_module 等扩展
}

更常见的做法是让 nginx 通过环境变量使用系统代理(不支持原生)。

sshuttle(VPN over SSH)

sshuttle 本身可通过 --proxy 参数使用 HTTP 代理连接 SSH 服务器:

sshuttle --dns -r user@server --proxy 127.0.0.1:7890 0/0

rclone(云存储同步)

# 环境变量
export HTTP_PROXY=http://127.0.0.1:7890
rclone ls remote:

# 或配置文件中添加
[http]
proxy = "http://127.0.0.1:7890"

restic(备份工具)

export HTTP_PROXY=http://127.0.0.1:7890
restic -r s3:s3.amazonaws.com/bucket backup /path

BorgBackup

export HTTP_PROXY=http://127.0.0.1:7890
borg create --remote-path borg user@host:repo::archive /path

duplicity

export HTTP_PROXY=http://127.0.0.1:7890
duplicity --progress /home scp://user@host/path

GnuPG(keyserver 代理)

编辑 ~/.gnupg/dirmngr.conf

http-proxy http://127.0.0.1:7890

MySQL Workbench 命令行

Workbench 命令行工具(mysql 客户端)可使用 proxychains

proxychains4 mysql -h db.example.com -u root -p

mongosh(MongoDB Shell)

export HTTP_PROXY=http://127.0.0.1:7890
mongosh "mongodb://localhost:27017"

Elasticsearch 客户端 curl

利用 curl--proxy 参数包装:

curl -x http://127.0.0.1:7890 -X GET "http://localhost:9200/_cat/indices"

logstash

logstash.yml 中配置:

http.proxy: http://127.0.0.1:7890

fluentd

export HTTP_PROXY=http://127.0.0.1:7890
fluentd -c config.conf

Vector(日志收集)

vector.tomlsinkssources 中可配置代理,或使用环境变量。

InfluxDB CLI(influx)

export HTTP_PROXY=http://127.0.0.1:7890
influx query 'from(bucket:"example") |> range(start:-1h)'

etcdctl

export HTTP_PROXY=http://127.0.0.1:7890
etcdctl get /key

MinIO Client(mc)

export HTTP_PROXY=http://127.0.0.1:7890
mc ls myminio

gsutil(Google Cloud Storage)

编辑 ~/.boto

[Boto]
proxy = 127.0.0.1
proxy_port = 7890

Azure Storage Explorer CLI(azcopy)

export HTTP_PROXY=http://127.0.0.1:7890
azcopy copy 'https://source.blob.core.windows.net/container/file' '/local/path'

k3s / k8s 集群内应用代理

通过注入环境变量方式(已在 k8s 部分说明),也可通过 Cluster 级别的 Proxy 配置。

NixOS / nix 包管理器

# 设置
nix config set http-proxy http://127.0.0.1:7890
# 或环境变量
export HTTP_PROXY=http://127.0.0.1:7890
nix-shell -p hello

Guix

export HTTP_PROXY=http://127.0.0.1:7890
guix pull

Chromium OS 开发者模式代理

~/.bashrc 中设置环境变量,通过 crosh shell 生效。

Termux(Android 终端)

~/.bashrc 中设置:

export http_proxy=http://127.0.0.1:7890
pkg update

iSH(iOS Alpine Linux)

类似 Termux,设置环境变量。

systemd --user 代理

~/.config/environment.d/proxy.conf 中添加:

HTTP_PROXY=http://127.0.0.1:7890
HTTPS_PROXY=http://127.0.0.1:7890

Cron 任务代理

在 crontab 文件顶部添加:

HTTP_PROXY=http://127.0.0.1:7890
HTTPS_PROXY=http://127.0.0.1:7890
* * * * * /path/to/script

总结

以上涵盖了绝大多数常用工具的代理配置方法。对于支持环境变量的工具,建议统一在 shell 配置文件中设置 http_proxy 等变量,避免重复配置。
若您的代理为 SOCKS5 类型,只需将 http://127.0.0.1:7890 替换为 socks5://127.0.0.1:7890 即可(部分工具可能需要额外支持)。