Follow below steps to enable/disable proxy in git and maven in Windows PC.
- Proxy configuration is turned on by default. To manually turn on, run "proxon" in git bash shell
- To turn off proxy, run "proxoff" command in git bash shell
Assuming you have git bash installed
-
Open c:\Users\[ME]\.bashrc
-
Add following snippet
function proxon(){ # environment variables are UPPERCASE even in git bash export PROXY_SERVER=[MY_PROXY_SERVER] export PROXY_PORT=8080 export PROXY_FLAG=false export HTTP_PROXY="http://$PROXY_SERVER:$PROXY_PORT" export HTTPS_PROXY=$HTTP_PROXY export FTP_PROXY=$HTTP_PROXY export SOCKS_PROXY=$HTTP_PROXY export NO_PROXY="localhost,127.0.0.1" # Update git config to use the proxy git config --global http.proxy $HTTP_PROXY git config --system http.sslVerify false env | grep -e _PROXY -e GIT_ | sort echo -e "\nProxy-related environment variables set." clear } # Disable proxy settings function proxoff(){ variables=("HTTP_PROXY" "HTTPS_PROXY" "FTP_PROXY" "SOCKS_PROXY") for i in "${variables[@]}" do unset $i done git config --global --unset http.proxy export PROXY_FLAG=true env | grep -e _PROXY -e GIT_ | sort echo -e "\nProxy-related environment variables removed." } # Turn on proxy settings by default proxon
-
Update proxy server and port as required
-
Update proxy info:
<proxy> <id>my_proxy</id> <active>${env.PROXY_FLAG}</active> <protocol>http</protocol> <host>${env.PROXY_SERVER}</host> <port>8080</port> <nonProxyHosts>${env.NO_PROXY}</nonProxyHosts> </proxy>