Skip to content

Commit ef7c520

Browse files
committed
nginx: support static package metadata
By putting a multi-version file at /tmp/npm/store/<pkgname>/package.json you can effectively lock a package to a given selection of versions for the lifetime of the npm registry. This file should be analogous to what would normally be served up at https://registry.npmjs.org/<pkgname>
1 parent 7a9aa39 commit ef7c520

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

nginx.conf

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ http {
3131
local ephemeralNPM = require "ephemeral-npm"
3232
ephemeralNPM.init()
3333
}
34+
3435
server {
3536
listen 4873;
3637
set $npm_config_registry '';
@@ -58,10 +59,19 @@ http {
5859
# we need to be able to make sub-requests using ngx.location.capture()
5960
location /-@- {
6061
internal;
61-
rewrite /-@-/(.+) /$1 break;
62-
resolver 127.0.0.1 ipv6=off;
63-
proxy_pass $npm_config_registry;
64-
proxy_buffers 32 1m;
62+
rewrite /-@-/(.+) /$1 break;
63+
root /tmp/npm/store;
64+
set $ephemeralCacheStatus "HIT";
65+
try_files /$1/package.json @fetch-meta;
66+
}
67+
location @fetch-meta {
68+
internal;
69+
set $ephemeralCacheStatus "MISS";
70+
resolver 127.0.0.1 ipv6=off;
71+
proxy_pass $npm_config_registry;
72+
proxy_buffers 512 512k;
73+
proxy_temp_path /tmp/npm/temp;
74+
proxy_buffering on;
6575
# need to disable encoding in order to be able to process it locally
6676
proxy_set_header Accept-Encoding "";
6777
}

0 commit comments

Comments
 (0)