title: How to do a https request with proxy
body: <p>I am able to do a http or https client request without setting up a proxy,</p>
  <pre><code>enter code here
  tr := &amp;http.Transport{
      TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true},     
  }
  
  client := &amp;http.Client{}
  client.Transport = tr
  
  request, err := http.NewRequest(&quot;HEAD&quot;, &quot;http://www.???.com&quot;, nil)
  request.Header.Set(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36&quot;)
  
  resp, err := client.Do(request)
  
  if err != nil {
      log.Fatalln(err)
      return
  }
  defer resp.Body.Close()
  
  httpcode = resp.Status
  </code></pre>
  <p>This script is working ok, I get a 200 ok when I request https url, but if I set up proxy , the script:</p>
  <pre><code>proxyString := &quot;https://47.91.179.xxx:443&quot;
  proxyUrl, _ := url.Parse(proxyString)
  
  tr := &amp;http.Transport{
      Proxy: http.ProxyURL(proxyUrl),
      TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, 
      
  }
  
  client := &amp;http.Client{}
  client.Transport = tr
  
  ....................
  </code></pre>
  <p>I always get &quot;Bad request&quot;, I read docs: <a href="https://golang.org/pkg/net/http/" rel="nofollow noreferrer">https://golang.org/pkg/net/http/</a>:</p>
  <p>...........
  Starting with Go 1.6, the http package has transparent support for the HTTP/2 protocol when using HTTPS. Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) or Server.TLSNextProto (for servers) to a non-nil, empty map. Alternatively, the following GODEBUG environment variables are currently supported:
  ..............</p>
  <p>So, I tried to stop http2:</p>
  <pre><code>tr := &amp;http.Transport{
      Proxy: http.ProxyURL(proxyUrl),
      //Proxy: http.ProxyFromEnvironment,
      TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true},
      TLSNextProto:    make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
  }
  </code></pre>
  <p>same problem, &quot;Bad request&quot;. I tried os.Setenv(&quot;HTTPS_PROXY&quot;, &quot;47.91.???.???:443&quot;), It is the same result.
  This is logged in server:</p>
  <pre><code>{S;}220.255.95.68{S;}-{S;}07/Mar/2017:17:01:47 +0800{S;}CONNECT www.panpacific.com:443 HTTP/1.1{S;}400{S;}173{S;}340{S;}-{S;}-{S;}-{S;}-{S;}-{S;}www.panpacific.com
  </code></pre>
  <p>So, Does golang support https client request via proxy? How do I get correct results?</p>