Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aneudysamparo/136c39477879869829f033beb26db95a to your computer and use it in GitHub Desktop.
Save aneudysamparo/136c39477879869829f033beb26db95a to your computer and use it in GitHub Desktop.
Working behind a proxy, Nudget, NPM, Git
Working behind a proxy Windows Env.
The following steps can be used for those working behind proxies that require authentication. All these methods will store your password in plain text, so use caution when doing this.
Setting the proxy for Nudget
Install the nuget.exe CLI by downloading it from nuget.org, saving that .exe file to a suitable folder, and adding that folder to your PATH environment variable, so that you can run nuget command from terminal.
nuget.exe config -set http_proxy=http://my.proxy.address:port
nuget.exe config -set http_proxy.user=mydomain\myUserName
nuget.exe config -set http_proxy.password=mySuperSecretPassword
Setting the proxy for NPM installs
Open a command prompt
Run the following commands replacing USERNAME, PASSWORD, PROXY_ADDRESS, and PROXY_PORT with your network's information:
npm config set proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT
npm config set https-proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT
Setting the proxy for Git
Open a command prompt
Run the following commands replacing USERNAME, PASSWORD, PROXY_ADDRESS, and PROXY_PORT with your network's information:
git config --global --add http.proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT
git config --global --add https.proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT
Run the following commands to prevent SSH problems:
git config --global url."https://".insteadOf git://
git config --global url."https://github.com/".insteadOf git@github.com: (don't remove the final colon)
If your computer is within a corporate network that uses personal network drives, ensure identical copies of your .gitconfig file exist on both the network drive and your local drive's user profile (e.g. F:\ and C:\Users\USERNAME).
Setting the proxy for other tasks
Many plugins will also look for environmental variables of HTTP_PROXY and HTTPS_PROXY when they need to call out to the internet.
You can set these variables with the value http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT each session by calling:
Windows Command Prompt: set HTTP_PROXY=http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT
Bash Shell: export HTTPS_PROXY=http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT
To avoid doing this every time, you can add these commands to your console's "RC" file. If you are using the Git Bash Shell on Windows, you can add the export statements to the ".bashrc" file in the root of your user profile (C:\Users\USERNAME). That file is run every time you open a Git Bash session, so the environmental variables will be available from the command line. You may need to create that file with a text editor, since Windows doesn't allow creating files starting with a period in Windows Explorer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment