Configuring a global proxy in Ubuntu allows all your system applications, including apt
, wget
, and curl
, to route their traffic through a specified proxy server. This setup eliminates the need for individual proxy configurations across different applications, ensuring consistent network settings and simplifying administrative tasks.
Environment variables are central to setting system-wide proxy configurations that apply to all users and applications.
/etc/environment
Filesudo nano /etc/environment
Insert the following lines, replacing username
, password
, proxy_address
, and proxy_port
with your proxy details.
http_proxy="http://username:password@proxy_address:proxy_port/"
https_proxy="https://username:password@proxy_address:proxy_port/"
ftp_proxy="ftp://username:password@proxy_address:proxy_port/"
no_proxy="localhost,127.0.0.1,::1"
HTTP_PROXY="http://username:password@proxy_address:proxy_port/"
HTTPS_PROXY="http://username:password@proxy_address:proxy_port/"
FTP_PROXY="http://username:password@proxy_address:proxy_port/"
NO_PROXY="localhost,127.0.0.1,::1"
Note: Including both lowercase and uppercase variables ensures compatibility with different applications.
Ctrl+O
to save and Ctrl+X
to exit the editor.
source /etc/environment
Alternatively, you can log out and log back in or reboot your system to apply the changes.
The Advanced Package Tool (APT) doesn't automatically inherit the environment proxy settings. You need to configure it separately to ensure package management operations use the proxy.
sudo nano /etc/apt/apt.conf.d/95proxies
Acquire::http::Proxy "http://username:password@proxy_address:proxy_port/";
Acquire::https::Proxy "https://username:password@proxy_address:proxy_port/";
Acquire::ftp::Proxy "ftp://username:password@proxy_address:proxy_port/";
Ctrl+O
to save and Ctrl+X
to exit.
Systemd services require explicit proxy configurations to adhere to the global proxy settings.
sudo nano /etc/systemd/system.conf
Under the [Manager]
section, add:
DefaultEnvironment="HTTP_PROXY=http://username:password@proxy_address:proxy_port/" "HTTPS_PROXY=http://username:password@proxy_address:proxy_port/" "NO_PROXY=localhost,127.0.0.1,::1"
Ctrl+O
to save and Ctrl+X
to exit.
sudo systemctl daemon-reload
sudo reboot
~/.wgetrc
File:
sudo nano ~/.wgetrc
http_proxy = http://username:password@proxy_address:proxy_port/
https_proxy = http://username:password@proxy_address:proxy_port/
ftp_proxy = http://username:password@proxy_address:proxy_port/
Ctrl+O
to save and Ctrl+X
to exit.
nano ~/.bashrc
export http_proxy="http://username:password@proxy_address:proxy_port/"
export https_proxy="https://username:password@proxy_address:proxy_port/"
export ftp_proxy="ftp://username:password@proxy_address:proxy_port/"
export no_proxy="localhost,127.0.0.1,::1"
Ctrl+O
to save and Ctrl+X
to exit.
source ~/.bashrc
For desktop environments, configuring the proxy through the GUI ensures that applications relying on GNOME settings use the proxy.
Navigate to Settings > Network > Network Proxy.
Ensuring that proxy configurations persist across system reboots and user sessions is crucial for consistent network behavior.
sudo nano /etc/profile.d/proxy.sh
export http_proxy="http://username:password@proxy_address:proxy_port/"
export https_proxy="https://username:password@proxy_address:proxy_port/"
export ftp_proxy="ftp://username:password@proxy_address:proxy_port/"
export no_proxy="localhost,127.0.0.1,::1"
sudo chmod +x /etc/profile.d/proxy.sh
source /etc/profile.d/proxy.sh
Verifying that the proxy settings are correctly applied ensures that all applications route their traffic through the proxy.
curl -I http://example.com
wget http://example.com
sudo apt update
Successful execution of these commands without proxy-related errors indicates a correctly configured global proxy.
Verify Proxy Reachability: Ensure that the proxy server is accessible from your machine.
Check for Typographical Errors: Even minor mistakes in configuration files can prevent the proxy from functioning correctly.
Confirm Environment Variables: Use the env | grep -i proxy
command to verify that proxy variables are set correctly.
Review File Permissions: Ensure that the proxy script files are executable and owned by the correct user.
Inspect Application-Specific Settings: Some applications might have their own proxy settings that override system configurations.
Configuring a global proxy in Ubuntu involves setting environment variables, configuring APT and systemd, and ensuring GUI applications adhere to the proxy settings. By following the steps outlined above, you can ensure a unified proxy configuration across all applications, simplifying network management and enhancing security.