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

Return to the regular view of this page.

Configure Repository mirror

Configure repository mirrors

Table of Contents

Now we have a working installation it's time to set up mirrors for package repositories.

Naming conventions

Although you can call the repositories anything you want, it's advisable to keep to a naming convention. The number of repositories will grow over time, and it will become obvious later which repository is for which package manager.

Because of this I advise the following:

  • Keep repository names lower case and use - as a word separator. Never use a space.
  • The first word in a repository name should be the type,
    e.g. apt for an apt repository, npm for a node/npm repository etc.
  • The second word in a repository name should be the distribution.
    For example, apt-debian for Debian, apt-ubuntu for Ubuntu or apt-raspbian for Raspberry PI OS.
  • Any subsequent words in the name would be for specific repository names.
    e.g. apt-debian-security for the Debian security repository.

Keeping to this scheme will make it easier to maintain as well as keeping like repositories next to each other within the Nexus UI.

Object Stores

Each repository mirror requires an object store to store the cached artefacts. It's advisable to create a new object store for each type of repository.

So for any mirror whose name starts with apt-debian then create a keystore called debian and use it as the backing store for all of them. Do the same for Ubuntu, Raspberry PI OS etc.

If you are mirroring third party repositories like NVidia or OBS then you can either create an object store for each or create one called thirdparty and use that for those smaller repositories. The naming is up to you, but it can help in keeping artefacts separate & not have individual large stores.

Configuring a repository mirror

The following subsections list how to configure each repository type:

1 - APT repository mirrors

How to configure a repository mirror for APT

APT repository mirrors are easy to configure.

Here we will create a repository for the default Debian repository located at http://deb.debian.org/debian

Create blob store

You only need to do this once per group of repositories.

So for Debian then create a blob store called debian, for Ubuntu then create ubuntu etc. Then for each mirror you create then reuse the same blob store for each group.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select blob store, then Create blob store
  3. Under Type select File
  4. Under Name enter debian
  5. Select Create blob store to create it.
Blank create blob panel

Create mirror

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select apt (proxy) as the repository type.
  4. Now fill in the required fields.

    Here we will use Debian as an example:

    1. For name enter apt-debian
    2. For Distribution buster - note this isn't as important as you might think but it is required
    3. For Remote storage enter the repository url http://deb.debian.org/debian
    4. For Blob store select the one you created earlier, debian if you are following my naming conventions.
  5. Once it's all filled in select Save and the Repositories list should now show it.
Blank APT config panel

Common repositories to mirror

The following table lists the repositories mirror covering Debian, Ubuntu and Raspberry PI OS:

Distribution Name Remote storage Blob store Distribution
Debian apt-debian http://deb.debian.org/debian debian buster
apt-debian-security http://security.debian.org/debian-security
Raspian /
Raspberry PI OS
apt-raspbian http://raspbian.raspberrypi.org/raspbian/ raspbian buster
apt-raspbian-archive http://archive.raspberrypi.org/debian/
Ubuntu apt-ubuntu-archive http://gb.archive.ubuntu.com/ubuntu ubuntu focal
apt-ubuntu-ports http://ports.ubuntu.com/ubuntu-ports
For ubuntu my apt-ubuntu-archive proxy goes to gb.archive.ubuntu.com as I'm in the UK. If you are using a different endpoint due to being elsewhere in the world you should be using the same one instead of the GB one.

Using the mirror

Once you have configured your repositories, you can then proceed to configure your machines to use them. This is described in the Using Repository mirrors section.

2 - NPM mirror

How to configure a mirror for NPM

Although NPM is used for NodeJS packages rather than operating system ones, I'm including it here as Nexus will happily proxy them as well, improving build times as any downloads are local and not over your internet connection.

Create blob store

Just like for APT we'll create a blobstore just for NPM. This will be called npm to follow the same guidelines.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select blob store, then Create blob store
  3. Under Type select File
  4. Under Name enter npm
  5. Select Create blob store to create it.

Create npm mirror

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select npm (proxy) as the repository type.
  4. Now fill in the required fields.

    1. For name enter npm-proxy
    2. For Remote storage enter the repository url https://registry.npmjs.org
    3. For Blob store select the one you created earlier, npm if you are following my naming conventions.
  5. Once it's all filled in select Save and the Repositories list should now show it.

Create npm group

This is optional. If you are going to just mirror the core npm repository then you can skip this and just use npm-proxy directly.

However, Nexus supports grouping multiple repositories together with a group, where if it cannot find an artefact in the first one it would check the next one. This is seamless to the client as all it knows about is there's a single repository.

One use-case for this is if you have a hosted repository where you store your own private artefacts. In this instance you'd create the proxy as above, then an npm-hosted repository. The group would then include both of them as if it's just one.

I'd advise you should create the group with just npm-proxy present as then your npm clients will use the group, and you can then seamlessly change the underlying proxies separately. For example, using an alternate upstream npm repository instead of the default one. You can do the switch in nexus without changing any client.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select npm (group) as the repository type.
  4. Now fill in the required fields:

    1. For name enter npm-group
    2. Under member repositories you will see two lists.

      On the left hand side select the npm repositories you want to be a member of this group and select >. It should then appear on the right hand side.

      You can change the priority of the entries by selecting the repository name and clicking the up or down arrows. The higher a repository is in the list then they are checked first.

  5. Once it's all filled in select Save and the Repositories list should now show it.

Using the mirror

Once you have configured your repositories, you can then now point npm to use it. This is described in the Using Repository mirrors section.

3 - PIP mirror

How to configure a mirror for PIP

PIP is the package manager for Python and Nexus does support acting as a mirror.

Create blob store

Just like for APT and NPM we'll create a blobstore just for PIP. This will be called pip to follow the same guidelines.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select blob store, then Create blob store
  3. Under Type select File
  4. Under Name enter pip
  5. Select Create blob store to create it.

Create pip/pypi mirror

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select pypi (proxy) as the repository type.
  4. Now fill in the required fields.

    1. For name enter pypi-proxy
    2. For Remote storage enter the repository url https://pypi.org
    3. For Blob store select the one you created earlier, pip if you are following my naming conventions.
  5. Once it's all filled in select Save and the Repositories list should now show it.

Create pip/pypi group

This is optional. If you are going to just mirror the core pypi repository then you can skip this and just use pypi-proxy directly.

However, Nexus supports grouping multiple repositories together with a group, where if it cannot find an artefact in the first one it would check the next one. This is seamless to the client as all it knows about is there's a single repository.

One use-case for this is if you have a hosted repository where you store your own private artefacts. In this instance you'd create the proxy as above, then a pypi-hosted repository. The group would then include both of them as if it's just one.

I'd advise you should create the group with just pypi-proxy present as then your pip clients will use the group, and you can then seamlessly change the underlying proxies separately. For example, using an alternate upstream pypi repository instead of the default one. You can do the switch in nexus without changing any client.

  1. Log in to Nexus and go to the admin page via the icon in the top nav bar.
  2. Select Repositories then the Create Repository
  3. Select pypi (group) as the repository type.
  4. Now fill in the required fields:

    1. For name enter pypi-group
    2. Under member repositories you will see two lists.

      On the left hand side select the npm repositories you want to be a member of this group and select >. It should then appear on the right hand side.

      You can change the priority of the entries by selecting the repository name and clicking the up or down arrows. The higher a repository is in the list then they are checked first.

  5. Once it's all filled in select Save and the Repositories list should now show it.

Using the mirror

Once you have configured your repositories, you can then now point pip to use it. This is described in the Using Repository mirrors section.