2018-01-08 20:45:03 +01:00
---
2018-07-06 07:11:59 +02:00
id: 配置
title: "配置文件"
2018-01-08 20:45:03 +01:00
---
此文件是 Verdaccio 的重要部分, 您可以在其中修改默认行为, 启用插件并扩展功能。
一个默认的配置文件已经在您首次运行 ` Verdaccio ` 时创建。
## 默认配置
默认配置支持 ** 私有(scoped) ** 包, 并允许匿名访问非私有包, 但只有 ** 已登陆用户才能发布包**。
```yaml
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
access: $all
publish: $authenticated
proxy: npmjs
'**':
proxy: npmjs
logs:
- {type: stdout, format: pretty, level: http}
```
## 模块
2018-07-21 16:34:10 +02:00
The following sections explain what each property means and the different options.
2018-01-08 20:45:03 +01:00
### 存储
是默认的存储方式。** Verdaccio 默认使用内置本地文件模式存储 ** 。
```yaml
storage: ./storage
```
2018-07-21 16:34:10 +02:00
### Plugins
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
Is the location of the plugin directory. Useful for Docker/Kubernetes based deployments.
```yaml
plugins: ./plugins
```
### Authentification
The authentification set up is done here, the default auth is based on `htpasswd` and is built-in. You can modify this behaviour via [plugins ](plugins.md ). For more information about this section read the [auth page ](auth.md ).
2018-01-08 20:45:03 +01:00
```yaml
auth:
htpasswd:
file: ./htpasswd
max_users: 1000
```
### Web UI
2018-07-21 16:34:10 +02:00
This properties allow you to modify the look and feel of the web UI. For more information about this section read the [web ui page ](web.md ).
2018-01-08 20:45:03 +01:00
```yaml
web:
enable: true
title: Verdaccio
logo: logo.png
```
### Uplinks
2018-07-21 16:34:10 +02:00
Uplinks is the ability of the system to fetch packages from remote registries when those packages are not available locally. For more information about this section read the [uplinks page ](uplinks.md ).
2018-01-08 20:45:03 +01:00
```yaml
uplinks:
npmjs:
url: https://registry.npmjs.org/
```
2018-07-21 16:34:10 +02:00
### Packages
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
Packages allow the user to control how the packages are gonna be accessed. For more information about this section read the [packages page ](packages.md ).
2018-01-08 20:45:03 +01:00
```yaml
packages:
'@*/*':
access: $all
publish: $authenticated
proxy: npmjs
```
## 高级设置
2018-07-21 16:34:10 +02:00
### Offline Publish
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
By default `verdaccio` does not allow to publish when the client is offline, that behavior can be overridden by setting this to *true* .
2018-01-08 20:45:03 +01:00
```yaml
publish:
allow_offline: false
```
2018-01-21 00:04:36 +01:00
< small > Since: < code > verdaccio@2.3.6< / code > due < a href = "https://github.com/verdaccio/verdaccio/pull/223" > #223< / a > < / small >
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
### URL Prefix
2018-01-08 20:45:03 +01:00
```yaml
url_prefix: https://dev.company.local/verdaccio/
```
2018-01-21 00:04:36 +01:00
Since: `verdaccio@2.3.6` due [#197 ](https://github.com/verdaccio/verdaccio/pull/197 )
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
### Max Body Size
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
By default the maximum body size for a JSON document is `10mb` , if you run in errors as `"request entity too large"` you may increase this value.
2018-01-08 20:45:03 +01:00
```yaml
2018-05-30 15:46:53 +02:00
max_body_size: 10mb
2018-01-08 20:45:03 +01:00
```
2018-07-21 16:34:10 +02:00
### Listen Port
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
`verdaccio` runs by default in the port `4873` . Changing the port can be done via [cli ](cli.md ) or in the configuration file, the following options are valid.
2018-01-08 20:45:03 +01:00
```yaml
listen:
New Crowdin translations (#479)
* New translations contributing.md (Chinese Simplified)
* New translations contributing.md (Chinese Traditional)
* New translations contributing.md (Chinese Traditional, Hong Kong)
* New translations contributing.md (Portuguese, Brazilian)
* New translations contributing.md (Spanish)
* New translations contributing.md (Urdu (Pakistan))
* New translations docker.md (Chinese Simplified)
* New translations docker.md (Chinese Traditional)
* New translations docker.md (Chinese Traditional, Hong Kong)
* New translations docker.md (Portuguese, Brazilian)
* New translations docker.md (Spanish)
* New translations docker.md (Urdu (Pakistan))
* New translations node-api.md (Chinese Simplified)
* New translations node-api.md (Chinese Traditional)
* New translations node-api.md (Chinese Traditional, Hong Kong)
* New translations node-api.md (Portuguese, Brazilian)
* New translations node-api.md (Spanish)
* New translations node-api.md (Urdu (Pakistan))
* New translations uplinks.md (Chinese Traditional)
* New translations uplinks.md (Chinese Traditional, Hong Kong)
* New translations uplinks.md (Portuguese, Brazilian)
* New translations uplinks.md (Spanish)
* New translations uplinks.md (Urdu (Pakistan))
* New translations uplinks.md (Chinese Simplified)
* New translations config.md (Chinese Simplified)
* New translations config.md (Spanish)
* New translations config.md (Urdu (Pakistan))
* New translations config.md (Chinese Traditional, Hong Kong)
* New translations config.md (Portuguese, Brazilian)
* New translations config.md (Chinese Traditional)
2018-01-20 09:09:16 +01:00
# - localhost:4873 # default value
# - http://localhost:4873 # same thing
# - 0.0.0.0:4873 # listen on all addresses (INADDR_ANY)
2018-01-08 20:45:03 +01:00
# - https://example.org:4873 # if you want to use https
New Crowdin translations (#479)
* New translations contributing.md (Chinese Simplified)
* New translations contributing.md (Chinese Traditional)
* New translations contributing.md (Chinese Traditional, Hong Kong)
* New translations contributing.md (Portuguese, Brazilian)
* New translations contributing.md (Spanish)
* New translations contributing.md (Urdu (Pakistan))
* New translations docker.md (Chinese Simplified)
* New translations docker.md (Chinese Traditional)
* New translations docker.md (Chinese Traditional, Hong Kong)
* New translations docker.md (Portuguese, Brazilian)
* New translations docker.md (Spanish)
* New translations docker.md (Urdu (Pakistan))
* New translations node-api.md (Chinese Simplified)
* New translations node-api.md (Chinese Traditional)
* New translations node-api.md (Chinese Traditional, Hong Kong)
* New translations node-api.md (Portuguese, Brazilian)
* New translations node-api.md (Spanish)
* New translations node-api.md (Urdu (Pakistan))
* New translations uplinks.md (Chinese Traditional)
* New translations uplinks.md (Chinese Traditional, Hong Kong)
* New translations uplinks.md (Portuguese, Brazilian)
* New translations uplinks.md (Spanish)
* New translations uplinks.md (Urdu (Pakistan))
* New translations uplinks.md (Chinese Simplified)
* New translations config.md (Chinese Simplified)
* New translations config.md (Spanish)
* New translations config.md (Urdu (Pakistan))
* New translations config.md (Chinese Traditional, Hong Kong)
* New translations config.md (Portuguese, Brazilian)
* New translations config.md (Chinese Traditional)
2018-01-20 09:09:16 +01:00
# - "[::1]:4873" # ipv6
2018-01-08 20:45:03 +01:00
# - unix:/tmp/verdaccio.sock # unix socket
```
### HTTPS
2018-07-21 16:34:10 +02:00
To enable `https` in `verdaccio` it's enough to set the `listen` flag with the protocol *https://* . For more information about this section read the [ssl page ](ssl.md ).
2018-01-08 20:45:03 +01:00
```yaml
https:
2018-02-16 19:32:53 +01:00
key: ./path/verdaccio-key.pem
cert: ./path/verdaccio-cert.pem
ca: ./path/verdaccio-csr.pem
2018-01-08 20:45:03 +01:00
```
2018-07-21 16:34:10 +02:00
### Proxy
2018-01-08 20:45:03 +01:00
2018-07-21 16:34:10 +02:00
Proxies are special-purpose HTTP servers designed to transfer data from remote servers to local clients.
2018-02-11 09:58:10 +01:00
#### http_proxy and https_proxy
2018-07-21 16:34:10 +02:00
If you have a proxy in your network you can set a `X-Forwarded-For` header using the following properties.
2018-02-11 09:58:10 +01:00
```yaml
http_proxy: http://something.local/
https_proxy: https://something.local/
```
#### no_proxy
2018-07-21 16:34:10 +02:00
This variable should contain a comma-separated list of domain extensions proxy should not be used for.
2018-02-11 09:58:10 +01:00
```yaml
2018-07-21 16:34:10 +02:00
no_proxy: localhost,127.0.0.1
2018-02-11 09:58:10 +01:00
```
2018-07-21 16:34:10 +02:00
### Notifications
2018-02-11 09:58:10 +01:00
2018-07-21 16:34:10 +02:00
Enabling notifications to third-party tools is fairly easy via web hooks. For more information about this section read the [notifications page ](notifications.md ).
2018-01-08 20:45:03 +01:00
```yaml
notify:
method: POST
headers: [{'Content-Type': 'application/json'}]
endpoint: https://usagge.hipchat.com/v2/room/3729485/notification?auth_token=mySecretToken
2018-02-11 09:58:10 +01:00
content: '{"color":"green","message":"New package published: * {{ name }}* ","notify":true,"message_format":"text"}'
2018-01-21 00:04:36 +01:00
```
2018-07-06 07:11:59 +02:00
> 有关更多配置设置的详细信息,请[核对源代码](https://github.com/verdaccio/verdaccio/tree/master/conf)。
2018-05-31 10:55:20 +02:00
2018-07-21 16:34:10 +02:00
### Audit
2018-05-31 10:55:20 +02:00
2018-06-07 17:19:13 +02:00
< small > Since: < code > verdaccio@3.0.0< / code > < / small >
2018-07-21 16:34:10 +02:00
`npm audit` is a new command released with [npm 6.x ](https://github.com/npm/npm/releases/tag/v6.1.0 ). Verdaccio includes a built-in middleware plugin to handle this command.
2018-05-31 10:55:20 +02:00
2018-07-06 07:11:59 +02:00
> 新安装采用默认版本,但是您可以添加以下代码段到配置文件中
2018-05-31 10:55:20 +02:00
```yaml
middlewares:
audit:
enabled: true
```