How to setup internet proxy on Gradle, Maven, NPM. Linux Bash, Ubuntu, Chrome on Linux

This article explains the ways to set internet proxy for various tools and OS such as Gradle, Maven, NPM, Linux Bash, Ubuntu, Chrome on Linux. Proxy is required to access the internet when one works inside a VPN (Virtual Private Network).

Image by Michael Schwarzenberger from Pixabay

Gradle

Create gradle.properties file at user home directory (~/<user>/.gradle on Linux based system and C:\Users\<user>\.gradle on Windows 8+), or in your project root folder to configure internet proxy. Then, add the following lines in it.


systemProp.http.proxyHost=<proxy host or ip e.g. proxy.xyz.com>
systemProp.http.proxyPort=<port e.g. 80>
systemProp.http.nonProxyHosts=*.xyz.com|localhost
systemProp.https.proxyHost=<proxy host or ip e.g. proxy.xyz.com>
systemProp.https.proxyPort=<port e.g. 80>
systemProp.https.nonProxyHosts=*.xyz.com|localhost




Maven

You can configure proxy in maven in settings.xml file. This file could be available at following locations based on type of maven installation you are using.

  • Maven Home: <MAVEN_HOME>/conf/settings.xml> 
  • Maven Repo<OS_USER_HOME>/.m2/settings.xml
  • Netbeans: <NETBEANS_HOME>/java/maven/conf/settings.xml
  • IntelliJ: Goto File -> Settings -> Build, Execution, Deployments -> Build Tools -> Maven. Here, you could set or check the path of settings.xml in User settings file input box. If you don't want to make any change in settings.xml. IntelliJ gives you option to add proxy in "importing" option page under Maven. You can add -DproxySet=true -DproxyHost=myproxy.com -DproxyPort=80 in "VM options for importer" in Maven "importing" settings dialog.
and add following lines in settings.xml for configuring proxy under <settings> parent tag:


<settings>
	<proxies>
		<proxy>
			<id>http</id>
			<active>false</active>
			<protocol>http</protocol>
			<host>proxy.xyz.com</host>
			<port>80</port>
		</proxy>
		<proxy>
			<id>https</id>
			<active>false</active>
			<protocol>https</protocol>
			<host>proxy.xyz.com</host>
			<port>80</port>
		</proxy>		
	</proxies>

        <!-- other configuration -->

</settings>




Bash Shell



  $ export HTTP_PROXY=http://www.xyz.com:80
  $ export HTTPS_PROXY=https://www.xyz.com:80
  $ export no_proxy=localhost,127.0.0.0/8,192.168.0.1:1234




NPM

In .npmrc available at USER_HOME (for e.g. ~/.npmrc) or project root folder


  proxy = http://www.xyz.com:80/
  https_proxy = https://www.xyz.com:80




bower

in .bowerrc (at ~/ or project near bower.json)
Work updating .bowerrc with (NOTICE the use of http:// in https-proxy)
{
    "directory" : "src/bower_modules",
    "proxy" : "",
    "https-proxy" : "",
    "strict-ssl" : false
  }




Ubuntu Proxy settings

dconf (System -> Proxy)



Ubuntu Chrome Proxy settings



sudo gedit /usr/share/applications/google-chrome.desktop

then modify following line:
Exec=/usr/bin/google-chrome-stable %U --proxy-auto-detect

other options are
--proxy-server="Ip proxy Server:port" --no-proxy-server --proxy-bypass-list:

To remove/add proxy from apt-get:
Acquire::http::proxy DIRECT;




Atom Editor


$ apm config set https_proxy "http://www.xyz.com:80"
$ apm config set proxy "http://www.xyz.com:80"



Do you enjoy this article? please help spread the word. Your views are valuable.
Post your view