连接包管理器
将 pip、npm、Go、Cargo、Maven、APT 等客户端安全连接到 Depsilo v0.9.4,并验证请求确实经过代理缓存。
本页示例适用于 Depsilo v0.9.4,并假设服务地址是 http://localhost:23333。如果你通过局域网地址、反向代理、HTTPS 或自定义端口访问 Depsilo,请把示例中的整个 origin 换成浏览器里打开 Portal 时使用的地址。
-
确认服务可达
Terminal window curl -fsS http://localhost:23333/ready -
配置一个客户端
从下方选择对应生态。优先使用项目级配置;需要修改用户级或系统级文件时,先备份原文件。
-
发出真实请求
第一次请求通常是 MISS。再次执行同一请求,随后在 Admin 的 Access logs 中确认请求经过 Depsilo,并观察第二次请求是否命中缓存。
需要完整的 pip、uv 与 Poetry 指引时,直接阅读配置 Python。
下面的命令写入 pip 的用户级配置:
pip config set global.index-url http://localhost:23333/pypi/simple/# 仅明文 HTTP 需要:pip config set global.trusted-host localhost:23333
pip install --dry-run --index-url http://localhost:23333/pypi/simple/ six不要把公网源放在 extra-index-url 中充当自动 fallback。pip 会同时考虑多个索引,可能绕过 Depsilo 的策略决策。uv、Poetry、Pipenv 和 PDM 使用同一个 /pypi/simple/ 端点;请在 Portal 中选择对应客户端,复制其项目级配置。
npm、pnpm、Yarn、Bun
Section titled “npm、pnpm、Yarn、Bun”npm config set registry http://localhost:23333/npm/npm config get registrynpm view --registry=http://localhost:23333/npm/ is-number versionnpm 与 pnpm 都可使用项目级或用户级 .npmrc:
registry=http://localhost:23333/npm/Yarn 2+ 使用 npmRegistryServer,Bun 使用 bunfig.toml 中的 [install].registry;它们的服务端路由同样是 /npm/。
Go Modules
Section titled “Go Modules”go env -w GOPROXY=http://localhost:23333/go/,directgo env GOPROXY保留 GOSUMDB,让 Go 继续校验公共模块的 checksum。
临时验证而不修改持久配置:
GOPROXY=http://localhost:23333/go/ go list -m -versions rsc.io/quoteCargo 必须把 crates.io 替换为 Depsilo;只增加一个命名 registry 并不会改变默认来源。
[source.crates-io]replace-with = "depsilo"
[source.depsilo]registry = "sparse+http://localhost:23333/crates/"sparse+ 前缀不可省略,Depsilo 的 Cargo 路由是 /crates/,不是 /cargo/。
cargo fetchMaven 没有通用的命令行参数可以覆盖所有远程仓库,应配置 mirror:
<settings> <mirrors> <mirror> <id>depsilo</id> <url>http://localhost:23333/maven/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors></settings>mvn help:effective-settings | grep depsilomirrorOf 为 * 时会接管构建声明的所有仓库;如需排除特定仓库,应明确调整该表达式,而不是依赖隐式 fallback。
Gradle
Section titled “Gradle”全局配置可放在 ~/.gradle/init.gradle,项目级配置则放进项目的 repositories:
allprojects { repositories { maven { url "http://localhost:23333/maven/" } }}gradle dependencies --refresh-dependenciesRubyGems 与 Bundler
Section titled “RubyGems 与 Bundler”bundle config mirror.https://rubygems.org http://localhost:23333/rubygems/bundle config get mirror.https://rubygems.orgBundler 默认写入当前项目的 .bundle/config;加 --global 才会写入用户级配置。
Composer
Section titled “Composer”composer config -g repo.packagist composer http://localhost:23333/composer/# 仅明文 HTTP 需要:composer config -g secure-http false
composer diagnoseComposer 在镜像拒绝某个 dist 后可能回退到原始 dist URL。若必须保证所有请求都经过策略控制,还需要在网络层限制客户端直连原始来源。
NuGet / dotnet
Section titled “NuGet / dotnet”dotnet nuget add source http://localhost:23333/nuget/v3/index.json -n depsilodotnet nuget list source上面的命令修改用户级 NuGet.Config。团队项目可把等价的 NuGet.Config 放在解决方案旁,并在需要时用 <clear /> 移除默认 nuget.org 来源。
channels: - http://localhost:23333/conda/pkgs/main - http://localhost:23333/conda/pkgs/rdefault_channels: []repodata_use_zst: falseAnaconda channel 路径必须包含 pkgs/。default_channels: [] 防止自动回退到 repo.anaconda.com;repodata_use_zst: false 避免 upstream 没有 .zst 元数据时产生 404。
R / CRAN
Section titled “R / CRAN”options(repos = c(CRAN = "http://localhost:23333/cran/"))helm repo add depsilo http://localhost:23333/helm/helm repo updatehelm search repo depsilo | head一个 Depsilo Helm upstream 对应一个 chart repository;chart 源由服务端 upstream 配置决定,不是 URL 后缀。
Hugging Face
Section titled “Hugging Face”export HF_ENDPOINT=http://localhost:23333/huggingfacehf download prajjwal1/bert-tiny --local-dir /tmp/bert-tiny需要鉴权的模型继续使用你自己的 HF_TOKEN。带上游凭据的响应不会进入共享缓存。
Depsilo 是 APT 反向代理。应替换 sources 文件中的仓库 URL,不要设置 Acquire::http::Proxy。下面是 Debian 13 “trixie” 示例;其他版本必须替换 suite,Ubuntu 应使用 /apt/ubuntu 和对应 codename。
Types: debURIs: http://localhost:23333/apt/debianSuites: trixie trixie-updatesComponents: mainSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: debURIs: http://localhost:23333/apt/debian-securitySuites: trixie-securityComponents: mainSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg先备份并人工编辑现有 sources;不要盲目运行跨发行版的 sed -i。Depsilo 原样传递已签名的仓库内容,APT 仍会执行正常的 GPG 验证。
sudo apt updateapt-cache policy | headAlpine apk
Section titled “Alpine apk”将 v3.20 换成 /etc/alpine-release 对应的主次版本:
http://localhost:23333/alpine/v3.20/mainhttp://localhost:23333/alpine/v3.20/communityDocker OCI
Section titled “Docker OCI”把配置合并进现有的 daemon JSON,不要覆盖其他键:
{ "registry-mirrors": ["http://localhost:23333"], "insecure-registries": ["localhost:23333"]}mirror URL 必须是 Depsilo 服务根地址;Docker 会自行请求 /v2/,不要追加 /docker/。insecure-registries 只用于 HTTP,修改后需重启 Docker。
- 用相同依赖连续发出两次真实请求;第一次通常回源,第二次才适合验证缓存命中。
- 在 Admin 的 Access logs 中核对生态、包名、状态和命中结果,不要仅凭客户端安装成功判断流量经过了 Depsilo。
- 配置前记录原 registry、index 或 sources;回滚时恢复该值,而不是增加一个并行公网 fallback。
- 容器或远程环境中的
localhost指向它自身。必须改成该客户端实际可达的 Depsilo 主机名或 IP。