Linux Proxy Configuration Complete Cheat Sheet (apt, yum, dnf, npm, wget, curl, git, k8s/containerd, OS Environment Variables)

When building a Linux environment behind a proxy, proxy configuration methods vary by tool, which often wastes time on troubleshooting every time. To solve this, I have compiled a cheat sheet covering the proxy configuration methods (with authentication) for the 10 most frequently used tools in Linux environments.

目次

Eliminating Proxy Configuration Hesitation

The main objective of this article is to centralize proxy configuration methods for major applications in Linux environments, preventing wasted time caused by misconfigurations or syntax errors. By focusing particularly on tools that frequently appear in development workflows, we provide a reference that allows you to complete configuration tasks without hesitation. This creates an environment where developers can focus on their core responsibilities—design and implementation—rather than infrastructure settings.

Communications for 10 Major Tools

This covers communication settings for a total of 10 major tools, ranging from system-wide OS environment variables, package managers (apt/apt-get, yum, dnf, npm), download tools (wget, curl), version control (git), to container orchestration (Kubernetes/containerd).

Main Factors Complicating Proxy Configuration

Proxy configuration is typically complicated by the following two factors.
First, configuration files are split between those applied system-wide (under /etc) and those applied per-user (under the home directory), and their formats differ (case sensitivity, presence or absence of equals signs, etc.).
Second, in authenticated proxies, if the password contains special characters such as “@" or “:", it causes URL parsing errors. These must be escaped using percent-encoding (e.g., converting @ to %40).

Linux Proxy Configuration Cheat Sheet

This quick reference guide assumes an authenticated proxy (e.g., [http://user:pass@proxy.example.com:8080/](http://user:pass@proxy.example.com:8080/)). These configuration details are basically common and applicable across Ubuntu LTS versions 22.04, 24.04, and 26.04. Notes on differences across Ubuntu LTS versions.

OS Environment Variables

Basic environment variables applied system-wide.
Target file: /etc/environment

http_proxy="http://user:pass@proxy.example.com:8080/"
https_proxy="http://user:pass@proxy.example.com:8080/"
no_proxy="localhost,127.0.0.1,.example.com"

apt / apt-get

Configuration for Debian-based package managers such as Ubuntu.
Target file: /etc/apt/apt.conf.d/proxy.conf

Acquire::http::Proxy "http://user:pass@proxy.example.com:8080/";
Acquire::https::Proxy "http://user:pass@proxy.example.com:8080/";

yum / dnf

Configuration for package managers used in Red Hat-based OSs.
Target file: /etc/yum.conf or /etc/dnf/dnf.conf

proxy=http://proxy.example.com:8080/
proxy_username=user
proxy_password=pass

npm

Configuration for Node.js package manager. Executed via command and saved to ~/.npmrc.
Command execution:

npm config set proxy http://user:pass@proxy.example.com:8080/
npm config set https-proxy http://user:pass@proxy.example.com:8080/

wget

Configuration for the file download tool.
Target file: ~/.wgetrc or /etc/wgetrc

use_proxy=on
http_proxy=http://user:pass@proxy.example.com:8080/
https_proxy=http://user:pass@proxy.example.com:8080/

curl

Configuration for the tool used for API communication and file retrieval.
Target file: ~/.curlrc

proxy="http://user:pass@proxy.example.com:8080/"

git

Configuration for the version control tool. Applied globally.
Command execution:

git config --global http.proxy http://user:pass@proxy.example.com:8080/
git config --global https.proxy http://user:pass@proxy.example.com:8080/

k8s (containerd)

Configuration for container runtimes used in Kubernetes, etc. Specified via Systemd.
Target file: /etc/systemd/system/containerd.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://user:pass@proxy.example.com:8080/"
Environment="HTTPS_PROXY=http://user:pass@proxy.example.com:8080/"
Environment="NO_PROXY=localhost,127.0.0.1,10.0.0.0/8"

After configuration, run the following commands to apply the changes.

systemctl daemon-reload
systemctl restart containerd

Notes on Differences Across Ubuntu LTS Versions

From Ubuntu 22.04 up to the latest 26.04, the basic syntax for proxy configuration across the aforementioned tools remains unchanged. However, note that the OS default network management tool has completely transitioned to Netplan, and the standard runtime in Kubernetes environments has completely shifted from Docker to containerd. Therefore, when troubleshooting container communication issues, you should prioritize checking the containerd proxy configuration via Systemd rather than OS environment variables.

Verifying External Communication Connectivity

After completing the configuration for each tool, verify whether communication is successful.
For example, when using curl, run curl -I [https://google.com](https://google.com) and verify that the HTTP status code “200 OK" is returned. For apt, run apt update; if repository information is successfully retrieved, the configuration has been correctly applied. For container environments, test image retrieval with crictl pull docker.io/library/alpine or similar.

Conclusion

To prevent communication blocks caused by corporate proxies and to smoothly proceed with development environment setup, we have centralized the communication settings for the 10 major tools. The main challenges are the scattering of configuration files across tools and parsing errors caused by special characters in authentication information. To address this, we organized the precise configuration syntax ranging from OS environment variables to apt, npm, k8s, etc., into a cheat sheet. As a result, this eliminates guesswork in configuration tasks and enables the immediate establishment of stable communication with external networks.