proxy settings

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://223.158.224.154:8080
export https_proxy://223.158.224.154:8080

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.

proxy_http=<username>:<password>@<proxyhostip>:<portnumber>

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 "http://223.158.224.154:8080/";
Acquire::https::proxy "https://223.158.224.154:8080/";
Acquire::ftp::proxy "ftp://223.158.224.154:8080/";

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=127.0.0.1, *.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. 

http_proxy="http://223.158.224.154:8080/" 
https_proxy="http://223.158.224.154:8080/"
ftp_proxy="ftp://223.158.224.154:8080/"
no_proxy="127.0.0.1, ::1, localhost

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

vim ~/.wget
user_proxy = on
http_proxy = "http://223.158.224.154:8080/" 
https_proxy = "http://223.158.224.154:8080/" 
ftp_proxy = "ftp://223.158.224.154:8080/"

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

That’s it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here