متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 239CI/CD · Artifacts

How to run a package proxy with Nexus

Every CI build downloads the same packages from npm, PyPI, Maven Central and Docker Hub — slow, rate-limited, and the build breaks when the internet or a registry is down. Nexus Repository sits in between: a proxy repository caches what builds download, a hosted repository stores your own packages, and a group combines them behind one URL. This how-to creates proxy, hosted and group repositories and points pip, npm and Docker at them.

  • 5 الدروس
  • 3 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

239.1

The quick answer

In Nexus (Administration → Repositories → Create repository):

NameRecipeSetting
pypi-proxypypi (proxy)Remote: https://pypi.org
pypi-internalpypi (hosted)Deployment: allow redeploy off
pypi-allpypi (group)Members: pypi-internal, pypi-proxy
/etc/pip.conf
[global]
index-url = https://nexus.example.com/repository/pypi-all/simple
pip install requests

الأوامر في هذا الدرس

239.2

Step by step

  1. Run Nexus behind a reverse proxy with TLS (see the full guide) and change the admin password at the first login. Turn off anonymous access if packages are internal.
  2. Proxy repositories — one per ecosystem: npm-proxy → https://registry.npmjs.org, maven-proxy → https://repo1.maven.org/maven2/, docker-proxy → https://registry-1.docker.io. The first download fills the cache; later builds are local and fast.
  3. Hosted repositories — for your own libraries and images (npm-internal, docker-internal). Turn off redeploy, so a released version can never be replaced.
  4. Groups — one URL per ecosystem; your own packages first, then the proxy.
  5. Point the tools at the group:
~/.npmrc
registry=https://nexus.example.com/repository/npm-all/
/etc/docker/daemon.json
{ "registry-mirrors": ["https://docker-mirror.example.com"] }

(Docker needs its own port or host name for the Docker group, set in the repository's HTTP connector or the reverse proxy.)

  1. Publish your own packages — with a CI user that may only deploy: twine upload --repository-url https://nexus.example.com/repository/pypi-internal/ dist/*, npm publish --registry …/npm-internal/.
  2. Cleanup policies — remove cached components not downloaded for 90 days, and run the compact blob store task, or the disk grows forever.
  3. Security — roles with least privilege (read for builds, deploy only for CI), and dependency confusion protection: your internal package names must not be fetched from the public proxy (use a scoped npm name or routing rules).

الأوامر في هذا الدرس

239.3

Check that it worked

pip install requests works through Nexus and the package appears in pypi-proxy (Browse); a second install on another machine is served from the cache; pip config list shows the Nexus index; your internal package installs from the same URL.

الأوامر في هذا الدرس

239.4

Common problems

ProblemCauseFix
401 UnauthorizedAnonymous access off and no credentials in the tool.Add a read user in pip.conf/.npmrc (via a secret).
pip 404URL without /simple for the index.Use …/repository/pypi-all/simple.
Docker pull through Nexus failsDocker needs a dedicated port/host name and TLS.Configure the Docker connector and the reverse proxy.
Disk fullNo cleanup policy.Cleanup policy + compact blob store task.
Old version of a package servedProxy metadata cache too long.Lower the metadata max age; invalidate the cache.
Internal package name taken from public npmDependency confusion.Scoped names (@company/…); routing rules to block.

239.5

Go further

1What is the difference between a proxy, a hosted and a group repository in Nexus?

A proxy caches a remote registry, a hosted repository stores your own packages, and a group combines several behind one URL.

2Why turn off redeploy on hosted repositories?

A released version can then never be replaced, so the same version always means the same package.

كل الأوامر في هذا الفصل