How To Set System-Wide Proxy on Ubuntu 20.04/19.10

We can configure and set system-wide proxy settings for ubuntu. This is used to bypass the internet traffic through the proxy server. We can use the Squid proxy server to filter the internet traffic which is coming from all the user’s accounts.

There’re many ways to set the proxy on the ubuntu machine. I will show you how to configure proxy on ubuntu 18.04/19.10.

Check Out: How To Install R and Rstudio On Ubuntu 20.04/19.10

How To Set System-wide Proxy on Ubuntu 20.04/19.10:

Suppose, you have a proxy server to filter the internet traffic from all the machines in your network. So, we have to add those networks in the system otherwise you won’t be able to access the internet based on proxy policy.

Go to the “Settings” -> Click on “Network” -> Click on “Network proxy” -> then select “Manual“.

I’ve defined the proxy settings for HTTP and HTTPS. you can also set it for FTP & socks host as shown in the above figure.

Check Out: How to Open a Firewall Port In Windows Server 2012

Once you have saved the settings, the system will receive them automatically. These settings are also required to set on the browser.

Open the firefox, Go to “Preferences” -> Click on “Network Settings” and put these settings. 

ubuntu system wide proxy

Save it.

System-Wide Proxy on Ubuntu:

We can also set proxy settings using the terminal on the ubuntu. Open the terminal using “ctrl+alt+t” and run the below command to get it. 

export http_proxy://
export https_proxy://

The export command will set the temporary environment variable that persistent on the shell you created or the user who created.

Check Out: How To Pull Files From GitHub Project Using Jenkins

Proxy Environmental Variables: 

  • http_proxy: Proxy server for HTTP traffic.
  • https_proxy: Proxy server for https traffic.
  • ftp_proxy: Proxy server for FTP traffic.
  • no_proxy: This is a pattern for IP address or domain that shouldn’t use the proxy. 

The format or template will be the same for http_proxy except no_proxy. you can also specify the proxy with username and password using the below commands.


Set Proxy For APT Manager:

We will create a file at this location /etc/apt/apt.conf.d/proxies and you can replace the IP with yours. 

Acquire::http::proxy "";
Acquire::https::proxy "";
Acquire::ftp::proxy "";

If you require authentication based proxy, you can use the below format to set the proxy.

Acquire::http::proxy http://<username>:<password>@<proxyhostip>:<portnumber>/";
Acquire::http::proxy http://<username>:<password>@<proxyhostip>:<portnumber>/";

Check Out: How To Install Sentrifugo Open Source HR Management Tool On Linux

Single User Proxy Settings:

We can also set it for a particular user by adding those commands in the .bash_profile file. Open the file and put these commands in the file. 

vi ~/.bash_profile
export proxy_http=<username>:<password>@<proxyhostip>:<portnumber>
export proxy_http=<username>:<password>@<proxyhostip>:<portnumber>
export no_http=, *.my.lan, localhost

If you want to reflect these changes immediately, you will have to run the below command otherwise this will work when you next time login to the server or try to exit from the current session. 

source ~/.bash_profile

For All Users:

In a similar way, we can also set the proxy for our own local pricy. we will have to make changes in the /etc/environment file. 

no_proxy=", ::1, localhost

In a similar way, set the proxy for wget only. Create a file ~/.wget

vim ~/.wget
user_proxy = on
http_proxy = "" 
https_proxy = "" 
ftp_proxy = ""

You can use these settings for all ubuntu versions. The process is same. 

That’s it.

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment