How to Configure Proxy Settings on Ubuntu 18.04

Published on: April 18, 2023
Last Updated: April 18, 2023

Proxies are one of the smartest tools you can use to access restricted content.

They are popular among businesses and creators who use proxies to spy on competitors, download, and take inspiration from content restricted at their locations.

You can even use proxies to access sites you got banned from. Hence, they have become a crucial part of our lives.

In this article, we’ll discuss multiple ways to set up proxies in Ubuntu 18.04.

This will not only help you browse the internet privately but also protect your data from getting collected.

We’ll go through three ways to set the proxy.

How to Configure Proxy Settings on Ubuntu 18.04

The first method involves Ubuntu proxy settings within the desktop.

The second method helps you set environment variables for the proxy server using a terminal or console.

Finally, we’ll learn about setting the proxy for all users in the system. Let’s get started.

Ubuntu Desktop Network Settings

Ubuntu Desktop Network Settings

You need access to the Network Settings to complete this method. But the trap where most people fall is getting confused by the sheer amount of data they see. For instance,

you’ll find many settings to set several parameters, and proxy settings for HTTP traffic, HTTPS traffic, and FTP traffic.

You can also set, ignore Hosts, this protects your proxy server from local traffic. So, how can you set up your proxy on Ubuntu Desktop?

  • Navigate to the bottom of the quick application access bar and click on “Show Applications” to launch.
  • Now, find “Settings” by typing it in.
  • Click on Network Tab > cog Icon near the Network Proxy label.
  • You will see a dialog box where you can enter your proxy server’s host name or IP address in the text fields.
  • Now, change the port number to match that of your proxy server.
  • Close the dialog box.
Ubuntu Desktop Network Settings 2

Ubuntu Terminal Proxy Settings

You can also set up a proxy using environment variables that range from HTTP traffic to FTP traffic. Now, proxy settings are non-persistent when you set them from the shell session.

VariableDescription
http_proxyProxy server for HTTP Traffic.
https_proxyProxy server for HTTPS traffic
ftp_proxyProxy server for FTP traffic
no_proxyPatterns for IP addresses or domain names that shouldn’t use the proxy


Remember that the value of every setting uses the same template, except for no_proxy 

You can also specify a proxy server port and user credentials like: 

proxy_http=username:[email protected]:port

Single User Temporary Proxy Settings

In this section, you’ll learn to override existing settings using the proxy environment variables from the command line.

This method helps you set a proxy for HTTP and HTTPS. This means you block the local traffic from going through the proxy.

For instance, let’s say the proxy server endpoint is my.proxy.server:8080 for HTTP traffic and my.proxy.server:8081 for HTTPS.

How to do it?

  • Open the Terminal window where you need proxy access.
  • Now, set and export the HTTP_PROXY variable.
HTTP_PROXY=user:[email protected]:8080

export

  • Set and export the HTTPS_PROXY variable.
HTTPS_PROXY=user:[email protected]:8081 sent to the proxy.

export

  • Finally, set and export the NO_PROXY variable to prevent local traffic from being
export NO_PROXY=localhost,127.0.0.1,.my.lan.domain

Single User Persistent Proxy Settings

Follow the below steps to set up a single user persistent proxy.

  • Open the bash profile.
  • Turn it into a text editor.
vi ~/.bash_profile
  • Change and add the lines to match your environment.
export http_proxy=username:[email protected]:8080
export https_proxy=username:[email protected]:8081
exprot no_proxy=localhost, 127.0.0.1, *.my.lan
  • Now, save your settings.
  • You don’t need to worry because the settings get applied. Hence, when you start a new session by logging into the server, you are going to notice the changes.
  • If you need to force apply the new proxy settings, execute the source command. 
source ~/.bash_profile

All Users

Ubuntu and Debian have a file: etc/environment where you can set global variables. But you need administrative settings to perform this.
This process involves setting a new user session.

  • Open the /etc/environment into a text editor. 
sudo vi /etc/environment
  • Change and add the lines to match your environment.
http_proxy="http://<username>:<password>@<hostname>:<port>/"
https_proxy="http://<username>:<password>@<hostname>:<port>/"
ftp_proxy="http://<username>:<password>@<hostname>:<port>/"
no_proxy="<pattern>,<pattern>,...

For example, if you do not need to enter a username or password, and your proxy server is my.proxyserver.net at port 8080, and you do not want local traffic going through the proxy, you would enter:

http_proxy="http://my.proxyserver.net:8080/"
https_proxy="http://my.proxyserver.net:8080/"
ftp_proxy="http://my.proxyserver.net:8080/"
no_proxy="localhost,127.0.0.1,::1
  • Save and exit the text editor.

Conclusion

There you have it. Now, you know to set up proxy from the Ubuntu desktop, terminal and for all users.

These Ubuntu proxy settings work flawlessly, and you can notice the changes immediately.

Stay on top of the latest technology trends — delivered directly to your inbox, free!

Subscription Form Posts

Don't worry, we don't spam

Written by Trevor Cooke

Trevor Cooke is an accomplished technology writer with a particular focus on privacy and security. He specializes in topics such as VPNs, encryption, and online anonymity. His articles have been published in a variety of respected technology publications, and he is known for his ability to explain complex technical concepts in a clear and accessible manner.
Latest Stories

Secure your digital life with NordVPN