Git repositories through a squid proxy

(This is a quick one, because I couldn't find the answer to today's problem on Google.)

Happy new year to you all! Already back working hard, with the snow and Christmas with my parents a dim and distant memory, I've been playing with drush make and squid proxies.

You can speed up lots of local drush-making with the http_proxy environment variable (which seems to be a general solution to proxying, as it's obeyed by both cURL and wget. Downloading lots of project zipfiles from drupal.org over and over again is much faster when you're secretly downloading from a local development machine.

However, there's a problem. If your makefile references a git repository on, say, github, then drush make will just fail when trying to create a local clone. Running the git clone instruction on its own yields a slightly cryptic error:

jp@jp-laptop:~/workflowing$ http_proxy=http://192.168.1.220/ git clone http://\
github.com/jpstacey/Drupal-ConfWizard.git /tmp/confwizard
 
Initialized empty Git repository in /tmp/confwizard/.git/
 
error: Failed connect to github.com:1080; Operation now in progress 
while accessing ...

You can also set GIT_CURL_VERBOSE=1 before your command, and see the connections timing out, but it doesn't help much. But that "1080" is the clue. It's the registered port for SOCKS servers.

What's happening is that PHP's internal HTTP libraries have defaulted to port 80, which our squid proxy is listening on, but git's cURL libraries assume that a HTTP proxy will be listening on the registered SOCKS port. The solution is to make the port unambiguous in the URL: http://192.168.1.220:80. When we did this, downloads worked just fine.

Comments

adding

ignore_expect_100 on

to squid.conf fixes that error