Conversation behind the proxy

bower install behind the proxy server cannot time out with the following settings (some settings are useless ...):

 git config --global http.proxy fr-proxy.example.com:3128 git config --global https.proxy fr-proxy.example.com:3128 export http_proxy=http://fr-proxy.example.com:3128 export https_proxy=http://fr-proxy.example.com:3128 npm config set proxy http://fr-proxy.example.com:3128 npm config set https-proxy http://fr-proxy.example.com:3128 npm config set registry http://registry.npmjs.org/ 

I also tried installing / uninstalling bower and bower clean cache .

+48
npm bower proxy
Feb 11 '14 at 2:48
source share
4 answers

Modify the .bowerrc file and add the desired proxy configuration:

 { "proxy":"http://<host>:<port>", "https-proxy":"http://<host>:<port>" } 

If you are working with an authenticated proxy, the user and password must be enabled as follows:

 { "proxy":"http://<user>:<password>@<host>:<port>", "https-proxy":"http://<user>:<password>@<host>:<port>" } 

Usually, .bowerrc is next to bower.json. And if there is no .bowerrc file next to the bower.json file, you can create it yourself.

+96
Apr 15 '14 at 15:17
source share

I have a problem with the bower list command, which was caused by the fact that bower uses git with git:// URLs to get a list of remote GitHub repositories, but the git:// protocol is blocked by our corporate firewall. To solve this problem in addition to setting environment variables, I have to add additional configurations to git too. Here is the complete list of commands that I must execute (do not forget to replace the proxy host and port with yours):

 # set proxy for command line tools export HTTP_PROXY=http://localhost:3128 export HTTPS_PROXY=http://localhost:3128 export http_proxy=http://localhost:3128 export https_proxy=http://localhost:3128 # add configuration to git command line tool git config --global http.proxy http://localhost:3128 git config --global https.proxy http://localhost:3128 git config --global url."http://".insteadOf git:// 

The standard environment variables in Bash are uppercase; for proxies, the HTTPS_PROXY and HTTPS_PROXY , but some tools expect them to be lowercase, one of these tools is the gazebo. That is why I prefer to have a proxy server in two cases: lower and upper.

Bower uses git to get packages from GitHub, so configuration keys need to be added to git as well. http.proxy and https.proxy are proxy server settings and should point to your proxy server. Last but not least, telling git not to use the git:// protocol, since it can be blocked by a firewall. You need to replace it with the standard http:// protocol. Someone suggests using https:// instead of git:// as follows: git config --global url."https://".insteadOf git:// but I got a Connection reset by peer error, so I use http:// , which works great for me.

At home, I do not use a proxy server and I do not have a corporate firewall, so I prefer to switch to the "normal" settings without a proxy server. Here is how I do it:

 # remove proxy environment variables unset HTTP_PROXY unset HTTPS_PROXY unset http_proxy unset https_proxy # remove git configurations git config --global --unset http.proxy git config --global --unset https.proxy git config --global --unset url."http://".insteadOf 

I don’t remember things very well, so I will never remember all these commands. On top of that, I'm lazy and don't want to type these long commands manually. This is why I created functions for setting and canceling proxy server settings. Here are 2 functions that I added to my .bashrc after some alias definitions:

 set_proxy() { export HTTP_PROXY=http://localhost:3128 export HTTPS_PROXY=http://localhost:3128 # some tools uses lowercase env variables export http_proxy=http://localhost:3128 export https_proxy=http://localhost:3128 # config git git config --global http.proxy http://localhost:3128 git config --global https.proxy http://localhost:3128 git config --global url."http://".insteadOf git:// } unset_proxy() { unset HTTP_PROXY unset HTTPS_PROXY unset http_proxy unset https_proxy git config --global --unset http.proxy git config --global --unset https.proxy git config --global --unset url."http://".insteadOf } 

Now that I need to install the proxy, I just run the set_proxy command and the unset unset_proxy command. With Bash autocomplete, I don’t even need to enter these commands, but let the tab complete them for me.

+29
Jun 17 '14 at 9:19
source share

My script (using git bash on Windows) to install the proxy was executed by another user from what I used for the gazebo. Environment variables were not taken into account.

Thus, the following setting is sufficient, as indicated in other answers:

 export http_proxy=http://fr-proxy.example.com:3128 export https_proxy=http://fr-proxy.example.com:3128 
+6
Mar 17 '14 at 10:09
source share

If your OS is Linux or OS X, try the following command bash http_proxy='proxy server' https_proxy='proxy server' bower

0
Apr 04 '14 at 4:41
source share



All Articles