Add NPM mirror hosting to unified mirrors

This patch makes the necessary modifications to host npm packages
on our mirrors. Changes include:

- index.json as a DirectoryIndex
- Rewrite rules for the AFS folder structure
- mod_substitute invocation to correctly reference absolute tarball
  url's described in the index.json files.

Change-Id: I7f7c6caa6af16101cf104f950968f3c6319b8243
This commit is contained in:
Michael Krotscheck
2016-04-08 15:44:45 -07:00
parent 8d5b262e7e
commit e47c469cc6
2 changed files with 33 additions and 0 deletions

View File

@@ -42,6 +42,22 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
RewriteCond %{DOCUMENT_ROOT}/wheel/$1/$2/$2$3 -d
RewriteRule ^/wheel/([^/]+)/([^/])([^/]*)(/.*)?$ /wheel/$1/$2/$2$3$4 [L]
<Directory <%= @docroot %>/npm/>
DirectoryIndex index.json
# npm's URL's are:
# /npm/-/index.json
# /npm/a/aabc/index.json
# /npm/a/aabc/latest/index.json
# /npm/a/aabc/-/aabc-0.0.0.tgz
RewriteCond %{REQUEST_URI} ^/npm/([^/])([^/]*)
RewriteCond %{DOCUMENT_ROOT}/npm/$1/$1$2 -d
RewriteRule ^([^/])([^/]*)(/.*)?$ $1/$1$2$3 [L]
AddOutputFilterByType SUBSTITUTE application/json
Substitute "s/localhost/<%= @srvname %>\/npm/ni"
</Directory>
ErrorLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_error.log
LogLevel warn
CustomLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/<%= @name %>_access.log combined