Mirroring the npm registry for much good

1
Primary
Mirror
0
Secondary
Mirrors
0
MegaBytes
Mirrored

Getting Started

Simply use the frea cli instead of npm!

$ npm i -g frea
...
$ frea --help

For yarn, use the --yarn flag!

$ frea --yarn --help

The cli tool takes care of proxying requests that need authentication to the official npm registry, everything else gets served by mirrors!

Becoming a Mirror

Anyone with a linux machine, a stable internet connection, and 4TB of storage can become a secondary mirror. It's super easy to get setup! First, install rsync and run:

rsync -r --progress rsync://primary.freajs.org:registry [DEST]

Next, install nginx and use the following config:

server {
    listen       80;
    server_name  registry.freajs.org;
    charset utf-8;
    root   [RSYNC DESTINATION FROM ABOVE];
    index  index.json;

    #cache the crap out of the tarballs
    location ~* ^.+\.(?:tgz)$ {
        expires 30d;
        tcp_nodelay off;
        open_file_cache max=3000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
    }

    #don't cache the main index
    location /-/index.json {
        expires -1;
    }

    #cache all json by modified time
    location / {
        expires modified +15m;
        try_files $uri
                  $uri/-/index.json
                  $uri/index.json
                  $uri.json
                  @primary;
    }

    location @primary {
        proxy_pass https://primary.freajs.org;
    }
}

Finally, setup a cron job that runs the rsync command. We recommend syncing multiple times an hour, at a bare minimum sync once every 24 hours.

Now shoot us an email at frea@blankenship.io w/ your domain name or IP address and we will add you to the mirrors

Note: we have lax definitions for availability. We can support long contiguous outages for mirros, we do health checks and graceful failovers, so we won't hold 100% downtime against you. But we expect that, when you are up, you are up. Consistent partial outages cause flakey npm installs, and that is a bummer for everyone.