How to Setup APT Proxy on Ubuntu 20.04 LTS

A proxy server is an intermediate server that sits between the client computer and the internet. Generally, it is used in the internal networks for unexpected access and to prevent attacks. It is also used to control internet access, bandwidth control and content filtering and blocking.

If your office or home network is behind a proxy server then you will need to set up a proxy in your web browser or network proxy setting to access the internet.

In this tutorial, we will show you how to set up proxy settings and apt-proxy in Ubuntu 20.04 Server and Desktop system.

Prerequisites

  • Ubuntu 20.04 desktop installed in your system.
  • A root password is configured the server.

Setup Proxy on Ubuntu Desktop

In order to set up a proxy on Ubuntu desktop, open the System Settings as shown below:

System Settings

Click on the Network => Network proxy. You should see the following screen:

Proxy settings

In the Method drop-down list, select Manual, provide your proxy server IP, port number and click on the Apply system-wide to apply the changes.

Setup Proxy for Single User

In some cases, you don't want to use proxy every time. In that case, you can set up a temporary proxy from the terminal windows.

To export the HTTP_PROXY variable temporarily, run the following command in your terminal:

export HTTP_PROXY=username:[email protected]:8181

To export the HTTPS_PROXY variable temporarily, run the following command in your terminal:

export HTTPS_PROXY=username:[email protected]:8182

If you want to set up a permanent proxy for a single user. You can do it by editing the file ~/.bashrc for a specific user:

nano ~/.bashrc

Add the following lines at the end of the file:

export http_proxy=username:[email protected]:8181
export https_proxy=username:[email protected]:8182

Save and close the file then activate the new proxy setting with the following command:

source ~/.bashrc

Setup Permanent Proxy for All User

If you want to set up a proxy setting for all users then you can set up it by editing the /etc/environment file:

nano /etc/environment

Add the following lines at the end of the file:

export http_proxy=username:[email protected]:8181
export https_proxy=username:[email protected]:8182

Save and close the file then activate the new proxy setting with the following command:

source /etc/environment

Setup Proxy for APT

You will need to set up a proxy for APT if you want to install the package from the Ubuntu repository. You can do it by creating a new configuration file at /etc/apt/apt.conf.d/:

nano /etc/apt/apt.conf.d/proxy.conf

Add the following lines:

Acquire::http::Proxy "http://username:[email protected]:8181/";
Acquire::https::Proxy "https://username:[email protected]:8182/";

Save and close the file when you are finished. You can now install any packages from the Ubuntu repository in your system

Conclusion

In the above guide, you learned how to set up a proxy on Ubuntu using diferrent methods. I hope you have now enough knowledge on proxy setting.

Share this page:

Suggested articles

0 Comment(s)

Add comment