Home > Blockchain >  verdaccio and nginx (refused to connect)
verdaccio and nginx (refused to connect)

Time:06-29

Use docker and nginx (ssl) not in docker. In browser http://my.site/verdaccio/ I don't have any problems, but in HTTPS i don't see packages "No Package Published Yet."

I get error in browser:

Refused to connect to 'http://my.site/verdaccio/-/verdaccio/packages' because it violates the following Content Security Policy

conf nginx like:

 location /verdaccio/ {
            proxy_pass http://localhost:6666/;
            proxy_redirect off;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            add_header 'Content-Security-Policy' 'upgrade-insecure-requests';

If I use recommended conf, page not load:

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://localhost:6666;
  proxy_redirect off;
}

And get some errors:

Mixed Content: The page at 'https://my.site/verdaccio/' was loaded over HTTPS, but requested an insecure script 'http://my.site/verdaccio/-/static/main.f6e570dfe38870ab429f5.js'. This request has been blocked; the content must be served over HTTPS.

CodePudding user response:

Set the VERDACCIO_PUBLIC_URL env variable to https://my.site

And in my configuration url_prefix: /verdaccio/

I recreate container, it work.

  • Related