Post

Using Nuget, npm, bower and github behind corporate proxy

This was surprisingly time consuming to have all those function properly behind the proxy. Two important tricks that makes things works were:

  1. Drop SSL/TLS from registries endpoints (I assume you’re aware of consequences when doing such thing)
  2. Do not pass domain name to proxy - only user name.

So here is a steps how this done (mainly for myself).

Nuget

  1. Close all instances of Visual Studio (the configuration file is updated when you close it, so settings will be overridden)
  2. Open %APPDATA%\NuGet\NuGet.Config
  3. Under configuration\packageRestore add a new key http_proxy with the following value: http://[USER WITHOUT DOMAIN]:[PASSWORD]@[IP OF PROXY]:[PORT]

Here is an example of configuration file:

1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  <add key="http_proxy" value="http://myaccount:mypassword@1.1.1.1:8080" />
  </packageRestore>
  ...
</configuration>

NPM

  1. Open %HOMEPATH%\.npmrc
  2. Add/replace the following:
1
2
3
4
registry=http://registry.npmjs.org/
proxy=http://myaccount:mypassword@1.1.1.1:8080
https-proxy=http://myaccount:mypassword@1.1.1.1:8080
strict-ssl=false

Bower

  1. Open %HOMEPATH%\.bowerrc
  2. Add/replace the following:
1
2
3
4
5
6
7
{
  "proxy": "http://myaccount:mypassword@1.1.1.1:8080",
  "https-proxy": "http://myaccount:mypassword@1.1.1.1:8080",
  "registry": {
    "search": ["http://bower.herokuapp.com"]
  }
}

Github

  1. Open %HOMEPATH%\.gitconfig
  2. Add the following:
1
2
3
4
5
[url "http://"]
insteadOf = https://
[http]
proxy = http://myaccount:mypassword@1.1.1.1:8080
sslverify = false

In some cases bower will still fail and JSPM as well, since git protocol is also may be blocked. To fix it, add additional block to the same file:

1
2
[url "https://"]
  insteadOf = git://