Search code examples
npmnexusnexus3

Scoped NPM projects via proxy with Nexus 3.2


I've been setting up Nexus 3.2 and particularly the NPM repository at the moment. I have a proxy repository pointing toward registry.npmjs.org I have been successful at publishing to a hosted repository on the same instance as well as downloading artifacts through a group repository on the instance using npm update -g.

Unfortunately, downloading scoped projects through the group is not working, essential for doing Angular 2 development. When I try, I get 404 errors:

brian$ npm install "@angular/common"
npm ERR! registry error parsing json
npm ERR! Unexpected token < in JSON at position 0
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>404 Not Found</title>
npm ERR! </head><body>
npm ERR! <h1>Not Found</h1>
npm ERR! <p>The requested URL /nexus/repository/npm_group/@angular/common was not found on this server.</p>
npm ERR! </body></html>
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/brian/.npm/_logs/2017-03-28T07_38_37_824Z-debug.log

Scopes are a highly touted feature of 3.x and I'm thrilled that they are mostly working. Because I can publish to protected repos and the proxy repository is populating with non-scoped dependencies, I think I am very close. How can I debug this?

FWIW, I have Nexus behind an Apache HTTPd server:

ProxyPass /nexus http://dev.example.com:8081/nexus nocanon
ProxyPassReverse /nexus http://dev.example.com:8081/nexus
  AllowEncodedSlashes On
<Location /nexus>
  RequestHeader set X-Forwarded-Proto "https"
  RequestHeader set X-Forwarded-Port "443"
</Location>

Thanks!


Solution

  • Solved: This SO answer covers the nuance of using AllowEncodedSlashes:

    Bug 46830: If AllowEncodedSlashes On is set in the global context, it is not inherited by virtual hosts. You must explicitly set AllowEncodedSlashes On in every container.

    As I had the configuration above, adding the AllowEncodedSlashes in the scope that I had it was incorrect, it needed to be placed in the VirtualHost scope for SSL. In my case, that was the NSS module (since I have certificates that are updated by FreeIPA).

    Once that was changed, everything worked great.