2017-12-16 07:29:14 -05:00
|
|
|
---
|
|
|
|
id: reverse-proxy
|
2018-02-16 13:32:53 -05:00
|
|
|
title: "Reverse Proxy Setup"
|
2017-12-16 07:29:14 -05:00
|
|
|
---
|
|
|
|
## Apache
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
Apache y mod_proxy no deberían decodificar/codificar barras y dejarlas como son:
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
<VirtualHost *:80>
|
|
|
|
AllowEncodedSlashes NoDecode
|
|
|
|
ProxyPass /npm http://127.0.0.1:4873 nocanon
|
|
|
|
ProxyPassReverse /npm http://127.0.0.1:4873
|
|
|
|
</VirtualHost>
|
|
|
|
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
### Configuración con SSL
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
config.yaml
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
url_prefix: https://npm.your.domain.com
|
|
|
|
```
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
Configuración del servidor virtual de Apache
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
apacheconfig
|
|
|
|
<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
|
|
|
|
</VirtualHost>
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
|
|
|
|
## Nginx
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 80 default_server;
|
|
|
|
location / {
|
|
|
|
proxy_pass http://127.0.0.1:4873/;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
## Run behind reverse proxy with different domain and port
|
|
|
|
|
|
|
|
If you run verdaccio behind reverse proxy, you may noticed all resource file served as relaticve path, like `http://127.0.0.1:4873/-/static`
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
Para resolver este problema, debes enviar el dominio real y el puerto a verdaccio con `Host` heade
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
Nginx configure should look like this:
|
|
|
|
|
|
|
|
```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;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
Para este caso, `url_prefix` NO debe establecerse en la configuración verdaccio
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
* * *
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
o a una instalación de sub-directorio:
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
```nginx
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-06-19 12:18:49 -05:00
|
|
|
Para este caso, `url_prefix` debe establecerse a `/verdaccio/`
|
2017-12-16 07:29:14 -05:00
|
|
|
|
|
|
|
> Note: There is a Slash after install path (`https://your-domain:port/vardaccio/`)!
|