This the multi-page printable view of this section.Click here to print.

Return to the regular view of this page.

APT repository mirrors

How to configure a Linux machine to use APT repository mirrors

Table of Contents

Configuring APT to use them

Make certain you make a backup of the files you will be editing below in-case you make a mistake.

Not doing so could cause you not to be able to make any further updates to your machine!

To switch over to using your new proxy you need to edit the apt sources files under /etc/apt/ then run apt-get update.

If you have followed the naming conventions above you can go in to /etc/apt/sources.list and replace any reference to the remote storage url in nexus with the new path.

You should also do this for anything in the /etc/apt/sources.list.d/ directory - but only those you have configured a proxy for!

For example, if your local nexus is accessible at http://10.11.12.13:8081/ then for the apt-ubuntu-archive proxy changing http://gb.archive.ubuntu.com/ubuntu in sources.list with http://10.11.12.13:8081/repository/apt-ubuntu-archive/

For example:

1deb http://gb.archive.ubuntu.com/ubuntu focal main restricted
2deb http://gb.archive.ubuntu.com/ubuntu focal-updates main restricted

becomes:

1deb http://10.11.12.13:8081/repository/apt-ubuntu-archive/ focal main restricted
2deb http://10.11.12.13:8081/repository/apt-ubuntu-archive/ focal-updates main restricted
Do not change the distribution field, e.g. focal-updates above. They should match that of the remote repository. Do not replace them with the value in the proxy!

If like me, you have https configured, then you should be using the correct https address and not the 8081 port.

Now run an update:

1sudo apt-get update

Apt should now access your local proxy. If this completes without any errors then any future upgrade or install will now use the proxy instead.