Hi there,
Can anibody here point me what is wrong with my proxy? I can't access https
sites.
package main
import (
"crypto/tls"
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
urlProxy, _ := url.Parse("http://192.168.0.10:3128")
proxy := httputil.NewSingleHostReverseProxy(urlProxy)
realDirector := proxy.Director
proxy.Director = func(r *http.Request) {
realDirector(r)
r.URL.Scheme = "https"
r.URL.Host = r.Host
}
proxy.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
log.Fatal(http.ListenAndServe(":8080", proxy))
}
This is what I get:
$ curl https://www.google.com -v
* Rebuilt URL to: https://www.google.com/
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.47.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 400 Bad Request
< Content-Length: 1555
< Content-Type: text/html; charset=UTF-8
< Date: Tue, 23 Aug 2016 13:31:12 GMT
<
* Received HTTP code 400 from proxy after CONNECT
* Closing connection 0
curl: (56) Received HTTP code 400 from proxy after CONNECT
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.