SINOPIA NPM allow connections to GITHUB as well as the NPM registry
SINOPIA LINK HERE We use SINOPIA as a proxy on our internal network behind the firewall to allow users to install NODE packages without an internet connection. We basically run sinopia on a machine that has access to the internet and the clients point to the server to install packages that are not locally available. We have been running into issues where installs that needed access to github would fail with something like this:
[15:29:07] user1@sb-user1:~/app/mc_api/lib/reports $ npm install --save slack/client --loglevel verbose
npm info it worked if it ends with ok
npm verb cli [ '/home/user1/node_local_install/.nvm/versions/node/v8.9.4/bin/node',
npm verb cli '/home/user1/node_local_install/.nvm/versions/node/v8.9.4/bin/npm',
npm verb cli 'install',
npm verb cli '--save',
npm verb cli 'slack/client',
npm verb cli '--loglevel',
npm verb cli 'verbose' ]
npm info using npm@6.4.1
npm info using node@v8.9.4
npm verb npm-session f40f30f7bf0339f9
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 1114ms
npm verb stack Error: exited with error code: 128
npm verb stack at ChildProcess. (/home/user1/node_local_install/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/pacote/lib/util/finished.js:12:19)
npm verb stack at emitTwo (events.js:126:13)
npm verb stack at ChildProcess.emit (events.js:214:7)
npm verb stack at maybeClose (internal/child_process.js:925:16)
npm verb stack at Socket.stream.socket.on (internal/child_process.js:346:11)
npm verb stack at emitOne (events.js:116:13)
npm verb stack at Socket.emit (events.js:211:7)
npm verb stack at Pipe._handle.close [as _onclose] (net.js:554:12)
npm verb cwd /home/user1/app/mc_api/lib/reports
npm verb Linux 2.6.32-754.3.5.el6.x86_64
npm verb argv "/home/user1/node_local_install/.nvm/versions/node/v8.9.4/bin/node" "/home/user1/node_local_install/.nvm/versions/node/v8.9.4/bin/npm" "install" "--save" "slack/client" "--loglevel" "verbose"
npm verb node v8.9.4
npm verb npm v6.4.1
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://[email protected]/slack/client.git
npm ERR!
npm ERR! ssh: connect to host github.com port 22: Connection refused
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm verb exit [ 1, true ]
npm timing npm Completed in 1497ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user1/.npm/_logs/2018-10-10T19_34_06_306Z-debug.log
As you can see, we are getting choked at:
npm ERR! ssh: connect to host github.com port 22: Connection refused
npm ERR! fatal: Could not read from remote repository.
To get around this we need to change the config.yml on the server to allow proxies to github, here is the final configuration. Hope this helps other users as we had a fun time trying to figure it out. Pay attention to the uplinks section and the proxy requests where github is defined.
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/rlidwka/sinopia/tree/master/conf
#
# path to a directory with all packages
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
#max_users: 1000
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
github:
url: https://github.com/
packages:
'@*/*':
# scoped packages
access: $all
publish: $authenticated
proxy:
- npmjs
- github
'*':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all
# allow all known users to publish packages
# (anyone can register by default, remember?)
publish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy:
- npmjs
- github
# log settings
logs:
#- {type: stdout, format: pretty, level: http}
- {type: file, path: sinopia.log, level: debug}
#Bind Address
listen:
- 0.0.0.0:4873
#