
Configuring a system-wide proxy on Ubuntu is essential when your network requires all internet traffic to pass through a specific server. This ensures consistent access and adherence to network policies across all applications running on your system. Properly setting up a system-wide proxy can be done through multiple methods, allowing you to choose the approach that best suits your needs, whether it’s a simple graphical interface setting or more advanced command-line configuration.
One common method involves using the Graphical User Interface (GUI). Navigate to your system’s settings, typically found in the system menu. Look for the “Network” or “Network Proxy” section. Here, you can select manual proxy configuration and enter the details for your HTTP, HTTPS, and FTP proxies, including the server address and port number. You can also specify hosts that should be accessed directly, bypassing the proxy.
For command-line users or for ensuring settings persist across various environments, configuring environment variables is a powerful technique. By editing files like /etc/environment or creating scripts in /etc/profile.d/, you can set http_proxy
, https_proxy
, ftp_proxy
, and no_proxy
variables. These variables are read by many command-line tools and applications, applying the proxy settings system-wide. Remember to use the format protocol_proxy="http://[username:password@]proxy_server_address:port/"
including optional authentication details. After editing these files, a system restart or logging out and back in is usually required for the changes to take effect.
Setting the proxy specifically for package management is also crucial if you use tools like apt behind a proxy. This is typically done by creating or editing a configuration file in the /etc/apt/apt.conf.d/ directory, for example, 70proxy
. Inside this file, you can specify Acquire::http::Proxy
, Acquire::https::Proxy
, and Acquire::ftp::Proxy
directives with your proxy server details. This ensures that apt
can download packages and updates correctly.
When setting up proxy configurations, especially using environment variables, it’s important to define non-proxy hosts. This is done using the no_proxy
variable, listing domain names or IP addresses that should be reached directly. Separate multiple entries with commas. For example, no_proxy="localhost,127.0.0.1,.local,internal-server.mydomain.com"
.
After configuring the proxy, always verify that it’s working correctly. You can test using command-line tools like curl
or wget
, or simply by browsing the web to see if pages load as expected. If you encounter issues, double-check the server address, port, authentication details, and ensure there are no conflicts between GUI settings and environment variables. A comprehensive approach ensures all network traffic from your system utilizes the defined proxy server, providing seamless and policy-compliant internet access.
Source: https://kifarunix.com/how-to-set-system-wide-proxy-in-ubuntu-18-04/