Setting Up a Proxy on Linux
Linux offers multiple ways to configure proxies — from system-wide environment variables to application-specific settings.
Environment Variables
The most common approach is setting environment variables. Most command-line tools and many applications respect these:
export http_proxy=http://username:password@proxy-host:port
export https_proxy=http://username:password@proxy-host:port
export no_proxy=localhost,127.0.0.1
For SOCKS5 proxies:
export ALL_PROXY=socks5://username:password@proxy-host:port
To make these settings persistent, add them to your shell config (~/.bashrc, ~/.zshrc, or ~/.profile):
echo 'export http_proxy=http://username:password@proxy-host:port' >> ~/.bashrc
echo 'export https_proxy=http://username:password@proxy-host:port' >> ~/.bashrc
source ~/.bashrc
System-Wide Configuration
For system-wide proxy settings (affects all users), edit /etc/environment:
http_proxy=http://username:password@proxy-host:port
https_proxy=http://username:password@proxy-host:port
no_proxy=localhost,127.0.0.1
GNOME Desktop
If you're using GNOME (Ubuntu, Fedora, etc.):
- Open Settings → Network → Network Proxy.
- Select Manual.
- Enter the proxy host and port for HTTP, HTTPS, or SOCKS.
- Close the settings — changes apply immediately.
APT Package Manager (Debian/Ubuntu)
To route APT through a proxy, create or edit /etc/apt/apt.conf.d/proxy.conf:
Acquire::http::Proxy "http://username:password@proxy-host:port";
Acquire::https::Proxy "http://username:password@proxy-host:port";
Verifying the Proxy
Test that your proxy is working:
curl -x http://username:password@proxy-host:port https://api.ipify.org
This should return the proxy's IP address instead of your own.
Tips
- Use
no_proxyto exclude local addresses and internal services from going through the proxy. - For Docker containers, configure proxy settings in
~/.docker/config.jsonor pass them as environment variables in yourdocker runcommand. - Many development tools (npm, pip, git) have their own proxy configuration — check their documentation if environment variables don't work.