Proxy Settings for most tools
During software development, we come across so many tools, editors and frameworks which have their own way to configure HTTP/HTTPS Proxy especially when using it from your Work environment. Many times, these settings will not work while at home since the proxy is not available. This blog is aimed to capture the settings for most tools for Linux/OSX in one single place from my cheat sheets.
Linux/OSX
Most tools will usually work by simply setting the environment variables. They are http_proxy
and https_proxy
.
I usually set aliases in my .profile or .bash_profile.
alias proxy='export http_proxy=http://www.example.com:80; export https_proxy=http://www.example.com:80'
alias noproxy='unset http_proxy; unset https_proxy'
Then depending on which network I am connected too, I simply run proxy
or noproxy
.
Git
-
Enable proxy
git config --global http.proxy http://www.example.com:80 git config --global https.proxy http://www.example.com:80
-
Disable proxy
git config --global --unset http.proxy git config --global --unset https.proxy
-
Verify your current settings
git config --global --list
NPM
-
Enable proxy
npm config set proxy http://www.example.com:80 npm config set https-proxy http://www.example.com:80 npm config set strict-ssl false
-
Disable proxy
npm config delete proxy npm config delete http-proxy
-
Verify your current settings
npm config list
Maven
-
Enable Proxy
To figure out which maven settings file is being used, run
mvn -X
in your project and look at the first few lines. Configure the settings.xml file as follows:<proxies> <proxy> <id>proxy</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</</username> <password>proxypass</password> <host>example.com/host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> </proxies>
If you set
active
above as true, proxy is always enabled. If you want to choose proxy at runtime, setactive
to false. Then while running the maven command, choosemvn <goals> -Pproxy
-
Disable Proxy
Set
active
as false or comment out the section above.
Gradle
-
Enable Proxy
You can add a
gradle.properties
to your current project directory or to your<home>/.gradle/gradle.properties
. Add the following lines:systemProp.http.proxyHost=www.example.com systemProp.http.proxyPort=80 systemProp.https.proxyHost=www.example.com systemProp.https.proxyPort=80
-
Disable proxy
Remove the above settings or comment them.
Docker
-
Enable proxy.
Edit
/etc/default/docker
, add two lines:export http_proxy="http://server:port" export https_proxy="http://server:port"
SVN
-
Enable proxy. Add the following to
~/.subversion/servers
.[global] http-proxy-host = www.example.com http-proxy-port = 80
APT-GET
-
Enable proxy. Edit
/etc/apt/apt.conf
. AddAcquire::http::proxy "http://www.example.com:80"; Acquire::https::proxy "http://www.example.com:80";
wget
wget will pick up the environment variables http_proxy
and https_proxy
. However if these environment variables are set, the proxy
will always be used. To use wget without proxy, use:
wget --no-proxy http://...
Brackets
-
Open Preferences, add the following to
brackets.json
"proxy": "http://www.example.com:80"
yum
-
Open /etc/yum.conf ( sudo vi /etc/yum.conf)
Add line: proxy=http://www.example.com:80
rpm
$ sudo rpm -ivh –httpproxy my.proxy.com –httpport 8000 http://pkgs.repoforge.org
Till then…
blog comments powered by Disqus