هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
In Nexus (Administration → Repositories → Create repository):
| Name | Recipe | Setting |
|---|---|---|
pypi-proxy | pypi (proxy) | Remote: https://pypi.org |
pypi-internal | pypi (hosted) | Deployment: allow redeploy off |
pypi-all | pypi (group) | Members: pypi-internal, pypi-proxy |
[global]
index-url = https://nexus.example.com/repository/pypi-all/simplepip install requestsStep by step
- 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.
- 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. - Hosted repositories — for your own libraries and images (
npm-internal,docker-internal). Turn off redeploy, so a released version can never be replaced. - Groups — one URL per ecosystem; your own packages first, then the proxy.
- Point the tools at the group:
registry=https://nexus.example.com/repository/npm-all/{ "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.)
- 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/. - Cleanup policies — remove cached components not downloaded for 90 days, and run the compact blob store task, or the disk grows forever.
- 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).
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.
Common problems
| Problem | Cause | Fix |
|---|---|---|
401 Unauthorized | Anonymous access off and no credentials in the tool. | Add a read user in pip.conf/.npmrc (via a secret). |
pip 404 | URL without /simple for the index. | Use …/repository/pypi-all/simple. |
| Docker pull through Nexus fails | Docker needs a dedicated port/host name and TLS. | Configure the Docker connector and the reverse proxy. |
| Disk full | No cleanup policy. | Cleanup policy + compact blob store task. |
| Old version of a package served | Proxy metadata cache too long. | Lower the metadata max age; invalidate the cache. |
| Internal package name taken from public npm | Dependency confusion. | Scoped names (@company/…); routing rules to block. |
Go further
- Command pages: pip, npm, docker.
- Next how-tos: Cache dependencies in CI, Push an image to a private registry, Create a local package repository, Build a pipeline with Jenkins.
- Learn it: Build tools at work — the same build. Full guide: Nexus.
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.