Using socks proxy with git for http(s) transport

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Using socks proxy with git for http(s) transport

Yves Blusseau-2
Hi all,

i have a socks proxy to access internet.
I successed in configuring git (with GIT_PROXY_COMMAND) to use the
socks proxy for GIT transport protocol.
But how to use this socks proxy with git for HTTP(S) transport protocol ?

Best Regards,
Yves
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: Using socks proxy with git for http(s) transport

Jeff King
On Wed, Mar 06, 2013 at 09:12:30AM +0100, Yves Blusseau wrote:

> i have a socks proxy to access internet.
> I successed in configuring git (with GIT_PROXY_COMMAND) to use the
> socks proxy for GIT transport protocol.
> But how to use this socks proxy with git for HTTP(S) transport protocol ?

Try:

  git config --global http.proxy 'socks://yourhost:port'

That will enable it for all git repositories on your machine. Git should
also respect any environment variables that curl handles (because we use
libcurl under the hood), if you prefer to set it up that way. See "man
curl" for details.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: Using socks proxy with git for http(s) transport

Yves Blusseau-2
> Try:
>
>   git config --global http.proxy 'socks://yourhost:port'
>
> That will enable it for all git repositories on your machine. Git should
> also respect any environment variables that curl handles (because we use
> libcurl under the hood), if you prefer to set it up that way. See "man
> curl" for details.

Thanks Jeff but it's not working.
I use git 1.8.15
My socks proxy listen on my localhost at port 1080 so I do:
git config --global http.proxy  'socks://127.0.0.1:1080'

But when i try to talk with a git server with http protocol i have:

GIT_TRACE=1 GIT_CURL_VERBOSE=1 git ls-remote
http://git.kernel.org/pub/scm/git/git.git

trace: built-in: git 'ls-remote' 'http://git.kernel.org/pub/scm/git/git.git'
trace: run_command: 'git-remote-http'
'http://git.kernel.org/pub/scm/git/git.git'
'http://git.kernel.org/pub/scm/git/git.git'
* Couldn't find host git.kernel.org in the .netrc file, using defaults
* About to connect() to proxy 127.0.0.1 port 1080
*   Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 1080
> GET http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.1.5
Host: git.kernel.org
Accept: */*
Accept-Encoding: gzip
Proxy-Connection: Keep-Alive
Pragma: no-cache

* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
error: Empty reply from server while accessing
http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack
fatal: HTTP request failed

As you can see git connect to my socks proxy (Connected to 127.0.0.1
(127.0.0.1) port 1080) but seems to send the http request directly
instead of a socks command. So it does'nt work :(

Regards,
Yves
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: Using socks proxy with git for http(s) transport

Yves Blusseau-2
In reply to this post by Jeff King
2013/3/6 Jeff King <[hidden email]>:

> Try:
>
>   git config --global http.proxy 'socks://yourhost:port'
>
> That will enable it for all git repositories on your machine. Git should
> also respect any environment variables that curl handles (because we use
> libcurl under the hood), if you prefer to set it up that way. See "man
> curl" for details.
>
> -Peff

Also try setting ALL_PROXY environment variable that curl handle:
export ALL_PROXY='socks5://127.0.0.1:1080'

Work with curl:
curl -v http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack

* About to connect() to proxy 127.0.0.1 port 1080 (#0)
*   Trying 127.0.0.1...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:--
--:--:--     0* 198
* 145
* 20
* 140
* Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0)
> GET /pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
> User-Agent: curl/7.29.1-DEV
> Host: git.kernel.org
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 06 Mar 2013 09:33:05 GMT
< Content-Type: application/x-git-upload-pack-advertisement
< Transfer-Encoding: chunked
< Connection: keep-alive
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
<
{ [data not shown]


But with git (without the http.proxy configuration in .gitconfig):

GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone
http://git.kernel.org/pub/scm/git/git.git
trace: built-in: git 'clone' 'http://git.kernel.org/pub/scm/git/git.git'
Cloning into 'git'...
trace: run_command: 'git-remote-http' 'origin'
'http://git.kernel.org/pub/scm/git/git.git'
* Couldn't find host git.kernel.org in the .netrc file, using defaults
* About to connect() to proxy 127.0.0.1 port 1080
*   Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 1080
> GET http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.1.5
Host: git.kernel.org
Accept: */*
Accept-Encoding: gzip
Proxy-Connection: Keep-Alive
Pragma: no-cache

* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
error: Empty reply from server while accessing
http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack
fatal: HTTP request failed

Regards,
Yves
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: Using socks proxy with git for http(s) transport

Jeff King
In reply to this post by Yves Blusseau-2
On Wed, Mar 06, 2013 at 10:21:42AM +0100, Yves Blusseau wrote:

