Skip to main content
EN

Home / Blog / Deployment

Developer proxy cheat sheet — Git, npm, pip, Go, Maven and SSH

Deployment2026-06-101322 words3 min read
Developer proxy cheat sheet — Git, npm, pip, Go, Maven and SSH

Command-line tools do not read the system proxy. This collects the configuration for the common ones in one place, to take what you need.

Assuming your mixed port is 7897 (check it in Clash Verge's port settings; defaults vary by version).

Try environment variables first — they cover more than half

Most tools that follow Unix convention respect these:

# macOS / Linux / WSL
export http_proxy=http://127.0.0.1:7897
export https_proxy=http://127.0.0.1:7897
export all_proxy=socks5://127.0.0.1:7897
export no_proxy="localhost,127.0.0.1,::1,*.local,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
# Windows PowerShell (current session)
$env:HTTP_PROXY  = "http://127.0.0.1:7897"
$env:HTTPS_PROXY = "http://127.0.0.1:7897"
$env:NO_PROXY    = "localhost,127.0.0.1,::1,*.local"
:: Windows CMD
set HTTP_PROXY=http://127.0.0.1:7897
set HTTPS_PROXY=http://127.0.0.1:7897

Make it a pair of shell functions:

# ~/.zshrc or ~/.bashrc
proxyon() {
  export http_proxy=http://127.0.0.1:7897
  export https_proxy=$http_proxy
  export all_proxy=socks5://127.0.0.1:7897
  export no_proxy="localhost,127.0.0.1,::1,*.local"
  echo "✓ proxy on"
}
proxyoff() {
  unset http_proxy https_proxy all_proxy no_proxy
  echo "✗ proxy off"
}

Git

Git has its own configuration system. Environment variables work for HTTPS but not for SSH.

# HTTPS
git config --global http.proxy http://127.0.0.1:7897
git config --global https.proxy http://127.0.0.1:7897

# undo
git config --global --unset http.proxy
git config --global --unset https.proxy

# inspect
git config --global --get-regexp proxy

Proxy one host only (recommended, so your corporate Git server does not also go through it):

git config --global http.https://github.com.proxy http://127.0.0.1:7897

Git over SSH ([email protected]:xxx.git) ignores http.proxy and needs SSH configuration:

# ~/.ssh/config
Host github.com
  HostName github.com
  User git
  Port 22
  # macOS / Linux
  ProxyCommand nc -X connect -x 127.0.0.1:7897 %h %p
  # Windows (Git Bash ships connect.exe)
  # ProxyCommand connect -H 127.0.0.1:7897 %h %p

npm / yarn / pnpm

# npm
npm config set proxy http://127.0.0.1:7897
npm config set https-proxy http://127.0.0.1:7897
npm config delete proxy && npm config delete https-proxy   # undo

# yarn (v1)
yarn config set proxy http://127.0.0.1:7897
yarn config set https-proxy http://127.0.0.1:7897

# pnpm
pnpm config set proxy http://127.0.0.1:7897
pnpm config set https-proxy http://127.0.0.1:7897

The settings live in ~/.npmrc and can be edited directly:

proxy=http://127.0.0.1:7897
https-proxy=http://127.0.0.1:7897
noproxy=localhost,127.0.0.1,.company.com

Python / pip

# one-off
pip install --proxy http://127.0.0.1:7897 requests

# permanent
pip config set global.proxy http://127.0.0.1:7897
pip config unset global.proxy

Config file locations:

  • Windows: %APPDATA%\pip\pip.ini
  • macOS/Linux: ~/.config/pip/pip.conf
[global]
proxy = http://127.0.0.1:7897
index-url = https://pypi.org/simple

The requests library reads the environment variables too, and can be told explicitly in code:

proxies = {
    "http": "http://127.0.0.1:7897",
    "https": "http://127.0.0.1:7897",
}
requests.get(url, proxies=proxies)

Go

# Go modules through the official proxy (usually enough, no local proxy needed)
go env -w GOPROXY=https://proxy.golang.org,direct

# a regional mirror
go env -w GOPROXY=https://goproxy.cn,direct

# keep private repositories off the proxy
go env -w GOPRIVATE=*.company.com,github.com/myorg/*

# when you do need the local proxy (pulling a private GitHub repo, say)
go env -w GOPROXY=direct
export HTTPS_PROXY=http://127.0.0.1:7897

go get respects the HTTP_PROXY and HTTPS_PROXY environment variables.

Java / Maven / Gradle

Maven (~/.m2/settings.xml):

<settings>
  <proxies>
    <proxy>
      <id>clash</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>127.0.0.1</host>
      <port>7897</port>
      <nonProxyHosts>localhost|127.0.0.1|*.company.com</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

Gradle (~/.gradle/gradle.properties):

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7897
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7897
systemProp.http.nonProxyHosts=localhost|127.0.0.1|*.company.com

JVM command-line flags:

java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7897 \
     -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=7897 \
     -Dhttp.nonProxyHosts="localhost|127.0.0.1" -jar app.jar

Rust / Cargo

~/.cargo/config.toml:

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

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

curl / wget

# curl, one-off
curl -x http://127.0.0.1:7897 https://example.com
curl --socks5 127.0.0.1:7897 https://example.com

# curl, permanent (~/.curlrc)
echo 'proxy = "http://127.0.0.1:7897"' >> ~/.curlrc

# wget, permanent (~/.wgetrc)
cat >> ~/.wgetrc <<'EOF'
use_proxy = on
http_proxy = http://127.0.0.1:7897
https_proxy = http://127.0.0.1:7897
EOF

System package managers

# apt (/etc/apt/apt.conf.d/95proxy)
echo 'Acquire::http::Proxy "http://127.0.0.1:7897";' | sudo tee /etc/apt/apt.conf.d/95proxy
echo 'Acquire::https::Proxy "http://127.0.0.1:7897";' | sudo tee -a /etc/apt/apt.conf.d/95proxy

# dnf/yum (add to /etc/dnf/dnf.conf)
# proxy=http://127.0.0.1:7897

# Homebrew (macOS) — reads the environment
export ALL_PROXY=socks5://127.0.0.1:7897
brew install xxx

A quick reference table

ToolHow to configureReads env vars
curl / wget-x flag or .curlrc
Git (HTTPS)git config http.proxy
Git (SSH)ProxyCommand in ~/.ssh/config
npm / yarn / pnpm.npmrc⚠️ Some versions
pippip.conf
GoEnv vars plus GOPROXY
Mavensettings.xml
Gradlegradle.properties
Cargo.cargo/config.toml
Docker daemonsystemd drop-in
apt / dnfTheir own config files⚠️ Lost under sudo
HomebrewEnvironment variables

Why environment variables sometimes do nothing

Common causesThe tool has its own configuration system (Maven, Gradle, the Docker daemon) — a config file is requiredYou used sudo and the environment was not passed through — add -EThe variables only apply to the current shell — a new terminal does not have themA case problem — some tools read only lowercase http_proxyThe tool is using SSH rather than HTTP — that needs ProxyCommandno_proxy is too broad and has excluded the target domain

The easier route: enable TUN

All of the above adds up, and every new tool you install may need doing again.

With TUN mode on, every command-line tool is proxied automatically and none of them needs configuring.

The cost is virtual adapter privileges, plus remembering to add private ranges to your direct rules:

prepend-rules:
  - IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
  - IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
  - IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
  - DOMAIN-SUFFIX,company.com,DIRECT
The trade-off between the two approachesConfigure each toolprecise and contno extra privileges neededtedious once you have many toolssuits serversTUN modeset once, every needs virtual adapter privilegescan conflict with containers or a VPNsuits a development machine

Verifying

# what exit IP am I using
curl https://api.ipify.org

# is Git going through the proxy (-v prints connection details)
GIT_CURL_VERBOSE=1 git ls-remote https://github.com/git/git 2>&1 | head -20

# npm settings
npm config list | grep -i proxy

You can also open the connections page in Clash Verge and watch for new entries while running a command — one appearing means the traffic came through.

In short

  • Try environment variables first; they cover curl, pip, Go, Cargo, Homebrew and plenty more
  • Git, npm, Maven, Gradle and Docker have their own configuration systems and must be done separately
  • SSH needs ProxyCommand, or switch to port 443
  • no_proxy is mandatory, or local and internal services all break
  • Remember -E with sudo
  • If it is all too much, enable TUN — but set up your private-range direct rules

Related: Docker and WSL2 proxying and process rules explained.


Related docs

Getting Docker and WSL2 onto the host's Clash proxy
Deployment Getting Docker and WSL2 onto the host's Clash proxy

127.0.0.1 inside a container is not the host. Configuration for all three Docker scenarios — daemon pulls, build time and run time — plus two approaches for WSL2's different networking modes.

2026-06-141330 words3 min read