wiki:verdaccio_installation
This is an old revision of the document!
Table of Contents
Verdaccio installation behind reverse proxy
Create a private npm registry (repository).
Create folder structure and conf file
mkdir verdaccio && cd verdaccio mkdir conf mkdir storage mkdir plugins
Put this in conf/config.yaml:
storage: /verdaccio/storage
plugins: /verdaccio/plugins
web:
title: Verdaccio
auth:
htpasswd:
file: /verdaccio/conf/htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
middlewares:
audit:
enabled: true
logs:
- {type: stdout, format: pretty, level: http}
We are using docker bind mount so we need to change the permissions
chown -R 10001:65533 /root/verdaccio/
Docker volume is the recommended method.
Pull from docker
docker run -it --detach \
--publish 4873:4873 \
--volume `pwd`/conf:/verdaccio/conf \
--volume `pwd`/storage:/verdaccio/storage \
--volume `pwd`/plugins:/verdaccio/plugins \
--name verdaccio \
verdaccio/verdaccio
Create user
In conf folder:
htpasswd -c htpasswd <username>
Apache reverse proxy config
<VirtualHost *:80> ServerName npm.example.com AllowEncodedSlashes NoDecode ProxyPreserveHost On SSLProxyEngine On ProxyRequests Off ProxyPass / http://localhost:4873/ nocanon ProxyPassReverse / http://localhost:4873/ RequestHeader set X-Forwarded-Proto "https" ErrorLog ${APACHE_LOG_DIR}/npm.example-error.log CustomLog ${APACHE_LOG_DIR}/npm.example-access.log combined RewriteEngine on RewriteCond %{SERVER_NAME} =npm.example.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>
SSL configuration:
IfModule mod_ssl.c> <VirtualHost *:443> ServerName npm.example.com AllowEncodedSlashes NoDecode ProxyPreserveHost On SSLProxyEngine On ProxyRequests Off ProxyPass / http://localhost:4873/ nocanon ProxyPassReverse / http://localhost:4873/ RequestHeader set X-Forwarded-Proto "https" ErrorLog ${APACHE_LOG_DIR}/npm.example-error.log CustomLog ${APACHE_LOG_DIR}/npm.example-access.log combined SSLCertificateFile /etc/letsencrypt/live/npm.example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/npm.example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule>
Tested on
- Debian 10
- Verdaccio 5.1.1
- Apache/2.4.38
See also
References
wiki/verdaccio_installation.1626958599.txt.gz · Last modified: by antisa
