Chat Zalo Chat Messenger Phone Number Đăng nhập
How to Setup APT Proxy on Ubuntu 22.04 LTS - Howtoforge

How to Setup APT Proxy on Ubuntu 22.04 LTS – Howtoforge

A proxy server is an intermediate server that sits between the client computer and the Internet. Generally, it is used in 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, you will need to configure

a proxy in your web browser or network proxy settings to access the Internet

.

In this tutorial, we will show you how to configure proxy and apt-proxy settings on Ubuntu 22.04 Server and Desktop system. The same steps also work on Ubuntu 20.04.

Prerequisites

Ubuntu

  • 22.04 desktop or Ubuntu 20.04 desktop installed on your PC.
  • Root access via sudo.

Configure Proxy

in Ubuntu Desktop To set up a proxy on an Ubuntu desktop, open System Settings

as shown below:

<img src="https://www.howtoforge.com/images/how_to_install_filerun_using_docker/big/ubuntu-settings.png" alt="Ubuntu System Settings" />

<img src

=”https://www.howtoforge.com/images/how_to_install_filerun_using_docker/ubuntu-settings.png”

alt=”Network Settings Ubuntu” /

>

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

Ubuntu Network Proxy

In the “

Method” drop-down list, select Manual, provide your proxy server IP and port number, and click the “Apply Systemwide Apply” button to apply the changes.

Configure proxy for a single user

In some cases, you don’t want to use a proxy every time. In that case, you can configure 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 configure a permanent proxy for a single user. You can do this by editing

the ~/.bashrc file for a specific user: nano ~/.bashrc Add the following

lines to the end of

the file: export http_proxy=username:[email protected]:8181 export https_proxy=username:[email protected]:8182 Save and

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

source ~/.bashrc

Permanent proxy settings for all users

If you want to configure proxy settings for all users, you can configure them by editing

the /etc/environment file: nano /etc/environment Add the following

lines to the end of

the file: export http_proxy=username:[email protected]:8181 export https_proxy=username:[email protected]:8182 Save and

close the file, and then activate the new proxy settings with the following command:

source /etc/environment

Configuration

proxy for APT

You will need to configure a proxy for APT if you want to install the package from the Ubuntu repository. You can do this by creating a new configuration file in

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

Add the following lines

: Acquire::http::P roxy “http://username:[email protected]:8181/”; Acquire::https::P roxy “https://username:[email protected]:8182/”;

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

Conclusion

In the previous guide, I have shown you how to set up a proxy in Ubuntu using different methods. I hope you now have enough knowledge of proxy settings.

Contact US