Is cleachtas coitianta é seachvótálaí droim ar ais a úsáid. Is iad na cumraíochtaí seo a leanas na na cinn is mó a mholtar agus a úsáidtear.
Tábhachtach, meastar gurb iad na ceanntásca a réitíonn an pobal ná X-Forwarded-Proto
don phrótacal agus Óstach
don fhearann, cuir isteach iad le do thoil do chumraíocht.
Apache
Níor cheart do Apache agus mod_proxy
slaisí a dhíchódú/ionchódú agus iad a fhágáil mar atá siad:
Chun é a shuiteáil ag cosán coibhneasta, /npm
, ar an bhfreastalaí
<VirtualHost *:80>
AllowEncodedSlashes NoDecode
ProxyPass /npm http://127.0.0.1:4873 nocanon
ProxyPassReverse /npm http://127.0.0.1:4873
</VirtualHost>
Chun suiteáil ag cosán fréimhe, /
, ar an bhfreastalaí
<VirtualHost *:80>
ServerName your.domain.com
ServerAdmin hello@your.domain.com
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
ProxyPass / http://127.0.0.1:4873/ nocanon
ProxyPassReverse / http://127.0.0.1:4873/
</VirtualHost>
Cumraíocht le SSL
Cumraíocht freastalaí fíorúil Apache.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName npm.your.domain.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/npm.your.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/npm.your.domain.com/privkey.pem
SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
ProxyPass / http://127.0.0.1:4873/ nocanon
ProxyPassReverse / http://127.0.0.1:4873/
RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>
</IfModule>
Seiceam neamhbhailí
Uaireanta is féidir leis an gcomhbhrú gzip praiseach a dhéanamh leis an iarratas agus npm install
ar siúl agus teachtaireachtaí earráide mar seo a bheith mar thoradh air:
npm WARN tar TAR_ENTRY_INVALID checksum failure
npm WARN tar zlib: incorrect data check
Is féidir é seo a cheartú trí chomhbhrú gzip a dhíchumasú don ósta fíorúil, trí é seo a chur le do chumraíocht:
SetEnv no-gzip 1
Mar thoradh ar chumraíocht mar seo:
<VirtualHost *:80>
AllowEncodedSlashes NoDecode
SetEnv no-gzip 1
ProxyPass /npm http://127.0.0.1:4873 nocanon
ProxyPassReverse /npm http://127.0.0.1:4873
</VirtualHost>
Níor cheart duit é a chur le do chumraíocht óstach fíorúil ach amháin má tá an cheist agat.
Nginx
Is sampla ducker
iomlán é an mhír seo a leanas agus is féidir é a thástáil inár stór samplaí Docker.
upstream verdaccio_v4 {
server verdaccio_relative_path_v4:4873;
keepalive 8;
}
upstream verdaccio_v4_root {
server verdaccio_relative_path_v4_root:8000;
keepalive 8;
}
upstream verdaccio_v3 {
server verdaccio_relative_path_latest_v3:7771;
keepalive 8;
}
server {
listen 80 default_server;
access_log /var/log/nginx/verdaccio.log;
charset utf-8;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://verdaccio_v4_root;
proxy_redirect off;
}
location ~ ^/verdaccio/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://verdaccio_v4/$1;
proxy_redirect off;
}
location ~ ^/verdacciov3/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://verdaccio_v3/$1;
proxy_redirect off;
}
}
Sampla SSL
server {
listen 80;
return 302 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name localhost;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://verdaccio_v4_root;
proxy_read_timeout 600;
proxy_redirect off;
}
location ~ ^/verdaccio/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://verdaccio_v4_root/$1;
proxy_redirect off;
}
}
Rith taobh thiar seachfhreastalaí droim ar ais le fearann agus port difriúil
Fo-eolaire
Má tá an URL iomlán á úsáid le haghaidh Verdaccio, ní gá duit url_prefix
a shaini ú, nó mura bhfuil bheadh rud mar seo uait i do config.yaml
.
url_prefix: /sub_directory/
Má ritheann tú Verdaccio taobh thiar de seachfhreastalaí droim ar ais, seans go dtabharfaidh tú faoi deara gach comhad acmhainne a sheirbheáil mar chonair choibhneasta, amhail http://127.0.0.1:4873/-/static
Chun an fhadhb seo a réiteach, ba cheart duit fíorfhearann agus port a sheoladh chuig Verdaccio le Host
ceanntásc
Ba cheart go mbeadh cuma mar seo ar chumraíocht Nginx:
location / {
proxy_pass http://127.0.0.1:4873/;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
Sa chás seo, ba cheart url_prefix
NÍ socrú i config Verdaccio
nó suiteáil fo-eolaire:
location ~ ^/verdaccio/(.*)$ {
proxy_pass http://127.0.0.1:4873/$1;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
Sa chás seo, ba cheart do url_prefix
a shocrú go /verdaccio/
Nóta: Tá slais i ndiaidh an chosáin suiteála (
https://your-domain:port/verdaccio/
)!
An url poiblí a shárú
Ó
verdaccio@5.0.0
Tá an VERDACCIO_PUBLIC_URL
nua ceaptha le húsáid taobh thiar de sheachvótálaithe, úsáidfear an athróg seo le haghaidh:
- Úsáidtear é mar bhunchonair chun freastal ar acmhainní UI mar (js, favicon, srl)
- Úsáidte ar bhunchosán meiteashonraí
dist
- Déanann sé neamhaird de cheanntásca
óstach
agusX-Forwarded-Proto
- Má shainmhínítear
url_prefix
chuirfí leis an athróg env é.
VERDACCIO_PUBLIC_URL='https://somedomain.org';
url_prefix: '/my_prefix'
// url -> https://somedomain.org/my_prefix/
VERDACCIO_PUBLIC_URL='https://somedomain.org';
url_prefix: '/'
// url -> https://somedomain.org/
VERDACCIO_PUBLIC_URL='https://somedomain.org/first_prefix';
url_prefix: '/second_prefix'
// url -> https://somedomain.org/second_prefix/'