Friday, February 12, 2016

All things about proxy



Protected by the great Chinese Firewall, I feel my mind is as pure as the WhiteSnow. But living in this mighty country as a software engineer, one thing is particularly painful: we have to be the Kung Fu Panda to jump over the wall to google and download things.
I experienced this pain vividly a few weeks ago when I had to re-install a computer, so I decided to write all the “jumping over wall” techniques down.

 

 git

BTW, when installing git, choose Run Git from the Windows Command Prompt.
 

git proxies are configured in C:\Users\ME\.gitconfig.
[https]
      proxy = PROXY
      sslverify = false
[http]
      sslverify = false
      proxy = PROXY
[url "https://"]
      insteadOf = git://
[url "https://github.com"]
        insteadOf = git://github.com             

 

npm

npm proxy needs to be setup in C:\Users\ME\.npmrc. Note, you can’t right click and create a file whose name starts with “.”. You can however create a blank file in your editor and save it as “.npmrc”.
strict-ssl=false
proxy=PROXY
https-proxy=PROXY

 

Vagrant

To be able to download boxes, I need to setup proxy environment variables in my windows machine:
HTTP_PROXY=PROXY
HTTPS_PROXY=PROXY

To enable VMs created by Vagant to be able to download things, I need to setup proxies for VMs as well, to do so, first I need to install a plugin for Vagant:
vagrant plugin install vagrant-proxyconf

Then I can setup proxies for VMs in Vagrantfile:
 if Vagrant.has_plugin?("vagrant-proxyconf")
            config.proxy.http = PROXY
            config.proxy.https = PROXY         
            config.proxy.ftp = PROXY           
            config.proxy.no_proxy  = "localhost,127.0.0.1,192.168.33.10"
end

One thing to note is that no_proxy should contain either domains or exact ip address. Wildcard ip addresses do not work, e.g. 192.168.33.* doesn’t work. See http://unix.stackexchange.com/questions/23452/set-a-network-range-in-the-no-proxy-environment-variable.

 

curl

curl will respect https_proxy, http_proxy, no_proxy environment variables (as configured by Vagrant above, for example). If you want curl to bypass proxy for certain url, include the domain or ip address in no_proxy.

You can also use --noproxy to bypass proxies.  
curl  -v --noproxy '*' -XGET "192.168.33.15:9200"

 

cygwin

This concerns install Cygwin. Follow the wizard step by step, and upon the following step, choose option 2:


This is actually very weird, I do not have proxy setup in IE, so the second option should be equal to first, but using the first or the third option, I simply can’t access any mirror site. Weird!

No comments:

Post a Comment