ProxyZen

Proxy in Linux, Docker and proxychains: a practical guide

28 November 2026 · 2 min read

How to use an HTTP or SOCKS5 proxy with login and password in Linux: environment variables, curl, apt, proxychains4, the Docker daemon and containers. With ready-to-copy configs.

On a server or a Linux desktop a proxy is set not in one place but per tool: the shell, curl, the package manager, Docker. Below are working configs for each — replace HOST, PORT, LOGIN and PASSWORD with the data from My proxies.

Environment variables (most programs)

Most command-line tools — curl, wget, pip, git — read the http_proxy and https_proxy variables:

export http_proxy="http://LOGIN:PASSWORD@HOST:PORT"
export https_proxy="$http_proxy"
export no_proxy="localhost,127.0.0.1"

Add these lines to ~/.bashrc to keep them after a reboot. If the password contains special characters like @ or #, URL-encode them.

curl

Check the exit IP with the -x option. socks5h means DNS is also resolved through the proxy, so there is no DNS leak:

curl -x http://LOGIN:PASSWORD@HOST:PORT https://api.ipify.org
curl -x socks5h://LOGIN:PASSWORD@HOST:PORT https://api.ipify.org

You should see the proxy IP, not the server’s.

apt (Debian, Ubuntu)

apt ignores shell variables when run with sudo, so set the proxy in its own config:

# /etc/apt/apt.conf.d/95proxy
Acquire::http::Proxy "http://LOGIN:PASSWORD@HOST:PORT";
Acquire::https::Proxy "http://LOGIN:PASSWORD@HOST:PORT";

proxychains4: any program through SOCKS5

proxychains forces any program — even one without proxy support — through a proxy chain. Install it and add your proxy to the end of the config:

sudo apt install proxychains4
# /etc/proxychains4.conf — [ProxyList]
socks5 HOST PORT LOGIN PASSWORD

proxychains4 curl https://api.ipify.org

Run any command with the proxychains4 prefix. For a chain of several proxies add more lines; strict_chain uses them in order.

Docker

The Docker daemon (pulling images) and containers need separate settings. For the daemon create a systemd drop-in:

# /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://LOGIN:PASSWORD@HOST:PORT"
Environment="HTTPS_PROXY=http://LOGIN:PASSWORD@HOST:PORT"
Environment="NO_PROXY=localhost,127.0.0.1"

sudo systemctl daemon-reload && sudo systemctl restart docker

For containers, Docker passes these variables automatically if you add them to the client config:

# ~/.docker/config.json
{
  "proxies": {
    "default": {
      "httpProxy": "http://LOGIN:PASSWORD@HOST:PORT",
      "httpsProxy": "http://LOGIN:PASSWORD@HOST:PORT",
      "noProxy": "localhost,127.0.0.1"
    }
  }
}

Tips

  • Use private IPv4 for servers that need a stable IP and unlimited traffic, residential with rotation for scraping.
  • For residential and mobile proxies use host ip.proxyzen.net, port 8080 (HTTP) or 1080 (SOCKS5); country and session go into the login.
  • Check the result with our proxy checker and see also proxies in Python and Node.js.

Proxies for Linux servers and Docker with HTTP and SOCKS5 — see prices.

Try ProxyZen

Private IPv4 and IPv6 for 3 to 90 days, residential and mobile per GB. Instant delivery, HTTP(S) and SOCKS5.

Trustpilot Write a review