跳到主要内容

上行链路

An uplink is a link with an external registry that provides access to external packages.

上行链路

使用

uplinks:
npmjs:
url: https://registry.npmjs.org/
server2:
url: http://mirror.local.net/
timeout: 100ms
server3:
url: http://mirror2.local.net:9000/
baduplink:
url: http://localhost:55666/

配置

你可以定义多个上行链路,每一个都必须有唯一的名称(键值). 它们可以有多个属性: They can have the following properties:

属性类型必须的范例支持版本描述默认值
urlstringhttps://registry.npmjs.org/全部外部注册服务器URLnpmjs
castring~./ssl/client.crt'全部SSL证书文件路径无默认值
timeoutstring100ms全部为请求设置新的超时时间30s
maxagestring10m全部the time threshold to the cache is valid2m
fail_timeoutstring10m全部请求在连续失败超过指定次数后的最长等待重试时间5m
max_failsnumber2全部请求连续失败的最大次数限制2
cacheboolean[true,false]>= 2.1缓存下载的远程tarball文件到本地true
authlist见下文>= 2.5指定“授权authorization”请求头的内容 详情见禁用
headerslistauthorization: "Bearer SecretJWToken=="全部上行链路请求的请求头header列表禁用
strict_sslboolean[true,false]>= 3.0为true时,会检测SSL证书的有效性true
agent_optionsobjectmaxSockets: 10>= 4.0.2options for the HTTP or HTTPS Agent responsible for managing uplink connection persistence and reuse more info无默认值

Auth属性

auth 属性内容是向上行链路发起请求时提供的授权令牌。 例如使用默认环境变量:

uplinks:
private:
url: https://private-registry.domain.com/registry
auth:
type: bearer
token_env: true # by defaults points to the environment variable `NPM_TOKEN`

or via a specified custom environment variable:

uplinks:
private:
url: https://private-registry.domain.com/registry
auth:
type: bearer
token_env: FOO_TOKEN # override the default `NPM_TOKEN` by a custom one

token_env: FOO_TOKEN内部将使用 process.env['FOO_TOKEN']

or by directly specifying a token oh the configuration file (not recommended by security corcerns):

uplinks:
private:
url: https://private-registry.domain.com/registry
auth:
type: bearer
token: "token"

注意: token的优先级高于token_env

须知

  • Uplinks must be registries compatible with the npm endpoints. Eg: verdaccio, sinopia@1.4.0, npmjs registry, yarn registry, JFrog, Nexus and more. Eg: verdaccio, sinopia@1.4.0, npmjs registry, yarn registry, JFrog, Nexus and more.
  • Setting cache to false will help to save space in your hard drive. Setting cache to false will help to save space in your hard drive. This will avoid store tarballs but it will keep metadata in folders.
  • Multiple uplinks might slow down the lookup of your packages. For each request an npm client makes, verdaccio makes 1 call to each configured uplink.
  • The (timeout, maxage and fail_timeout) format follow the NGINX measurement units
  • When using the Helm Chart, you can use secretEnvVars to inject sensitive environment variables, which can be used to configure private uplink auth.