通过代理Nexus 3.2实现NPM项目

时间:2017-03-28 07:51:10

标签: npm nexus nexus3

我目前正在设置Nexus 3.2,特别是NPM存储库。我有一个指向registry.npmjs.org的代理存储库我已成功发布到同一实例上的托管存储库,并使用npm update -g通过实例上的组存储库下载工件。

不幸的是,通过该组下载范围内的项目不起作用,这对于进行Angular 2开发至关重要。当我尝试时,我得到404错误:

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

范围是3.x的一个非常受欢迎的功能,我很高兴他们大部分都在工作。因为我可以发布到受保护的repos并且代理存储库填充了非范围的依赖项,所以我认为我非常接近。我该怎么调试呢?

FWIW,我在Apache HTTPd服务器后面有Nexus:

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>

谢谢!

1 个答案:

答案 0 :(得分:4)

已解决This SO answer涵盖了使用AllowEncodedSlashes的细微差别:

  

错误46830:如果在全局上下文中设置了AllowEncodedSlashes On,则虚拟主机不会继承它。您必须在每个容器中明确设置AllowEncodedSlashes On。

正如我上面的配置一样,在我拥有它的范围内添加AllowEncodedSlashes是不正确的,需要将其放在SSL的VirtualHost范围内。就我而言,那是NSS模块(因为我有FreeIPA更新的证书。)

一旦改变了,一切都很好。