How to Configure Proxy Settings on Ubuntu 18.04

Network Proxy dialog in Ubuntu

Are you looking for ways to enhance your privacy and security online? Setting up a proxy on your Ubuntu system allows you to browse anonymously and access blocked or restricted content.

In this comprehensive 3000+ word guide, you‘ll learn several methods for configuring proxy settings on Ubuntu 18.04. I‘ll provide detailed, step-by-step instructions for proxy setup through the GUI, terminal, and system-wide.

Let‘s start by examining the benefits of using proxies.

Why Use a Proxy?

Proxies act as an intermediary layer between your device and the wider internet. When you connect through a proxy, websites see the proxy‘s IP address instead of your own. This hides your identity and masks your geographic location.

According to research by Pew, 79% of internet users have taken steps to avoid surveillance by using privacy-enhancing technologies like proxies and VPNs.

Proxies are popular for several key reasons:

Enhanced Privacy and Anonymity

Your browsing data passes through an encrypted tunnel, preventing snooping by ISPs, network admins, and government agencies. This allows you to keep your online activity private.

Bypass Geographic Restrictions

Many sites restrict content based on location. Proxies let you access geo-blocked websites and services by masking where you‘re connecting from.

Evade Censorship

Authoritarian regimes actively censor and block sites containing prohibited content. Proxies allow citizens to bypass state censorship.

Access Restricted Networks

Schools, businesses, and public Wi-Fi often block certain websites using firewall rules. Proxies enable you to route around these restrictions.

Now that you know the main benefits of proxies, let‘s look at the various configuration methods on Ubuntu.

Ubuntu Desktop GUI Method

The Network Settings GUI provides an intuitive way to set up a proxy server for your entire system.

  1. Click the Show Applications icon in the bottom left corner and search for "Settings".
  2. Click the Network tab.
  3. Click the gear icon next to Network Proxy. This opens the proxy configuration dialog.

Network Proxy dialog in Ubuntu

  1. In the Method drop-down, select Manual.
  2. Enter your proxy server‘s IP address or hostname in the HTTP Proxy, HTTPS Proxy, and FTP Proxy fields.
  3. Change the port number if needed to match your proxy service.
  4. Check the Bypass proxies for field and enter any local hostnames or IP ranges you want to exclude from going through the proxy.
  5. Click Close to save the settings.

This configures your Ubuntu system to route all web traffic through the defined proxy server. The settings apply to all user accounts and are persistent across reboots.

If you need to disable the proxy, simply return to Network Settings and change the Method back to None.

The main downside of the GUI method is the lack of authentication support. Let‘s look at more advanced terminal-based options next.

Ubuntu Terminal Method

Setting proxy variables via the command line provides greater control than the GUI method. You can specify credentials, configure proxies only for certain protocols, and set proxies on a per-user basis.

Here are some key variables for proxy configurations:

Variable Description
HTTP_PROXY Defines proxy server for HTTP requests
HTTPS_PROXY Sets proxy server for HTTPS requests
FTP_PROXY Specifies proxy server for FTP transfers
NO_PROXY Lists hostnames & IP addresses to bypass proxy

The syntax for setting these variables is:

proxy_protocol=protocol://[username:password@]proxy-url:port

For example:

HTTP_PROXY=http://username:[email protected]:8080

Optionally, you can define each component separately:

proxy_server=192.168.0.1
proxy_port=8080
proxy_user=username
proxy_pass=password

Let‘s go through two methods of configuring proxies via the terminal – temporary and persistent.

Temporary Single-User Proxy

To quickly set a temporary proxy for your current shell session:

  1. Launch a terminal window.
  2. Set the HTTP proxy variable:

    HTTP_PROXY=http://proxy-ip:port
  3. Set the HTTPS proxy variable:

    HTTPS_PROXY=http://proxy-ip:port 
  4. Set servers to exclude from the proxy:

    NO_PROXY=localhost,127.0.0.1
  5. Export each variable:

    export HTTP_PROXY
    export HTTPS_PROXY
    export NO_PROXY

This overrides any existing proxy settings within this terminal window. The configuration will be lost when you close the terminal.

Persistent Single-User Proxy

To retain proxy settings between sessions, add the variables to your Bash profile:

  1. Open your Bash profile config file in a text editor:

    nano ~/.bash_profile
  2. Add the proxy variable exports using your details:

    export HTTP_PROXY=http://username:password@proxy-url:port
    export HTTPS_PROXY=https://username:password@proxy-url:port
    export NO_PROXY=localhost,127.0.0.1
  3. Save and close the file.
  4. Source the profile to load the new configuration:

    source ~/.bash_profile

Now your proxy settings will persist across terminal sessions and reboots.

To disable, simply comment out or delete the variable exports in your Bash profile.

System-Wide Proxy for All Users

For network-wide proxy settings, you can add variables to the /etc/environment file:

  1. Open the file for editing with root privileges:

    sudo nano /etc/environment
  2. Add the proxy variable exports:

    HTTP_PROXY="http://username:password@proxy-url:port/"
    HTTPS_PROXY="https://username:password@proxy-url:port/"  
    NO_PROXY="localhost,127.0.0.1,::1"
  3. Save and close the file.
  4. Load the new configuration:

    source /etc/environment

This sets up a system-wide proxy for all users that will persist across reboots. To revert the change, edit /etc/environment again and remove or comment out the proxy exports.

Proxy Server Types

There are various types of proxy protocols, each with their own use cases:

Proxy Type Description Use Cases
HTTP Proxy Forwards HTML/web traffic General web browsing, video streaming
HTTPS Proxy Forwards encrypted HTTPS traffic Secure web browsing
SOCKS Proxy Forwards all TCP connections Gaming, P2P, streaming media
Email Proxy Forwards SMTP/POP/IMAP email Accessing email anonymously

When choosing a proxy for your Ubuntu system, consider the primary activities you‘ll use it for – general web use, streaming media, gaming, email, etc.

Many proxy providers offer access to multiple protocols. For example, you can use HTTP and SOCKS proxies from the same server by configuring the appropriate environment variables.

Should You Use a Proxy or VPN?

Proxies have some overlap with VPNs (virtual private networks). However, there are some key differences:

Encryption – VPNs always encrypt your traffic. Proxies only encrypt data if using HTTPS.

IP Hiding – VPNs replace your IP address. Proxies keep your IP visible to the remote server.

Access Restrictions – VPNs access restricted networks. Proxies only bypass webpage blocking.

Speed – Proxies route web traffic only. VPNs slow other traffic like gaming.

Cost – VPNs tend to be pricier than proxy services.

For complete anonymity and heavy-duty encryption, a VPN is preferable. Proxies provide a lighter layer of privacy focused on web browsing. Many privacy-conscious users combine proxies and VPNs for maximum security.

Conclusion

Configuring proxy settings in Ubuntu is straightforward once you know the different methods. The desktop UI works well for basic setups, while the terminal provides finer-grained control.

Proxies enable you to access geo-restricted content, keep your browsing activities private, and evade censorship. Setting up a proxy server on your Ubuntu desktop enhances online privacy and circumvention.

As you evaluate proxy services, consider the protocols, locations, and privacy policies that matter most for your use case. Proxies provide an additional layer of security alongside VPNs and other privacy tools.

Now you have the knowledge to configure web traffic routing through a proxy on Ubuntu for private and anonymous internet access.

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.