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:
- Drop SSL/TLS from registries endpoints (I assume you're aware of consequences when doing such thing)
- Do not pass domain name to proxy - only user name.
So here is a steps how this done (mainly for myself).
Nuget
- Close all instances of Visual Studio (the configuration file is updated when you close it, so settings will be overridden)
- Open
%APPDATA%\NuGet\NuGet.Config
- Under
configuration\packageRestore
add a new keyhttp_proxy
with the following value:http://[USER WITHOUT DOMAIN]:[PASSWORD]@[IP OF PROXY]:[PORT]
Here is an example of configuration file:
<?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
- Open
%HOMEPATH%\.npmrc
- Add/replace the following:
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
- Open
%HOMEPATH%\.bowerrc
- Add/replace the following:
{
"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
- Open
%HOMEPATH%\.gitconfig
- Add the following:
[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:
[url "https://"]
insteadOf = git://