{"thread":{"id":"32979","subject":"https_proxy and libcurl","startedAt":"2013-02-22T21:19:10Z","lastAt":"2013-02-27T21:16:29Z","messageCount":4,"participants":["Phil Hord","Junio C Hamano","Daniel Stenberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"210057","messageId":"CABURp0qQ6tO0B4Ya6OStX59SJqG-Jx1F4g6MUL7tVwR_6VgDhw@mail.gmail.com","threadId":"32979","inReplyTo":null,"subject":"https_proxy and libcurl","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-02-22T21:19:10Z","receivedAt":"2013-02-22T21:19:10Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"I have been unable to clone via http proxy because of a wrongly\nconfigured proxy setup in my lab.\n\nI had this env:\n\n    http_proxy=http://proxy.myco.com\n    https_proxy=https://proxy.myco.com\n\nThe problem is that libcurl ignores the protocol part of the proxy\nurl, and it defaults to port 1080. wget honors the protocol specifier,\nbut it defaults to port 80 if none is given.\n\nSo, I thought my env was equivalent to this:\n\n    http_proxy=proxy.myco.com:80\n    https_proxy=proxy.myco.com:443\n\nSo it is with wget.  But with curl, it is equivalent to this:\n\n    http_proxy=proxy.myco.com:1080\n    https_proxy=proxy.myco.com:1080\n\nGit clone gave a confusing (but correct) error message:\n\n    $ export https_proxy=https://proxy.myco.com\n    $ git clone https://github.com/git/git\n    Cloning into 'git'...\n    error: The requested URL returned error: 500 while accessing\nhttps://github.com/git/git/info/refs?service=git-upload-pack\n    fatal: HTTP request failed\n\n\nIf I didn't have https_proxy set at all, I got a long timeout as it\ntried to connect directly and ran into our firewall.\n\n    $ unset https_proxy\n    $ git clone https://github.com/git/git\n    Cloning into 'git'...\n    error: Failed connect to github.com:443; Connection timed out\nwhile accessing\nhttps://github.com/git/git/info/refs?service=git-upload-pack\n    fatal: HTTP request failed\n\nThis also did not help, of course:\n    'git config http.proxy https://proxy.myco.com'\n\nBut this did:\n    'git config http.proxy https://proxy.myco.com:443'\n\n\nThe fix was to specify the port explicitly, like this:\n\n    http_proxy=proxy.myco.com:80\n    https_proxy=proxy.myco.com:443\n\nPhil\n\n[1] An added wrinkle is that there is a proxy server listening on\n1080, but it does not support encrypted connections.  A listener on\n443 does handle https requests correctly.\n"},{"id":"210060","messageId":"7v7gm0c8ub.fsf@alter.siamese.dyndns.org","threadId":"32979","inReplyTo":"CABURp0qQ6tO0B4Ya6OStX59SJqG-Jx1F4g6MUL7tVwR_6VgDhw@mail.gmail.com","subject":"Re: https_proxy and libcurl","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-22T21:55:08Z","receivedAt":"2013-02-22T21:55:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <phil.hord@gmail.com> writes:\n\n> I have been unable to clone via http proxy because of a wrongly\n> configured proxy setup in my lab.\n>\n> I had this env:\n>\n>     http_proxy=http://proxy.myco.com\n>     https_proxy=https://proxy.myco.com\n>\n> The problem is that libcurl ignores the protocol part of the proxy\n> url, and it defaults to port 1080. wget honors the protocol specifier,\n> but it defaults to port 80 if none is given.\n\nIIRC, the historical norm is to set these to <host>:<port>.\n\nSo many people mistakenly write them with <method>:// that some\ntools over time learned to strip and ignore that prefix, though.\n\n> The fix was to specify the port explicitly, like this:\n>\n>     http_proxy=proxy.myco.com:80\n>     https_proxy=proxy.myco.com:443\n\nYeah, that is the correct syntax to use.  Is there anything you want\nGit to do to be more helpful?\n"},{"id":"210063","messageId":"alpine.DEB.2.00.1302222306130.27393@tvnag.unkk.fr","threadId":"32979","inReplyTo":"7v7gm0c8ub.fsf@alter.siamese.dyndns.org","subject":"Re: https_proxy and libcurl","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2013-02-22T22:09:39Z","receivedAt":"2013-02-22T22:09:39Z","isPatch":false,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Fri, 22 Feb 2013, Junio C Hamano wrote:\n\n>>     http_proxy=http://proxy.myco.com\n>>     https_proxy=https://proxy.myco.com\n>>\n>> The problem is that libcurl ignores the protocol part of the proxy\n>> url, and it defaults to port 1080. wget honors the protocol specifier,\n>> but it defaults to port 80 if none is given.\n>\n> IIRC, the historical norm is to set these to <host>:<port>.\n>\n> So many people mistakenly write them with <method>:// that some tools over \n> time learned to strip and ignore that prefix, though.\n\nYou're right, but also what exactly is the https:// _to_ the proxy supposed to \nmean? The standard procedure to connect to a proxy when communicating with \neither HTTP or HTTPS is using plain HTTP.\n\nIf you would want port 443 for a HTTPS connection to a proxy, you'd use:\n\n   https_proxy=http://proxy.myco.com:443\n\nOr without the ignore protocol prefix:\n\n   https_proxy=proxy.myco.com:443\n\n-- \n\n  / daniel.haxx.se\n"},{"id":"210411","messageId":"CABURp0o0+V+K90HfP4UfRFJ3s6VK-bWzWg2kwz=4XVRSMpo41Q@mail.gmail.com","threadId":"32979","inReplyTo":"7v7gm0c8ub.fsf@alter.siamese.dyndns.org","subject":"Re: https_proxy and libcurl","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-02-27T21:16:29Z","receivedAt":"2013-02-27T21:16:29Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Fri, Feb 22, 2013 at 4:55 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Phil Hord <phil.hord@gmail.com> writes:\n>\n>> I have been unable to clone via http proxy because of a wrongly\n>> configured proxy setup in my lab.\n>>\n>> I had this env:\n>>\n>>     http_proxy=http://proxy.myco.com\n>>     https_proxy=https://proxy.myco.com\n>>\n>> The problem is that libcurl ignores the protocol part of the proxy\n>> url, and it defaults to port 1080. wget honors the protocol specifier,\n>> but it defaults to port 80 if none is given.\n>\n> IIRC, the historical norm is to set these to <host>:<port>.\n>\n> So many people mistakenly write them with <method>:// that some\n> tools over time learned to strip and ignore that prefix, though.\n\nOn the server in question, I use wget to retrieve packages in another\nscript.  When our firewall was tightened in the past, this script\nbroke.  I fixed it by setting the https_proxy as I listed above.  This\nsatisfied wget and I got on with life.\n\nI do not need git connectivity to remotes from this server very often.\n But when I tried, it failed with an error message that did not\nimplicate the proxy server.  But it was the proxy server that returned\nthe error 500.\n\n  error: The requested URL returned error: 500 while accessing\n       https://github.com/git/git/info/refs?service=git-upload-pack\n\n>\n>> The fix was to specify the port explicitly, like this:\n>>\n>>     http_proxy=proxy.myco.com:80\n>>     https_proxy=proxy.myco.com:443\n>\n> Yeah, that is the correct syntax to use.  Is there anything you want\n> Git to do to be more helpful?\n\nMaybe Git can tell me more about proxy failures.  Or maybe Git doesn't\nknow because curl hides the knowledge.  Something like this:\n\n  error: The proxy server at proxy.myco.com:1080\n       returned error: 500 while accessing\n       https://github.com/git/git/info/refs?service=git-upload-pack\n\nMaybe Git can warn me that the protocol prefix (if provided) is going\nto be ignored or that I have failed to provide a port.  Either of\nthese would be \"above and beyond\" the norm. But since curl is internal\nto Git and its errors are digested by Git, it is less obvious where to\nbegin looking to solve such a problem; git doesn't provide the\nplethora of connection-debugging output options that curl itself does.\n\nFwiw, the proxy info originated with our IT department who mostly had\nto answer the question for Windows users and servers.  Windows appears\nto default to port 8080 when no port is specified.  Port 8080 would\nalso have worked, but curl defaults to 1080.  It seems that the curl\ndefault of 1080 is the only one that caused me trouble.\n\nMy basest hope is that someone suffering similar troubles will find\nthis thread in a search for \"git proxy error\".\n\nPhil\n"}]}