You are reading a quick tutorial on how to configure apt proxy server and client on Ubuntu 20.04 Focal Fossa Linux
In this tutorial you will learn:
- How to install and configure apt proxy server
- How to start apt proxy server
- How to open firewall port for apt proxy incoming traffic
- How to configure apt proxy client
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Installed or upgraded Ubuntu 20.04 Focal Fossa |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Apt proxy server configuration
- If you have already configured your apt cacher proxy server then simply skip this part and move to the below section on how to configure apt proxy client.
As a proxy server we will be using the
apt-cacher
. Let’s start by installation of the proxy server:$ sudo apt install apt-cacher
- By default the your new apt proxy server will deny any traffic from unknown hosts and this may result in the following error message
403 Access to cache prohibited
.To configure allowed hosts open the main apt cacher configuration file
/etc/apt-cacher/apt-cacher.conf
and uncomment the following line to allow any host to access apt-cacher’s resources:allowed_hosts = *
Read the enclosed documentation regarding the
allowed_hosts
directive if the above configuration is to permissive for your environment. - Start and enable the proxy server to start after reboot:
$ sudo systemctl enable --now apt-cacher
- Confirm that the apt proxy is up and running. The apt proxy server should be now listening on port
3142
:$ ss -tl | grep 3142 LISTEN 0 128 0.0.0.0:3142 0.0.0.0:*
- In case your Ubuntu system has firewall enabled, you will need to open a firewall port
3142
in order to allow incoming traffic:$ sudo ufw allow from any to any port 3142 proto tcp
Apt proxy client configuration
- Using your apt-cacher proxy IP address or host name create a file eg.
/etc/apt/apt.conf.d/30proxy
with the following content while updating the IP address with the IP address of your apt-cacher server:Acquire::http { Proxy "http://192.168.1.115:3142"; };
- All is now ready and configured. Run
apt
command to confirm the apt cacher proxy configuration:$ sudo apt udpate
If all went well check the content of the
/var/cache/apt-cacher/
directory of your apt proxy server for new packages and updates.