所以我们有一个nginx代理caching,即使在npm停机的情况下也可以保持正常运行。
有时这个服务器(显然每隔几个月)就开始为某个特定的软件包返回400 bad request 。 我认为这是一个损坏的caching或什么的。 所以我们擦拭caching,然后我们可以再次npm install 。 我们试着简单的重启服务器,但结果还不够。 值得一提的是,对于同一个对象(即tar.gz文件),实际的源代码(npm本身)会返回200OK。
这里是configuration: https : //github.com/parris/private-npm-registry/blob/master/nginx/server.conf (随时探索周围的文件)。
configuration看起来像这样:
server { listen 8888; server_name localhost; location / { proxy_pass https://registry.npmjs.org/; proxy_cache npm; proxy_cache_valid 200 302 3d; proxy_cache_valid 404 1m; # npm adds "_resolved": 'registry.npmjs.org/xyz.tgz" to package.json files # this rewrites things correctly sub_filter 'registry.npmjs.org' 'localhost:8888'; sub_filter_once off; sub_filter_types application/json; } }