> > Try:
> >
> >   git config --global http.proxy 'socks://yourhost:port'
> >
> > That will enable it for all git repositories on your machine. Git should
> > also respect any environment variables that curl handles (because we use
> > libcurl under the hood), if you prefer to set it up that way. See "man
> > curl" for details.
>
> Thanks Jeff but it's not working.

Hmm. I just double-checked, and it works for me.

> I use git 1.8.15

I assume you mean 1.8.1.5 here.

> My socks proxy listen on my localhost at port 1080 so I do:
> git config --global http.proxy  'socks://127.0.0.1:1080'

That looks right to me.

> But when i try to talk with a git server with http protocol i have:
> [...]
> * About to connect() to proxy 127.0.0.1 port 1080
> *   Trying 127.0.0.1... * connected
> * Connected to 127.0.0.1 (127.0.0.1) port 1080
> > GET http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
> [...]
> * Empty reply from server

If I set up a simple socks proxy with ssh, like:

  ssh -v -D 1080 my-ssh-host

and run the same command, I get:

  * About to connect() to proxy localhost port 1080 (#0)
  *   Trying 127.0.0.1...
  * SOCKS4 request granted.
  * Connected to localhost (127.0.0.1) port 1080 (#0)
  > GET /pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
  [...]
  < HTTP/1.1 200 OK

and it works. It does look like curl is treating localhost:1080 as a
regular http proxy. What version of libcurl do you have? Is there
anything in your environment that might be causing it to override the
configured proxy setting (e.g., an http_proxy or https_proxy environment
variable)?

> As you can see git connect to my socks proxy (Connected to 127.0.0.1
> (127.0.0.1) port 1080) but seems to send the http request directly
> instead of a socks command. So it does'nt work :(

Yeah, that definitely looks like the problem.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: Using socks proxy with git for http(s) transport

Yves Blusseau-2
2013/3/6 Jeff King <[hidden email]>:

> On Wed, Mar 06, 2013 at 10:21:42AM +0100, Yves Blusseau wrote:
>
>> > Try:
>> >
>> >   git config --global http.proxy 'socks://yourhost:port'
>> >
>> > That will enable it for all git repositories on your machine. Git should
>> > also respect any environment variables that curl handles (because we use
>> > libcurl under the hood), if you prefer to set it up that way. See "man
>> > curl" for details.
>>
>> Thanks Jeff but it's not working.
>
> Hmm. I just double-checked, and it works for me.
>
>> I use git 1.8.15
>
> I assume you mean 1.8.1.5 here.

Yes it's 1.8.15 sorry for the mistake

>
>> My socks proxy listen on my localhost at port 1080 so I do:
>> git config --global http.proxy  'socks://127.0.0.1:1080'
>
> That looks right to me.
>
>> But when i try to talk with a git server with http protocol i have:
>> [...]
>> * About to connect() to proxy 127.0.0.1 port 1080
>> *   Trying 127.0.0.1... * connected
>> * Connected to 127.0.0.1 (127.0.0.1) port 1080
>> > GET http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
>> [...]
>> * Empty reply from server
>
> If I set up a simple socks proxy with ssh, like:
>
>   ssh -v -D 1080 my-ssh-host

My socks proxy is also a socks proxy with ssh

>
> and run the same command, I get:
>
>   * About to connect() to proxy localhost port 1080 (#0)
>   *   Trying 127.0.0.1...
>   * SOCKS4 request granted.
>   * Connected to localhost (127.0.0.1) port 1080 (#0)
>   > GET /pub/scm/git/git.git/info/refs?service=git-upload-pack HTTP/1.1
>   [...]
>   < HTTP/1.1 200 OK

You have a (#0) in the log that i have when using curl directly with
the socks proxy
>
> and it works. It does look like curl is treating localhost:1080 as a
> regular http proxy. What version of libcurl do you have? Is there
> anything in your environment that might be causing it to override the
> configured proxy setting (e.g., an http_proxy or https_proxy environment
> variable)?
I have try with an old version of curl: 7.15.5 and with the latest in
development curl 7.29.1-DEV.
But it seem that git-remote-http is compile with the old one.

I have no http/proxy environment variables
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: Using socks proxy with git for http(s) transport

Daniel Stenberg
On Wed, 6 Mar 2013, Yves Blusseau wrote:

> I have try with an old version of curl: 7.15.5 and with the latest in
> development curl 7.29.1-DEV. But it seem that git-remote-http is compile
> with the old one.

libcurl 7.15.5 is over 6 years old.

The support for "socks[*]://" prefixes in proxy names was added to libcurl
7.21.7 (June 23 2011).

--

  / daniel.haxx.se
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: SSL socks proxy list: CONNECTABLE 100%

ciorapalb100
In reply to this post by Yves Blusseau-2
24.21.139.76:9855
173.57.153.187:62189
96.43.245.75:26101
24.107.48.229:8169
75.136.147.231:4351


SSL socks proxy list: CONNECTABLE 100%


More socks at: http://actualproxy.biz/